Bug 1442587 - Part 2: Avoid Vector<Value> in JSONParser. r=Waldo
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 30 Aug 2018 13:24:15 -0500
changeset 435372 f88bf0327d46c9e5fc9835d77aba06fee1a7ec8e
parent 435352 f33e65ea17cfa05865ab838768428b91d82934cc
child 435373 eb2019c9a30eb0b32dff94bce7fd62645c886036
push id34612
push userdvarga@mozilla.com
push dateMon, 10 Sep 2018 16:15:39 +0000
treeherdermozilla-central@0418c9abdeb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1442587
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1442587 - Part 2: Avoid Vector<Value> in JSONParser. r=Waldo
js/src/vm/JSONParser.cpp
js/src/vm/JSONParser.h
--- a/js/src/vm/JSONParser.cpp
+++ b/js/src/vm/JSONParser.cpp
@@ -40,28 +40,21 @@ JSONParserBase::~JSONParserBase()
 
     for (size_t i = 0; i < freeProperties.length(); i++)
         js_delete(freeProperties[i]);
 }
 
 void
 JSONParserBase::trace(JSTracer* trc)
 {
-    for (size_t i = 0; i < stack.length(); i++) {
-        if (stack[i].state == FinishArrayElement) {
-            ElementVector& elements = stack[i].elements();
-            for (size_t j = 0; j < elements.length(); j++)
-                TraceRoot(trc, &elements[j], "JSONParser element");
-        } else {
-            PropertyVector& properties = stack[i].properties();
-            for (size_t j = 0; j < properties.length(); j++) {
-                TraceRoot(trc, &properties[j].value, "JSONParser property value");
-                TraceRoot(trc, &properties[j].id, "JSONParser property id");
-            }
-        }
+    for (auto& elem : stack) {
+        if (elem.state == FinishArrayElement)
+            elem.elements().trace(trc);
+        else
+            elem.properties().trace(trc);
     }
 }
 
 template <typename CharT>
 void
 JSONParser<CharT>::getTextPosition(uint32_t* column, uint32_t* line)
 {
     CharPtr ptr = begin;
--- a/js/src/vm/JSONParser.h
+++ b/js/src/vm/JSONParser.h
@@ -44,21 +44,21 @@ class MOZ_STACK_CLASS JSONParserBase
     // parse this keeps track of the stack of arrays and objects which have
     // been started but not finished yet. The actual JS object is not
     // allocated until the literal is closed, so that the result can be sized
     // according to its contents and have its type and shape filled in using
     // caches.
 
     // State for an array that is currently being parsed. This includes all
     // elements that have been seen so far.
-    typedef Vector<Value, 20> ElementVector;
+    typedef GCVector<Value, 20> ElementVector;
 
     // State for an object that is currently being parsed. This includes all
     // the key/value pairs that have been seen so far.
-    typedef Vector<IdValuePair, 10> PropertyVector;
+    typedef GCVector<IdValuePair, 10> PropertyVector;
 
     // Possible states the parser can be in between values.
     enum ParserState {
         // An array element has just being parsed.
         FinishArrayElement,
 
         // An object property has just been parsed.
         FinishObjectMember,