OLD | NEW |
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 Loading... |
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; | |
70 | 69 |
71 | 70 |
72 // ----------------------------------------------------------------------------- | 71 // ----------------------------------------------------------------------------- |
73 // Implementation of Label | 72 // Implementation of Label |
74 | 73 |
75 int Label::pos() const { | 74 int Label::pos() const { |
76 if (pos_ < 0) return -pos_ - 1; | 75 if (pos_ < 0) return -pos_ - 1; |
77 if (pos_ > 0) return pos_ - 1; | 76 if (pos_ > 0) return pos_ - 1; |
78 UNREACHABLE(); | 77 UNREACHABLE(); |
79 return 0; | 78 return 0; |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 const_cast<double*>(&DoubleConstant::min_int))); | 715 const_cast<double*>(&DoubleConstant::min_int))); |
717 } | 716 } |
718 | 717 |
719 | 718 |
720 ExternalReference ExternalReference::address_of_one_half() { | 719 ExternalReference ExternalReference::address_of_one_half() { |
721 return ExternalReference(reinterpret_cast<void*>( | 720 return ExternalReference(reinterpret_cast<void*>( |
722 const_cast<double*>(&DoubleConstant::one_half))); | 721 const_cast<double*>(&DoubleConstant::one_half))); |
723 } | 722 } |
724 | 723 |
725 | 724 |
726 ExternalReference ExternalReference::address_of_negative_infinity() { | |
727 return ExternalReference(reinterpret_cast<void*>( | |
728 const_cast<double*>(&DoubleConstant::negative_infinity))); | |
729 } | |
730 | |
731 | |
732 #ifndef V8_INTERPRETED_REGEXP | 725 #ifndef V8_INTERPRETED_REGEXP |
733 | 726 |
734 ExternalReference ExternalReference::re_check_stack_guard_state() { | 727 ExternalReference ExternalReference::re_check_stack_guard_state() { |
735 Address function; | 728 Address function; |
736 #ifdef V8_TARGET_ARCH_X64 | 729 #ifdef V8_TARGET_ARCH_X64 |
737 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); | 730 function = FUNCTION_ADDR(RegExpMacroAssemblerX64::CheckStackGuardState); |
738 #elif V8_TARGET_ARCH_IA32 | 731 #elif V8_TARGET_ARCH_IA32 |
739 function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState); | 732 function = FUNCTION_ADDR(RegExpMacroAssemblerIA32::CheckStackGuardState); |
740 #elif V8_TARGET_ARCH_ARM | 733 #elif V8_TARGET_ARCH_ARM |
741 function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState); | 734 function = FUNCTION_ADDR(RegExpMacroAssemblerARM::CheckStackGuardState); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 static double div_two_doubles(double x, double y) { | 786 static double div_two_doubles(double x, double y) { |
794 return x / y; | 787 return x / y; |
795 } | 788 } |
796 | 789 |
797 | 790 |
798 static double mod_two_doubles(double x, double y) { | 791 static double mod_two_doubles(double x, double y) { |
799 return modulo(x, y); | 792 return modulo(x, y); |
800 } | 793 } |
801 | 794 |
802 | 795 |
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; | |
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 | |
848 static int native_compare_doubles(double y, double x) { | 796 static int native_compare_doubles(double y, double x) { |
849 if (x == y) return EQUAL; | 797 if (x == y) return EQUAL; |
850 return x < y ? LESS : GREATER; | 798 return x < y ? LESS : GREATER; |
851 } | 799 } |
852 | 800 |
853 | 801 |
854 ExternalReference ExternalReference::double_fp_operation( | 802 ExternalReference ExternalReference::double_fp_operation( |
855 Token::Value operation) { | 803 Token::Value operation) { |
856 typedef double BinaryFPOperation(double x, double y); | 804 typedef double BinaryFPOperation(double x, double y); |
857 BinaryFPOperation* function = NULL; | 805 BinaryFPOperation* function = NULL; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); | 883 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
936 state_.written_position = state_.current_position; | 884 state_.written_position = state_.current_position; |
937 written = true; | 885 written = true; |
938 } | 886 } |
939 | 887 |
940 // Return whether something was written. | 888 // Return whether something was written. |
941 return written; | 889 return written; |
942 } | 890 } |
943 | 891 |
944 } } // namespace v8::internal | 892 } } // namespace v8::internal |
OLD | NEW |