clearCode() should clear code
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Aug 2015 01:18:45 +0000 (01:18 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Aug 2015 01:18:45 +0000 (01:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148203

Reviewed by Saam Barati.

Clearing code used to require two steps: clearCode() and
clearUnlinkedCodeForRecompilation(). Unsurprisingly, clients sometimes
did one or the other or both without much rhyme or reason.

This patch simplifies things by merging both functions into clearCode().

* bytecode/UnlinkedFunctionExecutable.h:
* debugger/Debugger.cpp:
* heap/Heap.cpp:
(JSC::Heap::deleteAllCompiledCode):
(JSC::Heap::clearUnmarkedExecutables):
(JSC::Heap::deleteAllUnlinkedFunctionCode): Deleted. No need for this
function anymore since it was only used by clients who already called
clearCode() (and it would be terribly wrong to use without doing both.)

* heap/Heap.h:
(JSC::Heap::sizeAfterLastFullCollection):
* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::TypeRecompiler::visit):
(Inspector::TypeRecompiler::operator()):
* runtime/Executable.cpp:
(JSC::FunctionExecutable::visitChildren):
(JSC::FunctionExecutable::clearCode):
(JSC::FunctionExecutable::clearUnlinkedCodeForRecompilation): Deleted.
* runtime/Executable.h:
* runtime/VM.cpp:
(JSC::VM::deleteAllCode):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188675 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h
Source/JavaScriptCore/debugger/Debugger.cpp
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
Source/JavaScriptCore/runtime/Executable.cpp
Source/JavaScriptCore/runtime/Executable.h
Source/JavaScriptCore/runtime/VM.cpp

index ea52d14..7b8313b 100644 (file)
@@ -1,3 +1,38 @@
+2015-08-19  Geoffrey Garen  <ggaren@apple.com>
+
+        clearCode() should clear code
+        https://bugs.webkit.org/show_bug.cgi?id=148203
+
+        Reviewed by Saam Barati.
+
+        Clearing code used to require two steps: clearCode() and
+        clearUnlinkedCodeForRecompilation(). Unsurprisingly, clients sometimes
+        did one or the other or both without much rhyme or reason.
+
+        This patch simplifies things by merging both functions into clearCode().
+
+        * bytecode/UnlinkedFunctionExecutable.h:
+        * debugger/Debugger.cpp:
+        * heap/Heap.cpp:
+        (JSC::Heap::deleteAllCompiledCode):
+        (JSC::Heap::clearUnmarkedExecutables):
+        (JSC::Heap::deleteAllUnlinkedFunctionCode): Deleted. No need for this
+        function anymore since it was only used by clients who already called
+        clearCode() (and it would be terribly wrong to use without doing both.)
+
+        * heap/Heap.h:
+        (JSC::Heap::sizeAfterLastFullCollection):
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::TypeRecompiler::visit):
+        (Inspector::TypeRecompiler::operator()):
+        * runtime/Executable.cpp:
+        (JSC::FunctionExecutable::visitChildren):
+        (JSC::FunctionExecutable::clearCode):
+        (JSC::FunctionExecutable::clearUnlinkedCodeForRecompilation): Deleted.
+        * runtime/Executable.h:
+        * runtime/VM.cpp:
+        (JSC::VM::deleteAllCode):
+
 2015-08-19  Alex Christensen  <achristensen@webkit.org>
 
         CMake Windows build should not include files directly from other Source directories
index 4e054b2..cf8d4cb 100644 (file)
@@ -102,7 +102,7 @@ public:
 
     FunctionExecutable* link(VM&, const SourceCode&, int overrideLineNumber = -1);
 
-    void clearCodeForRecompilation()
+    void clearCode()
     {
         m_codeBlockForCall.clear();
         m_codeBlockForConstruct.clear();
index 4d7871f..08dcec6 100644 (file)
@@ -88,7 +88,6 @@ inline void Recompiler::visit(JSCell* cell)
 
     ExecState* exec = function->scope()->globalObject()->JSGlobalObject::globalExec();
     executable->clearCode();
-    executable->clearUnlinkedCodeForRecompilation();
     if (m_debugger == function->scope()->globalObject()->debugger())
         m_sourceProviders.add(executable->source().provider(), exec);
 }
index 5a805ae..020f46f 100644 (file)
@@ -936,15 +936,6 @@ void Heap::deleteAllCompiledCode()
     m_codeBlocks.deleteUnmarkedAndUnreferenced(FullCollection);
 }
 
-void Heap::deleteAllUnlinkedFunctionCode()
-{
-    for (ExecutableBase* current : m_compiledCode) {
-        if (!current->isFunctionExecutable())
-            continue;
-        static_cast<FunctionExecutable*>(current)->clearUnlinkedCodeForRecompilation();
-    }
-}
-
 void Heap::clearUnmarkedExecutables()
 {
     GCPHASE(ClearUnmarkedExecutables);
index 9cbebdc..1c93702 100644 (file)
@@ -209,7 +209,6 @@ public:
     size_t sizeAfterLastFullCollection() const { return m_sizeAfterLastFullCollect; }
 
     JS_EXPORT_PRIVATE void deleteAllCompiledCode();
-    void deleteAllUnlinkedFunctionCode();
 
     void didAllocate(size_t);
     void didAbandon(size_t);
index 83d7b69..3456255 100644 (file)
@@ -316,7 +316,6 @@ public:
 
         FunctionExecutable* executable = jsCast<FunctionExecutable*>(cell);
         executable->clearCode();
-        executable->clearUnlinkedCodeForRecompilation();
     }
     inline IterationStatus operator()(JSCell* cell)
     {
index 9dc694f..6a5123d 100644 (file)
@@ -557,13 +557,9 @@ void FunctionExecutable::visitChildren(JSCell* cell, SlotVisitor& visitor)
     visitor.append(&thisObject->m_singletonFunction);
 }
 
-void FunctionExecutable::clearUnlinkedCodeForRecompilation()
-{
-    m_unlinkedExecutable->clearCodeForRecompilation();
-}
-
 void FunctionExecutable::clearCode()
 {
+    m_unlinkedExecutable->clearCode();
     m_codeBlockForCall = nullptr;
     m_codeBlockForConstruct = nullptr;
     Base::clearCode();
index cf2bde8..ebb3966 100644 (file)
@@ -640,7 +640,6 @@ public:
     JSString* nameValue() const { return m_unlinkedExecutable->nameValue(); }
     size_t parameterCount() const { return m_unlinkedExecutable->parameterCount(); } // Excluding 'this'!
 
-    void clearUnlinkedCodeForRecompilation();
     static void visitChildren(JSCell*, SlotVisitor&);
     static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto)
     {
index 917c55f..bfcf799 100644 (file)
@@ -485,7 +485,6 @@ void VM::deleteAllCode()
     m_codeCache->clear();
     m_regExpCache->deleteAllCode();
     heap.deleteAllCompiledCode();
-    heap.deleteAllUnlinkedFunctionCode();
     heap.reportAbandonedObjectGraph();
 }