Title: [198648] trunk
Revision
198648
Author
[email protected]
Date
2016-03-24 15:43:06 -0700 (Thu, 24 Mar 2016)

Log Message

Web Inspector: Separate Debugger enable state from the debugger breakpoints enabled state
https://bugs.webkit.org/show_bug.cgi?id=152193
<rdar://problem/23867520>

Reviewed by Joseph Pecoraro.

Source/_javascript_Core:

When all breakpoints are disabled, we can recompile all JS
code and remove the necessary debugging code that is emitted.
This allows for the code that is executing to be almost as fast
as it is with the debugger completely disabled. This is in preparation for:
https://bugs.webkit.org/show_bug.cgi?id=155809
which will introduce a high fidelity profiler. That profiler
could be built off the principle that breakpoints are disabled
when we're performing a high fidelity profile. Doing so, for example,
allows the sampling profiler to better measure the real performance
of the JS of a particular application.

* debugger/Debugger.cpp:
(JSC::Debugger::setBreakpointsActivated):
(JSC::Debugger::setPauseOnExceptionsState):
* debugger/Debugger.h:
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::Graph):
* inspector/JSGlobalObjectScriptDebugServer.cpp:
(Inspector::JSGlobalObjectScriptDebugServer::attachDebugger):
(Inspector::JSGlobalObjectScriptDebugServer::detachDebugger):
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::enable):
* runtime/Executable.cpp:
(JSC::ScriptExecutable::newCodeBlockFor):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::createProgramCodeBlock):
(JSC::JSGlobalObject::createEvalCodeBlock):
(JSC::JSGlobalObject::createModuleProgramCodeBlock):
(JSC::JSGlobalObject::queueMicrotask):
(JSC::JSGlobalObject::hasDebugger):
(JSC::JSGlobalObject::hasInteractiveDebugger):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::runtimeFlags):
(JSC::JSGlobalObject::hasDebugger): Deleted.

Source/WebCore:

No new tests because this is already tested by inspector tests.

* inspector/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::attachDebugger):
(WebCore::PageScriptDebugServer::detachDebugger):

LayoutTests:

* inspector/script-profiler/event-type-API.html:
* inspector/script-profiler/event-type-Microtask.html:
* inspector/script-profiler/event-type-Other.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (198647 => 198648)


--- trunk/LayoutTests/ChangeLog	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/LayoutTests/ChangeLog	2016-03-24 22:43:06 UTC (rev 198648)
@@ -1,3 +1,15 @@
+2016-03-24  Saam barati  <[email protected]>
+
+        Web Inspector: Separate Debugger enable state from the debugger breakpoints enabled state
+        https://bugs.webkit.org/show_bug.cgi?id=152193
+        <rdar://problem/23867520>
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/script-profiler/event-type-API.html:
+        * inspector/script-profiler/event-type-Microtask.html:
+        * inspector/script-profiler/event-type-Other.html:
+
 2016-03-24  Daniel Bates  <[email protected]>
 
         Update expected results following <http://trac.webkit.org/changeset/198591>

Modified: trunk/LayoutTests/inspector/script-profiler/event-type-API.html (198647 => 198648)


--- trunk/LayoutTests/inspector/script-profiler/event-type-API.html	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/LayoutTests/inspector/script-profiler/event-type-API.html	2016-03-24 22:43:06 UTC (rev 198648)
@@ -36,7 +36,7 @@
         }
     });
 
-    // FIXME: <https://webkit.org/b/152193> Web Inspector: Separate Debugger enable state from being attached
+    // FIXME: <https://webkit.org/b/155851> Web Inspector: We should separate out attaching the debugger from the Debugger.enable event
     // Debugger should not need to be enabled for profiling to work.
     InspectorProtocol.sendCommand("Debugger.enable", {});
 

Modified: trunk/LayoutTests/inspector/script-profiler/event-type-Microtask.html (198647 => 198648)


--- trunk/LayoutTests/inspector/script-profiler/event-type-Microtask.html	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/LayoutTests/inspector/script-profiler/event-type-Microtask.html	2016-03-24 22:43:06 UTC (rev 198648)
@@ -37,7 +37,7 @@
         }
     });
 
