Title: [172402] trunk/Source/_javascript_Core
Revision
172402
Author
[email protected]
Date
2014-08-11 12:19:47 -0700 (Mon, 11 Aug 2014)

Log Message

Web Inspector: use type builders to construct high fidelity type information payloads
https://bugs.webkit.org/show_bug.cgi?id=135803

Reviewed by Timothy Hatcher.

Due to some typos in the protocol file, the code had worked with raw objects
rather than with type builders. Convert to using builders.

* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/protocol/Runtime.json: Fix 'item' for 'items'; true for 'true'.
* runtime/HighFidelityTypeProfiler.cpp:
(JSC::HighFidelityTypeProfiler::getTypesForVariableAtOffsetForInspector):
* runtime/HighFidelityTypeProfiler.h:
* runtime/TypeSet.cpp:
(JSC::TypeSet::allStructureRepresentations):
(JSC::StructureShape::stringRepresentation):
(JSC::StructureShape::inspectorRepresentation):
* runtime/TypeSet.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (172401 => 172402)


--- trunk/Source/_javascript_Core/ChangeLog	2014-08-11 18:59:44 UTC (rev 172401)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-08-11 19:19:47 UTC (rev 172402)
@@ -1,3 +1,26 @@
+2014-08-11  Brian J. Burg  <[email protected]>
+
+        Web Inspector: use type builders to construct high fidelity type information payloads
+        https://bugs.webkit.org/show_bug.cgi?id=135803
+
+        Reviewed by Timothy Hatcher.
+
+        Due to some typos in the protocol file, the code had worked with raw objects
+        rather than with type builders. Convert to using builders.
+
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets):
+        * inspector/agents/InspectorRuntimeAgent.h:
+        * inspector/protocol/Runtime.json: Fix 'item' for 'items'; true for 'true'.
+        * runtime/HighFidelityTypeProfiler.cpp:
+        (JSC::HighFidelityTypeProfiler::getTypesForVariableAtOffsetForInspector):
+        * runtime/HighFidelityTypeProfiler.h:
+        * runtime/TypeSet.cpp:
+        (JSC::TypeSet::allStructureRepresentations):
+        (JSC::StructureShape::stringRepresentation):
+        (JSC::StructureShape::inspectorRepresentation):
+        * runtime/TypeSet.h:
+
 2014-08-11  Mark Hahnenberg  <[email protected]>
 
         for-in optimization should also make sure the base matches the object being iterated

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp (172401 => 172402)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp	2014-08-11 18:59:44 UTC (rev 172401)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp	2014-08-11 19:19:47 UTC (rev 172402)
@@ -194,19 +194,19 @@
 {
 }
 
