Web Inspector: Move the computation that results in UI strings from JSC to the Web...
authorsaambarati1@gmail.com <saambarati1@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Oct 2014 21:35:20 +0000 (21:35 +0000)
committersaambarati1@gmail.com <saambarati1@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Oct 2014 21:35:20 +0000 (21:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137295

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

Remove unnecessary functions and properties from JSC that are
now being computed inside the Web Inspector.

* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
* inspector/protocol/Runtime.json:
* runtime/TypeSet.cpp:
(JSC::TypeSet::allPrimitiveTypeNames): Deleted.
* runtime/TypeSet.h:

Source/WebInspectorUI:

The inspector now computes a set of properties that was previously
computed inside JSC.

This patch also addresses the weird experience of the
type of an expression claiming to be both a Number and
an Integer. This could be a bit confusing because Number
is supposed to represent Double|Integer and the previous
UI implied that Number was equivalent to Double. The new UI only
ever shows either the type of Number or Integer when showing
the type information of an expression. It never shows both Number
and Integer simultaneously to describe a single expression.

* UserInterface/Models/TypeSet.js:
(WebInspector.TypeSet):
(WebInspector.TypeSet.prototype.isContainedIn):
(WebInspector.TypeSet.prototype.get primitiveTypeNames):
* UserInterface/Views/TypePropertiesSection.js:
(WebInspector.TypePropertiesSection):
(WebInspector.TypePropertiesSection.prototype.onpopulate):
* UserInterface/Views/TypeTokenView.js:
(WebInspector.TypeTokenView):
(WebInspector.TypeTokenView.prototype.update):
(WebInspector.TypeTokenView.prototype._shouldShowPopover):
(WebInspector.TypeTokenView.prototype._displayTypeName):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
Source/JavaScriptCore/inspector/protocol/Runtime.json
Source/JavaScriptCore/runtime/TypeSet.cpp
Source/JavaScriptCore/runtime/TypeSet.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/TypeSet.js
Source/WebInspectorUI/UserInterface/Views/TypePropertiesSection.js
Source/WebInspectorUI/UserInterface/Views/TypeTokenView.js

index d447d3c..fe33ac2 100644 (file)
@@ -1,3 +1,20 @@
+2014-10-03  Saam Barati  <saambarati1@gmail.com>
+
+        Web Inspector: Move the computation that results in UI strings from JSC to the Web Inspector
+        https://bugs.webkit.org/show_bug.cgi?id=137295
+
+        Reviewed by Timothy Hatcher.
+
+        Remove unnecessary functions and properties from JSC that are
+        now being computed inside the Web Inspector. 
+
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
+        * inspector/protocol/Runtime.json:
+        * runtime/TypeSet.cpp:
+        (JSC::TypeSet::allPrimitiveTypeNames): Deleted.
+        * runtime/TypeSet.h:
+
 2014-10-02  Filip Pizlo  <fpizlo@apple.com>
 
         FTL should sink PutLocals
index 80a0d9f..c00f3fe 100644 (file)
@@ -242,7 +242,6 @@ void InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets(ErrorString& er
 
         if (isValid) {
             description->setLeastCommonAncestor(typeSet->leastCommonAncestor());
-            description->setPrimitiveTypeNames(typeSet->allPrimitiveTypeNames());
             description->setStructures(typeSet->allStructureRepresentations());
             description->setTypeSet(typeSet->inspectorTypeSet());
             description->setIsTruncated(typeSet->isOverflown());
index 0bbe71f..157353a 100644 (file)
                 { "name": "isValid", "type": "boolean", "description": "If true, we were able to correlate the offset successfuly with a program location. If false, the offset may be bogus or the offset may be from a CodeBlock that hasn't executed." },
                 { "name": "leastCommonAncestor", "type": "string", "optional": true, "description": "Least common ancestor of all Constructors if the TypeDescription has seen any structures. This string is the display name of the shared constructor function." },
                 { "name": "typeSet", "$ref": "TypeSet", "optional": true, "description": "Set of booleans for determining the aggregate type of this type description." },
-                { "name": "primitiveTypeNames", "type": "array", "items": { "type": "string" }, "optional": true, "description": "Array of type names for primitive types (int, string, etc) seen at an instruction." },
                 { "name": "structures", "type": "array", "items": { "$ref": "StructureDescription" }, "optional": true, "description": "Array of descriptions for all structures seen for this variable." },
                 { "name": "isTruncated", "type": "boolean", "optional": true, "description": "If true, this indicates that no more structures are being profiled because some maximum threshold has been reached and profiling has stopped because of memory pressure." }
             ]
index b193005..238443d 100644 (file)
@@ -237,25 +237,6 @@ String TypeSet::leastCommonAncestor() const
 }
 
 #if ENABLE(INSPECTOR)
-PassRefPtr<Inspector::Protocol::Array<String>> TypeSet::allPrimitiveTypeNames() const
-{
-    RefPtr<Inspector::Protocol::Array<String>> seen = Inspector::Protocol::Array<String>::create();
-    if (m_seenTypes & TypeUndefined)
-        seen->addItem(ASCIILiteral("Undefined"));
-    if (m_seenTypes & TypeNull)
-        seen->addItem(ASCIILiteral("Null"));
-    if (m_seenTypes & TypeBoolean)
-        seen->addItem(ASCIILiteral("Boolean"));
-    if (m_seenTypes & TypeMachineInt)
-        seen->addItem(ASCIILiteral("Integer"));
-    if (m_seenTypes & TypeNumber)
-        seen->addItem(ASCIILiteral("Number"));
-    if (m_seenTypes & TypeString)
-        seen->addItem(ASCIILiteral("String"));
-
-    return seen.release();
-}
-
 PassRefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::StructureDescription>> TypeSet::allStructureRepresentations() const
 {
     RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::StructureDescription>> description = Inspector::Protocol::Array<Inspector::Protocol::Runtime::StructureDescription>::create();
index d58bff7..70324a1 100644 (file)
@@ -102,7 +102,6 @@ public:
     void invalidateCache();
     String dumpTypes() const;
     String displayName() const;
-    PassRefPtr<Inspector::Protocol::Array<String>> allPrimitiveTypeNames() const;
     PassRefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::StructureDescription>> allStructureRepresentations() const;
     String toJSONString() const;
     bool isOverflown() const { return m_isOverflown; }
index 8770caa..bb96a88 100644 (file)
@@ -1,3 +1,35 @@
+2014-10-03  Saam Barati  <saambarati1@gmail.com>
+
+        Web Inspector: Move the computation that results in UI strings from JSC to the Web Inspector
+        https://bugs.webkit.org/show_bug.cgi?id=137295
+
+        Reviewed by Timothy Hatcher.
+
+        The inspector now computes a set of properties that was previously 
+        computed inside JSC. 
+
+        This patch also addresses the weird experience of the 
+        type of an expression claiming to be both a Number and 
+        an Integer. This could be a bit confusing because Number 
+        is supposed to represent Double|Integer and the previous
+        UI implied that Number was equivalent to Double. The new UI only 
+        ever shows either the type of Number or Integer when showing
+        the type information of an expression. It never shows both Number
+        and Integer simultaneously to describe a single expression.
+
+        * UserInterface/Models/TypeSet.js:
+        (WebInspector.TypeSet):
+        (WebInspector.TypeSet.prototype.isContainedIn):
+        (WebInspector.TypeSet.prototype.get primitiveTypeNames):
+        * UserInterface/Views/TypePropertiesSection.js:
+        (WebInspector.TypePropertiesSection):
+        (WebInspector.TypePropertiesSection.prototype.onpopulate):
+        * UserInterface/Views/TypeTokenView.js:
+        (WebInspector.TypeTokenView):
+        (WebInspector.TypeTokenView.prototype.update):
+        (WebInspector.TypeTokenView.prototype._shouldShowPopover):
+        (WebInspector.TypeTokenView.prototype._displayTypeName):
+
 2014-10-02  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Cannot add a new CSS Rule to elements with 3 or more class names
index 2dd8c57..583b338 100644 (file)
@@ -49,6 +49,8 @@ WebInspector.TypeSet = function(runtimeTypeDescriptionPayload)
 
     console.assert(bitString);
     this._bitString = bitString;
+
+    this._primitiveTypeNames = null;
 };
 
 WebInspector.TypeSet.fromPayload = function(payload)
@@ -91,5 +93,32 @@ WebInspector.TypeSet.prototype = {
         // 0b0010 != bitString
 
         return this._bitString && (this._bitString & test) === this._bitString;
+    },
+
+    get primitiveTypeNames()
+    {
+        if (this._primitiveTypeNames)
+            return this._primitiveTypeNames;
+
+        this._primitiveTypeNames = [];
+        var typeSet = this._types.typeSet;
+        if (typeSet.isUndefined)
+            this._primitiveTypeNames.push("Undefined");
+        if (typeSet.isNull)
+            this._primitiveTypeNames.push("Null");
+        if (typeSet.isBoolean)
+            this._primitiveTypeNames.push("Boolean");
+        if (typeSet.isString)
+            this._primitiveTypeNames.push("String");
+
+        // It's implied that type Integer is contained in type Number. Don't put 
+        // both 'Integer' and 'Number' into the set because this could imply that 
+        // Number means to Double instead of Double|Integer.
+        if (typeSet.isNumber)
+            this._primitiveTypeNames.push("Number");
+        else if (typeSet.isInteger)
+            this._primitiveTypeNames.push("Integer");
+
+        return this._primitiveTypeNames;
     }
 };
