Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: src/assembler.cc

Issue 5640004: Allow the optimizing code generator to call Math.pow with untagged doubles. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #error "Unknown architecture." 59 #error "Unknown architecture."
60 #endif // Target architecture. 60 #endif // Target architecture.
61 #endif // V8_INTERPRETED_REGEXP 61 #endif // V8_INTERPRETED_REGEXP
62 62
63 namespace v8 { 63 namespace v8 {
64 namespace internal { 64 namespace internal {
65 65
66 66
67 const double DoubleConstant::min_int = kMinInt; 67 const double DoubleConstant::min_int = kMinInt;
68 const double DoubleConstant::one_half = 0.5; 68 const double DoubleConstant::one_half = 0.5;
69 const double DoubleConstant::negative_infinity = -V8_INFINITY;
69 70
70 71
71 // ----------------------------------------------------------------------------- 72 // -----------------------------------------------------------------------------
72 // Implementation of Label 73 // Implementation of Label
73 74
74 int Label::pos() const { 75 int Label::pos() const {
75 if (pos_ < 0) return -pos_ - 1; 76 if (pos_ < 0) return -pos_ - 1;
76 if (pos_ > 0) return pos_ - 1; 77 if (pos_ > 0) return pos_ - 1;
77 UNREACHABLE(); 78 UNREACHABLE();
78 return 0; 79 return 0;
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 const_cast<double*>(&DoubleConstant::min_int))); 716 const_cast<double*>(&DoubleConstant::min_int)));
716 } 717 }
717 718
718 719
719 ExternalReference ExternalReference::address_of_one_half() { 720 ExternalReference ExternalReference::address_of_one_half() {
720 return ExternalReference(reinterpret_cast<void*>( 721 return ExternalReference(reinterpret_cast<void*>(
721 const_cast<double*>(&DoubleConstant::one_half))); 722 const_cast<double*>(&DoubleConstant::one_half)));
722 } 723 }
723 724
724 725
726 ExternalReference ExternalReference::address_of_negative_infinity() {
727 return ExternalReference(reinterpret_cast<void*>(
728 const_cast<double*>(&DoubleConstant::negative_infinity)));
729 }
730
731
725 #ifndef V8_INTERPRETED_REGEXP 732 #ifndef V8_INTERPRETED_REGEXP
726 733
727 ExternalReference ExternalReference::re_check_stack_guard_state() { 734 ExternalReference ExternalReference::re_check_stack_guard_state() {
728 Address function; 735 Address function;
729 #ifdef V8_TARGET_ARCH_X64 736 #ifdef V8_TARGET_ARCH_X64
730 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); 737 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState);
731 #elif V8_TARGET_ARCH_IA32 738 #elif V8_TARGET_ARCH_IA32
732 function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState); 739 function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState);
733 #elif V8_TARGET_ARCH_ARM 740 #elif V8_TARGET_ARCH_ARM
734 function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState); 741 function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 static double div_two_doubles(double x, double y) { 793 static double div_two_doubles(double x, double y) {
787 return x / y; 794 return x / y;
788 } 795 }
789 796
790 797
791 static double mod_two_doubles(double x, double y) { 798 static double mod_two_doubles(double x, double y) {
792 return modulo(x, y); 799 return modulo(x, y);
793 } 800 }
794 801
795 802
803 // Helper function to compute x^y, where y is known to be an
804 // integer. Uses binary decomposition to limit the number of
805 // multiplications; see the discussion in "Hacker's Delight" by Henry
806 // S. Warren, Jr., figure 11-6, page 213.
807 double power_double_int(double x, int y) {
808 double m = (y < 0) ? 1/x : x;
Florian Schneider 2010/12/08 14:09:27 --> 1 / x
William Hesse 2010/12/08 14:53:16 Done.
809 unsigned n = (y < 0) ? -y : y;
810 double p = 1;
811 while (n != 0) {
812 if ((n & 1) != 0) p *= m;
813 m *= m;
814 if ((n & 2) != 0) p *= m;
815 m *= m;
816 n >>= 2;
817 }
818 return p;
819 }
820
821
822 double power_double_double(double x, double y) {
823 int y_int = static_cast<int>(y);
824 if (y == y_int) {
825 return power_double_int(x, y_int); // Returns 1.0 for exponent 0.
826 }
827 if (!isinf(x)) {
828 if (y == 0.5) return sqrt(x);
829 if (y == -0.5) return 1.0 / sqrt(x);
830 }
831 if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) {
832 return OS::nan_value();
833 }
834 return pow(x, y);
835 }
836
837
838 ExternalReference ExternalReference::power_double_double_function() {
839 return ExternalReference(Redirect(FUNCTION_ADDR(power_double_double)));
840 }
841
842
843 ExternalReference ExternalReference::power_double_int_function() {
844 return ExternalReference(Redirect(FUNCTION_ADDR(power_double_int)));
845 }
846
847
796 static int native_compare_doubles(double y, double x) { 848 static int native_compare_doubles(double y, double x) {
797 if (x == y) return EQUAL; 849 if (x == y) return EQUAL;
798 return x < y ? LESS : GREATER; 850 return x < y ? LESS : GREATER;
799 } 851 }
800 852
801 853
802 ExternalReference ExternalReference::double_fp_operation( 854 ExternalReference ExternalReference::double_fp_operation(
803 Token::Value operation) { 855 Token::Value operation) {
804 typedef double BinaryFPOperation(double x, double y); 856 typedef double BinaryFPOperation(double x, double y);
805 BinaryFPOperation* function = NULL; 857 BinaryFPOperation* function = NULL;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); 935 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position);
884 state_.written_position = state_.current_position; 936 state_.written_position = state_.current_position;
885 written = true; 937 written = true;
886 } 938 }
887 939
888 // Return whether something was written. 940 // Return whether something was written.
889 return written; 941 return written;
890 } 942 }
891 943
892 } } // namespace v8::internal 944 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/assembler.h ('k') | src/hydrogen.cc » ('j') | src/hydrogen-instructions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698