Call Heap::discardAllCompiledCode() in low memory situations
https://bugs.webkit.org/show_bug.cgi?id=83335
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
Restructured Heap::discardAllCompiledCode() to do the "Is JavaScriptRunning?"
check inline so that it can be called directly without this check.
* heap/Heap.cpp:
(JSC::Heap::discardAllCompiledCode):
(JSC::Heap::collectAllGarbage):
* heap/Heap.h: Added JS_EXPORT_PRIVATE to discardAllCompiledCode() so it can be
called from WebCore.
(Heap):
* runtime/JSGlobalData.h: Removed unused " void discardAllCompiledCode()" declaration.
(JSGlobalData):
Source/WebCore:
Added call to discardAllCompiledCode() when under memory pressure.
We can re-JIT as needed. This is similar to what we used to do when we did
a full GC which also cleaned up JIT code. Doing a full GC typically didn't
help our memory situation, in fact it made things worse in the really low
memory situation as it caused more paging.
Added pass through discardAllCompiledCode() method to GCController.
* bindings/js/GCController.cpp:
(WebCore::GCController::discardAllCompiledCode):
(WebCore):
* bindings/js/GCController.h:
(GCController):
* platform/mac/MemoryPressureHandlerMac.mm:
(WebCore::MemoryPressureHandler::releaseMemory):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113445 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/heap/Heap.cpp b/Source/JavaScriptCore/heap/Heap.cpp
index a41764f..0b4d9a8 100644
--- a/Source/JavaScriptCore/heap/Heap.cpp
+++ b/Source/JavaScriptCore/heap/Heap.cpp
@@ -772,8 +772,9 @@
{
// If JavaScript is running, it's not safe to recompile, since we'll end
// up throwing away code that is live on the stack.
- ASSERT(!m_globalData->dynamicGlobalObject);
-
+ if (m_globalData->dynamicGlobalObject)
+ return;
+
for (FunctionExecutable* current = m_functions.head(); current; current = current->next())
current->discardCode();
}
@@ -782,8 +783,7 @@
{
if (!m_isSafeToCollect)
return;
- if (!m_globalData->dynamicGlobalObject)
- discardAllCompiledCode();
+ discardAllCompiledCode();
collect(DoSweep);
}