Really "fix" CTI mode on windows 2k3.
[WebKit-https.git] / JavaScriptCore / wtf / FastMalloc.cpp
index aa1a108..a7c7f7c 100644 (file)
@@ -174,10 +174,12 @@ void* tryFastZeroedMalloc(size_t n)
 #include <stdlib.h>
 #if !PLATFORM(WIN_OS)
     #include <pthread.h>
+#else
+    #include "windows.h"
 #endif
 
 namespace WTF {
-    
+
 void* tryFastMalloc(size_t n) 
 {
     ASSERT(!isForbidden());
@@ -231,6 +233,28 @@ void* fastRealloc(void* p, size_t n)
 
 void releaseFastMallocFreeMemory() { }
 
+#if HAVE(VIRTUALALLOC)
+void* fastMallocExecutable(size_t n)
+{
+    return VirtualAlloc(0, n, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
+}
+
+void fastFreeExecutable(void* p)
+{ 
+    VirtualFree(p, 0, MEM_RELEASE); 
+}
+#else
+void* fastMallocExecutable(size_t n)
+{
+    return fastMalloc(n);
+}
+
+void fastFreeExecutable(void* p)
+{ 
+    fastFree(p);
+}
+#endif
+
 } // namespace WTF
 
 #if PLATFORM(DARWIN)
@@ -3361,6 +3385,16 @@ void* realloc(void* old_ptr, size_t new_size) {
   }
 }
 
+void* fastMallocExecutable(size_t n)
+{
+    return malloc<false>(n);
+}
+
+void fastFreeExecutable(void* p)
+{ 
+    free(p);
+}
+
 #ifdef WTF_CHANGES
 #undef do_malloc
 #else