Commit 81903a76 authored by oliver@apple.com's avatar oliver@apple.com
Browse files

Really "fix" CTI mode on windows 2k3.

Reviewed my Maciej Stachowiak

This adds new methods fastMallocExecutable and fastFreeExecutable
to wrap allocation for cti code.  This still just makes fastMalloc
return executable memory all the time, which will be fixed in a
later patch.

However in windows debug builds all executable allocations will be
allocated on separate executable pages, which should resolve any
remaining 2k3 issues.  Conveniently the 2k3 bot will now also fail
if there are any fastFree vs. fastFreeExecutable errors.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37804 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5c2a8899
2008-10-22 Oliver Hunt <oliver@apple.com>
Reviewed by Maciej Stachowiak.
Really "fix" CTI mode on windows 2k3.
This adds new methods fastMallocExecutable and fastFreeExecutable
to wrap allocation for cti code. This still just makes fastMalloc
return executable memory all the time, which will be fixed in a
later patch.
However in windows debug builds all executable allocations will be
allocated on separate executable pages, which should resolve any
remaining 2k3 issues. Conveniently the 2k3 bot will now also fail
if there are any fastFree vs. fastFreeExecutable errors.
* ChangeLog:
* VM/CodeBlock.cpp:
(JSC::CodeBlock::~CodeBlock):
* kjs/regexp.cpp:
(JSC::RegExp::~RegExp):
* masm/X86Assembler.h:
(JSC::JITCodeBuffer::copy):
* wtf/FastMalloc.cpp:
(WTF::fastMallocExecutable):
(WTF::fastFreeExecutable):
(WTF::TCMallocStats::fastMallocExecutable):
(WTF::TCMallocStats::fastFreeExecutable):
* wtf/FastMalloc.h:
2008-10-22 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
......
......@@ -945,7 +945,7 @@ CodeBlock::~CodeBlock()
for (size_t i = 0; i < size; ++i) {
derefStructureIDs(&instructions[structureIDInstructions[i].opcodeIndex]);
if (structureIDInstructions[i].stubRoutine)
fastFree(structureIDInstructions[i].stubRoutine);
WTF::fastFreeExecutable(structureIDInstructions[i].stubRoutine);
if (CallLinkInfo* callLinkInfo = structureIDInstructions[i].linkInfoPtr) {
callLinkInfo->callee->removeCaller(callLinkInfo);
delete callLinkInfo;
......@@ -956,7 +956,7 @@ CodeBlock::~CodeBlock()
unlinkCallers();
if (ctiCode)
fastFree(ctiCode);
WTF::fastFreeExecutable(ctiCode);
#endif
}
......
......@@ -105,7 +105,7 @@ RegExp::~RegExp()
jsRegExpFree(m_regExp);
#if ENABLE(WREC)
if (m_wrecFunction)
fastFree(m_wrecFunction);
WTF::fastFreeExecutable(m_wrecFunction);
#endif
}
......
......@@ -30,6 +30,8 @@
#include <wtf/Assertions.h>
#include <wtf/AlwaysInline.h>
#include <wtf/FastMalloc.h>
#if HAVE(MMAN)
#include <sys/mman.h>
#endif
......@@ -123,7 +125,7 @@ public:
if (!m_index)
return 0;
void* result = fastMalloc(m_index);
void* result = WTF::fastMallocExecutable(m_index);
if (!result)
return 0;
......
......@@ -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
......
......@@ -41,6 +41,9 @@ namespace WTF {
void fastFree(void* p);
void* fastMallocExecutable(size_t n);
void fastFreeExecutable(void* p);
#ifndef NDEBUG
void fastMallocForbid();
void fastMallocAllow();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment