V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
codegen.cc
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 UnaryMathFunction fast_##name##_function = nullptr; \
17  double std_##name(double x) { return std::name(x); } \
18  void init_fast_##name##_function() { \
19  if (FLAG_fast_math) fast_##name##_function = generator(); \
20  if (!fast_##name##_function) fast_##name##_function = std_##name; \
21  } \
22  void lazily_initialize_fast_##name() { \
23  if (!fast_##name##_function) init_fast_##name##_function(); \
24  } \
25  double fast_##name(double x) { return (*fast_##name##_function)(x); }
26 
27 UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction)
28 
29 #undef UNARY_MATH_FUNCTION
30 
31 } // namespace internal
32 } // namespace v8
Definition: libplatform.h:13