index cd7ada5..53a5029 100644 (file)
@@ -27,6 +27,7 @@ WebInspector.TypePropertiesSection = function(types, title, subtitle)
 {
     this.emptyPlaceholder = WebInspector.UIString("No Properties");
     this.types = types;
+    this._typeSet = WebInspector.TypeSet.fromPayload(this.types);
 
     WebInspector.PropertiesSection.call(this, title, subtitle);
 };
@@ -39,7 +40,7 @@ WebInspector.TypePropertiesSection.prototype = {
     {
         this.propertiesTreeOutline.removeChildren();
 
-        var primitiveTypeNames = this.types.primitiveTypeNames;
+        var primitiveTypeNames = this._typeSet.primitiveTypeNames;
         var structures = this.types.structures;
         var properties = [];
         for (var struct of structures) {
index 0351a1b..ab830bf 100644 (file)
@@ -39,6 +39,7 @@ WebInspector.TypeTokenView = function(tokenAnnotator, shouldHaveRightMargin, sho
     this.element = span;
     this._tokenAnnotator = tokenAnnotator;
     this._types = null;
+    this._typeSet = null;
     this._colorClass = null;
 
     this._popoverTitle = WebInspector.TypeTokenView.titleForPopover(titleType, functionOrVariableName);
@@ -89,6 +90,7 @@ WebInspector.TypeTokenView.prototype = {
     update: function(types)
     {
         this._types = types;
+        this._typeSet = WebInspector.TypeSet.fromPayload(this._types);
 
         var title = this._displayTypeName();
         this.element.textContent = title;
@@ -129,7 +131,10 @@ WebInspector.TypeTokenView.prototype = {
 
     _shouldShowPopover: function()
     {
-        if (this._types.primitiveTypeNames && this._types.primitiveTypeNames.length > 1)
+        if (!this._types.isValid)
+            return false;
+
+        if (this._typeSet.primitiveTypeNames.length > 1)
             return true;
 
         if (this._types.structures && this._types.structures.length)
@@ -140,9 +145,12 @@ WebInspector.TypeTokenView.prototype = {
 
     _displayTypeName: function()
     {
-        var typeSet = WebInspector.TypeSet.fromPayload(this._types);
+        if (!this._types.isValid)
+            return "";
+
+        var typeSet = this._typeSet;
 
-        if (this._types.leastCommonAncestor && !(this._types.primitiveTypeNames && this._types.primitiveTypeNames.length)) {
+        if (this._types.leastCommonAncestor && !this._typeSet.primitiveTypeNames.length) {
             if (typeSet.isContainedIn(WebInspector.TypeSet.TypeBit.Object))
                 return this._types.leastCommonAncestor;
             if (typeSet.isContainedIn(WebInspector.TypeSet.TypeBit.Object | WebInspector.TypeSet.NullOrUndefinedTypeBits))