Bug 977011 - Tenure JSOP_NEWOBJECT payload. r=terrence
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Thu, 27 Feb 2014 07:22:41 -0800
changeset 171325 2c0ffb315be38cfbe05fb697f0877c07c3be24c9
parent 171324 8c7cf76ab17da5da3928c3a7d134141c617fd4ea
child 171326 74196538e7a21c2bfdb370b392f4425d5db3d713
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersterrence
bugs977011
milestone30.0a1
Bug 977011 - Tenure JSOP_NEWOBJECT payload. r=terrence
js/src/frontend/BytecodeEmitter.cpp
js/src/jit-test/tests/xdr/trivial.js
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -5870,17 +5870,17 @@ EmitObject(ExclusiveContext *cx, Bytecod
 
     /*
      * Try to construct the shape of the object as we go, so we can emit a
      * JSOP_NEWOBJECT with the final shape instead.
      */
     RootedObject obj(cx);
     if (bce->script->compileAndGo()) {
         gc::AllocKind kind = GuessObjectGCKind(pn->pn_count);
-        obj = NewBuiltinClassInstance(cx, &JSObject::class_, kind);
+        obj = NewBuiltinClassInstance(cx, &JSObject::class_, kind, TenuredObject);
         if (!obj)
             return false;
     }
 
     for (ParseNode *pn2 = pn->pn_head; pn2; pn2 = pn2->pn_next) {
         /* Emit an index for t[2] for later consumption by JSOP_INITELEM. */
         ParseNode *pn3 = pn2->pn_left;
         bool isIndex = false;
--- a/js/src/jit-test/tests/xdr/trivial.js
+++ b/js/src/jit-test/tests/xdr/trivial.js
@@ -27,8 +27,12 @@ evalWithCache(test, { assertEqBytecode: 
 
 // code a function which is used.
 test = "function f() { return 1; }; f();";
 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
 
 // code a function which is not used.
 test = "function f() { return 1; }; 1;";
 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
+
+// code a function which has an object literal.
+test = "function f() { return { x: 2 }; }; f();";
+evalWithCache(test, { assertEqBytecode: true });