Bug 1153057 - Properly initialize the [[HomeObject]] of methods with computed property names. (r=jorendorff)

This commit is contained in:
Eric Faust 2015-04-10 13:47:53 -07:00
parent 0777bf19a9
commit 7a041ef5f2
5 changed files with 11 additions and 8 deletions

View File

@ -6755,7 +6755,7 @@ BytecodeEmitter::emitPropertyList(ParseNode* pn, MutableHandlePlainObject objp,
propdef->pn_right->pn_funbox->needsHomeObject())
{
MOZ_ASSERT(propdef->pn_right->pn_funbox->function()->isMethod());
if (!emit1(JSOP_INITHOMEOBJECT))
if (!emit2(JSOP_INITHOMEOBJECT, isIndex))
return false;
}
@ -7112,7 +7112,7 @@ BytecodeEmitter::emitClass(ParseNode* pn)
return false;
if (constructor->pn_funbox->needsHomeObject()) {
if (!emit1(JSOP_INITHOMEOBJECT))
if (!emit2(JSOP_INITHOMEOBJECT, 0))
return false;
}

View File

@ -0,0 +1 @@
({ "0"() { eval(); } });

View File

@ -1,4 +1,3 @@
print("foo");
var test = `
// This is super weird. A super property reference in the spec contains two
@ -18,10 +17,12 @@ class derived extends base {
constructor() { }
test(expected) { super.test(expected); }
testArrow() { return (() => super.test(this)); }
["testCPN"](expected) { super.test(expected); }
}
let derivedInstance = new derived();
derivedInstance.test(derivedInstance);
derivedInstance.testCPN(derivedInstance);
let obj = { test: derivedInstance.test };
obj.test(obj);

View File

@ -3970,7 +3970,8 @@ END_CASE(JSOP_OBJWITHPROTO)
CASE(JSOP_INITHOMEOBJECT)
{
MOZ_ASSERT(REGS.stackDepth() >= 2);
uint8_t skipOver = GET_UINT8(REGS.pc);
MOZ_ASSERT(REGS.stackDepth() >= 2 + skipOver);
/* Load the function to be initialized */
RootedFunction& func = rootFunction0;
@ -3979,7 +3980,7 @@ CASE(JSOP_INITHOMEOBJECT)
/* Load the home object */
RootedNativeObject& obj = rootNativeObject0;
obj = &REGS.sp[-2].toObject().as<NativeObject>();
obj = &REGS.sp[-2 - skipOver].toObject().as<NativeObject>();
MOZ_ASSERT(obj->is<PlainObject>() || obj->is<JSFunction>());
func->setExtendedSlot(FunctionExtended::METHOD_HOMEOBJECT_SLOT, ObjectValue(*obj));

View File

@ -870,10 +870,10 @@
* the set, and leaves both on the stack.
* Category: Literals
* Type: Object
* Operands:
* Stack: homeObject, fun => homeObject, fun
* Operands: uint8_t n
* Stack: homeObject, [...n], fun => homeObject, [...n], fun
*/\
macro(JSOP_INITHOMEOBJECT, 92, "inithomeobject", NULL, 1, 2, 2, JOF_BYTE|JOF_SET|JOF_DETECTING) \
macro(JSOP_INITHOMEOBJECT, 92, "inithomeobject", NULL, 2, 2, 2, JOF_UINT8) \
\
/*
* Initialize a named property in an object literal, like '{a: x}'.