Changeset 44341 in webkit for trunk/JavaScriptCore/jit/ExecutableAllocatorPosix.cpp
- Timestamp:
- Jun 1, 2009, 6:20:35 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/jit/ExecutableAllocatorPosix.cpp
r42705 r44341 28 28 #include "ExecutableAllocator.h" 29 29 30 #if ENABLE(ASSEMBLER) && !(PLATFORM(MAC) && PLATFORM(X86_64))30 #if ENABLE(ASSEMBLER) 31 31 32 32 #include <sys/mman.h> … … 35 35 36 36 namespace JSC { 37 38 #if !(PLATFORM(MAC) && PLATFORM(X86_64)) 37 39 38 40 void ExecutableAllocator::intializePageSize() … … 43 45 ExecutablePool::Allocation ExecutablePool::systemAlloc(size_t n) 44 46 { 45 ExecutablePool::Allocation alloc = { reinterpret_cast<char*>(mmap(NULL, n, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY, 0)), n };47 ExecutablePool::Allocation alloc = { reinterpret_cast<char*>(mmap(NULL, n, INITIAL_PROTECTION_FLAGS, MAP_PRIVATE | MAP_ANON, VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY, 0)), n }; 46 48 return alloc; 47 49 } 48 50 49 void ExecutablePool::systemRelease(const ExecutablePool::Allocation& alloc) 51 void ExecutablePool::systemRelease(const ExecutablePool::Allocation& alloc) 50 52 { 51 53 int result = munmap(alloc.pages, alloc.size); … … 53 55 } 54 56 57 #endif // !(PLATFORM(MAC) && PLATFORM(X86_64)) 58 59 #if ENABLE(ASSEMBLER_WX_EXCLUSIVE) 60 void ExecutableAllocator::reprotectRegion(void* start, size_t size, ProtectionSeting setting) 61 { 62 if (!pageSize) 63 intializePageSize(); 64 65 // Calculate the start of the page containing this region, 66 // and account for this extra memory within size. 67 intptr_t startPtr = reinterpret_cast<intptr_t>(start); 68 intptr_t pageStartPtr = startPtr & ~(pageSize - 1); 69 void* pageStart = reinterpret_cast<void*>(pageStartPtr); 70 size += (startPtr - pageStartPtr); 71 72 // Round size up 73 size += (pageSize - 1); 74 size &= ~(pageSize - 1); 75 76 mprotect(pageStart, size, (setting == Writable) ? PROTECTION_FLAGS_RW : PROTECTION_FLAGS_RX); 77 } 78 #endif 79 55 80 } 56 81
Note:
See TracChangeset
for help on using the changeset viewer.