Title: [188714] trunk/Source/_javascript_Core
Revision
188714
Author
[email protected]
Date
2015-08-20 15:53:24 -0700 (Thu, 20 Aug 2015)

Log Message

forEachCodeBlock should wait for all CodeBlocks automatically
https://bugs.webkit.org/show_bug.cgi?id=148255

Reviewed by Saam Barati.

Previously, all clients needed to wait manually before calling
forEachCodeBlock. That's easy to get wrong, and at least one place
got it wrong. Let's do this automatically instead.

* debugger/Debugger.cpp:
(JSC::Debugger::Debugger):
(JSC::Debugger::setSteppingMode):
(JSC::Debugger::toggleBreakpoint): No need to wait manually;
forEachCodeBlock will do it automatically now.

(JSC::Debugger::recompileAllJSFunctions): We still need to wait manually
here because this is an iteration of the heap, which does not wait
automatically. Use the new helper function for waiting.

(JSC::Debugger::clearBreakpoints):
(JSC::Debugger::clearDebuggerRequests):
(JSC::Debugger::setBreakpointsActivated):
(JSC::Debugger::forEachCodeBlock): Deleted. No need to wait manually.

* debugger/Debugger.h:

* dfg/DFGWorklist.cpp:
(JSC::DFG::completeAllPlansForVM):
* dfg/DFGWorklist.h:
(JSC::DFG::completeAllPlansForVM): Added a helper function that replaces
vm.prepareToDeleteCode. This new function is clearer because we need
to call it sometimes even if we are not going to delete code.

* heap/HeapInlines.h:
(JSC::Heap::forEachCodeBlock): Moved.

* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::recompileAllJSFunctionsForTypeProfiling): Use the new helper
function.

* runtime/JSCInlines.h:
(JSC::Heap::forEachCodeBlock): Do the waiting automatically.

* runtime/VM.cpp:
(JSC::VM::stopSampling):
(JSC::VM::deleteAllCode):
(JSC::VM::setEnabledProfiler):
(JSC::VM::prepareToDeleteCode): Deleted.
* runtime/VM.h: No need to wait manually.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (188713 => 188714)


--- trunk/Source/_javascript_Core/ChangeLog	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-08-20 22:53:24 UTC (rev 188714)
@@ -1,3 +1,55 @@
+2015-08-20  Geoffrey Garen  <[email protected]>
+
+        forEachCodeBlock should wait for all CodeBlocks automatically
+        https://bugs.webkit.org/show_bug.cgi?id=148255
+
+        Reviewed by Saam Barati.
+
+        Previously, all clients needed to wait manually before calling
+        forEachCodeBlock. That's easy to get wrong, and at least one place
+        got it wrong. Let's do this automatically instead.
+
+        * debugger/Debugger.cpp:
+        (JSC::Debugger::Debugger):
+        (JSC::Debugger::setSteppingMode):
+        (JSC::Debugger::toggleBreakpoint): No need to wait manually;
+        forEachCodeBlock will do it automatically now.
+
+        (JSC::Debugger::recompileAllJSFunctions): We still need to wait manually
+        here because this is an iteration of the heap, which does not wait
+        automatically. Use the new helper function for waiting.
+
+        (JSC::Debugger::clearBreakpoints):
+        (JSC::Debugger::clearDebuggerRequests):
+        (JSC::Debugger::setBreakpointsActivated):
+        (JSC::Debugger::forEachCodeBlock): Deleted. No need to wait manually.
+
+        * debugger/Debugger.h:
+
+        * dfg/DFGWorklist.cpp:
+        (JSC::DFG::completeAllPlansForVM):
+        * dfg/DFGWorklist.h:
+        (JSC::DFG::completeAllPlansForVM): Added a helper function that replaces
+        vm.prepareToDeleteCode. This new function is clearer because we need
+        to call it sometimes even if we are not going to delete code.
+
+        * heap/HeapInlines.h:
+        (JSC::Heap::forEachCodeBlock): Moved.
+
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::recompileAllJSFunctionsForTypeProfiling): Use the new helper
+        function.
+
+        * runtime/JSCInlines.h:
+        (JSC::Heap::forEachCodeBlock): Do the waiting automatically.
+
+        * runtime/VM.cpp:
+        (JSC::VM::stopSampling):
+        (JSC::VM::deleteAllCode):
+        (JSC::VM::setEnabledProfiler):
+        (JSC::VM::prepareToDeleteCode): Deleted.
+        * runtime/VM.h: No need to wait manually.
+
 2015-08-20  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r188675.

