Changeset 39673 in webkit for trunk/JavaScriptCore/interpreter/RegisterFile.h
- Timestamp:
- Jan 6, 2009, 11:41:33 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.