| 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 18 matching lines...) Expand all Loading... |
| 29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | 30 |
| 31 // The original source code covered by the above license above has been | 31 // The original source code covered by the above license above has been |
| 32 // modified significantly by Google Inc. | 32 // modified significantly by Google Inc. |
| 33 // Copyright 2012 the V8 project authors. All rights reserved. | 33 // Copyright 2012 the V8 project authors. All rights reserved. |
| 34 | 34 |
| 35 #include "src/assembler.h" | 35 #include "src/assembler.h" |
| 36 | 36 |
| 37 #include <cmath> | 37 #include <cmath> |
| 38 #include "src/api.h" | 38 #include "src/api.h" |
| 39 #include "src/base/cpu.h" |
| 39 #include "src/base/lazy-instance.h" | 40 #include "src/base/lazy-instance.h" |
| 41 #include "src/base/platform/platform.h" |
| 40 #include "src/builtins.h" | 42 #include "src/builtins.h" |
| 41 #include "src/counters.h" | 43 #include "src/counters.h" |
| 42 #include "src/cpu.h" | |
| 43 #include "src/cpu-profiler.h" | 44 #include "src/cpu-profiler.h" |
| 44 #include "src/debug.h" | 45 #include "src/debug.h" |
| 45 #include "src/deoptimizer.h" | 46 #include "src/deoptimizer.h" |
| 46 #include "src/execution.h" | 47 #include "src/execution.h" |
| 47 #include "src/ic.h" | 48 #include "src/ic.h" |
| 48 #include "src/isolate-inl.h" | 49 #include "src/isolate-inl.h" |
| 49 #include "src/jsregexp.h" | 50 #include "src/jsregexp.h" |
| 50 #include "src/platform.h" | |
| 51 #include "src/regexp-macro-assembler.h" | 51 #include "src/regexp-macro-assembler.h" |
| 52 #include "src/regexp-stack.h" | 52 #include "src/regexp-stack.h" |
| 53 #include "src/runtime.h" | 53 #include "src/runtime.h" |
| 54 #include "src/serialize.h" | 54 #include "src/serialize.h" |
| 55 #include "src/store-buffer-inl.h" | 55 #include "src/store-buffer-inl.h" |
| 56 #include "src/stub-cache.h" | 56 #include "src/stub-cache.h" |
| 57 #include "src/token.h" | 57 #include "src/token.h" |
| 58 | 58 |
| 59 #if V8_TARGET_ARCH_IA32 | 59 #if V8_TARGET_ARCH_IA32 |
| 60 #include "src/ia32/assembler-ia32-inl.h" // NOLINT | 60 #include "src/ia32/assembler-ia32-inl.h" // NOLINT |
| (...skipping 30 matching lines...) Expand all Loading... |
| 91 #endif // Target architecture. | 91 #endif // Target architecture. |
| 92 #endif // V8_INTERPRETED_REGEXP | 92 #endif // V8_INTERPRETED_REGEXP |
| 93 | 93 |
| 94 namespace v8 { | 94 namespace v8 { |
| 95 namespace internal { | 95 namespace internal { |
| 96 | 96 |
| 97 // ----------------------------------------------------------------------------- | 97 // ----------------------------------------------------------------------------- |
| 98 // Common double constants. | 98 // Common double constants. |
| 99 | 99 |
| 100 struct DoubleConstant BASE_EMBEDDED { | 100 struct DoubleConstant BASE_EMBEDDED { |
| 101 double min_int; | 101 double min_int; |
| 102 double one_half; | 102 double one_half; |
| 103 double minus_one_half; | 103 double minus_one_half; |
| 104 double minus_zero; | 104 double minus_zero; |
| 105 double zero; | 105 double zero; |
| 106 double uint8_max_value; | 106 double uint8_max_value; |
| 107 double negative_infinity; | 107 double negative_infinity; |
| 108 double canonical_non_hole_nan; | 108 double canonical_non_hole_nan; |
| 109 double the_hole_nan; | 109 double the_hole_nan; |
| 110 double uint32_bias; | 110 double uint32_bias; |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 static DoubleConstant double_constants; | 113 static DoubleConstant double_constants; |
| 114 | 114 |
| 115 const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING"; | 115 const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING"; |
| 116 | 116 |
| 117 static bool math_exp_data_initialized = false; | 117 static bool math_exp_data_initialized = false; |
| 118 static Mutex* math_exp_data_mutex = NULL; | 118 static base::Mutex* math_exp_data_mutex = NULL; |
| 119 static double* math_exp_constants_array = NULL; | 119 static double* math_exp_constants_array = NULL; |
| 120 static double* math_exp_log_table_array = NULL; | 120 static double* math_exp_log_table_array = NULL; |
| 121 | 121 |
| 122 // ----------------------------------------------------------------------------- | 122 // ----------------------------------------------------------------------------- |
| 123 // Implementation of AssemblerBase | 123 // Implementation of AssemblerBase |
| 124 | 124 |
| 125 AssemblerBase::AssemblerBase(Isolate* isolate, void* buffer, int buffer_size) | 125 AssemblerBase::AssemblerBase(Isolate* isolate, void* buffer, int buffer_size) |
| 126 : isolate_(isolate), | 126 : isolate_(isolate), |
| 127 jit_cookie_(0), | 127 jit_cookie_(0), |
| 128 enabled_cpu_features_(0), | 128 enabled_cpu_features_(0), |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 // ----------------------------------------------------------------------------- | 900 // ----------------------------------------------------------------------------- |
| 901 // Implementation of ExternalReference | 901 // Implementation of ExternalReference |
| 902 | 902 |
| 903 void ExternalReference::SetUp() { | 903 void ExternalReference::SetUp() { |
| 904 double_constants.min_int = kMinInt; | 904 double_constants.min_int = kMinInt; |
| 905 double_constants.one_half = 0.5; | 905 double_constants.one_half = 0.5; |
| 906 double_constants.minus_one_half = -0.5; | 906 double_constants.minus_one_half = -0.5; |
| 907 double_constants.minus_zero = -0.0; | 907 double_constants.minus_zero = -0.0; |
| 908 double_constants.uint8_max_value = 255; | 908 double_constants.uint8_max_value = 255; |
| 909 double_constants.zero = 0.0; | 909 double_constants.zero = 0.0; |
| 910 double_constants.canonical_non_hole_nan = OS::nan_value(); | 910 double_constants.canonical_non_hole_nan = base::OS::nan_value(); |
| 911 double_constants.the_hole_nan = BitCast<double>(kHoleNanInt64); | 911 double_constants.the_hole_nan = BitCast<double>(kHoleNanInt64); |
| 912 double_constants.negative_infinity = -V8_INFINITY; | 912 double_constants.negative_infinity = -V8_INFINITY; |
| 913 double_constants.uint32_bias = | 913 double_constants.uint32_bias = |
| 914 static_cast<double>(static_cast<uint32_t>(0xFFFFFFFF)) + 1; | 914 static_cast<double>(static_cast<uint32_t>(0xFFFFFFFF)) + 1; |
| 915 | 915 |
| 916 math_exp_data_mutex = new Mutex(); | 916 math_exp_data_mutex = new base::Mutex(); |
| 917 } | 917 } |
| 918 | 918 |
| 919 | 919 |
| 920 void ExternalReference::InitializeMathExpData() { | 920 void ExternalReference::InitializeMathExpData() { |
| 921 // Early return? | 921 // Early return? |
| 922 if (math_exp_data_initialized) return; | 922 if (math_exp_data_initialized) return; |
| 923 | 923 |
| 924 LockGuard<Mutex> lock_guard(math_exp_data_mutex); | 924 base::LockGuard<base::Mutex> lock_guard(math_exp_data_mutex); |
| 925 if (!math_exp_data_initialized) { | 925 if (!math_exp_data_initialized) { |
| 926 // If this is changed, generated code must be adapted too. | 926 // If this is changed, generated code must be adapted too. |
| 927 const int kTableSizeBits = 11; | 927 const int kTableSizeBits = 11; |
| 928 const int kTableSize = 1 << kTableSizeBits; | 928 const int kTableSize = 1 << kTableSizeBits; |
| 929 const double kTableSizeDouble = static_cast<double>(kTableSize); | 929 const double kTableSizeDouble = static_cast<double>(kTableSize); |
| 930 | 930 |
| 931 math_exp_constants_array = new double[9]; | 931 math_exp_constants_array = new double[9]; |
| 932 // Input values smaller than this always return 0. | 932 // Input values smaller than this always return 0. |
| 933 math_exp_constants_array[0] = -708.39641853226408; | 933 math_exp_constants_array[0] = -708.39641853226408; |
| 934 // Input values larger than this always return +Infinity. | 934 // Input values larger than this always return +Infinity. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 | 1024 |
| 1025 ExternalReference ExternalReference:: | 1025 ExternalReference ExternalReference:: |
| 1026 store_buffer_overflow_function(Isolate* isolate) { | 1026 store_buffer_overflow_function(Isolate* isolate) { |
| 1027 return ExternalReference(Redirect( | 1027 return ExternalReference(Redirect( |
| 1028 isolate, | 1028 isolate, |
| 1029 FUNCTION_ADDR(StoreBuffer::StoreBufferOverflow))); | 1029 FUNCTION_ADDR(StoreBuffer::StoreBufferOverflow))); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 | 1032 |
| 1033 ExternalReference ExternalReference::flush_icache_function(Isolate* isolate) { | 1033 ExternalReference ExternalReference::flush_icache_function(Isolate* isolate) { |
| 1034 return ExternalReference(Redirect(isolate, FUNCTION_ADDR(CPU::FlushICache))); | 1034 return ExternalReference( |
| 1035 Redirect(isolate, FUNCTION_ADDR(CpuFeatures::FlushICache))); |
| 1035 } | 1036 } |
| 1036 | 1037 |
| 1037 | 1038 |
| 1038 ExternalReference ExternalReference::delete_handle_scope_extensions( | 1039 ExternalReference ExternalReference::delete_handle_scope_extensions( |
| 1039 Isolate* isolate) { | 1040 Isolate* isolate) { |
| 1040 return ExternalReference(Redirect( | 1041 return ExternalReference(Redirect( |
| 1041 isolate, | 1042 isolate, |
| 1042 FUNCTION_ADDR(HandleScope::DeleteExtensions))); | 1043 FUNCTION_ADDR(HandleScope::DeleteExtensions))); |
| 1043 } | 1044 } |
| 1044 | 1045 |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 int y_int = static_cast<int>(y); | 1500 int y_int = static_cast<int>(y); |
| 1500 if (y == y_int) { | 1501 if (y == y_int) { |
| 1501 return std::ldexp(1.0, y_int); | 1502 return std::ldexp(1.0, y_int); |
| 1502 } | 1503 } |
| 1503 } | 1504 } |
| 1504 #endif | 1505 #endif |
| 1505 | 1506 |
| 1506 // The checks for special cases can be dropped in ia32 because it has already | 1507 // The checks for special cases can be dropped in ia32 because it has already |
| 1507 // been done in generated code before bailing out here. | 1508 // been done in generated code before bailing out here. |
| 1508 if (std::isnan(y) || ((x == 1 || x == -1) && std::isinf(y))) { | 1509 if (std::isnan(y) || ((x == 1 || x == -1) && std::isinf(y))) { |
| 1509 return OS::nan_value(); | 1510 return base::OS::nan_value(); |
| 1510 } | 1511 } |
| 1511 return std::pow(x, y); | 1512 return std::pow(x, y); |
| 1512 } | 1513 } |
| 1513 | 1514 |
| 1514 | 1515 |
| 1515 ExternalReference ExternalReference::power_double_double_function( | 1516 ExternalReference ExternalReference::power_double_double_function( |
| 1516 Isolate* isolate) { | 1517 Isolate* isolate) { |
| 1517 return ExternalReference(Redirect(isolate, | 1518 return ExternalReference(Redirect(isolate, |
| 1518 FUNCTION_ADDR(power_double_double), | 1519 FUNCTION_ADDR(power_double_double), |
| 1519 BUILTIN_FP_FP_CALL)); | 1520 BUILTIN_FP_FP_CALL)); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 r2 = r2 - ad; | 1653 r2 = r2 - ad; |
| 1653 } | 1654 } |
| 1654 delta = ad - r2; | 1655 delta = ad - r2; |
| 1655 } while (q1 < delta || (q1 == delta && r1 == 0)); | 1656 } while (q1 < delta || (q1 == delta && r1 == 0)); |
| 1656 int32_t mul = static_cast<int32_t>(q2 + 1); | 1657 int32_t mul = static_cast<int32_t>(q2 + 1); |
| 1657 multiplier_ = (d < 0) ? -mul : mul; | 1658 multiplier_ = (d < 0) ? -mul : mul; |
| 1658 shift_ = p - 32; | 1659 shift_ = p - 32; |
| 1659 } | 1660 } |
| 1660 | 1661 |
| 1661 } } // namespace v8::internal | 1662 } } // namespace v8::internal |
| OLD | NEW |