Unreviewed rollout of r162534, this caused inspector test failures.
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Jan 2014 21:02:16 +0000 (21:02 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Jan 2014 21:02:16 +0000 (21:02 +0000)
* bindings/js/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::addListener):
(WebCore::PageScriptDebugServer::removeListener):
(WebCore::PageScriptDebugServer::recompileAllJSFunctions):
(WebCore::PageScriptDebugServer::didRemoveLastListener):
* bindings/js/PageScriptDebugServer.h:
* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::ScriptDebugServer):
(WebCore::ScriptDebugServer::recompileAllJSFunctionsSoon):
(WebCore::ScriptDebugServer::recompileAllJSFunctionsTimerFired):
* bindings/js/ScriptDebugServer.h:
* bindings/js/WorkerScriptDebugServer.cpp:
(WebCore::WorkerScriptDebugServer::addListener):
(WebCore::WorkerScriptDebugServer::recompileAllJSFunctions):
(WebCore::WorkerScriptDebugServer::removeListener):
* inspector/InspectorProfilerAgent.cpp:

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/PageScriptDebugServer.cpp
Source/WebCore/bindings/js/PageScriptDebugServer.h
Source/WebCore/bindings/js/ScriptDebugServer.cpp
Source/WebCore/bindings/js/ScriptDebugServer.h
Source/WebCore/bindings/js/WorkerScriptDebugServer.cpp
Source/WebCore/inspector/InspectorProfilerAgent.cpp

index 9627768..205d9e6 100644 (file)
@@ -1,3 +1,24 @@
+2014-01-22  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Unreviewed rollout of r162534, this caused inspector test failures.
+
+        * bindings/js/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::addListener):
+        (WebCore::PageScriptDebugServer::removeListener):
+        (WebCore::PageScriptDebugServer::recompileAllJSFunctions):
+        (WebCore::PageScriptDebugServer::didRemoveLastListener):
+        * bindings/js/PageScriptDebugServer.h:
+        * bindings/js/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::ScriptDebugServer):
+        (WebCore::ScriptDebugServer::recompileAllJSFunctionsSoon):
+        (WebCore::ScriptDebugServer::recompileAllJSFunctionsTimerFired):
+        * bindings/js/ScriptDebugServer.h:
+        * bindings/js/WorkerScriptDebugServer.cpp:
+        (WebCore::WorkerScriptDebugServer::addListener):
+        (WebCore::WorkerScriptDebugServer::recompileAllJSFunctions):
+        (WebCore::WorkerScriptDebugServer::removeListener):
+        * inspector/InspectorProfilerAgent.cpp:
+
 2014-01-22  peavo@outlook.com  <peavo@outlook.com>
 
         Crashes in setTextForIterator
index 50daf26..1cec7b3 100644 (file)
@@ -94,12 +94,10 @@ void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* pag
     OwnPtr<ListenerSet>& listeners = m_pageListenersMap.add(page, nullptr).iterator->value;
     if (!listeners)
         listeners = adoptPtr(new ListenerSet);
-
-    bool wasEmpty = listeners->isEmpty();
     listeners->add(listener);
 
-    if (wasEmpty)
-        didAddFirstListener(page);
+    recompileAllJSFunctionsSoon();
+    page->setDebugger(this);
 }
 
 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, Page* page)
@@ -113,7 +111,6 @@ void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, Page*
 
     ListenerSet* listeners = it->value.get();
     listeners->remove(listener);
-
     if (listeners->isEmpty()) {
         m_pageListenersMap.remove(it);
         didRemoveLastListener(page);
@@ -123,7 +120,11 @@ void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, Page*
 void PageScriptDebugServer::recompileAllJSFunctions()
 {
     JSLockHolder lock(JSDOMWindow::commonVM());
-    Debugger::recompileAllJSFunctions(JSDOMWindow::commonVM());
+    // If JavaScript stack is not empty postpone recompilation.
+    if (JSDOMWindow::commonVM()->entryScope)
+        recompileAllJSFunctionsSoon();
+    else
+        Debugger::recompileAllJSFunctions(JSDOMWindow::commonVM());
 }
 
 ScriptDebugServer::ListenerSet* PageScriptDebugServer::getListenersForGlobalObject(JSGlobalObject* globalObject)
@@ -160,13 +161,6 @@ void PageScriptDebugServer::didContinue(JSC::JSGlobalObject* globalObject)
         setJavaScriptPaused(page->group(), false);
 }
 
-void PageScriptDebugServer::didAddFirstListener(Page* page)
-{
-    // Set debugger before recompiling to get sourceParsed callbacks.
-    page->setDebugger(this);
-    recompileAllJSFunctions();
-}
-
 void PageScriptDebugServer::didRemoveLastListener(Page* page)
 {
     ASSERT(page);
@@ -174,9 +168,8 @@ void PageScriptDebugServer::didRemoveLastListener(Page* page)
     if (m_pausedPage == page)
         m_doneProcessingDebuggerEvents = true;
 
-    // Clear debugger before recompiling because we do not need sourceParsed callbacks.
-    page->setDebugger(nullptr);
-    recompileAllJSFunctions();
+    recompileAllJSFunctionsSoon();
+    page->setDebugger(0);
 }
 
 void PageScriptDebugServer::runEventLoopWhilePaused()
