Bug 1368454 - Optimize js::CreateIterResultObject by using ObjectGroup::newPlainObject instead of manually creating the object and defining its properties. r=jandem
☠☠ backed out by 53accdb19e4f ☠ ☠
authorTill Schneidereit <till@tillschneidereit.net>
Mon, 29 May 2017 12:00:45 +0200
changeset 419583 75d0af6c7c49e3988d2d24efd602d032d6c63de1
parent 419582 80bb069a8fd565c147403f94b0e583954f70abc1
child 419584 c49b7e6e9811851c02017fae4150a3624a84f3fc
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1368454
milestone56.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 1368454 - Optimize js::CreateIterResultObject by using ObjectGroup::newPlainObject instead of manually creating the object and defining its properties. r=jandem This should improve performance of creating the object and TI for code using iteration result objects. MozReview-Commit-ID: 2QGqFs7V3uH
js/src/jsiter.cpp
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -1040,34 +1040,29 @@ js::LookupInIteratorCache(JSContext* cx,
 }
 
 // ES 2017 draft 7.4.7.
 JSObject*
 js::CreateIterResultObject(JSContext* cx, HandleValue value, bool done)
 {
     // Step 1 (implicit).
 
-    // Step 2.
-    RootedObject resultObj(cx, NewBuiltinClassInstance<PlainObject>(cx));
-    if (!resultObj)
-        return nullptr;
-
-    // Step 3.
-    if (!DefineProperty(cx, resultObj, cx->names().value, value))
+    Rooted<IdValueVector> props(cx, IdValueVector(cx));
+    if (!props.reserve(2))
         return nullptr;
 
-    // Step 4.
-    if (!DefineProperty(cx, resultObj, cx->names().done,
-                        done ? TrueHandleValue : FalseHandleValue))
-    {
-        return nullptr;
-    }
+    // Step 2 (reordered).
+    props.infallibleAppend(IdValuePair(NameToId(cx->names().value), value));
 
-    // Step 5.
-    return resultObj;
+    // Step 3 (reordered).
+    props.infallibleAppend(IdValuePair(NameToId(cx->names().done),
+                                       done ? TrueHandleValue : FalseHandleValue));
+
+    // Steps 1, 5.
+    return ObjectGroup::newPlainObject(cx, props.begin(), props.length(), GenericObject);
 }
 
 bool
 js::ThrowStopIteration(JSContext* cx)
 {
     MOZ_ASSERT(!JS_IsExceptionPending(cx));
 
     // StopIteration isn't a constructor, but it's stored in GlobalObject