Changeset 42842 in webkit for trunk/JavaScriptCore
- Timestamp:
- Apr 24, 2009, 2:53:46 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r42811 r42842 1 2009-04-23 Oliver Hunt <[email protected]> 2 3 Reviewed by Geoff Garen. 4 5 <rdar://problem/6050421> JavaScript register file should remap to release physical pages accumulated during deep recursion 6 7 We now track the maximum extent of the RegisterFile, and when we reach the final 8 return from JS (so the stack portion of the registerfile becomes empty) we see 9 if that extent is greater than maxExcessCapacity. If it is we use madvise or 10 VirtualFree to release the physical pages that were backing the excess. 11 12 * interpreter/RegisterFile.cpp: 13 (JSC::RegisterFile::releaseExcessCapacity): 14 * interpreter/RegisterFile.h: 15 (JSC::RegisterFile::RegisterFile): 16 (JSC::RegisterFile::shrink): 17 (JSC::RegisterFile::grow): 18 1 19 2009-04-23 Mark Rowe <[email protected]> 2 20 -
trunk/JavaScriptCore/interpreter/RegisterFile.cpp
r39673 r42842 43 43 } 44 44 45 void RegisterFile::releaseExcessCapacity() 46 { 47 m_maxUsed = m_start; 48 void* memoryToRelease = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(reinterpret_cast<char*>(m_start) + commitSize * 2 - 1) & ~(commitSize - 1)); 49 ptrdiff_t size = reinterpret_cast<char*>(m_end) - reinterpret_cast<char*>(memoryToRelease); 50 #if HAVE(MMAP) && !HAVE(VIRTUALALLOC) 51 while (madvise(memoryToRelease, size, MADV_FREE) == -1 && errno == EAGAIN) { } 52 #elif HAVE(VIRTUALALLOC) 53 VirtualFree(memoryToRelease, size, MEM_DECOMMIT); 54 m_commitEnd = memoryToRelease; 55 #endif 56 } 57 45 58 } // namespace JSC -
trunk/JavaScriptCore/interpreter/RegisterFile.h
r42705 r42842 115 115 static const size_t defaultMaxGlobals = 8192; 116 116 static const size_t commitSize = 1 << 14; 117 // Allow 8k of excess registers before we start trying to reap the registerfile 118 static const ptrdiff_t maxExcessCapacity = 8 * 1024; 117 119 118 120 RegisterFile(size_t capacity = defaultCapacity, size_t maxGlobals = defaultMaxGlobals); … … 139 141 140 142 private: 143 void releaseExcessCapacity(); 141 144 size_t m_numGlobals; 142 145 const size_t m_maxGlobals; … … 145 148 Register* m_max; 146 149 Register* m_buffer; 150 Register* m_maxUsed; 151 147 152 #if HAVE(VIRTUALALLOC) 148 153 Register* m_commitEnd; … … 186 191 m_start = m_buffer + maxGlobals; 187 192 m_end = m_start; 193 m_maxUsed = m_end; 188 194 m_max = m_start + capacity; 189 195 } … … 193 199 if (newEnd < m_end) 194 200 m_end = newEnd; 201 if (m_end == m_start && (m_maxUsed - m_start) > maxExcessCapacity) 202 releaseExcessCapacity(); 195 203 } 196 204 … … 214 222 #endif 215 223 224 if (newEnd > m_maxUsed) 225 m_maxUsed = newEnd; 226 216 227 m_end = newEnd; 217 228 return true;
Note:
See TracChangeset
for help on using the changeset viewer.