| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/codegen.h" | 5 #include "src/codegen.h" |
| 6 | 6 |
| 7 #if defined(V8_OS_AIX) | 7 #if defined(V8_OS_AIX) |
| 8 #include <fenv.h> // NOLINT(build/c++11) | 8 #include <fenv.h> // NOLINT(build/c++11) |
| 9 #endif | 9 #endif |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 double result = std::fmod(x, y); | 57 double result = std::fmod(x, y); |
| 58 int exception = fetestexcept(FE_UNDERFLOW); | 58 int exception = fetestexcept(FE_UNDERFLOW); |
| 59 return (exception ? x : result); | 59 return (exception ? x : result); |
| 60 #else | 60 #else |
| 61 return std::fmod(x, y); | 61 return std::fmod(x, y); |
| 62 #endif | 62 #endif |
| 63 } | 63 } |
| 64 #endif // defined(_WIN64) | 64 #endif // defined(_WIN64) |
| 65 | 65 |
| 66 | 66 |
| 67 #define UNARY_MATH_FUNCTION(name, generator) \ | 67 #define UNARY_MATH_FUNCTION(name, generator) \ |
| 68 static UnaryMathFunction fast_##name##_function = NULL; \ | 68 static UnaryMathFunctionWithIsolate fast_##name##_function = nullptr; \ |
| 69 void init_fast_##name##_function() { \ | 69 double std_##name(double x, Isolate* isolate) { return std::name(x); } \ |
| 70 fast_##name##_function = generator; \ | 70 void init_fast_##name##_function(Isolate* isolate) { \ |
| 71 } \ | 71 if (FLAG_fast_math) fast_##name##_function = generator(isolate); \ |
| 72 double fast_##name(double x) { \ | 72 if (!fast_##name##_function) fast_##name##_function = std_##name; \ |
| 73 return (*fast_##name##_function)(x); \ | 73 } \ |
| 74 } | 74 void lazily_initialize_fast_##name(Isolate* isolate) { \ |
| 75 if (!fast_##name##_function) init_fast_##name##_function(isolate); \ |
| 76 } \ |
| 77 double fast_##name(double x, Isolate* isolate) { \ |
| 78 return (*fast_##name##_function)(x, isolate); \ |
| 79 } |
| 75 | 80 |
| 76 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction()) | 81 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction) |
| 82 UNARY_MATH_FUNCTION(exp, CreateExpFunction) |
| 77 | 83 |
| 78 #undef UNARY_MATH_FUNCTION | 84 #undef UNARY_MATH_FUNCTION |
| 79 | 85 |
| 80 static UnaryMathFunctionWithIsolate fast_exp_function = NULL; | |
| 81 | |
| 82 | |
| 83 double std_exp(double x, Isolate* isolate) { | |
| 84 return std::exp(x); | |
| 85 } | |
| 86 | |
| 87 | |
| 88 void init_fast_exp_function(Isolate* isolate) { | |
| 89 if (FLAG_fast_math) fast_exp_function = CreateExpFunction(isolate); | |
| 90 if (!fast_exp_function) fast_exp_function = std_exp; | |
| 91 } | |
| 92 | |
| 93 | |
| 94 double fast_exp(double x, Isolate* isolate) { | |
| 95 return (*fast_exp_function)(x, isolate); | |
| 96 } | |
| 97 | |
| 98 | |
| 99 void lazily_initialize_fast_exp(Isolate* isolate) { | |
| 100 if (fast_exp_function == nullptr) { | |
| 101 init_fast_exp_function(isolate); | |
| 102 } | |
| 103 } | |
| 104 | |
| 105 | 86 |
| 106 #define __ ACCESS_MASM(masm_) | 87 #define __ ACCESS_MASM(masm_) |
| 107 | 88 |
| 108 #ifdef DEBUG | 89 #ifdef DEBUG |
| 109 | 90 |
| 110 Comment::Comment(MacroAssembler* masm, const char* msg) | 91 Comment::Comment(MacroAssembler* masm, const char* msg) |
| 111 : masm_(masm), msg_(msg) { | 92 : masm_(masm), msg_(msg) { |
| 112 __ RecordComment(msg); | 93 __ RecordComment(msg); |
| 113 } | 94 } |
| 114 | 95 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 os << "source_position = " << literal->start_position() << "\n"; | 222 os << "source_position = " << literal->start_position() << "\n"; |
| 242 } | 223 } |
| 243 code->Disassemble(debug_name.get(), os); | 224 code->Disassemble(debug_name.get(), os); |
| 244 os << "--- End code ---\n"; | 225 os << "--- End code ---\n"; |
| 245 } | 226 } |
| 246 #endif // ENABLE_DISASSEMBLER | 227 #endif // ENABLE_DISASSEMBLER |
| 247 } | 228 } |
| 248 | 229 |
| 249 } // namespace internal | 230 } // namespace internal |
| 250 } // namespace v8 | 231 } // namespace v8 |
| OLD | NEW |