Commit dfd546b9 authored by weinig@apple.com's avatar weinig@apple.com

2009-04-20 Sam Weinig <sam@webkit.org>

        Reviewed by Kevin McCullough.

        Always tag mmaped memory on darwin and clean up #defines
        now that they are a little bigger.

        * interpreter/RegisterFile.h:
        (JSC::RegisterFile::RegisterFile):
        * jit/ExecutableAllocatorFixedVMPool.cpp:
        (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator):
        * jit/ExecutableAllocatorPosix.cpp:
        (JSC::ExecutablePool::systemAlloc):
        * runtime/Collector.cpp:
        (JSC::allocateBlock):



git-svn-id: svn://svn.chromium.org/blink/trunk@42676 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7d70e0f9
2009-04-20 Sam Weinig <sam@webkit.org>
Reviewed by Kevin McCullough.
Always tag mmaped memory on darwin and clean up #defines
now that they are a little bigger.
* interpreter/RegisterFile.h:
(JSC::RegisterFile::RegisterFile):
* jit/ExecutableAllocatorFixedVMPool.cpp:
(JSC::FixedVMPoolAllocator::FixedVMPoolAllocator):
* jit/ExecutableAllocatorPosix.cpp:
(JSC::ExecutablePool::systemAlloc):
* runtime/Collector.cpp:
(JSC::allocateBlock):
2009-04-20 Sam Weinig <sam@webkit.org> 2009-04-20 Sam Weinig <sam@webkit.org>
Rubber-stamped by Tim Hatcher. Rubber-stamped by Tim Hatcher.
...@@ -44,6 +44,18 @@ ...@@ -44,6 +44,18 @@
#include <mach/vm_statistics.h> #include <mach/vm_statistics.h>
#endif #endif
#if PLATFORM(DARWIN)
// On Mac OS X, the VM subsystem allows tagging memory requested from mmap and vm_map
// in order to aid tools that inspect system memory use.
#if defined(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE)
#define TAG_FOR_REGISTERFILE_MEMORY VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE)
#else
#define TAG_FOR_REGISTERFILE_MEMORY VM_MAKE_TAG(65)
#endif
#else
#define TAG_FOR_REGISTERFILE_MEMORY -1
#endif
namespace JSC { namespace JSC {
/* /*
...@@ -165,12 +177,7 @@ namespace JSC { ...@@ -165,12 +177,7 @@ namespace JSC {
{ {
size_t bufferLength = (capacity + maxGlobals) * sizeof(Register); size_t bufferLength = (capacity + maxGlobals) * sizeof(Register);
#if HAVE(MMAP) #if HAVE(MMAP)
#if PLATFORM(DARWIN) && defined(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE) m_buffer = static_cast<Register*>(mmap(0, bufferLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, TAG_FOR_REGISTERFILE_MEMORY, 0));
#define OPTIONAL_TAG VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE)
#else
#define OPTIONAL_TAG -1
#endif
m_buffer = static_cast<Register*>(mmap(0, bufferLength, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, OPTIONAL_TAG, 0));
if (m_buffer == MAP_FAILED) { if (m_buffer == MAP_FAILED) {
fprintf(stderr, "Could not allocate register file: %d\n", errno); fprintf(stderr, "Could not allocate register file: %d\n", errno);
CRASH(); CRASH();
...@@ -227,4 +234,6 @@ namespace JSC { ...@@ -227,4 +234,6 @@ namespace JSC {
} // namespace JSC } // namespace JSC
#undef TAG_FOR_REGISTERFILE_MEMORY
#endif // RegisterFile_h #endif // RegisterFile_h
...@@ -39,6 +39,14 @@ ...@@ -39,6 +39,14 @@
#include <unistd.h> #include <unistd.h>
#include <wtf/AVLTree.h> #include <wtf/AVLTree.h>
// On Mac OS X, the VM subsystem allows tagging memory requested from mmap and vm_map
// in order to aid tools that inspect system memory use.
#if defined(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR)
#define TAG_FOR_EXECUTABLEALLOCATOR_MEMORY VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR)
#else
#define TAG_FOR_EXECUTABLEALLOCATOR_MEMORY VM_MAKE_TAG(64)
#endif
using namespace WTF; using namespace WTF;
namespace JSC { namespace JSC {
...@@ -281,15 +289,8 @@ public: ...@@ -281,15 +289,8 @@ public:
: commonSize(commonSize) : commonSize(commonSize)
, countFreedSinceLastCoalesce(0) , countFreedSinceLastCoalesce(0)
{ {
#if defined(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR)
#define OPTIONAL_TAG VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR)
#else
#define OPTIONAL_TAG -1
#endif
// Allocate two gigabytes of memory. // Allocate two gigabytes of memory.
void* base = mmap(NULL, totalHeapSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, OPTIONAL_TAG, 0); void* base = mmap(NULL, totalHeapSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, TAG_FOR_EXECUTABLEALLOCATOR_MEMORY, 0);
if (!base) if (!base)
CRASH(); CRASH();
...@@ -426,4 +427,6 @@ void ExecutablePool::systemRelease(const ExecutablePool::Allocation& allocation) ...@@ -426,4 +427,6 @@ void ExecutablePool::systemRelease(const ExecutablePool::Allocation& allocation)
} }
#undef TAG_FOR_EXECUTABLEALLOCATOR_MEMORY
#endif // HAVE(ASSEMBLER) #endif // HAVE(ASSEMBLER)
...@@ -36,6 +36,18 @@ ...@@ -36,6 +36,18 @@
#include <mach/vm_statistics.h> #include <mach/vm_statistics.h>
#endif #endif
#if PLATFORM(DARWIN)
// On Mac OS X, the VM subsystem allows tagging memory requested from mmap and vm_map
// in order to aid tools that inspect system memory use.
#if defined(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR)
#define TAG_FOR_EXECUTABLEALLOCATOR_MEMORY VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR)
#else
#define TAG_FOR_EXECUTABLEALLOCATOR_MEMORY VM_MAKE_TAG(64)
#endif
#else
#define TAG_FOR_EXECUTABLEALLOCATOR_MEMORY -1
#endif
namespace JSC { namespace JSC {
void ExecutableAllocator::intializePageSize() void ExecutableAllocator::intializePageSize()
...@@ -45,13 +57,7 @@ void ExecutableAllocator::intializePageSize() ...@@ -45,13 +57,7 @@ void ExecutableAllocator::intializePageSize()
ExecutablePool::Allocation ExecutablePool::systemAlloc(size_t n) ExecutablePool::Allocation ExecutablePool::systemAlloc(size_t n)
{ {
#if PLATFORM(DARWIN) && defined(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR) ExecutablePool::Allocation alloc = { reinterpret_cast<char*>(mmap(NULL, n, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, TAG_FOR_EXECUTABLEALLOCATOR_MEMORY, 0)), n };
#define OPTIONAL_TAG VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR)
#else
#define OPTIONAL_TAG -1
#endif
ExecutablePool::Allocation alloc = { reinterpret_cast<char*>(mmap(NULL, n, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, OPTIONAL_TAG, 0)), n };
return alloc; return alloc;
} }
...@@ -63,4 +69,6 @@ void ExecutablePool::systemRelease(const ExecutablePool::Allocation& alloc) ...@@ -63,4 +69,6 @@ void ExecutablePool::systemRelease(const ExecutablePool::Allocation& alloc)
} }
#undef TAG_FOR_EXECUTABLEALLOCATOR_MEMORY
#endif // HAVE(ASSEMBLER) #endif // HAVE(ASSEMBLER)
...@@ -74,6 +74,16 @@ ...@@ -74,6 +74,16 @@
#define DEBUG_COLLECTOR 0 #define DEBUG_COLLECTOR 0
#define COLLECT_ON_EVERY_ALLOCATION 0 #define COLLECT_ON_EVERY_ALLOCATION 0
#if PLATFORM(DARWIN)
// On Mac OS X, the VM subsystem allows tagging memory requested from mmap and vm_map
// in order to aid tools that inspect system memory use.
#if defined(VM_MEMORY_JAVASCRIPT_CORE)
#define TAG_FOR_COLLECTOR_MEMORY VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_CORE)
#else
#define TAG_FOR_COLLECTOR_MEMORY VM_MAKE_TAG(63)
#endif
#endif
using std::max; using std::max;
namespace JSC { namespace JSC {
...@@ -182,14 +192,9 @@ template <HeapType heapType> ...@@ -182,14 +192,9 @@ template <HeapType heapType>
static NEVER_INLINE CollectorBlock* allocateBlock() static NEVER_INLINE CollectorBlock* allocateBlock()
{ {
#if PLATFORM(DARWIN) #if PLATFORM(DARWIN)
#if defined(VM_MEMORY_JAVASCRIPT_CORE)
#define TAG VM_MAKE_TAG(VM_MEMORY_JAVASCRIPT_CORE)
#else
#define TAG 0
#endif
vm_address_t address = 0; vm_address_t address = 0;
// FIXME: tag the region as a JavaScriptCore heap when we get a registered VM tag: <rdar://problem/6054788>. // FIXME: tag the region as a JavaScriptCore heap when we get a registered VM tag: <rdar://problem/6054788>.
vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE|TAG, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT); vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT);
#elif PLATFORM(SYMBIAN) #elif PLATFORM(SYMBIAN)
// no memory map in symbian, need to hack with fastMalloc // no memory map in symbian, need to hack with fastMalloc
void* address = fastMalloc(BLOCK_SIZE); void* address = fastMalloc(BLOCK_SIZE);
...@@ -1130,3 +1135,7 @@ Heap::iterator Heap::primaryHeapEnd() ...@@ -1130,3 +1135,7 @@ Heap::iterator Heap::primaryHeapEnd()
} }
} // namespace JSC } // namespace JSC
#if PLATFORM(DARWIN)
#undef TAG_FOR_COLLECTOR_MEMORY
#endif
Markdown is supported
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