Changeset 43885 in webkit for trunk/JavaScriptCore/interpreter
- Timestamp:
- May 19, 2009, 8:25:47 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/interpreter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/interpreter/RegisterFile.cpp
r42862 r43885 45 45 void RegisterFile::releaseExcessCapacity() 46 46 { 47 #if HAVE(MMAP) && HAVE(MADV_FREE) && !HAVE(VIRTUALALLOC) 48 while (madvise(m_start, (m_max - m_start) * sizeof(Register), MADV_FREE) == -1 && errno == EAGAIN) { } 49 #elif HAVE(VIRTUALALLOC) 50 VirtualFree(madvise(m_start, (m_max - m_start) * sizeof(Register), MEM_DECOMMIT); 51 m_commitEnd = m_start; 52 #endif 47 53 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(MADV_FREE) && !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 = reinterpret_cast<Register*>(memoryToRelease);55 #endif56 54 } 57 55 -
trunk/JavaScriptCore/interpreter/RegisterFile.h
r42842 r43885 157 157 }; 158 158 159 // FIXME: Add a generic getpagesize() to WTF, then move this function to WTF as well. 160 inline bool isPageAligned(size_t size) { return size != 0 && size % (8 * 1024) == 0; } 161 159 162 inline RegisterFile::RegisterFile(size_t capacity, size_t maxGlobals) 160 163 : m_numGlobals(0) … … 166 169 , m_globalObject(0) 167 170 { 171 // Verify that our values will play nice with mmap and VirtualAlloc. 172 ASSERT(isPageAligned(maxGlobals)); 173 ASSERT(isPageAligned(capacity)); 174 168 175 size_t bufferLength = (capacity + maxGlobals) * sizeof(Register); 169 176 #if HAVE(MMAP) … … 197 204 inline void RegisterFile::shrink(Register* newEnd) 198 205 { 199 if (newEnd < m_end) 200 m_end = newEnd; 201 if (m_end == m_start && (m_maxUsed - m_start) > maxExcessCapacity) 206 if (newEnd >= m_end) 207 return; 208 m_end = newEnd; 209 if (m_end == m_start && (m_maxUsed - m_start) > maxExcessCapacity) 202 210 releaseExcessCapacity(); 203 211 }
Note:
See TracChangeset
for help on using the changeset viewer.