Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: src/codegen.cc

Issue 1473683004: Lazily initialize fast_sqrt() and pass an Isolate parameter to it (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codegen.h ('k') | src/crankshaft/hydrogen-instructions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codegen.cc
diff --git a/src/codegen.cc b/src/codegen.cc
index 47066887e00224d6362cbffb9ac0b7e4b75a428e..40f2f4d62c17ca9309851f47ae2b9a797bad6374 100644
--- a/src/codegen.cc
+++ b/src/codegen.cc
@@ -64,44 +64,25 @@ double modulo(double x, double y) {
#endif // defined(_WIN64)
-#define UNARY_MATH_FUNCTION(name, generator) \
-static UnaryMathFunction fast_##name##_function = NULL; \
-void init_fast_##name##_function() { \
- fast_##name##_function = generator; \
-} \
-double fast_##name(double x) { \
- return (*fast_##name##_function)(x); \
-}
+#define UNARY_MATH_FUNCTION(name, generator) \
+ static UnaryMathFunctionWithIsolate fast_##name##_function = nullptr; \
+ double std_##name(double x, Isolate* isolate) { return std::name(x); } \
+ void init_fast_##name##_function(Isolate* isolate) { \
+ if (FLAG_fast_math) fast_##name##_function = generator(isolate); \
+ if (!fast_##name##_function) fast_##name##_function = std_##name; \
+ } \
+ void lazily_initialize_fast_##name(Isolate* isolate) { \
+ if (!fast_##name##_function) init_fast_##name##_function(isolate); \
+ } \
+ double fast_##name(double x, Isolate* isolate) { \
+ return (*fast_##name##_function)(x, isolate); \
+ }
-UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
+UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction)
+UNARY_MATH_FUNCTION(exp, CreateExpFunction)
#undef UNARY_MATH_FUNCTION
-static UnaryMathFunctionWithIsolate fast_exp_function = NULL;
-
-
-double std_exp(double x, Isolate* isolate) {
- return std::exp(x);
-}
-
-
-void init_fast_exp_function(Isolate* isolate) {
- if (FLAG_fast_math) fast_exp_function = CreateExpFunction(isolate);
- if (!fast_exp_function) fast_exp_function = std_exp;
-}
-
-
-double fast_exp(double x, Isolate* isolate) {
- return (*fast_exp_function)(x, isolate);
-}
-
-
-void lazily_initialize_fast_exp(Isolate* isolate) {
- if (fast_exp_function == nullptr) {
- init_fast_exp_function(isolate);
- }
-}
-
#define __ ACCESS_MASM(masm_)
« no previous file with comments | « src/codegen.h ('k') | src/crankshaft/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698