Changeset 39673 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jan 6, 2009, 11:41:33 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r39672 r39673 1 2009-01-06 Oliver Hunt <[email protected]> 2 3 Reviewed by Gavin Barraclough. 4 5 <rdar://problem/6040850> JavaScript register file should use VirtualAlloc on Windows 6 7 Fairly simple, just reserve 4Mb of address space for the 8 register file, and then commit one section at a time. We 9 don't release committed memory as we drop back, but then 10 mac doesn't either so this probably not too much of a 11 problem. 12 13 * interpreter/RegisterFile.cpp: 14 (JSC::RegisterFile::~RegisterFile): 15 * interpreter/RegisterFile.h: 16 (JSC::RegisterFile::RegisterFile): 17 (JSC::RegisterFile::grow): 18 1 19 2009-01-06 Alexey Proskuryakov <[email protected]> 2 20 -
trunk/JavaScriptCore/interpreter/RegisterFile.cpp
r38520 r39673 37 37 munmap(m_buffer, ((m_max - m_start) + m_maxGlobals) * sizeof(Register)); 38 38 #elif HAVE(VIRTUALALLOC) 39 // FIXME: Use VirtualFree. 40 fastFree(m_buffer); 39 VirtualFree(m_buffer, 0, MEM_RELEASE); 41 40 #else 42 41 #error "Don't know how to release virtual memory on this platform." -
trunk/JavaScriptCore/interpreter/RegisterFile.h
r39351 r39673 112 112 static const size_t defaultCapacity = 524288; 113 113 static const size_t defaultMaxGlobals = 8192; 114 static const size_t allocationSize = 1 << 14; 115 static const size_t allocationSizeMask = allocationSize - 1; 114 116 115 117 RegisterFile(size_t capacity = defaultCapacity, size_t maxGlobals = defaultMaxGlobals) … … 130 132 } 131 133 #elif HAVE(VIRTUALALLOC) 132 // FIXME: Use VirtualAlloc, and commit pages as we go. 133 m_buffer = static_cast<Register*>(fastMalloc(bufferLength)); 134 // Ensure bufferLength is a multiple of allocation size 135 bufferLength = (bufferLength + allocationSizeMask) & ~allocationSizeMask; 136 m_buffer = static_cast<Register*>(VirtualAlloc(0, bufferLength, MEM_RESERVE, PAGE_READWRITE)); 137 if (!m_buffer) { 138 fprintf(stderr, "Could not allocate register file: %d\n", errno); 139 CRASH(); 140 } 141 int initialAllocation = (maxGlobals * sizeof(Register) + allocationSizeMask) & ~allocationSizeMask; 142 void* commitCheck = VirtualAlloc(m_buffer, initialAllocation, MEM_COMMIT, PAGE_READWRITE); 143 if (commitCheck != m_buffer) { 144 fprintf(stderr, "Could not allocate register file: %d\n", errno); 145 CRASH(); 146 } 147 m_maxCommitted = reinterpret_cast<Register*>(reinterpret_cast<char*>(m_buffer) + initialAllocation); 134 148 #else 135 149 #error "Don't know how to reserve virtual memory on this platform." … … 161 175 return false; 162 176 #if !HAVE(MMAP) && HAVE(VIRTUALALLOC) 163 // FIXME: Use VirtualAlloc, and commit pages as we go. 177 if (newEnd > m_maxCommitted) { 178 ptrdiff_t additionalAllocation = ((reinterpret_cast<char*>(newEnd) - reinterpret_cast<char*>(m_maxCommitted)) + allocationSizeMask) & ~allocationSizeMask; 179 if (!VirtualAlloc(m_maxCommitted, additionalAllocation, MEM_COMMIT, PAGE_READWRITE)) { 180 fprintf(stderr, "Could not allocate register file: %d\n", errno); 181 CRASH(); 182 } 183 m_maxCommitted = reinterpret_cast<Register*>(reinterpret_cast<char*>(m_maxCommitted) + additionalAllocation); 184 } 164 185 #endif 165 186 m_end = newEnd; … … 184 205 Register* m_max; 185 206 Register* m_buffer; 207 #if HAVE(VIRTUALALLOC) 208 Register* m_maxCommitted; 209 #endif 210 186 211 JSGlobalObject* m_globalObject; // The global object whose vars are currently stored in the register file. 187 212 };
Note:
See TracChangeset
for help on using the changeset viewer.