Changeset 64105 in webkit
- Timestamp:
- Jul 26, 2010 10:02:09 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 3 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/CMakeListsEfl.txt
r64101 r64105 1 1 LIST(APPEND JavaScriptCore_SOURCES 2 2 jit/ExecutableAllocatorFixedVMPool.cpp 3 jit/ExecutableAllocator Posix.cpp3 jit/ExecutableAllocator.cpp 4 4 runtime/MarkStackPosix.cpp 5 5 ) -
trunk/JavaScriptCore/ChangeLog
r64101 r64105 1 2010-07-26 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Bug 43009 - Abstract out page allocation from executable allocators 6 7 It would be great to have a single platform abstraction for block allocation, rather than copy/paste code. 8 9 In this initial implementation I've made Symbian fall back to use malloc/free for non-executable memory. 10 I think this will match current behaviour for the next client we will want to port across (RegisterFile & 11 Collector). 12 13 * CMakeListsEfl.txt: 14 * GNUmakefile.am: 15 * JavaScriptCore.gypi: 16 * JavaScriptCore.pro: 17 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: 18 * JavaScriptCore.xcodeproj/project.pbxproj: 19 * jit/ExecutableAllocator.cpp: 20 (JSC::ExecutableAllocator::intializePageSize): 21 (JSC::ExecutablePool::systemAlloc): 22 (JSC::ExecutablePool::systemRelease): 23 (JSC::ExecutableAllocator::isValid): 24 * jit/ExecutableAllocator.h: 25 (JSC::ExecutablePool::ExecutablePool): 26 (JSC::ExecutablePool::poolAllocate): 27 * jit/ExecutableAllocatorFixedVMPool.cpp: 28 (JSC::FixedVMPoolAllocator::release): 29 (JSC::FixedVMPoolAllocator::reuse): 30 (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): 31 (JSC::FixedVMPoolAllocator::alloc): 32 (JSC::FixedVMPoolAllocator::free): 33 (JSC::FixedVMPoolAllocator::isValid): 34 (JSC::FixedVMPoolAllocator::isWithinVMPool): 35 (JSC::ExecutablePool::systemAlloc): 36 (JSC::ExecutablePool::systemRelease): 37 * jit/ExecutableAllocatorPosix.cpp: Removed. 38 * jit/ExecutableAllocatorSymbian.cpp: Removed. 39 * jit/ExecutableAllocatorWin.cpp: Removed. 40 * wscript: 41 * wtf/PageAllocator.cpp: Added. 42 (WTF::protection): 43 (WTF::PageAllocation::commit): 44 (WTF::PageAllocation::decommit): 45 (WTF::PageAllocator::allocate): 46 (WTF::PageAllocator::reserve): 47 (WTF::PageAllocator::deallocate): 48 (WTF::PageAllocator::pagesize): 49 * wtf/PageAllocator.h: Added. 50 (WTF::PageAllocation::PageAllocation): 51 (WTF::PageAllocation::base): 52 (WTF::PageAllocation::size): 53 (WTF::PageAllocation::chunk): 54 (WTF::PageAllocation::operator!): 55 (WTF::PageAllocator::): 56 1 57 2010-07-26 Gavin Barraclough <barraclough@apple.com> 2 58 -
trunk/JavaScriptCore/GNUmakefile.am
r64101 r64105 527 527 javascriptcore_sources += \ 528 528 JavaScriptCore/wtf/ThreadSpecificWin.cpp \ 529 JavaScriptCore/jit/ExecutableAllocatorWin.cpp \530 529 JavaScriptCore/runtime/MarkStackWin.cpp 531 530 else 532 531 javascriptcore_sources += \ 533 532 JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp \ 534 JavaScriptCore/jit/ExecutableAllocatorPosix.cpp \535 533 JavaScriptCore/runtime/MarkStackPosix.cpp 536 534 endif -
trunk/JavaScriptCore/JavaScriptCore.gypi
r64101 r64105 111 111 'jit/ExecutableAllocator.h', 112 112 'jit/ExecutableAllocatorFixedVMPool.cpp', 113 'jit/ExecutableAllocatorPosix.cpp',114 'jit/ExecutableAllocatorWin.cpp',115 113 'jit/JIT.cpp', 116 114 'jit/JIT.h', -
trunk/JavaScriptCore/JavaScriptCore.pro
r64101 r64105 95 95 interpreter/RegisterFile.cpp \ 96 96 jit/ExecutableAllocatorFixedVMPool.cpp \ 97 jit/ExecutableAllocatorPosix.cpp \98 jit/ExecutableAllocatorSymbian.cpp \99 jit/ExecutableAllocatorWin.cpp \100 97 jit/ExecutableAllocator.cpp \ 101 98 jit/JITArithmetic.cpp \ -
trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r64101 r64105 1642 1642 </File> 1643 1643 <File 1644 RelativePath="..\..\jit\ExecutableAllocatorWin.cpp"1645 >1646 </File>1647 <File1648 1644 RelativePath="..\..\jit\JIT.cpp" 1649 1645 > -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r64101 r64105 199 199 860161E60F3A83C100F84710 /* MacroAssemblerX86Common.h in Headers */ = {isa = PBXBuildFile; fileRef = 860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */; }; 200 200 8626BECF11928E3900782FAB /* StringStatics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8626BECE11928E3900782FAB /* StringStatics.cpp */; }; 201 8627E5EB11F1281900A313B5 /* PageAllocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8627E5E911F1281900A313B5 /* PageAllocation.cpp */; }; 202 8627E5EC11F1281900A313B5 /* PageAllocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 8627E5EA11F1281900A313B5 /* PageAllocation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 201 203 863B23E00FC6118900703AA4 /* MacroAssemblerCodeRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */; settings = {ATTRIBUTES = (Private, ); }; }; 202 204 86565742115BE3DA00291F40 /* CString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86565740115BE3DA00291F40 /* CString.cpp */; }; … … 313 315 A76EE6590FAE59D5003F069A /* NativeFunctionWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = A76EE6580FAE59D5003F069A /* NativeFunctionWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; }; 314 316 A7795590101A74D500114E55 /* MarkStack.h in Headers */ = {isa = PBXBuildFile; fileRef = A779558F101A74D500114E55 /* MarkStack.h */; settings = {ATTRIBUTES = (Private, ); }; }; 315 A782F1A50EEC9FA20036273F /* ExecutableAllocatorPosix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A782F1A40EEC9FA20036273F /* ExecutableAllocatorPosix.cpp */; };316 317 A783A0D111A36DCA00563D20 /* JSObjectWithGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; 317 318 A783A2AB11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */; }; … … 768 769 860161E20F3A83C100F84710 /* MacroAssemblerX86Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerX86Common.h; sourceTree = "<group>"; }; 769 770 8626BECE11928E3900782FAB /* StringStatics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringStatics.cpp; path = text/StringStatics.cpp; sourceTree = "<group>"; }; 771 8627E5E911F1281900A313B5 /* PageAllocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageAllocation.cpp; sourceTree = "<group>"; }; 772 8627E5EA11F1281900A313B5 /* PageAllocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageAllocation.h; sourceTree = "<group>"; }; 770 773 863B23DF0FC60E6200703AA4 /* MacroAssemblerCodeRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MacroAssemblerCodeRef.h; sourceTree = "<group>"; }; 771 774 86565740115BE3DA00291F40 /* CString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CString.cpp; path = text/CString.cpp; sourceTree = "<group>"; }; … … 813 816 86D3B3C110159D7F002865E7 /* LinkBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LinkBuffer.h; sourceTree = "<group>"; }; 814 817 86D3B3C210159D7F002865E7 /* RepatchBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RepatchBuffer.h; sourceTree = "<group>"; }; 815 86DB645F0F954E9100D7D921 /* ExecutableAllocatorWin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocatorWin.cpp; sourceTree = "<group>"; };816 818 86DB64630F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocatorFixedVMPool.cpp; sourceTree = "<group>"; }; 817 819 86E116B00FE75AC800B512BC /* CodeLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeLocation.h; sourceTree = "<group>"; }; … … 915 917 A76EE6580FAE59D5003F069A /* NativeFunctionWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeFunctionWrapper.h; sourceTree = "<group>"; }; 916 918 A779558F101A74D500114E55 /* MarkStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkStack.h; sourceTree = "<group>"; }; 917 A782F1A40EEC9FA20036273F /* ExecutableAllocatorPosix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExecutableAllocatorPosix.cpp; sourceTree = "<group>"; };918 919 A783A0D011A36DCA00563D20 /* JSObjectWithGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSObjectWithGlobalObject.h; sourceTree = "<group>"; }; 919 920 A783A2AA11A5BE8400563D20 /* JSObjectWithGlobalObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSObjectWithGlobalObject.cpp; sourceTree = "<group>"; }; … … 1254 1255 A7B48DB50EE74CFC00DCBDB6 /* ExecutableAllocator.h */, 1255 1256 86DB64630F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp */, 1256 A782F1A40EEC9FA20036273F /* ExecutableAllocatorPosix.cpp */,1257 86DB645F0F954E9100D7D921 /* ExecutableAllocatorWin.cpp */,1258 1257 1429D92D0ED22D7000B89619 /* JIT.cpp */, 1259 1258 1429D92E0ED22D7000B89619 /* JIT.h */, … … 1447 1446 9303F567099118FA00AD71B8 /* OwnPtr.h */, 1448 1447 440B7AED0FAF7FCB0073323E /* OwnPtrCommon.h */, 1448 8627E5E911F1281900A313B5 /* PageAllocation.cpp */, 1449 8627E5EA11F1281900A313B5 /* PageAllocation.h */, 1449 1450 44DD48520FAEA85000D6B4EB /* PassOwnPtr.h */, 1450 1451 6580F795094070560082C219 /* PassRefPtr.h */, … … 2188 2189 86D08D5411793613006E5ED0 /* WTFThreadData.h in Headers */, 2189 2190 9688CB160ED12B4E001D649F /* X86Assembler.h in Headers */, 2191 8627E5EC11F1281900A313B5 /* PageAllocation.h in Headers */, 2190 2192 ); 2191 2193 runOnlyForDeploymentPostprocessing = 0; … … 2497 2499 A7B48F490EE8936F00DCBDB6 /* ExecutableAllocator.cpp in Sources */, 2498 2500 86DB64640F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp in Sources */, 2499 A782F1A50EEC9FA20036273F /* ExecutableAllocatorPosix.cpp in Sources */,2500 2501 14F8BA3E107EC886009892DC /* FastMalloc.cpp in Sources */, 2501 2502 147F39CB107EC37600427A48 /* FunctionConstructor.cpp in Sources */, … … 2628 2629 868BFA17117CF19900B908B1 /* WTFString.cpp in Sources */, 2629 2630 86D08D5311793613006E5ED0 /* WTFThreadData.cpp in Sources */, 2631 8627E5EB11F1281900A313B5 /* PageAllocation.cpp in Sources */, 2630 2632 ); 2631 2633 runOnlyForDeploymentPostprocessing = 0; -
trunk/JavaScriptCore/jit/ExecutableAllocator.cpp
r64101 r64105 34 34 size_t ExecutableAllocator::pageSize = 0; 35 35 36 #if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND) 37 38 void ExecutableAllocator::intializePageSize() 39 { 40 #if CPU(ARMV5_OR_LOWER) 41 // The moving memory model (as used in ARMv5 and earlier platforms) 42 // on Symbian OS limits the number of chunks for each process to 16. 43 // To mitigate this limitation increase the pagesize to allocate 44 // fewer, larger chunks. Set the page size to 256 Kb to compensate 45 // for moving memory model limitation 46 ExecutableAllocator::pageSize = 256 * 1024; 47 #else 48 ExecutableAllocator::pageSize = PageAllocation::pagesize(); 49 #endif 50 } 51 52 ExecutablePool::Allocation ExecutablePool::systemAlloc(size_t size) 53 { 54 PageAllocation allocation = PageAllocation::allocate(size, PageAllocation::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true); 55 if (!allocation) 56 CRASH(); 57 return allocation; 58 } 59 60 void ExecutablePool::systemRelease(ExecutablePool::Allocation& allocation) 61 { 62 allocation.deallocate(); 63 } 64 65 bool ExecutableAllocator::isValid() const 66 { 67 return true; 68 } 69 70 #endif 71 36 72 #if ENABLE(ASSEMBLER_WX_EXCLUSIVE) 73 74 #if OS(WINDOWS) || OS(SYMBIAN) 75 #error "ASSEMBLER_WX_EXCLUSIVE not yet suported on this platform." 76 #endif 77 37 78 void ExecutableAllocator::reprotectRegion(void* start, size_t size, ProtectionSeting setting) 38 79 { … … 53 94 mprotect(pageStart, size, (setting == Writable) ? PROTECTION_FLAGS_RW : PROTECTION_FLAGS_RX); 54 95 } 96 55 97 #endif 56 98 57 99 #if CPU(ARM_TRADITIONAL) && OS(LINUX) && COMPILER(RVCT) 100 58 101 __asm void ExecutableAllocator::cacheFlush(void* code, size_t size) 59 102 { … … 68 111 bx lr 69 112 } 113 70 114 #endif 71 115 -
trunk/JavaScriptCore/jit/ExecutableAllocator.h
r64101 r64105 29 29 #include <limits> 30 30 #include <wtf/Assertions.h> 31 #include <wtf/PageAllocation.h> 31 32 #include <wtf/PassRefPtr.h> 32 33 #include <wtf/RefCounted.h> … … 59 60 #define PROTECTION_FLAGS_RW (PROT_READ | PROT_WRITE) 60 61 #define PROTECTION_FLAGS_RX (PROT_READ | PROT_EXEC) 61 #define INITIAL_PROTECTION_FLAGS PROTECTION_FLAGS_RX62 #else 63 #define INITIAL_PROTECTION_FLAGS (PROT_READ | PROT_WRITE | PROT_EXEC)62 #define EXECUTABLE_POOL_WRITABLE false 63 #else 64 #define EXECUTABLE_POOL_WRITABLE true 64 65 #endif 65 66 … … 86 87 class ExecutablePool : public RefCounted<ExecutablePool> { 87 88 private: 88 struct Allocation { 89 char* pages; 90 size_t size; 91 #if OS(SYMBIAN) 92 RChunk* chunk; 93 #endif 94 }; 89 typedef PageAllocation Allocation; 95 90 typedef Vector<Allocation, 2> AllocationList; 96 91 … … 122 117 ~ExecutablePool() 123 118 { 124 AllocationList:: const_iterator end = m_pools.end();125 for (AllocationList:: const_iterator ptr = m_pools.begin(); ptr != end; ++ptr)119 AllocationList::iterator end = m_pools.end(); 120 for (AllocationList::iterator ptr = m_pools.begin(); ptr != end; ++ptr) 126 121 ExecutablePool::systemRelease(*ptr); 127 122 } … … 131 126 private: 132 127 static Allocation systemAlloc(size_t n); 133 static void systemRelease( constAllocation& alloc);128 static void systemRelease(Allocation& alloc); 134 129 135 130 ExecutablePool(size_t n); … … 297 292 Allocation mem = systemAlloc(allocSize); 298 293 m_pools.append(mem); 299 m_freePtr = mem.pages;294 m_freePtr = static_cast<char*>(mem.base()); 300 295 if (!m_freePtr) 301 296 CRASH(); // Failed to allocate … … 308 303 309 304 Allocation result = systemAlloc(allocSize); 310 if (!result. pages)305 if (!result.base()) 311 306 CRASH(); // Failed to allocate 312 307 … … 314 309 if ((allocSize - n) > static_cast<size_t>(m_end - m_freePtr)) { 315 310 // Replace allocation pool 316 m_freePtr = result.pages+ n;317 m_end = result.pages+ allocSize;311 m_freePtr = static_cast<char*>(result.base()) + n; 312 m_end = static_cast<char*>(result.base()) + allocSize; 318 313 } 319 314 320 315 m_pools.append(result); 321 return result. pages;316 return result.base(); 322 317 } 323 318 -
trunk/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp
r64101 r64105 125 125 typedef AVLTree<AVLTreeAbstractorForFreeList, 40> SizeSortedFreeTree; 126 126 127 // Use madvise as apropriate to prevent freed pages from being spilled,128 // and to attempt to ensure that used memory is reported correctly.129 #if HAVE(MADV_FREE_REUSE)130 127 void release(void* position, size_t size) 131 128 { 132 while (madvise(position, size, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }129 m_allocation.decommit(position, size); 133 130 } 134 131 135 132 void reuse(void* position, size_t size) 136 133 { 137 while (madvise(position, size, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { } 138 } 139 #elif HAVE(MADV_DONTNEED) 140 void release(void* position, size_t size) 141 { 142 while (madvise(position, size, MADV_DONTNEED) == -1 && errno == EAGAIN) { } 143 } 144 145 void reuse(void*, size_t) {} 146 #else 147 void release(void*, size_t) {} 148 void reuse(void*, size_t) {} 149 #endif 134 bool okay = m_allocation.commit(position, size, EXECUTABLE_POOL_WRITABLE, true); 135 ASSERT_UNUSED(okay, okay); 136 } 150 137 151 138 // All addition to the free list should go through this method, rather than … … 289 276 : m_commonSize(commonSize) 290 277 , m_countFreedSinceLastCoalesce(0) 291 , m_totalHeapSize(totalHeapSize)292 278 { 293 279 // Cook up an address to allocate at, using the following recipe: … … 300 286 // 2^24, which should put up somewhere in the middle of usespace (in the address range 301 287 // 0x200000000000 .. 0x5fffffffffff). 288 #if VM_POOL_ASLR 302 289 intptr_t randomLocation = 0; 303 #if VM_POOL_ASLR304 290 randomLocation = arc4random() & ((1 << 25) - 1); 305 291 randomLocation += (1 << 24); 306 292 randomLocation <<= 21; 293 m_allocation = PageAllocation::reserveAt(reinterpret_cast<void*>(randomLocation), false, totalHeapSize, PageAllocation::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true); 294 #else 295 m_allocation = PageAllocation::reserve(totalHeapSize, PageAllocation::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true); 307 296 #endif 308 m_base = mmap(reinterpret_cast<void*>(randomLocation), m_totalHeapSize, INITIAL_PROTECTION_FLAGS, MAP_PRIVATE | MAP_ANON, VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY, 0); 309 310 if (m_base) { 311 // For simplicity, we keep all memory in m_freeList in a 'released' state. 312 // This means that we can simply reuse all memory when allocating, without 313 // worrying about it's previous state, and also makes coalescing m_freeList 314 // simpler since we need not worry about the possibility of coalescing released 315 // chunks with non-released ones. 316 release(m_base, m_totalHeapSize); 317 m_freeList.insert(new FreeListEntry(m_base, m_totalHeapSize)); 318 } 297 298 if (!!m_allocation) 299 m_freeList.insert(new FreeListEntry(m_allocation.base(), m_allocation.size())); 319 300 #if !ENABLE(INTERPRETER) 320 301 else … … 323 304 } 324 305 325 void* alloc(size_t size) 306 PageAllocation alloc(size_t size) 307 { 308 return PageAllocation(allocInternal(size), size, m_allocation); 309 } 310 311 void free(PageAllocation allocation) 312 { 313 void* pointer = allocation.base(); 314 size_t size = allocation.size(); 315 316 ASSERT(!!m_allocation); 317 // Call release to report to the operating system that this 318 // memory is no longer in use, and need not be paged out. 319 ASSERT(isWithinVMPool(pointer, size)); 320 release(pointer, size); 321 322 // Common-sized allocations are stored in the m_commonSizedAllocations 323 // vector; all other freed chunks are added to m_freeList. 324 if (size == m_commonSize) 325 m_commonSizedAllocations.append(pointer); 326 else 327 addToFreeList(new FreeListEntry(pointer, size)); 328 329 // Do some housekeeping. Every time we reach a point that 330 // 16MB of allocations have been freed, sweep m_freeList 331 // coalescing any neighboring fragments. 332 m_countFreedSinceLastCoalesce += size; 333 if (m_countFreedSinceLastCoalesce >= COALESCE_LIMIT) { 334 m_countFreedSinceLastCoalesce = 0; 335 coalesceFreeSpace(); 336 } 337 } 338 339 bool isValid() const { return !!m_allocation; } 340 341 private: 342 void* allocInternal(size_t size) 326 343 { 327 344 #if ENABLE(INTERPRETER) 328 if (!m_ base)345 if (!m_allocation) 329 346 return 0; 330 347 #else 331 ASSERT( m_base);348 ASSERT(!!m_allocation); 332 349 #endif 333 350 void* result; … … 391 408 } 392 409 393 void free(void* pointer, size_t size)394 {395 ASSERT(m_base);396 // Call release to report to the operating system that this397 // memory is no longer in use, and need not be paged out.398 ASSERT(isWithinVMPool(pointer, size));399 release(pointer, size);400 401 // Common-sized allocations are stored in the m_commonSizedAllocations402 // vector; all other freed chunks are added to m_freeList.403 if (size == m_commonSize)404 m_commonSizedAllocations.append(pointer);405 else406 addToFreeList(new FreeListEntry(pointer, size));407 408 // Do some housekeeping. Every time we reach a point that409 // 16MB of allocations have been freed, sweep m_freeList410 // coalescing any neighboring fragments.411 m_countFreedSinceLastCoalesce += size;412 if (m_countFreedSinceLastCoalesce >= COALESCE_LIMIT) {413 m_countFreedSinceLastCoalesce = 0;414 coalesceFreeSpace();415 }416 }417 418 bool isValid() const { return !!m_base; }419 420 private:421 422 410 #ifndef NDEBUG 423 411 bool isWithinVMPool(void* pointer, size_t size) 424 412 { 425 return pointer >= m_ base && (reinterpret_cast<char*>(pointer) + size <= reinterpret_cast<char*>(m_base) + m_totalHeapSize);413 return pointer >= m_allocation.base() && (reinterpret_cast<char*>(pointer) + size <= reinterpret_cast<char*>(m_allocation.base()) + m_allocation.size()); 426 414 } 427 415 #endif … … 437 425 size_t m_countFreedSinceLastCoalesce; 438 426 439 void* m_base; 440 size_t m_totalHeapSize; 427 PageAllocation m_allocation; 441 428 }; 442 429 … … 460 447 { 461 448 SpinLockHolder lock_holder(&spinlock); 462 463 449 ASSERT(allocator); 464 ExecutablePool::Allocation alloc = {reinterpret_cast<char*>(allocator->alloc(size)), size}; 465 return alloc; 466 } 467 468 void ExecutablePool::systemRelease(const ExecutablePool::Allocation& allocation) 450 return allocator->alloc(size); 451 } 452 453 void ExecutablePool::systemRelease(ExecutablePool::Allocation& allocation) 469 454 { 470 455 SpinLockHolder lock_holder(&spinlock); 471 472 456 ASSERT(allocator); 473 allocator->free(allocation .pages, allocation.size);457 allocator->free(allocation); 474 458 } 475 459 -
trunk/JavaScriptCore/wscript
r64101 r64105 39 39 if building_on_win32: 40 40 jscore_excludes += ['ExecutableAllocatorPosix.cpp', 'MarkStackPosix.cpp', 'ThreadingPthreads.cpp'] 41 sources += [' jit/ExecutableAllocatorWin.cpp', 'runtime/MarkStackWin.cpp']41 sources += ['runtime/MarkStackWin.cpp'] 42 42 else: 43 43 jscore_excludes.append('JSStringRefBSTR.cpp') -
trunk/JavaScriptGlue/ChangeLog
r62367 r64105 1 2010-07-26 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Bug 43009 - Abstract out page allocation from executable allocators 6 7 * ForwardingHeaders/wtf/PageAllocation.h: Added. 8 1 9 2010-07-01 Oliver Hunt <oliver@apple.com> 2 10 -
trunk/WebCore/ChangeLog
r64104 r64105 1 2010-07-26 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 Bug 43009 - Abstract out page allocation from executable allocators 6 7 * ForwardingHeaders/wtf/PageAllocation.h: Added. 8 1 9 2010-07-26 Yuta Kitamura <yutak@chromium.org> 2 10
Note: See TracChangeset
for help on using the changeset viewer.