]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - interpreter/RegisterFile.cpp
JavaScriptCore-576.tar.gz
[apple/javascriptcore.git] / interpreter / RegisterFile.cpp
index 50698f5f010ef3191e7a69eeb2cb772d848e3dbc..510effe0dd6c09a83584dc748969412823c52a17 100644 (file)
@@ -36,10 +36,24 @@ RegisterFile::~RegisterFile()
 #if HAVE(MMAP)
     munmap(m_buffer, ((m_max - m_start) + m_maxGlobals) * sizeof(Register));
 #elif HAVE(VIRTUALALLOC)
+#if OS(WINCE)
+    VirtualFree(m_buffer, DWORD(m_commitEnd) - DWORD(m_buffer), MEM_DECOMMIT);
+#endif
     VirtualFree(m_buffer, 0, MEM_RELEASE);
 #else
-    #error "Don't know how to release virtual memory on this platform."
+    fastFree(m_buffer);
+#endif
+}
+
+void RegisterFile::releaseExcessCapacity()
+{
+#if HAVE(MMAP) && HAVE(MADV_FREE) && !HAVE(VIRTUALALLOC)
+    while (madvise(m_start, (m_max - m_start) * sizeof(Register), MADV_FREE) == -1 && errno == EAGAIN) { }
+#elif HAVE(VIRTUALALLOC)
+    VirtualFree(m_start, (m_max - m_start) * sizeof(Register), MEM_DECOMMIT);
+    m_commitEnd = m_start;
 #endif
+    m_maxUsed = m_start;
 }
 
 } // namespace JSC