Changeset 62511 in webkit
- Timestamp:
- Jul 5, 2010 5:22:42 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r62493 r62511 1 2010-07-05 Gavin Barraclough <barraclough@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 https://bugs.webkit.org/show_bug.cgi?id=41641 6 7 Update compile flags to allow use of ExecutableAllocatorFixedVMPool on platforms 8 other than x86-64 (this may be useful on 32-bit platforms, too). 9 10 Simplify ifdefs by dividing into thwo broad allocation strategies 11 (ENABLE_EXECUTABLE_ALLOCATOR_FIXED & ENABLE_EXECUTABLE_ALLOCATOR_DEMAND). 12 13 Rename constant used in the code to have names descriptive of their purpose, 14 rather than their specific value on a given platform. 15 16 * jit/ExecutableAllocator.cpp: 17 (JSC::ExecutableAllocator::reprotectRegion): 18 (JSC::ExecutableAllocator::cacheFlush): 19 * jit/ExecutableAllocatorFixedVMPool.cpp: 20 (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): 21 (JSC::FixedVMPoolAllocator::free): 22 (JSC::ExecutablePool::systemAlloc): 23 * jit/ExecutableAllocatorPosix.cpp: 24 * jit/ExecutableAllocatorSymbian.cpp: 25 * jit/ExecutableAllocatorWin.cpp: 26 * wtf/Platform.h: 27 1 28 2010-07-05 Steve Block <steveblock@google.com> 2 29 -
trunk/JavaScriptCore/jit/ExecutableAllocator.cpp
r39083 r62511 34 34 size_t ExecutableAllocator::pageSize = 0; 35 35 36 #if ENABLE(ASSEMBLER_WX_EXCLUSIVE) 37 void ExecutableAllocator::reprotectRegion(void* start, size_t size, ProtectionSeting setting) 38 { 39 if (!pageSize) 40 intializePageSize(); 41 42 // Calculate the start of the page containing this region, 43 // and account for this extra memory within size. 44 intptr_t startPtr = reinterpret_cast<intptr_t>(start); 45 intptr_t pageStartPtr = startPtr & ~(pageSize - 1); 46 void* pageStart = reinterpret_cast<void*>(pageStartPtr); 47 size += (startPtr - pageStartPtr); 48 49 // Round size up 50 size += (pageSize - 1); 51 size &= ~(pageSize - 1); 52 53 mprotect(pageStart, size, (setting == Writable) ? PROTECTION_FLAGS_RW : PROTECTION_FLAGS_RX); 54 } 55 #endif 56 57 #if CPU(ARM_TRADITIONAL) && OS(LINUX) && COMPILER(RVCT) 58 __asm void ExecutableAllocator::cacheFlush(void* code, size_t size) 59 { 60 ARM 61 push {r7} 62 add r1, r1, r0 63 mov r7, #0xf0000 64 add r7, r7, #0x2 65 mov r2, #0x0 66 svc #0x0 67 pop {r7} 68 bx lr 69 } 70 #endif 71 36 72 } 37 73 -
trunk/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp
r57821 r62511 28 28 #include "ExecutableAllocator.h" 29 29 30 #if ENABLE( ASSEMBLER) && OS(DARWIN) && CPU(X86_64)30 #if ENABLE(EXECUTABLE_ALLOCATOR_FIXED) 31 31 32 32 #include <errno.h> … … 40 40 #include <wtf/VMTags.h> 41 41 42 #if CPU(X86_64) 43 // These limits suitable on 64-bit platforms (particularly x86-64, where we require all jumps to have a 2Gb max range). 44 #define VM_POOL_SIZE (2u * 1024u * 1024u * 1024u) // 2Gb 45 #define COALESCE_LIMIT (16u * 1024u * 1024u) // 16Mb 46 #define VM_POOL_ASLR 1 47 #else 48 // These limits are hopefully sensible on embedded platforms. 49 #define VM_POOL_SIZE (32u * 1024u * 1024u) // 32Mb 50 #define COALESCE_LIMIT (4u * 1024u * 1024u) // 4Mb 51 #define VM_POOL_ASLR 0 52 #endif 53 42 54 using namespace WTF; 43 55 44 56 namespace JSC { 45 46 #define TWO_GB (2u * 1024u * 1024u * 1024u)47 #define SIXTEEN_MB (16u * 1024u * 1024u)48 57 49 58 // FreeListEntry describes a free chunk of memory, stored in the freeList. … … 292 301 // 2^24, which should put up somewhere in the middle of usespace (in the address range 293 302 // 0x200000000000 .. 0x5fffffffffff). 294 intptr_t randomLocation = arc4random() & ((1 << 25) - 1); 303 intptr_t randomLocation = 0; 304 #if VM_POOL_ASLR 305 randomLocation = arc4random() & ((1 << 25) - 1); 295 306 randomLocation += (1 << 24); 296 307 randomLocation <<= 21; 308 #endif 297 309 m_base = mmap(reinterpret_cast<void*>(randomLocation), m_totalHeapSize, INITIAL_PROTECTION_FLAGS, MAP_PRIVATE | MAP_ANON, VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY, 0); 298 310 if (!m_base) … … 388 400 // coalescing any neighboring fragments. 389 401 m_countFreedSinceLastCoalesce += size; 390 if (m_countFreedSinceLastCoalesce >= SIXTEEN_MB) {402 if (m_countFreedSinceLastCoalesce >= COALESCE_LIMIT) { 391 403 m_countFreedSinceLastCoalesce = 0; 392 404 coalesceFreeSpace(); … … 430 442 431 443 if (!allocator) 432 allocator = new FixedVMPoolAllocator(JIT_ALLOCATOR_LARGE_ALLOC_SIZE, TWO_GB);444 allocator = new FixedVMPoolAllocator(JIT_ALLOCATOR_LARGE_ALLOC_SIZE, VM_POOL_SIZE); 433 445 ExecutablePool::Allocation alloc = {reinterpret_cast<char*>(allocator->alloc(size)), size}; 434 446 return alloc; -
trunk/JavaScriptCore/jit/ExecutableAllocatorPosix.cpp
r58167 r62511 28 28 #include "ExecutableAllocator.h" 29 29 30 #if ENABLE( ASSEMBLER) && OS(UNIX) && !OS(SYMBIAN)30 #if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND) && !OS(WINDOWS) && !OS(SYMBIAN) 31 31 32 32 #include <sys/mman.h> … … 35 35 36 36 namespace JSC { 37 38 #if !(OS(DARWIN) && CPU(X86_64))39 37 40 38 void ExecutableAllocator::intializePageSize() … … 58 56 } 59 57 60 #endif // !(OS(DARWIN) && CPU(X86_64))61 62 #if ENABLE(ASSEMBLER_WX_EXCLUSIVE)63 void ExecutableAllocator::reprotectRegion(void* start, size_t size, ProtectionSeting setting)64 {65 if (!pageSize)66 intializePageSize();67 68 // Calculate the start of the page containing this region,69 // and account for this extra memory within size.70 intptr_t startPtr = reinterpret_cast<intptr_t>(start);71 intptr_t pageStartPtr = startPtr & ~(pageSize - 1);72 void* pageStart = reinterpret_cast<void*>(pageStartPtr);73 size += (startPtr - pageStartPtr);74 75 // Round size up76 size += (pageSize - 1);77 size &= ~(pageSize - 1);78 79 mprotect(pageStart, size, (setting == Writable) ? PROTECTION_FLAGS_RW : PROTECTION_FLAGS_RX);80 }81 #endif82 83 #if CPU(ARM_TRADITIONAL) && OS(LINUX) && COMPILER(RVCT)84 __asm void ExecutableAllocator::cacheFlush(void* code, size_t size)85 {86 ARM87 push {r7}88 add r1, r1, r089 mov r7, #0xf000090 add r7, r7, #0x291 mov r2, #0x092 svc #0x093 pop {r7}94 bx lr95 }96 #endif97 98 58 } 99 59 100 #endif // HAVE(ASSEMBLER)60 #endif -
trunk/JavaScriptCore/jit/ExecutableAllocatorSymbian.cpp
r52791 r62511 23 23 #include "ExecutableAllocator.h" 24 24 25 #if ENABLE( ASSEMBLER) && OS(SYMBIAN)25 #if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND) && OS(SYMBIAN) 26 26 27 27 #include <e32hal.h> -
trunk/JavaScriptCore/jit/ExecutableAllocatorWin.cpp
r52791 r62511 28 28 #include "ExecutableAllocator.h" 29 29 30 #if ENABLE( ASSEMBLER) && OS(WINDOWS)30 #if ENABLE(EXECUTABLE_ALLOCATOR_DEMAND) && OS(WINDOWS) 31 31 32 32 #include "windows.h" -
trunk/JavaScriptCore/wtf/Platform.h
r62422 r62511 1044 1044 #endif 1045 1045 1046 /* Pick which allocator to use; we only need an executable allocator if the assembler is compiled in. 1047 On x86-64 we use a single fixed mmap, on other platforms we mmap on demand. */ 1048 #if ENABLE(ASSEMBLER) 1049 #if CPU(X86_64) 1050 #define ENABLE_EXECUTABLE_ALLOCATOR_FIXED 1 1051 #else 1052 #define ENABLE_EXECUTABLE_ALLOCATOR_DEMAND 1 1053 #endif 1054 #endif 1055 1046 1056 #if !defined(ENABLE_PAN_SCROLLING) && OS(WINDOWS) 1047 1057 #define ENABLE_PAN_SCROLLING 1
Note: See TracChangeset
for help on using the changeset viewer.