Revision: 21163
Author:   [email protected]
Date:     Tue May  6 11:14:37 2014 UTC
Log:      Move generated math methods from platform to codegen

BUG=none
[email protected]
LOG=n

Review URL: https://codereview.chromium.org/269823006
http://code.google.com/p/v8/source/detail?r=21163

Modified:
 /branches/bleeding_edge/src/codegen.cc
 /branches/bleeding_edge/src/codegen.h
 /branches/bleeding_edge/src/platform-posix.cc
 /branches/bleeding_edge/src/platform-win32.cc
 /branches/bleeding_edge/src/platform.h
 /branches/bleeding_edge/src/v8.cc

=======================================
--- /branches/bleeding_edge/src/codegen.cc      Tue May  6 09:28:08 2014 UTC
+++ /branches/bleeding_edge/src/codegen.cc      Tue May  6 11:14:37 2014 UTC
@@ -17,6 +17,65 @@
 namespace v8 {
 namespace internal {

+
+#if defined(_WIN64)
+typedef double (*ModuloFunction)(double, double);
+static ModuloFunction modulo_function = NULL;
+// Defined in codegen-x64.cc.
+ModuloFunction CreateModuloFunction();
+
+void init_modulo_function() {
+  modulo_function = CreateModuloFunction();
+}
+
+
+double modulo(double x, double y) {
+  // Note: here we rely on dependent reads being ordered. This is true
+  // on all architectures we currently support.
+  return (*modulo_function)(x, y);
+}
+#elif defined(_WIN32)
+
+double modulo(double x, double y) {
+  // Workaround MS fmod bugs. ECMA-262 says:
+ // dividend is finite and divisor is an infinity => result equals dividend + // dividend is a zero and divisor is nonzero finite => result equals dividend
+  if (!(std::isfinite(x) && (!std::isfinite(y) && !std::isnan(y))) &&
+      !(x == 0 && (y != 0 && std::isfinite(y)))) {
+    x = fmod(x, y);
+  }
+  return x;
+}
+#else  // POSIX
+
+double modulo(double x, double y) {
+  return std::fmod(x, 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);                   \
+}
+
+UNARY_MATH_FUNCTION(exp, CreateExpFunction())
+UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
+
+#undef UNARY_MATH_FUNCTION
+
+
+void lazily_initialize_fast_exp() {
+  if (fast_exp_function == NULL) {
+    init_fast_exp_function();
+  }
+}
+
+
 #define __ ACCESS_MASM(masm_)

 #ifdef DEBUG
=======================================
--- /branches/bleeding_edge/src/codegen.h       Tue May  6 09:28:08 2014 UTC
+++ /branches/bleeding_edge/src/codegen.h       Tue May  6 11:14:37 2014 UTC
@@ -97,6 +97,18 @@
 UnaryMathFunction CreateSqrtFunction();


+double modulo(double x, double y);
+
+// Custom implementation of math functions.
+double fast_exp(double input);
+double fast_sqrt(double input);
+#ifdef _WIN64
+void init_modulo_function();
+#endif
+void lazily_initialize_fast_exp();
+void init_fast_sqrt_function();
+
+
 class ElementsTransitionGenerator : public AllStatic {
  public:
   // If |mode| is set to DONT_TRACK_ALLOCATION_SITE,
=======================================
--- /branches/bleeding_edge/src/platform-posix.cc Fri May 2 10:14:37 2014 UTC +++ /branches/bleeding_edge/src/platform-posix.cc Tue May 6 11:14:37 2014 UTC
@@ -43,7 +43,6 @@

 #include "v8.h"

-#include "codegen.h"
 #include "isolate-inl.h"
 #include "platform.h"

@@ -285,33 +284,6 @@
// ----------------------------------------------------------------------------
 // Math functions

-double modulo(double x, double y) {
-  return std::fmod(x, y);
-}
-
-
-#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);                   \
-}
-
-UNARY_MATH_FUNCTION(exp, CreateExpFunction())
-UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
-
-#undef UNARY_MATH_FUNCTION
-
-
-void lazily_initialize_fast_exp() {
-  if (fast_exp_function == NULL) {
-    init_fast_exp_function();
-  }
-}
-
-
 double OS::nan_value() {
   // NAN from math.h is defined in C99 and not in POSIX.
   return NAN;
@@ -541,8 +513,6 @@
   OS::memcopy_uint8_function =
       CreateMemCopyUint8Function(&OS::MemCopyUint8Wrapper);
 #endif
-  // fast_exp is initialized lazily.
-  init_fast_sqrt_function();
 }


=======================================
--- /branches/bleeding_edge/src/platform-win32.cc Fri May 2 10:14:37 2014 UTC +++ /branches/bleeding_edge/src/platform-win32.cc Tue May 6 11:14:37 2014 UTC
@@ -19,7 +19,6 @@

 #include "v8.h"

-#include "codegen.h"
 #include "isolate-inl.h"
 #include "platform.h"

@@ -130,68 +129,6 @@

 #endif  // V8_TARGET_ARCH_IA32

-#ifdef _WIN64
-typedef double (*ModuloFunction)(double, double);
-static ModuloFunction modulo_function = NULL;
-// Defined in codegen-x64.cc.
-ModuloFunction CreateModuloFunction();
-
-void init_modulo_function() {
-  modulo_function = CreateModuloFunction();
-}
-
-
-double modulo(double x, double y) {
-  // Note: here we rely on dependent reads being ordered. This is true
-  // on all architectures we currently support.
-  return (*modulo_function)(x, y);
-}
-#else  // Win32
-
-double modulo(double x, double y) {
-  // Workaround MS fmod bugs. ECMA-262 says:
- // dividend is finite and divisor is an infinity => result equals dividend - // dividend is a zero and divisor is nonzero finite => result equals dividend
-  if (!(std::isfinite(x) && (!std::isfinite(y) && !std::isnan(y))) &&
-      !(x == 0 && (y != 0 && std::isfinite(y)))) {
-    x = fmod(x, y);
-  }
-  return x;
-}
-
-#endif  // _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);                   \
-}
-
-UNARY_MATH_FUNCTION(exp, CreateExpFunction())
-UNARY_MATH_FUNCTION(sqrt, CreateSqrtFunction())
-
-#undef UNARY_MATH_FUNCTION
-
-
-void lazily_initialize_fast_exp() {
-  if (fast_exp_function == NULL) {
-    init_fast_exp_function();
-  }
-}
-
-
-void MathSetup() {
-#ifdef _WIN64
-  init_modulo_function();
-#endif
-  // fast_exp is initialized lazily.
-  init_fast_sqrt_function();
-}
-

 class TimezoneCache {
  public:
@@ -516,9 +453,6 @@


 void OS::PostSetUp() {
- // Math functions depend on CPU features therefore they are initialized after
-  // CPU.
-  MathSetup();
 #if V8_TARGET_ARCH_IA32
   OS::MemMoveFunction generated_memmove = CreateMemMoveFunction();
   if (generated_memmove != NULL) {
=======================================
--- /branches/bleeding_edge/src/platform.h      Fri May  2 10:14:37 2014 UTC
+++ /branches/bleeding_edge/src/platform.h      Tue May  6 11:14:37 2014 UTC
@@ -73,16 +73,6 @@
 namespace v8 {
 namespace internal {

-double modulo(double x, double y);
-
-// Custom implementation of math functions.
-double fast_exp(double input);
-double fast_sqrt(double input);
-// The custom exp implementation needs 16KB of lookup data; initialize it
-// on demand.
-void lazily_initialize_fast_exp();
-
-
// ----------------------------------------------------------------------------
 // Fast TLS support

=======================================
--- /branches/bleeding_edge/src/v8.cc   Mon May  5 16:33:23 2014 UTC
+++ /branches/bleeding_edge/src/v8.cc   Tue May  6 11:14:37 2014 UTC
@@ -110,6 +110,12 @@
   bool serializer_enabled = Serializer::enabled(NULL);
   CpuFeatures::Probe(serializer_enabled);
   OS::PostSetUp();
+  // The custom exp implementation needs 16KB of lookup data; initialize it
+  // on demand.
+  init_fast_sqrt_function();
+#ifdef _WIN64
+  init_modulo_function();
+#endif
   ElementsAccessor::InitializeOncePerProcess();
   LOperand::SetUpCaches();
   SetUpJSCallerSavedCodeData();

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to