-    // FIXME: <https://webkit.org/b/152193> Web Inspector: Separate Debugger enable state from being attached
+    // FIXME: <https://webkit.org/b/155851> Web Inspector: We should separate out attaching the debugger from the Debugger.enable event
     // Debugger should not need to be enabled for profiling to work.
     InspectorProtocol.sendCommand("Debugger.enable", {});
 

Modified: trunk/LayoutTests/inspector/script-profiler/event-type-Other.html (198647 => 198648)


--- trunk/LayoutTests/inspector/script-profiler/event-type-Other.html	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/LayoutTests/inspector/script-profiler/event-type-Other.html	2016-03-24 22:43:06 UTC (rev 198648)
@@ -54,7 +54,7 @@
         }
     });
 
-    // FIXME: <https://webkit.org/b/152193> Web Inspector: Separate Debugger enable state from being attached
+    // FIXME: <https://webkit.org/b/155851> Web Inspector: We should separate out attaching the debugger from the Debugger.enable event
     // Debugger should not need to be enabled for profiling to work.
     InspectorProtocol.sendCommand("Debugger.enable", {});
 

Modified: trunk/Source/_javascript_Core/ChangeLog (198647 => 198648)


--- trunk/Source/_javascript_Core/ChangeLog	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-03-24 22:43:06 UTC (rev 198648)
@@ -1,3 +1,46 @@
+2016-03-24  Saam barati  <[email protected]>
+
+        Web Inspector: Separate Debugger enable state from the debugger breakpoints enabled state
+        https://bugs.webkit.org/show_bug.cgi?id=152193
+        <rdar://problem/23867520>
+
+        Reviewed by Joseph Pecoraro.
+
+        When all breakpoints are disabled, we can recompile all JS
+        code and remove the necessary debugging code that is emitted.
+        This allows for the code that is executing to be almost as fast
+        as it is with the debugger completely disabled. This is in preparation for:
+        https://bugs.webkit.org/show_bug.cgi?id=155809
+        which will introduce a high fidelity profiler. That profiler
+        could be built off the principle that breakpoints are disabled
+        when we're performing a high fidelity profile. Doing so, for example,
+        allows the sampling profiler to better measure the real performance
+        of the JS of a particular application.
+
+        * debugger/Debugger.cpp:
+        (JSC::Debugger::setBreakpointsActivated):
+        (JSC::Debugger::setPauseOnExceptionsState):
+        * debugger/Debugger.h:
+        * dfg/DFGGraph.cpp:
+        (JSC::DFG::Graph::Graph):
+        * inspector/JSGlobalObjectScriptDebugServer.cpp:
+        (Inspector::JSGlobalObjectScriptDebugServer::attachDebugger):
+        (Inspector::JSGlobalObjectScriptDebugServer::detachDebugger):
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::enable):
+        * runtime/Executable.cpp:
+        (JSC::ScriptExecutable::newCodeBlockFor):
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::createProgramCodeBlock):
+        (JSC::JSGlobalObject::createEvalCodeBlock):
+        (JSC::JSGlobalObject::createModuleProgramCodeBlock):
+        (JSC::JSGlobalObject::queueMicrotask):
+        (JSC::JSGlobalObject::hasDebugger):
+        (JSC::JSGlobalObject::hasInteractiveDebugger):
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::runtimeFlags):
+        (JSC::JSGlobalObject::hasDebugger): Deleted.
+
 2016-03-24  Michael Saboff  <[email protected]>
 
         Create private builtin helper advanceStringIndexUnicode() for use by RegExp builtins

Modified: trunk/Source/_javascript_Core/debugger/Debugger.cpp (198647 => 198648)


--- trunk/Source/_javascript_Core/debugger/Debugger.cpp	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/_javascript_Core/debugger/Debugger.cpp	2016-03-24 22:43:06 UTC (rev 198648)
@@ -528,7 +528,11 @@
 
 void Debugger::setBreakpointsActivated(bool activated)
 {
+    if (activated == m_breakpointsActivated)
+        return;
+
     m_breakpointsActivated = activated;
+    recompileAllJSFunctions();
 }
 
 void Debugger::setPauseOnExceptionsState(PauseOnExceptionsState pause)

Modified: trunk/Source/_javascript_Core/debugger/Debugger.h (198647 => 198648)


