Line data Source code
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
3 : // found in the LICENSE file.
4 :
5 : #include "src/codegen.h"
6 :
7 : #include <cmath>
8 : #include <memory>
9 :
10 : #include "src/flags.h"
11 :
12 : namespace v8 {
13 : namespace internal {
14 :
15 : #define UNARY_MATH_FUNCTION(name, generator) \
16 : static UnaryMathFunctionWithIsolate fast_##name##_function = nullptr; \
17 : double std_##name(double x, Isolate* isolate) { return std::name(x); } \
18 : void init_fast_##name##_function(Isolate* isolate) { \
19 : if (FLAG_fast_math) fast_##name##_function = generator(isolate); \
20 : if (!fast_##name##_function) fast_##name##_function = std_##name; \
21 : } \
22 : void lazily_initialize_fast_##name(Isolate* isolate) { \
23 : if (!fast_##name##_function) init_fast_##name##_function(isolate); \
24 : } \
25 : double fast_##name(double x, Isolate* isolate) { \
26 : return (*fast_##name##_function)(x, isolate); \
27 : }
28 :
29 0 : UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction)
30 :
31 : #undef UNARY_MATH_FUNCTION
32 :
33 : } // namespace internal
34 : } // namespace v8
|