Modified: trunk/Source/_javascript_Core/debugger/Debugger.cpp (188713 => 188714)


--- trunk/Source/_javascript_Core/debugger/Debugger.cpp	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/debugger/Debugger.cpp	2015-08-20 22:53:24 UTC (rev 188714)
@@ -145,13 +145,6 @@
     Debugger& m_debugger;
 };
 
-template<typename Functor>
-void Debugger::forEachCodeBlock(Functor& functor)
-{
-    m_vm->prepareToDeleteCode();
-    m_vm->heap.forEachCodeBlock(functor);
-}
-
 Debugger::Debugger(bool isInWorkerThread)
     : m_vm(nullptr)
     , m_pauseOnExceptionsState(DontPauseOnExceptions)
@@ -248,8 +241,6 @@
     if (mode == m_steppingMode || !m_vm)
         return;
 
-    m_vm->prepareToDeleteCode();
-
     m_steppingMode = mode;
     SetSteppingModeFunctor functor(this, mode);
     m_vm->heap.forEachCodeBlock(functor);
@@ -340,7 +331,7 @@
     if (!m_vm)
         return;
     ToggleBreakpointFunctor functor(this, breakpoint, enabledOrNot);
-    forEachCodeBlock(functor);
+    m_vm->heap.forEachCodeBlock(functor);
 }
 
 void Debugger::recompileAllJSFunctions(VM* vm)
@@ -358,7 +349,9 @@
         return;
     }
 
-    vm->prepareToDeleteCode();
+#if ENABLE(DFG_JIT)
+    DFG::completeAllPlansForVM(*m_vm);
+#endif
 
     Recompiler recompiler(this);
     HeapIterationScope iterationScope(vm->heap);
@@ -530,7 +523,7 @@
     if (!m_vm)
         return;
     ClearCodeBlockDebuggerRequestsFunctor functor(this);
-    forEachCodeBlock(functor);
+    m_vm->heap.forEachCodeBlock(functor);
 }
 
 class Debugger::ClearDebuggerRequestsFunctor {
@@ -555,7 +548,7 @@
 {
     ASSERT(m_vm);
     ClearDebuggerRequestsFunctor functor(globalObject);
-    forEachCodeBlock(functor);
+    m_vm->heap.forEachCodeBlock(functor);
 }
 
 void Debugger::setBreakpointsActivated(bool activated)

Modified: trunk/Source/_javascript_Core/debugger/Debugger.h (188713 => 188714)


--- trunk/Source/_javascript_Core/debugger/Debugger.h	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/debugger/Debugger.h	2015-08-20 22:53:24 UTC (rev 188714)
@@ -185,8 +185,6 @@
 
     void clearDebuggerRequests(JSGlobalObject*);
 
-    template<typename Functor> inline void forEachCodeBlock(Functor&);
-
     VM* m_vm;
     HashSet<JSGlobalObject*> m_globalObjects;
 

Modified: trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp (188713 => 188714)


--- trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/dfg/DFGWorklist.cpp	2015-08-20 22:53:24 UTC (rev 188714)
@@ -448,6 +448,14 @@
     return 0;
 }
 
+void completeAllPlansForVM(VM& vm)
+{
+    for (unsigned i = DFG::numberOfWorklists(); i--;) {
+        if (DFG::Worklist* worklist = DFG::worklistForIndexOrNull(i))
+            worklist->completeAllPlansForVM(vm);
+    }
+}
+
 } } // namespace JSC::DFG
 
 #endif // ENABLE(DFG_JIT)

Modified: trunk/Source/_javascript_Core/dfg/DFGWorklist.h (188713 => 188714)


--- trunk/Source/_javascript_Core/dfg/DFGWorklist.h	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/dfg/DFGWorklist.h	2015-08-20 22:53:24 UTC (rev 188714)
@@ -139,6 +139,8 @@
     }
 }
 
+void completeAllPlansForVM(VM&);
+
 } } // namespace JSC::DFG
 
 #endif // ENABLE(DFG_JIT)

Modified: trunk/Source/_javascript_Core/heap/HeapInlines.h (188713 => 188714)


--- trunk/Source/_javascript_Core/heap/HeapInlines.h	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/heap/HeapInlines.h	2015-08-20 22:53:24 UTC (rev 188714)
@@ -203,11 +203,6 @@
     return forEachProtectedCell(functor);
 }
 