--- trunk/Source/_javascript_Core/debugger/Debugger.h	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/_javascript_Core/debugger/Debugger.h	2016-03-24 22:43:06 UTC (rev 198648)
@@ -62,7 +62,8 @@
         return m_currentException;
     }
 
-    bool needsExceptionCallbacks() const { return m_pauseOnExceptionsState != DontPauseOnExceptions; }
+    bool needsExceptionCallbacks() const { return m_breakpointsActivated && m_pauseOnExceptionsState != DontPauseOnExceptions; }
+    bool isInteractivelyDebugging() const { return m_breakpointsActivated; }
 
     enum ReasonForDetach {
         TerminatingDebuggingSession,
@@ -75,7 +76,6 @@
     BreakpointID setBreakpoint(Breakpoint, unsigned& actualLine, unsigned& actualColumn);
     void removeBreakpoint(BreakpointID);
     void clearBreakpoints();
-    void setBreakpointsActivated(bool);
     void activateBreakpoints() { setBreakpointsActivated(true); }
     void deactivateBreakpoints() { setBreakpointsActivated(false); }
 
@@ -199,6 +199,7 @@
         BreakpointDisabled,
         BreakpointEnabled
     };
+    void setBreakpointsActivated(bool);
     void toggleBreakpoint(CodeBlock*, Breakpoint&, BreakpointState);
     void applyBreakpoints(CodeBlock*);
     void toggleBreakpoint(Breakpoint&, BreakpointState);

Modified: trunk/Source/_javascript_Core/dfg/DFGGraph.cpp (198647 => 198648)


--- trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/_javascript_Core/dfg/DFGGraph.cpp	2016-03-24 22:43:06 UTC (rev 198648)
@@ -78,7 +78,7 @@
 {
     ASSERT(m_profiledBlock);
     
-    m_hasDebuggerEnabled = m_profiledBlock->globalObject()->hasDebugger()
+    m_hasDebuggerEnabled = m_profiledBlock->globalObject()->hasInteractiveDebugger()
         || Options::forceDebuggerBytecodeGeneration();
 }
 

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectScriptDebugServer.cpp (198647 => 198648)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectScriptDebugServer.cpp	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectScriptDebugServer.cpp	2016-03-24 22:43:06 UTC (rev 198648)
@@ -43,7 +43,6 @@
 void JSGlobalObjectScriptDebugServer::attachDebugger()
 {
     attach(&m_globalObject);
-    recompileAllJSFunctions();
 }
 
 void JSGlobalObjectScriptDebugServer::detachDebugger(bool isBeingDestroyed)

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp (198647 => 198648)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorDebuggerAgent.cpp	2016-03-24 22:43:06 UTC (rev 198648)
@@ -88,7 +88,6 @@
     if (m_enabled)
         return;
 
-    m_scriptDebugServer.setBreakpointsActivated(true);
     m_scriptDebugServer.addListener(this);
 
     if (m_listener)

Modified: trunk/Source/_javascript_Core/runtime/Executable.cpp (198647 => 198648)


--- trunk/Source/_javascript_Core/runtime/Executable.cpp	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/_javascript_Core/runtime/Executable.cpp	2016-03-24 22:43:06 UTC (rev 198648)
@@ -297,7 +297,7 @@
     RELEASE_ASSERT(!executable->codeBlockFor(kind));
     JSGlobalObject* globalObject = scope->globalObject();
     ParserError error;
