Use persistent type sets for initializer opcodes, bug 714600. r=dvander

This commit is contained in:
Brian Hackett 2012-01-05 06:50:46 -08:00
parent cb01e05f33
commit 81b6aa3645
3 changed files with 9 additions and 5 deletions

View File

@ -4765,6 +4765,7 @@ EmitNewInit(JSContext *cx, BytecodeEmitter *bce, JSProtoKey key, ParseNode *pn,
{
if (Emit3(cx, bce, JSOP_NEWINIT, (jsbytecode) key, 0) < 0)
return false;
CheckTypeSet(cx, bce, JSOP_NEWINIT);
#if JS_HAS_SHARP_VARS
if (bce->hasSharps()) {
if (pn->pn_count != 0)
@ -6977,6 +6978,7 @@ EmitArray(JSContext *cx, BytecodeEmitter *bce, ParseNode *pn, jsint sharpnum)
ptrdiff_t off = EmitN(cx, bce, JSOP_NEWARRAY, 3);
if (off < 0)
return false;
CheckTypeSet(cx, bce, JSOP_NEWARRAY);
jsbytecode *pc = bce->code(off);
SET_UINT24(pc, pn->pn_count);
}

View File

@ -3896,14 +3896,16 @@ ScriptAnalysis::analyzeTypesBytecode(JSContext *cx, unsigned offset,
case JSOP_NEWARRAY:
case JSOP_NEWOBJECT: {
TypeObject *initializer = GetInitializerType(cx, script, pc);
TypeSet *types = script->analysis()->bytecodeTypes(pc);
if (script->hasGlobal()) {
if (!initializer)
return false;
pushed[0].addType(cx, Type::ObjectType(initializer));
types->addType(cx, Type::ObjectType(initializer));
} else {
JS_ASSERT(!initializer);
pushed[0].addType(cx, Type::UnknownType());
types->addType(cx, Type::UnknownType());
}
types->addSubset(cx, &pushed[0]);
break;
}

View File

@ -251,9 +251,9 @@ OPDEF(JSOP_UINT16, 88, "uint16", NULL, 3, 0, 1, 16, JOF_UINT16
* shape, which can be set at the start and slots then filled in directly.
* NEWINIT has an extra byte so it can be exchanged with NEWOBJECT during emit.
*/
OPDEF(JSOP_NEWINIT, 89, "newinit", NULL, 3, 0, 1, 19, JOF_UINT8)
OPDEF(JSOP_NEWARRAY, 90, "newarray", NULL, 4, 0, 1, 19, JOF_UINT24)
OPDEF(JSOP_NEWOBJECT, 91, "newobject", NULL, 3, 0, 1, 19, JOF_OBJECT)
OPDEF(JSOP_NEWINIT, 89, "newinit", NULL, 3, 0, 1, 19, JOF_UINT8|JOF_TYPESET)
OPDEF(JSOP_NEWARRAY, 90, "newarray", NULL, 4, 0, 1, 19, JOF_UINT24|JOF_TYPESET)
OPDEF(JSOP_NEWOBJECT, 91, "newobject", NULL, 3, 0, 1, 19, JOF_OBJECT|JOF_TYPESET)
OPDEF(JSOP_ENDINIT, 92, "endinit", NULL, 1, 0, 0, 19, JOF_BYTE)
OPDEF(JSOP_INITPROP, 93, "initprop", NULL, 3, 2, 1, 3, JOF_ATOM|JOF_PROP|JOF_SET|JOF_DETECTING)
OPDEF(JSOP_INITELEM, 94, "initelem", NULL, 1, 3, 1, 3, JOF_BYTE|JOF_ELEM|JOF_SET|JOF_DETECTING)