Index: src/platform-win32.cc |
diff --git a/src/platform-win32.cc b/src/platform-win32.cc |
index 50a9e5b1ac01773327fb9d49115f0e45ae37988a..0901fcaf7684471c3f22b23e69d1bb10780ea99a 100644 |
--- a/src/platform-win32.cc |
+++ b/src/platform-win32.cc |
@@ -176,16 +176,45 @@ double ceiling(double x) { |
static Mutex* limit_mutex = NULL; |
+#if defined(V8_TARGET_ARCH_IA32) |
+static OS::MemCopyFunction memcopy_function = NULL; |
+static Mutex* memcopy_function_mutex = OS::CreateMutex(); |
+// Defined in codegen-ia32.cc. |
+OS::MemCopyFunction CreateMemCopyFunction(); |
+ |
+// Copy memory area to disjoint memory area. |
+void OS::MemCopy(void* dest, const void* src, size_t size) { |
+ if (memcopy_function == NULL) { |
+ ScopedLock lock(memcopy_function_mutex); |
+ Isolate::EnsureDefaultIsolate(); |
+ if (memcopy_function == NULL) { |
+ memcopy_function = CreateMemCopyFunction(); |
+ } |
+ } |
+ (*memcopy_function)(dest, src, size); |
+#ifdef DEBUG |
+ CHECK_EQ(0, memcmp(dest, src, size)); |
+#endif |
+} |
+#endif // V8_TARGET_ARCH_IA32 |
#ifdef _WIN64 |
typedef double (*ModuloFunction)(double, double); |
- |
+static ModuloFunction modulo_function = NULL; |
+static Mutex* modulo_function_mutex = OS::CreateMutex(); |
// Defined in codegen-x64.cc. |
ModuloFunction CreateModuloFunction(); |
double modulo(double x, double y) { |
- static ModuloFunction function = CreateModuloFunction(); |
- return function(x, y); |
+ if (modulo_function == NULL) { |
+ ScopedLock lock(modulo_function_mutex); |
+ Isolate::EnsureDefaultIsolate(); |
+ if (modulo_function == NULL) { |
+ Release_Store(reinterpret_cast<AtomicWord*>(&modulo_function), |
+ reinterpret_cast<AtomicWord>(CreateModuloFunction())); |
+ } |
+ } |
+ return (*modulo_function)(x, y); |
} |
#else // Win32 |