-    DebuggerMode debuggerMode = globalObject->hasDebugger() ? DebuggerOn : DebuggerOff;
+    DebuggerMode debuggerMode = globalObject->hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;
     ProfilerMode profilerMode = globalObject->hasLegacyProfiler() ? ProfilerOn : ProfilerOff;
     UnlinkedFunctionCodeBlock* unlinkedCodeBlock = 
         executable->m_unlinkedExecutable->unlinkedCodeBlockFor(

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (198647 => 198648)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2016-03-24 22:43:06 UTC (rev 198648)
@@ -1000,7 +1000,7 @@
 {
     ParserError error;
     JSParserStrictMode strictMode = executable->isStrictMode() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict;
-    DebuggerMode debuggerMode = hasDebugger() ? DebuggerOn : DebuggerOff;
+    DebuggerMode debuggerMode = hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;
     ProfilerMode profilerMode = hasLegacyProfiler() ? ProfilerOn : ProfilerOff;
     UnlinkedProgramCodeBlock* unlinkedCodeBlock = vm().codeCache()->getProgramCodeBlock(
         vm(), executable, executable->source(), JSParserBuiltinMode::NotBuiltin, strictMode, 
@@ -1021,7 +1021,7 @@
 {
     ParserError error;
     JSParserStrictMode strictMode = executable->isStrictMode() ? JSParserStrictMode::Strict : JSParserStrictMode::NotStrict;
-    DebuggerMode debuggerMode = hasDebugger() ? DebuggerOn : DebuggerOff;
+    DebuggerMode debuggerMode = hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;
     ProfilerMode profilerMode = hasLegacyProfiler() ? ProfilerOn : ProfilerOff;
     UnlinkedEvalCodeBlock* unlinkedCodeBlock = vm().codeCache()->getEvalCodeBlock(
         vm(), executable, executable->source(), JSParserBuiltinMode::NotBuiltin, strictMode, thisTDZMode, isArrowFunctionContext, debuggerMode, profilerMode, error, variablesUnderTDZ);
@@ -1040,7 +1040,7 @@
 UnlinkedModuleProgramCodeBlock* JSGlobalObject::createModuleProgramCodeBlock(CallFrame* callFrame, ModuleProgramExecutable* executable)
 {
     ParserError error;
-    DebuggerMode debuggerMode = hasDebugger() ? DebuggerOn : DebuggerOff;
+    DebuggerMode debuggerMode = hasInteractiveDebugger() ? DebuggerOn : DebuggerOff;
     ProfilerMode profilerMode = hasLegacyProfiler() ? ProfilerOn : ProfilerOff;
     UnlinkedModuleProgramCodeBlock* unlinkedCodeBlock = vm().codeCache()->getModuleProgramCodeBlock(
         vm(), executable, executable->source(), JSParserBuiltinMode::NotBuiltin, debuggerMode, profilerMode, error);
@@ -1152,4 +1152,14 @@
     vm().queueMicrotask(this, task);
 }
 
+bool JSGlobalObject::hasDebugger() const
+{ 
+    return m_debugger;
+}
+
+bool JSGlobalObject::hasInteractiveDebugger() const 
+{ 
+    return m_debugger && m_debugger->isInteractivelyDebugging();
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (198647 => 198648)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2016-03-24 22:43:06 UTC (rev 198648)
@@ -368,7 +368,8 @@
 
     DECLARE_EXPORT_INFO;
 
-    bool hasDebugger() const { return m_debugger; }
+    bool hasDebugger() const;
+    bool hasInteractiveDebugger() const;
     bool hasLegacyProfiler() const;
     const RuntimeFlags& runtimeFlags() const { return m_runtimeFlags; }
 

Modified: trunk/Source/WebCore/ChangeLog (198647 => 198648)


--- trunk/Source/WebCore/ChangeLog	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/WebCore/ChangeLog	2016-03-24 22:43:06 UTC (rev 198648)
@@ -1,3 +1,17 @@
+2016-03-24  Saam barati  <[email protected]>
+
+        Web Inspector: Separate Debugger enable state from the debugger breakpoints enabled state
+        https://bugs.webkit.org/show_bug.cgi?id=152193
+        <rdar://problem/23867520>
+
+        Reviewed by Joseph Pecoraro.
+
+        No new tests because this is already tested by inspector tests.
+
+        * inspector/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::attachDebugger):
+        (WebCore::PageScriptDebugServer::detachDebugger):
+
 2016-03-24  Jer Noble  <[email protected]>
 
         [MSE] Make calling HTMLMediaElement.buffered less expensive

Modified: trunk/Source/WebCore/inspector/PageScriptDebugServer.cpp (198647 => 198648)


--- trunk/Source/WebCore/inspector/PageScriptDebugServer.cpp	2016-03-24 22:35:35 UTC (rev 198647)
+++ trunk/Source/WebCore/inspector/PageScriptDebugServer.cpp	2016-03-24 22:43:06 UTC (rev 198648)
@@ -60,7 +60,6 @@
 void PageScriptDebugServer::attachDebugger()
 {
     m_page.setDebugger(this);
-    recompileAllJSFunctions();
 }
 
 void PageScriptDebugServer::detachDebugger(bool isBeingDestroyed)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to