-template<typename Functor> inline void Heap::forEachCodeBlock(Functor& functor)
-{
-    return m_codeBlocks.iterate<Functor>(functor);
-}
-
 inline void* Heap::allocateWithDestructor(size_t bytes)
 {
 #if ENABLE(ALLOCATION_LOGGING)

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp (188713 => 188714)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp	2015-08-20 22:53:24 UTC (rev 188714)
@@ -33,6 +33,7 @@
 #include "InspectorRuntimeAgent.h"
 
 #include "Completion.h"
+#include "DFGWorklist.h"
 #include "HeapIterationScope.h"
 #include "InjectedScript.h"
 #include "InjectedScriptManager.h"
@@ -332,7 +333,9 @@
     bool needsToRecompile = shouldRecompileFromTypeProfiler || shouldRecompileFromControlFlowProfiler;
 
     if (needsToRecompile) {
-        vm.prepareToDeleteCode();
+#if ENABLE(DFG_JIT)
+        DFG::completeAllPlansForVM(vm);
+#endif
         TypeRecompiler recompiler;
         HeapIterationScope iterationScope(vm.heap);
         vm.heap.objectSpace().forEachLiveCell(iterationScope, recompiler);

Modified: trunk/Source/_javascript_Core/runtime/JSCInlines.h (188713 => 188714)


--- trunk/Source/_javascript_Core/runtime/JSCInlines.h	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/runtime/JSCInlines.h	2015-08-20 22:53:24 UTC (rev 188714)
@@ -38,6 +38,7 @@
 // header that pulls in most (all?) of the interesting things in JSC.
 
 #include "CallFrameInlines.h"
+#include "DFGWorklist.h"
 #include "ExceptionHelpers.h"
 #include "GCIncomingRefCountedInlines.h"
 #include "HeapInlines.h"
@@ -53,4 +54,18 @@
 #include "StructureInlines.h"
 #include "WeakGCMapInlines.h"
 
+namespace JSC {
+
+template<typename Functor> inline void Heap::forEachCodeBlock(Functor& functor)
+{
+    // We don't know the full set of CodeBlocks until compilation has terminated.
+#if ENABLE(DFG_JIT)
+    DFG::completeAllPlansForVM(*m_vm);
+#endif
+
+    return m_codeBlocks.iterate<Functor>(functor);
+}
+
+} // namespace JSC
+
 #endif // JSCInlines_h

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (188713 => 188714)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2015-08-20 22:53:24 UTC (rev 188714)
@@ -471,23 +471,14 @@
     interpreter->stopSampling();
 }
 
-void VM::prepareToDeleteCode()
-{
-#if ENABLE(DFG_JIT)
-    for (unsigned i = DFG::numberOfWorklists(); i--;) {
-        if (DFG::Worklist* worklist = DFG::worklistForIndexOrNull(i))
-            worklist->completeAllPlansForVM(*this);
-    }
-#endif // ENABLE(DFG_JIT)
-}
-
 void VM::deleteAllCode()
 {
-    prepareToDeleteCode();
     m_codeCache->clear();
     m_regExpCache->deleteAllCode();
+#if ENABLE(DFG_JIT)
+    DFG::completeAllPlansForVM(*this);
+#endif
     heap.deleteAllCompiledCode();
-    heap.deleteAllUnlinkedFunctionCode();
     heap.reportAbandonedObjectGraph();
 }
 
@@ -708,7 +699,6 @@
 {
     m_enabledProfiler = profiler;
     if (m_enabledProfiler) {
-        prepareToDeleteCode();
         SetEnabledProfilerFunctor functor;
         heap.forEachCodeBlock(functor);
     }

Modified: trunk/Source/_javascript_Core/runtime/VM.h (188713 => 188714)


--- trunk/Source/_javascript_Core/runtime/VM.h	2015-08-20 22:51:21 UTC (rev 188713)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2015-08-20 22:53:24 UTC (rev 188714)
@@ -533,8 +533,6 @@
     JSLock& apiLock() { return *m_apiLock; }
     CodeCache* codeCache() { return m_codeCache.get(); }
 
-    void prepareToDeleteCode();
-        
     JS_EXPORT_PRIVATE void deleteAllCode();
 
     void registerWatchpointForImpureProperty(const Identifier&, Watchpoint*);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to