-void InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets(ErrorString* errorString, const RefPtr<Inspector::InspectorArray>& in_locations, RefPtr<Inspector::InspectorArray>& out_types)
+void InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets(ErrorString* errorString, const RefPtr<Inspector::InspectorArray>& locations, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::TypeDescription>>& typeDescriptions)
 {
     static const bool verbose = false;
     VM& vm = globalVM();
-    out_types = Inspector::InspectorArray::create();
+    typeDescriptions = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::TypeDescription>::create();
     if (!vm.isProfilingTypesWithHighFidelity())
         return;
 
     double start = currentTimeMS();
     vm.highFidelityLog()->processHighFidelityLog("User Query");
 
-    for (size_t i = 0; i < in_locations->length(); i++) {
-        RefPtr<Inspector::InspectorValue> value = in_locations->get(i);
+    for (size_t i = 0; i < locations->length(); i++) {
+        RefPtr<Inspector::InspectorValue> value = locations->get(i);
         RefPtr<InspectorObject> location;
         if (!value->asObject(&location)) {
             *errorString = ASCIILiteral("Array of TypeLocation objects has an object that does not have type of TypeLocation.");
@@ -219,11 +219,11 @@
         location->getNumber(ASCIILiteral("typeInformationDescriptor"), &descriptor);
         location->getString(ASCIILiteral("sourceID"), &sourceIDAsString);
         location->getNumber(ASCIILiteral("divot"), &divot);
-        
-        RefPtr<Inspector::InspectorObject> typeDescription = Inspector::InspectorObject::create();
+
+        RefPtr<Inspector::TypeBuilder::Runtime::TypeDescription> typeDescription = Inspector::TypeBuilder::Runtime::TypeDescription::create();
         bool okay;
         vm.highFidelityTypeProfiler()->getTypesForVariableAtOffsetForInspector(static_cast<TypeProfilerSearchDescriptor>(descriptor), divot, sourceIDAsString.toIntPtrStrict(&okay), typeDescription);
-        out_types->pushObject(typeDescription);
+        typeDescriptions->addItem(typeDescription);
     }
 
     double end = currentTimeMS();

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.h (172401 => 172402)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.h	2014-08-11 18:59:44 UTC (rev 172401)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.h	2014-08-11 19:19:47 UTC (rev 172402)
@@ -66,7 +66,7 @@
     virtual void getProperties(ErrorString*, const String& objectId, const bool* ownProperties, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>>& internalProperties) override final;
     virtual void releaseObjectGroup(ErrorString*, const String& objectGroup) override final;
     virtual void run(ErrorString*) override;
-    virtual void getRuntimeTypesForVariablesAtOffsets(ErrorString*, const RefPtr<Inspector::InspectorArray>& in_locations, RefPtr<Inspector::InspectorArray>& out_types) override;
+    virtual void getRuntimeTypesForVariablesAtOffsets(ErrorString*, const RefPtr<Inspector::InspectorArray>& locations, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::TypeDescription>>&) override;
     
     void setScriptDebugServer(ScriptDebugServer* scriptDebugServer) { m_scriptDebugServer = scriptDebugServer; }
 

Modified: trunk/Source/_javascript_Core/inspector/protocol/Runtime.json (172401 => 172402)


--- trunk/Source/_javascript_Core/inspector/protocol/Runtime.json	2014-08-11 18:59:44 UTC (rev 172401)
+++ trunk/Source/_javascript_Core/inspector/protocol/Runtime.json	2014-08-11 19:19:47 UTC (rev 172402)
@@ -116,9 +116,9 @@
             "id": "StructureDescription",
             "type": "object",
             "properties": [
-                { "name": "fields", "type": "array",  "items": { "type": "string" }, "description": "Array of strings, where the strings represent object properties." },
-                { "name": "constructorName", "type": "string", "description": "Name of the constructor." },
-                { "name": "prototypeStructure", "$ref": "StructureDescription", "optional": "true", "description": "Pointer to the StructureRepresentation of the protoype if one exists." }
+                { "name": "fields", "type": "array",  "items": { "type": "string" }, "optional": true, "description": "Array of strings, where the strings represent object properties." },
+                { "name": "constructorName", "type": "string", "optional": true, "description": "Name of the constructor." },
+                { "name": "prototypeStructure", "$ref": "StructureDescription", "optional": true, "description": "Pointer to the StructureRepresentation of the protoype if one exists." }
             ]
         },
         {
@@ -127,8 +127,8 @@
             "description": "Container for type information that has been gathered.",
             "properties": [
                 { "name": "displayTypeName", "type": "string", "optional": true, "description": "What the inspector should display as a simple type." },
-                { "name": "localPrimitiveTypeNames", "type": "array", "items": { "type": "string" }, "optional": "true", "description": "Array of type names for primtive types (int, string, etc) seen at an instruction" },
-                { "name": "localObjectTypeNames", "type": "array", "items": { "type": "string" }, "optional": "true", "description": "Array of type names for all object seen at an instruction" },
+                { "name": "localPrimitiveTypeNames", "type": "array", "items": { "type": "string" }, "optional": true, "description": "Array of type names for primtive types (int, string, etc) seen at an instruction" },
+                { "name": "localObjectTypeNames", "type": "array", "items": { "type": "string" }, "optional": true, "description": "Array of type names for all object seen at an instruction" },
                 { "name": "localStructures", "type": "array", "items": { "$ref": "StructureDescription" }, "optional": true, "description": "Array of descriptions for all structures seen at this this instruction." },
                 { "name": "globalPrimitiveTypeNames", "type": "array", "items": { "type": "string" }, "optional": true, "description": "Array of type names for all primitive types seen globally." },
                 { "name": "globalObjectTypeNames", "type": "array", "items": { "type": "string" }, "optional": true, "description": "Array of type names for all primitive types seen globally." },
@@ -236,7 +236,7 @@
                 { "name": "locations", "type": "array", "items": { "$ref": "TypeLocation" }, "description": "An array of type locations we're requesting information for. Results are expected in the same order they're sent in."}
             ],
             "returns": [
-                { "name": "types", "type": "array", "item": { "$ref": "TypeDescription", "description": "Types for requested variable." } }
+                { "name": "types", "type": "array", "items": { "$ref": "TypeDescription", "description": "Types for requested variable." } }
             ],
             "description": "Returns detailed informtation on given function."
         }

Modified: trunk/Source/_javascript_Core/runtime/HighFidelityTypeProfiler.cpp (172401 => 172402)


--- trunk/Source/_javascript_Core/runtime/HighFidelityTypeProfiler.cpp	2014-08-11 18:59:44 UTC (rev 172401)
+++ trunk/Source/_javascript_Core/runtime/HighFidelityTypeProfiler.cpp	2014-08-11 19:19:47 UTC (rev 172402)
@@ -69,21 +69,21 @@
     bucket.append(location);
 }
 
-void HighFidelityTypeProfiler::getTypesForVariableAtOffsetForInspector(TypeProfilerSearchDescriptor descriptor, unsigned divot, intptr_t sourceID, RefPtr<Inspector::InspectorObject>& ret)
+void HighFidelityTypeProfiler::getTypesForVariableAtOffsetForInspector(TypeProfilerSearchDescriptor descriptor, unsigned divot, intptr_t sourceID, RefPtr<Inspector::TypeBuilder::Runtime::TypeDescription>& description)
 {
     TypeLocation* location = findLocation(divot, sourceID, descriptor);
     if (!location)
         return;
 
     if (location->m_globalTypeSet && location->m_globalVariableID != HighFidelityNoGlobalIDExists) {
-        ret->setString(ASCIILiteral("displayTypeName"), location->m_globalTypeSet->displayName());
-        ret->setArray(ASCIILiteral("globalPrimitiveTypeNames"), location->m_globalTypeSet->allPrimitiveTypeNames()->asArray());
-        ret->setArray(ASCIILiteral("globalStructures"), location->m_globalTypeSet->allStructureRepresentations()->asArray());
+        description->setDisplayTypeName(location->m_globalTypeSet->displayName());
+        description->setGlobalPrimitiveTypeNames(location->m_globalTypeSet->allPrimitiveTypeNames());
+        description->setGlobalStructures(location->m_globalTypeSet->allStructureRepresentations());
     } else
-        ret->setString(ASCIILiteral("displayTypeName"), location->m_instructionTypeSet->displayName());
+        description->setDisplayTypeName(location->m_instructionTypeSet->displayName());
 
-    ret->setArray(ASCIILiteral("localPrimitiveTypeNames"), location->m_instructionTypeSet->allPrimitiveTypeNames()->asArray());
-    ret->setArray(ASCIILiteral("localStructures"), location->m_instructionTypeSet->allStructureRepresentations()->asArray());
+    description->setLocalPrimitiveTypeNames(location->m_instructionTypeSet->allPrimitiveTypeNames());
+    description->setLocalStructures(location->m_instructionTypeSet->allStructureRepresentations());
 }
 
 static bool descriptorMatchesTypeLocation(TypeProfilerSearchDescriptor descriptor, TypeLocation* location)

Modified: trunk/Source/_javascript_Core/runtime/HighFidelityTypeProfiler.h (172401 => 172402)


--- trunk/Source/_javascript_Core/runtime/HighFidelityTypeProfiler.h	2014-08-11 18:59:44 UTC (rev 172401)
+++ trunk/Source/_javascript_Core/runtime/HighFidelityTypeProfiler.h	2014-08-11 19:19:47 UTC (rev 172402)
@@ -36,9 +36,6 @@
 namespace Inspector { namespace TypeBuilder  { namespace Runtime {
 class TypeDescription;
 }}}
-namespace Inspector {
-class InspectorObject;
-}
 
 namespace JSC {
 
@@ -99,7 +96,7 @@
 class HighFidelityTypeProfiler {
 public:
     void logTypesForTypeLocation(TypeLocation*);
-    void getTypesForVariableAtOffsetForInspector(TypeProfilerSearchDescriptor descriptor, unsigned divot, intptr_t sourceID, RefPtr<Inspector::InspectorObject>&);
+    void getTypesForVariableAtOffsetForInspector(TypeProfilerSearchDescriptor descriptor, unsigned divot, intptr_t sourceID, RefPtr<Inspector::TypeBuilder::Runtime::TypeDescription>&);
     void insertNewLocation(TypeLocation*);
     FunctionHasExecutedCache* functionHasExecutedCache() { return &m_functionHasExecutedCache; }
     TypeLocationCache* typeLocationCache() { return &m_typeLocationCache; }

Modified: trunk/Source/_javascript_Core/runtime/TypeSet.cpp (172401 => 172402)


--- trunk/Source/_javascript_Core/runtime/TypeSet.cpp	2014-08-11 18:59:44 UTC (rev 172401)
+++ trunk/Source/_javascript_Core/runtime/TypeSet.cpp	2014-08-11 19:19:47 UTC (rev 172402)
@@ -236,14 +236,14 @@
     return seen.release();
 }
 
-PassRefPtr<Inspector::TypeBuilder::Array<Inspector::InspectorObject>> TypeSet::allStructureRepresentations() const
+PassRefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::StructureDescription>> TypeSet::allStructureRepresentations() const
 {
-    RefPtr<Inspector::TypeBuilder::Array<Inspector::InspectorObject>> ret = Inspector::TypeBuilder::Array<Inspector::InspectorObject>::create();
+    RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::StructureDescription>> description = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::StructureDescription>::create();
 
     for (size_t i = 0; i < m_structureHistory->size(); i++)
-        ret->addItem(m_structureHistory->at(i)->inspectorRepresentation());
+        description->addItem(m_structureHistory->at(i)->inspectorRepresentation());
 
-    return ret.release();
+    return description.release();
 }
 
 String TypeSet::leastCommonAncestor() const
@@ -341,8 +341,8 @@
 
     representation.append("{");
     while (curShape) {
-        for (auto iter = curShape->m_fields.begin(), end = curShape->m_fields.end(); iter != end; ++iter) {
-            String prop((*iter).get());
+        for (auto it = curShape->m_fields.begin(), end = curShape->m_fields.end(); it != end; ++it) {
+            String prop((*it).get());
             representation.append(prop);
             representation.append(", ");
         }
@@ -364,23 +364,23 @@
     return representation.toString();
 }
 
-PassRefPtr<Inspector::InspectorObject> StructureShape::inspectorRepresentation()
+PassRefPtr<Inspector::TypeBuilder::Runtime::StructureDescription> StructureShape::inspectorRepresentation()
 {
-    RefPtr<Inspector::InspectorObject> base = Inspector::InspectorObject::create();
-    RefPtr<Inspector::InspectorObject> currentObject = base;
+    RefPtr<Inspector::TypeBuilder::Runtime::StructureDescription> base = Inspector::TypeBuilder::Runtime::StructureDescription::create();
+    RefPtr<Inspector::TypeBuilder::Runtime::StructureDescription> currentObject = base;
     RefPtr<StructureShape> currentShape = this;
 
     while (currentShape) {
-        RefPtr<Inspector::TypeBuilder::Array<String>> fields = Inspector::TypeBuilder::Array<String>::create();
-        for (auto iter = currentShape->m_fields.begin(), end = currentShape->m_fields.end(); iter != end; ++iter)
-            fields->addItem((*iter).get());
+        auto fields = Inspector::TypeBuilder::Array<String>::create();
+        for (auto it = currentShape->m_fields.begin(), end = currentShape->m_fields.end(); it != end; ++it)
+            fields->addItem((*it).get());
 
-        currentObject->setArray(ASCIILiteral("fields"), fields->asArray());
-        currentObject->setString(ASCIILiteral("constructorName"), currentShape->m_constructorName);
+        currentObject->setFields(fields);
+        currentObject->setConstructorName(currentShape->m_constructorName);
 
         if (currentShape->m_proto) {
-            RefPtr<Inspector::InspectorObject> nextObject = Inspector::InspectorObject::create();
-            currentObject->setObject(ASCIILiteral("prototypeStructure"), nextObject);
+            RefPtr<Inspector::TypeBuilder::Runtime::StructureDescription> nextObject = Inspector::TypeBuilder::Runtime::StructureDescription::create();
+            currentObject->setPrototypeStructure(nextObject);
             currentObject = nextObject;
         }
 

Modified: trunk/Source/_javascript_Core/runtime/TypeSet.h (172401 => 172402)


--- trunk/Source/_javascript_Core/runtime/TypeSet.h	2014-08-11 18:59:44 UTC (rev 172401)
+++ trunk/Source/_javascript_Core/runtime/TypeSet.h	2014-08-11 19:19:47 UTC (rev 172402)
@@ -32,15 +32,17 @@
 #include <wtf/text/WTFString.h>
 #include <wtf/Vector.h>
 
-namespace Inspector { namespace TypeBuilder  { 
-template<typename T>
-class Array;
-}}
+namespace Inspector {
+namespace TypeBuilder  {
+template<typename T> class Array;
 
-namespace Inspector { 
-class InspectorObject;
+namespace Runtime {
+class StructureDescription;
 }
 
+}
+}
+
 namespace JSC {
 
 class JSValue;
@@ -68,7 +70,7 @@
     void markAsFinal();
     void addProperty(RefPtr<StringImpl>);
     String stringRepresentation();
-    PassRefPtr<Inspector::InspectorObject> inspectorRepresentation();
+    PassRefPtr<Inspector::TypeBuilder::Runtime::StructureDescription> inspectorRepresentation();
     void setConstructorName(String name) { m_constructorName = (name.isEmpty() ? "Object" : name); }
     String constructorName() { return m_constructorName; }
     void setProto(PassRefPtr<StructureShape> shape) { m_proto = shape; }
@@ -93,7 +95,7 @@
     JS_EXPORT_PRIVATE String seenTypes() const;
     String displayName() const;
     PassRefPtr<Inspector::TypeBuilder::Array<String>> allPrimitiveTypeNames() const;
-    PassRefPtr<Inspector::TypeBuilder::Array<Inspector::InspectorObject>> allStructureRepresentations() const;
+    PassRefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::StructureDescription>> allStructureRepresentations() const;
 
 private:
     String leastCommonAncestor() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to