aboutsummaryrefslogtreecommitdiffstats
path: root/src/3rdparty/masm/stubs
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-02-07 16:46:03 +0100
committerLars Knoll <lars.knoll@digia.com>2013-02-09 10:46:40 +0100
commit5165917f44b2d05fa0808759e57c6cd244162be3 (patch)
tree08db92293bf8ff6c157f3f8ddba2f271692f63ae /src/3rdparty/masm/stubs
parent11e932e634cf0a2bd214b9925ad31ecd0e3aba73 (diff)
Make ExecutableAllocator compile on Windows
Use VirtualAlloc and friends instead of mmap. Change-Id: I52a90cebb111cf923d86ce6a821717dc7e02ad85 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/masm/stubs')
-rw-r--r--src/3rdparty/masm/stubs/ExecutableAllocator.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/3rdparty/masm/stubs/ExecutableAllocator.h b/src/3rdparty/masm/stubs/ExecutableAllocator.h
index de04ffe977..47768c6931 100644
--- a/src/3rdparty/masm/stubs/ExecutableAllocator.h
+++ b/src/3rdparty/masm/stubs/ExecutableAllocator.h
@@ -45,8 +45,12 @@
#include <RefCounted.h>
#include <wtf/PageBlock.h>
+#if OS(WINDOWS)
+#include <windows.h>
+#else
#include <sys/mman.h>
#include <unistd.h>
+#endif
namespace JSC {
@@ -58,14 +62,22 @@ struct ExecutableMemoryHandle : public RefCounted<ExecutableMemoryHandle> {
{
size_t pageSize = WTF::pageSize();
m_size = (m_size + pageSize - 1) & ~(pageSize - 1);
+#if OS(WINDOWS)
+ m_data = VirtualAlloc(0, m_size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
+#else
#if OS(DARWIN)
# define MAP_ANONYMOUS MAP_ANON
#endif
m_data = mmap(0, m_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+#endif
}
~ExecutableMemoryHandle()
{
+#if OS(WINDOWS)
+ VirtualFree(m_data, 0, MEM_RELEASE);
+#else
munmap(m_data, m_size);
+#endif
}
inline void shrink(size_t) {
@@ -96,8 +108,13 @@ struct ExecutableAllocator {
size_t pageSize = WTF::pageSize();
size_t iaddr = reinterpret_cast<size_t>(addr);
size_t roundAddr = iaddr & ~(pageSize - static_cast<size_t>(1));
+#if OS(WINDOWS)
+ DWORD oldProtect;
+ VirtualProtect(reinterpret_cast<void*>(roundAddr), size + (iaddr - roundAddr), PAGE_EXECUTE_READWRITE, &oldProtect);
+#else
int mode = PROT_READ | PROT_WRITE | PROT_EXEC;
mprotect(reinterpret_cast<void*>(roundAddr), size + (iaddr - roundAddr), mode);
+#endif
}
};