index c702cfa..ed7f24e 100644 (file)
@@ -65,7 +65,6 @@ private:
 
     virtual void runEventLoopWhilePaused();
 
-    void didAddFirstListener(Page*);
     void didRemoveLastListener(Page*);
 
     void setJavaScriptPaused(const PageGroup&, bool paused);
index 403dfe9..dac52a2 100644 (file)
@@ -40,7 +40,6 @@
 #include "JavaScriptCallFrame.h"
 #include "PageConsole.h"
 #include "Sound.h"
-#include "Timer.h"
 #include <bindings/ScriptValue.h>
 #include <debugger/DebuggerCallFrame.h>
 #include <parser/SourceProvider.h>
@@ -58,6 +57,7 @@ ScriptDebugServer::ScriptDebugServer(bool isInWorkerThread)
     : Debugger(isInWorkerThread)
     , m_doneProcessingDebuggerEvents(true)
     , m_callingListeners(false)
+    , m_recompileTimer(this, &ScriptDebugServer::recompileAllJSFunctionsTimerFired)
 {
 }
 
@@ -313,6 +313,16 @@ void ScriptDebugServer::handlePause(Debugger::ReasonForPause, JSGlobalObject* vm
     dispatchFunctionToListeners(&ScriptDebugServer::dispatchDidContinue, vmEntryGlobalObject);
 }
 
+void ScriptDebugServer::recompileAllJSFunctionsSoon()
+{
+    m_recompileTimer.startOneShot(0);
+}
+
+void ScriptDebugServer::recompileAllJSFunctionsTimerFired(Timer<ScriptDebugServer>&)
+{
+    recompileAllJSFunctions();
+}
+
 const Vector<ScriptBreakpointAction>& ScriptDebugServer::getActionsForBreakpoint(JSC::BreakpointID breakpointID)
 {
     ASSERT(breakpointID != JSC::noBreakpointID);
index 93540ae..fa0ee5d 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "ScriptBreakpoint.h"
 #include "ScriptDebugListener.h"
+#include "Timer.h"
 #include <bindings/ScriptObject.h>
 #include <debugger/Debugger.h>
 #include <wtf/HashMap.h>
@@ -58,6 +59,7 @@ public:
     void removeBreakpoint(JSC::BreakpointID);
     void clearBreakpoints();
 
+    void recompileAllJSFunctionsSoon();
     virtual void recompileAllJSFunctions() = 0;
 
     const Vector<ScriptBreakpointAction>& getActionsForBreakpoint(JSC::BreakpointID);
@@ -107,9 +109,12 @@ private:
     virtual void handlePause(JSC::Debugger::ReasonForPause, JSC::JSGlobalObject*) override final;
     virtual void notifyDoneProcessingDebuggerEvents() override final;
 
+    void recompileAllJSFunctionsTimerFired(Timer<ScriptDebugServer>&);
+
     unsigned m_hitCount;
     bool m_callingListeners;
     BreakpointIDToActionsMap m_breakpointIDToActions;
+    Timer<ScriptDebugServer> m_recompileTimer;
 
     friend class DebuggerCallFrameScope;
 };
index ed31a3a..bec9e57 100644 (file)
@@ -55,13 +55,22 @@ void WorkerScriptDebugServer::addListener(ScriptDebugListener* listener)
     if (!listener)
         return;
 
-    bool wasEmpty = m_listeners.isEmpty();
+    if (m_listeners.isEmpty())
+        m_workerGlobalScope->script()->attachDebugger(this);
     m_listeners.add(listener);
+    recompileAllJSFunctions();
+}
 
-    if (wasEmpty) {
-        m_workerGlobalScope->script()->attachDebugger(this);
-        recompileAllJSFunctions();
-    }
+void WorkerScriptDebugServer::recompileAllJSFunctions()
+{
+    JSC::VM* vm = m_workerGlobalScope->script()->vm();
+
+    JSC::JSLockHolder lock(vm);
+    // If JavaScript stack is not empty postpone recompilation.
+    if (vm->entryScope)
+        recompileAllJSFunctionsSoon();
+    else
+        JSC::Debugger::recompileAllJSFunctions(vm);
 }
 
 void WorkerScriptDebugServer::removeListener(ScriptDebugListener* listener)
@@ -70,19 +79,8 @@ void WorkerScriptDebugServer::removeListener(ScriptDebugListener* listener)
         return;
 
     m_listeners.remove(listener);
-
-    if (m_listeners.isEmpty()) {
+    if (m_listeners.isEmpty())
         m_workerGlobalScope->script()->detachDebugger(this);
-        recompileAllJSFunctions();
-    }
-}
-
-void WorkerScriptDebugServer::recompileAllJSFunctions()
-{
-    JSC::VM* vm = m_workerGlobalScope->script()->vm();
-
-    JSC::JSLockHolder lock(vm);
-    JSC::Debugger::recompileAllJSFunctions(vm);
 }
 
 void WorkerScriptDebugServer::runEventLoopWhilePaused()
index b68dfbe..1f25a3e 100644 (file)
@@ -73,7 +73,7 @@ public:
 private:
     virtual void recompileScript() override
     {
-        PageScriptDebugServer::shared().recompileAllJSFunctions();
+        PageScriptDebugServer::shared().recompileAllJSFunctionsSoon();
     }
 
     virtual void startProfiling(const String& title) override