Web Inspector: Introduce a method to enable code coverage profiler without enabling...
authorsbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Aug 2016 23:32:03 +0000 (23:32 +0000)
committersbarati@apple.com <sbarati@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Aug 2016 23:32:03 +0000 (23:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160750
<rdar://problem/27793469>

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::disableTypeProfiler):
(Inspector::InspectorRuntimeAgent::enableControlFlowProfiler):
(Inspector::InspectorRuntimeAgent::disableControlFlowProfiler):
(Inspector::InspectorRuntimeAgent::setTypeProfilerEnabledState):
(Inspector::InspectorRuntimeAgent::setControlFlowProfilerEnabledState):
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/protocol/Runtime.json:

Source/WebInspectorUI:

* UserInterface/Base/Main.js:
(WebInspector.loaded):
* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype._setTypeTokenAnnotatorEnabledState):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h
Source/JavaScriptCore/inspector/protocol/Runtime.json
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js

index efa8102..6a8965d 100644 (file)
@@ -1,5 +1,22 @@
 2016-08-15  Saam Barati  <sbarati@apple.com>
 
+        Web Inspector: Introduce a method to enable code coverage profiler without enabling type profiler
+        https://bugs.webkit.org/show_bug.cgi?id=160750
+        <rdar://problem/27793469>
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::disableTypeProfiler):
+        (Inspector::InspectorRuntimeAgent::enableControlFlowProfiler):
+        (Inspector::InspectorRuntimeAgent::disableControlFlowProfiler):
+        (Inspector::InspectorRuntimeAgent::setTypeProfilerEnabledState):
+        (Inspector::InspectorRuntimeAgent::setControlFlowProfilerEnabledState):
+        * inspector/agents/InspectorRuntimeAgent.h:
+        * inspector/protocol/Runtime.json:
+
+2016-08-15  Saam Barati  <sbarati@apple.com>
+
         Array.prototype.map builtin should go on the fast path when constructor===@Array
         https://bugs.webkit.org/show_bug.cgi?id=160836
 
index 5b22544..b50129c 100644 (file)
@@ -317,6 +317,16 @@ void InspectorRuntimeAgent::disableTypeProfiler(ErrorString&)
     setTypeProfilerEnabledState(false);
 }
 
+void InspectorRuntimeAgent::enableControlFlowProfiler(ErrorString&)
+{
+    setControlFlowProfilerEnabledState(true);
+}
+
+void InspectorRuntimeAgent::disableControlFlowProfiler(ErrorString&)
+{
+    setControlFlowProfilerEnabledState(false);
+}
+
 void InspectorRuntimeAgent::setTypeProfilerEnabledState(bool isTypeProfilingEnabled)
 {
     if (m_isTypeProfilingEnabled == isTypeProfilingEnabled)
@@ -326,10 +336,22 @@ void InspectorRuntimeAgent::setTypeProfilerEnabledState(bool isTypeProfilingEnab
     VM& vm = m_vm;
     vm.whenIdle([&vm, isTypeProfilingEnabled] () {
         bool shouldRecompileFromTypeProfiler = (isTypeProfilingEnabled ? vm.enableTypeProfiler() : vm.disableTypeProfiler());
-        bool shouldRecompileFromControlFlowProfiler = (isTypeProfilingEnabled ? vm.enableControlFlowProfiler() : vm.disableControlFlowProfiler());
-        bool needsToRecompile = shouldRecompileFromTypeProfiler || shouldRecompileFromControlFlowProfiler;
+        if (shouldRecompileFromTypeProfiler)
+            vm.deleteAllCode();
+    });
+}
+
+void InspectorRuntimeAgent::setControlFlowProfilerEnabledState(bool isControlFlowProfilingEnabled)
+{
+    if (m_isControlFlowProfilingEnabled == isControlFlowProfilingEnabled)
+        return;
+    m_isControlFlowProfilingEnabled = isControlFlowProfilingEnabled;
+
+    VM& vm = m_vm;
+    vm.whenIdle([&vm, isControlFlowProfilingEnabled] () {
+        bool shouldRecompileFromControlFlowProfiler = (isControlFlowProfilingEnabled ? vm.enableControlFlowProfiler() : vm.disableControlFlowProfiler());
 
-        if (needsToRecompile)
+        if (shouldRecompileFromControlFlowProfiler)
             vm.deleteAllCode();
     });
 }
index 4b87cad..915118b 100644 (file)
@@ -70,6 +70,8 @@ public:
     void getRuntimeTypesForVariablesAtOffsets(ErrorString&, const Inspector::InspectorArray& locations, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::TypeDescription>>&) override;
     void enableTypeProfiler(ErrorString&) override;
     void disableTypeProfiler(ErrorString&) override;
+    void enableControlFlowProfiler(ErrorString&) override;
+    void disableControlFlowProfiler(ErrorString&) override;
     void getBasicBlocks(ErrorString&, const String& in_sourceID, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::BasicBlock>>& out_basicBlocks) override;
 
     bool enabled() const { return m_enabled; }
@@ -86,12 +88,14 @@ protected:
 
 private:
     void setTypeProfilerEnabledState(bool);
+    void setControlFlowProfilerEnabledState(bool);
 
     InjectedScriptManager& m_injectedScriptManager;
     ScriptDebugServer& m_scriptDebugServer;
     JSC::VM& m_vm;
     bool m_enabled {false};
     bool m_isTypeProfilingEnabled {false};
+    bool m_isControlFlowProfilingEnabled {false};
 };
 
 } // namespace Inspector
index af874d6..06d65c1 100644 (file)
             "description": "Disables type profiling on the VM."
         },
         {
+            "name": "enableControlFlowProfiler",
+            "description": "Enables control flow profiling on the VM."
+        },
+        {
+            "name": "disableControlFlowProfiler",
+            "description": "Disables control flow profiling on the VM."
+        },
+        {
             "name": "getBasicBlocks",
             "parameters": [
                 { "name": "sourceID", "type": "string", "description": "Indicates which sourceID information is requested for." }
index 77b9b23..09d82e3 100644 (file)
@@ -1,3 +1,16 @@
+2016-08-15  Saam Barati  <sbarati@apple.com>
+
+        Web Inspector: Introduce a method to enable code coverage profiler without enabling type profiler
+        https://bugs.webkit.org/show_bug.cgi?id=160750
+        <rdar://problem/27793469>
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector.loaded):
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WebInspector.SourceCodeTextEditor.prototype._setTypeTokenAnnotatorEnabledState):
+
 2016-08-12  Timothy Hatcher  <timothy@apple.com>
 
         Web Inspector: Add application/vnd.api+json as a valid JSON MIME-type
index b398b3b..820e5ba 100644 (file)
@@ -160,8 +160,11 @@ WebInspector.loaded = function()
 
     // COMPATIBILITY (iOS 8): Page.enableTypeProfiler did not exist.
     this.showJavaScriptTypeInformationSetting = new WebInspector.Setting("show-javascript-type-information", false);
-    if (this.showJavaScriptTypeInformationSetting.value && window.RuntimeAgent && RuntimeAgent.enableTypeProfiler)
+    if (this.showJavaScriptTypeInformationSetting.value && window.RuntimeAgent && RuntimeAgent.enableTypeProfiler) {
         RuntimeAgent.enableTypeProfiler();
+        if (RuntimeAgent.enableControlFlowProfiler)
+            RuntimeAgent.enableControlFlowProfiler();
+    }
 
     // COMPATIBILITY (iOS 8): Page.setShowPaintRects did not exist.
     this.showPaintRectsSetting = new WebInspector.Setting("show-paint-rects", false);
index 22e1e7c..13fcaf9 100644 (file)
@@ -1692,6 +1692,8 @@ WebInspector.SourceCodeTextEditor = class SourceCodeTextEditor extends WebInspec
             console.assert(this.visible, "Annotators should not be enabled if the TextEditor is not visible");
 
             RuntimeAgent.enableTypeProfiler();
+            if (RuntimeAgent.enableControlFlowProfiler)
+                RuntimeAgent.enableControlFlowProfiler();
 
             this._typeTokenAnnotator.reset();
             if (this._basicBlockAnnotator) {