Bug 994937 - remove some JSOP_CALL opcodes (r=djvj)

--HG--
extra : rebase_source : 8859238bb98fe91f6c7bbb99d3eab3fee6936b69
This commit is contained in:
Luke Wagner 2014-04-10 17:52:52 -05:00
parent f1f536a756
commit 298c0cefa8
15 changed files with 26 additions and 135 deletions

View File

@ -1237,7 +1237,6 @@ EmitVarOp(ExclusiveContext *cx, ParseNode *pn, JSOp op, BytecodeEmitter *bce)
switch (op) {
case JSOP_GETARG: case JSOP_GETLOCAL: op = JSOP_GETALIASEDVAR; break;
case JSOP_SETARG: case JSOP_SETLOCAL: op = JSOP_SETALIASEDVAR; break;
case JSOP_CALLARG: case JSOP_CALLLOCAL: op = JSOP_CALLALIASEDVAR; break;
default: MOZ_ASSUME_UNREACHABLE("unexpected var op");
}
@ -2131,37 +2130,10 @@ EmitFinishIteratorResult(ExclusiveContext *cx, BytecodeEmitter *bce, bool done)
static bool
EmitNameOp(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn, bool callContext)
{
JSOp op;
if (!BindNameToSlot(cx, bce, pn))
return false;
op = pn->getOp();
if (callContext) {
switch (op) {
case JSOP_NAME:
op = JSOP_CALLNAME;
break;
case JSOP_GETINTRINSIC:
op = JSOP_CALLINTRINSIC;
break;
case JSOP_GETGNAME:
op = JSOP_CALLGNAME;
break;
case JSOP_GETARG:
op = JSOP_CALLARG;
break;
case JSOP_GETLOCAL:
op = JSOP_CALLLOCAL;
break;
case JSOP_GETALIASEDVAR:
op = JSOP_CALLALIASEDVAR;
break;
default:
JS_ASSERT(op == JSOP_CALLEE);
break;
}
}
JSOp op = pn->getOp();
if (op == JSOP_CALLEE) {
if (Emit1(cx, bce, op) < 0)
@ -2179,7 +2151,7 @@ EmitNameOp(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn, bool callC
/* Need to provide |this| value for call */
if (callContext) {
if (op == JSOP_CALLNAME && bce->needsImplicitThis()) {
if (op == JSOP_NAME && bce->needsImplicitThis()) {
if (!EmitAtomOp(cx, pn, JSOP_IMPLICITTHIS, bce))
return false;
} else {

View File

@ -151,7 +151,7 @@ struct BytecodeEmitter
Normal,
/*
* Emit JSOP_CALLINTRINSIC instead of JSOP_NAME and assert that
* Emit JSOP_GETINTRINSIC instead of JSOP_NAME and assert that
* JSOP_NAME and JSOP_*GNAME don't ever get emitted. See the comment
* for the field |selfHostingMode| in Parser.h for details.
*/

View File

@ -1915,12 +1915,6 @@ BaselineCompiler::emit_JSOP_GETGNAME()
return true;
}
bool
BaselineCompiler::emit_JSOP_CALLGNAME()
{
return emit_JSOP_GETGNAME();
}
bool
BaselineCompiler::emit_JSOP_BINDGNAME()
{
@ -2063,12 +2057,6 @@ BaselineCompiler::emit_JSOP_GETALIASEDVAR()
return true;
}
bool
BaselineCompiler::emit_JSOP_CALLALIASEDVAR()
{
return emit_JSOP_GETALIASEDVAR();
}
bool
BaselineCompiler::emit_JSOP_SETALIASEDVAR()
{
@ -2143,12 +2131,6 @@ BaselineCompiler::emit_JSOP_NAME()
return true;
}
bool
BaselineCompiler::emit_JSOP_CALLNAME()
{
return emit_JSOP_NAME();
}
bool
BaselineCompiler::emit_JSOP_BINDNAME()
{
@ -2201,12 +2183,6 @@ BaselineCompiler::emit_JSOP_GETINTRINSIC()
return true;
}
bool
BaselineCompiler::emit_JSOP_CALLINTRINSIC()
{
return emit_JSOP_GETINTRINSIC();
}
typedef bool (*DefVarOrConstFn)(JSContext *, HandlePropertyName, unsigned, HandleObject);
static const VMFunction DefVarOrConstInfo = FunctionInfo<DefVarOrConstFn>(DefVarOrConst);
@ -2374,12 +2350,6 @@ BaselineCompiler::emit_JSOP_GETLOCAL()
return true;
}
bool
BaselineCompiler::emit_JSOP_CALLLOCAL()
{
return emit_JSOP_GETLOCAL();
}
bool
BaselineCompiler::emit_JSOP_SETLOCAL()
{
@ -2474,12 +2444,6 @@ BaselineCompiler::emit_JSOP_GETARG()
return emitFormalArgAccess(arg, /* get = */ true);
}
bool
BaselineCompiler::emit_JSOP_CALLARG()
{
return emit_JSOP_GETARG();
}
bool
BaselineCompiler::emit_JSOP_SETARG()
{

View File

@ -105,7 +105,6 @@ namespace jit {
_(JSOP_DELELEM) \
_(JSOP_IN) \
_(JSOP_GETGNAME) \
_(JSOP_CALLGNAME) \
_(JSOP_BINDGNAME) \
_(JSOP_SETGNAME) \
_(JSOP_SETNAME) \
@ -116,23 +115,18 @@ namespace jit {
_(JSOP_LENGTH) \
_(JSOP_GETXPROP) \
_(JSOP_GETALIASEDVAR) \
_(JSOP_CALLALIASEDVAR) \
_(JSOP_SETALIASEDVAR) \
_(JSOP_NAME) \
_(JSOP_CALLNAME) \
_(JSOP_BINDNAME) \
_(JSOP_DELNAME) \
_(JSOP_GETINTRINSIC) \
_(JSOP_CALLINTRINSIC) \
_(JSOP_DEFVAR) \
_(JSOP_DEFCONST) \
_(JSOP_SETCONST) \
_(JSOP_DEFFUN) \
_(JSOP_GETLOCAL) \
_(JSOP_CALLLOCAL) \
_(JSOP_SETLOCAL) \
_(JSOP_GETARG) \
_(JSOP_CALLARG) \
_(JSOP_SETARG) \
_(JSOP_CALL) \
_(JSOP_FUNCALL) \

View File

@ -5638,10 +5638,6 @@ TryAttachGlobalNameStub(JSContext *cx, HandleScript script, jsbytecode *pc,
bool isScripted;
if (IsCacheableGetPropCall(cx, global, global, shape, &isScripted) && !isScripted)
{
#ifdef JS_HAS_NO_SUCH_METHOD
if (JSOp(*pc) == JSOP_CALLGNAME)
return true;
#endif
ICStub *monitorStub = stub->fallbackMonitorStub()->firstMonitorStub();
IonSpew(IonSpew_BaselineIC, " Generating GetName(GlobalName/NativeGetter) stub");
RootedFunction getter(cx, &shape->getterObject()->as<JSFunction>());
@ -5758,7 +5754,7 @@ DoGetNameFallback(JSContext *cx, BaselineFrame *frame, ICGetName_Fallback *stub,
mozilla::DebugOnly<JSOp> op = JSOp(*pc);
FallbackICSpew(cx, stub, "GetName(%s)", js_CodeName[JSOp(*pc)]);
JS_ASSERT(op == JSOP_NAME || op == JSOP_CALLNAME || op == JSOP_GETGNAME || op == JSOP_CALLGNAME);
JS_ASSERT(op == JSOP_NAME || op == JSOP_GETGNAME);
RootedPropertyName name(cx, script->getName(pc));
@ -5935,7 +5931,7 @@ DoGetIntrinsicFallback(JSContext *cx, BaselineFrame *frame, ICGetIntrinsic_Fallb
mozilla::DebugOnly<JSOp> op = JSOp(*pc);
FallbackICSpew(cx, stub, "GetIntrinsic(%s)", js_CodeName[JSOp(*pc)]);
JS_ASSERT(op == JSOP_GETINTRINSIC || op == JSOP_CALLINTRINSIC);
JS_ASSERT(op == JSOP_GETINTRINSIC);
if (!GetIntrinsicOperation(cx, pc, res))
return false;

View File

@ -3732,9 +3732,7 @@ class ICIn_Fallback : public ICFallbackStub
// GetName
// JSOP_NAME
// JSOP_CALLNAME
// JSOP_GETGNAME
// JSOP_CALLGNAME
class ICGetName_Fallback : public ICMonitoredFallbackStub
{
friend class ICStubSpace;
@ -3930,7 +3928,6 @@ class ICBindName_Fallback : public ICFallbackStub
// GetIntrinsic
// JSOP_GETINTRINSIC
// JSOP_CALLINTRINSIC
class ICGetIntrinsic_Fallback : public ICMonitoredFallbackStub
{
friend class ICStubSpace;

View File

@ -148,12 +148,10 @@ BytecodeAnalysis::init(TempAllocator &alloc, GSNCache &gsn)
break;
case JSOP_NAME:
case JSOP_CALLNAME:
case JSOP_BINDNAME:
case JSOP_SETNAME:
case JSOP_DELNAME:
case JSOP_GETALIASEDVAR:
case JSOP_CALLALIASEDVAR:
case JSOP_SETALIASEDVAR:
case JSOP_LAMBDA:
case JSOP_LAMBDA_ARROW:

View File

@ -1480,7 +1480,6 @@ IonBuilder::inspectOpcode(JSOp op)
return jsop_rest();
case JSOP_GETARG:
case JSOP_CALLARG:
if (info().argsObjAliasesFormals()) {
MGetArgumentsObjectArg *getArg = MGetArgumentsObjectArg::New(alloc(),
current->argumentsObject(),
@ -1496,7 +1495,6 @@ IonBuilder::inspectOpcode(JSOp op)
return jsop_setarg(GET_ARGNO(pc));
case JSOP_GETLOCAL:
case JSOP_CALLLOCAL:
current->pushLocal(GET_LOCALNO(pc));
return true;
@ -1585,7 +1583,6 @@ IonBuilder::inspectOpcode(JSOp op)
return pushConstant(Int32Value(GET_UINT16(pc)));
case JSOP_GETGNAME:
case JSOP_CALLGNAME:
{
PropertyName *name = info().getAtom(pc)->asPropertyName();
return jsop_getgname(name);
@ -1602,14 +1599,12 @@ IonBuilder::inspectOpcode(JSOp op)
}
case JSOP_NAME:
case JSOP_CALLNAME:
{
PropertyName *name = info().getAtom(pc)->asPropertyName();
return jsop_getname(name);
}
case JSOP_GETINTRINSIC:
case JSOP_CALLINTRINSIC:
{
PropertyName *name = info().getAtom(pc)->asPropertyName();
return jsop_intrinsic(name);
@ -1634,7 +1629,6 @@ IonBuilder::inspectOpcode(JSOp op)
return true;
case JSOP_GETALIASEDVAR:
case JSOP_CALLALIASEDVAR:
return jsop_getaliasedvar(ScopeCoordinate(pc));
case JSOP_SETALIASEDVAR:

View File

@ -517,9 +517,7 @@ ExtendedUse(jsbytecode *pc)
return true;
switch ((JSOp)*pc) {
case JSOP_GETARG:
case JSOP_CALLARG:
case JSOP_GETLOCAL:
case JSOP_CALLLOCAL:
return true;
default:
return false;
@ -554,12 +552,10 @@ static inline uint32_t GetBytecodeSlot(JSScript *script, jsbytecode *pc)
switch (JSOp(*pc)) {
case JSOP_GETARG:
case JSOP_CALLARG:
case JSOP_SETARG:
return ArgSlot(GET_ARGNO(pc));
case JSOP_GETLOCAL:
case JSOP_CALLLOCAL:
case JSOP_SETLOCAL:
return LocalSlot(script, GET_LOCALNO(pc));
@ -928,7 +924,6 @@ ScriptAnalysis::analyzeBytecode(JSContext *cx)
}
case JSOP_GETLOCAL:
case JSOP_CALLLOCAL:
case JSOP_SETLOCAL:
JS_ASSERT(GET_LOCALNO(pc) < script_->nfixed());
break;
@ -1091,9 +1086,7 @@ ScriptAnalysis::analyzeLifetimes(JSContext *cx)
switch (op) {
case JSOP_GETARG:
case JSOP_CALLARG:
case JSOP_GETLOCAL:
case JSOP_CALLLOCAL:
case JSOP_THIS: {
uint32_t slot = GetBytecodeSlot(script_, pc);
if (!slotEscapes(slot)) {

View File

@ -1498,26 +1498,20 @@ ExpressionDecompiler::decompilePC(jsbytecode *pc)
switch (op) {
case JSOP_GETGNAME:
case JSOP_CALLGNAME:
case JSOP_NAME:
case JSOP_CALLNAME:
case JSOP_GETINTRINSIC:
case JSOP_CALLINTRINSIC:
return write(loadAtom(pc));
case JSOP_GETARG:
case JSOP_CALLARG: {
case JSOP_GETARG: {
unsigned slot = GET_ARGNO(pc);
JSAtom *atom = getArg(slot);
return write(atom);
}
case JSOP_GETLOCAL:
case JSOP_CALLLOCAL: {
case JSOP_GETLOCAL: {
uint32_t i = GET_LOCALNO(pc);
if (JSAtom *atom = getLocal(i, pc))
return write(atom);
return write("(intermediate value)");
}
case JSOP_CALLALIASEDVAR:
case JSOP_GETALIASEDVAR: {
JSAtom *atom = ScopeCoordinateName(cx->runtime()->scopeCoordinateNameCache, script, pc);
JS_ASSERT(atom);

View File

@ -1103,14 +1103,6 @@ HandleError(JSContext *cx, InterpreterRegs &regs)
goto error; \
JS_END_MACRO
/*
* Ensure that the interpreter switch can close call-bytecode cases in the
* same way as non-call bytecodes.
*/
JS_STATIC_ASSERT(JSOP_NAME_LENGTH == JSOP_CALLNAME_LENGTH);
JS_STATIC_ASSERT(JSOP_GETARG_LENGTH == JSOP_CALLARG_LENGTH);
JS_STATIC_ASSERT(JSOP_GETLOCAL_LENGTH == JSOP_CALLLOCAL_LENGTH);
/*
* Same for JSOP_SETNAME and JSOP_SETPROP, which differ only slightly but
* remain distinct for the decompiler.
@ -1626,6 +1618,7 @@ CASE(JSOP_UNUSED49)
CASE(JSOP_UNUSED50)
CASE(JSOP_UNUSED51)
CASE(JSOP_UNUSED52)
CASE(JSOP_UNUSED57)
CASE(JSOP_UNUSED101)
CASE(JSOP_UNUSED102)
CASE(JSOP_UNUSED103)
@ -1635,10 +1628,12 @@ CASE(JSOP_UNUSED107)
CASE(JSOP_UNUSED124)
CASE(JSOP_UNUSED125)
CASE(JSOP_UNUSED126)
CASE(JSOP_UNUSED138)
CASE(JSOP_UNUSED139)
CASE(JSOP_UNUSED140)
CASE(JSOP_UNUSED141)
CASE(JSOP_UNUSED142)
CASE(JSOP_UNUSED146)
CASE(JSOP_UNUSED147)
CASE(JSOP_UNUSED148)
CASE(JSOP_BACKPATCH)
@ -1685,6 +1680,9 @@ CASE(JSOP_UNUSED207)
CASE(JSOP_UNUSED208)
CASE(JSOP_UNUSED209)
CASE(JSOP_UNUSED210)
CASE(JSOP_UNUSED211)
CASE(JSOP_UNUSED212)
CASE(JSOP_UNUSED213)
CASE(JSOP_UNUSED219)
CASE(JSOP_UNUSED220)
CASE(JSOP_UNUSED221)
@ -2729,9 +2727,7 @@ CASE(JSOP_IMPLICITTHIS)
END_CASE(JSOP_IMPLICITTHIS)
CASE(JSOP_GETGNAME)
CASE(JSOP_CALLGNAME)
CASE(JSOP_NAME)
CASE(JSOP_CALLNAME)
{
RootedValue &rval = rootValue0;
@ -2744,7 +2740,6 @@ CASE(JSOP_CALLNAME)
END_CASE(JSOP_NAME)
CASE(JSOP_GETINTRINSIC)
CASE(JSOP_CALLINTRINSIC)
{
RootedValue &rval = rootValue0;
@ -2899,7 +2894,6 @@ CASE(JSOP_REST)
}
END_CASE(JSOP_REST)
CASE(JSOP_CALLALIASEDVAR)
CASE(JSOP_GETALIASEDVAR)
{
ScopeCoordinate sc = ScopeCoordinate(REGS.pc);
@ -2924,7 +2918,6 @@ CASE(JSOP_SETALIASEDVAR)
END_CASE(JSOP_SETALIASEDVAR)
CASE(JSOP_GETARG)
CASE(JSOP_CALLARG)
{
unsigned i = GET_ARGNO(REGS.pc);
if (script->argsObjAliasesFormals())
@ -2945,7 +2938,6 @@ CASE(JSOP_SETARG)
END_CASE(JSOP_SETARG)
CASE(JSOP_GETLOCAL)
CASE(JSOP_CALLLOCAL)
{
uint32_t i = GET_LOCALNO(REGS.pc);
PUSH_COPY_SKIP_CHECK(REGS.fp()->unaliasedLocal(i));

View File

@ -160,7 +160,7 @@
macro(JSOP_SETPROP, 54, "setprop", NULL, 5, 2, 1, JOF_ATOM|JOF_PROP|JOF_SET|JOF_DETECTING|JOF_TMPSLOT) \
macro(JSOP_GETELEM, 55, "getelem", NULL, 1, 2, 1, JOF_BYTE |JOF_ELEM|JOF_TYPESET|JOF_LEFTASSOC) \
macro(JSOP_SETELEM, 56, "setelem", NULL, 1, 3, 1, JOF_BYTE |JOF_ELEM|JOF_SET|JOF_DETECTING) \
macro(JSOP_CALLNAME, 57, "callname", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_TYPESET) \
macro(JSOP_UNUSED57, 57, "unused57", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_CALL, 58, "call", NULL, 3, -1, 1, JOF_UINT16|JOF_INVOKE|JOF_TYPESET) \
macro(JSOP_NAME, 59, "name", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_TYPESET) \
macro(JSOP_DOUBLE, 60, "double", NULL, 5, 0, 1, JOF_DOUBLE) \
@ -359,10 +359,10 @@
* uint24 slot: the slot containing the variable in the ScopeObject (this
* 'slot' does not include RESERVED_SLOTS).
*/ \
macro(JSOP_GETALIASEDVAR, 136,"getaliasedvar",NULL, 5, 0, 1, JOF_SCOPECOORD|JOF_NAME|JOF_TYPESET) \
macro(JSOP_CALLALIASEDVAR,137,"callaliasedvar",NULL, 5, 0, 1, JOF_SCOPECOORD|JOF_NAME|JOF_TYPESET) \
macro(JSOP_SETALIASEDVAR, 138,"setaliasedvar",NULL, 5, 1, 1, JOF_SCOPECOORD|JOF_NAME|JOF_SET|JOF_DETECTING) \
macro(JSOP_GETALIASEDVAR, 136,"getaliasedvar",NULL, 5, 0, 1, JOF_SCOPECOORD|JOF_NAME|JOF_TYPESET) \
macro(JSOP_SETALIASEDVAR, 137,"setaliasedvar",NULL, 5, 1, 1, JOF_SCOPECOORD|JOF_NAME|JOF_SET|JOF_DETECTING) \
\
macro(JSOP_UNUSED138, 138, "unused138", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED139, 139, "unused139", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED140, 140, "unused140", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED141, 141, "unused141", NULL, 1, 0, 0, JOF_BYTE) \
@ -376,11 +376,11 @@
* intrinsic functions the runtime doesn't give client JS code access to.
*/ \
macro(JSOP_GETINTRINSIC, 143, "getintrinsic", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_TYPESET) \
macro(JSOP_CALLINTRINSIC, 144, "callintrinsic", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_TYPESET) \
macro(JSOP_SETINTRINSIC, 145, "setintrinsic", NULL, 5, 2, 1, JOF_ATOM|JOF_NAME|JOF_SET|JOF_DETECTING) \
macro(JSOP_BINDINTRINSIC, 146, "bindintrinsic", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_SET) \
macro(JSOP_SETINTRINSIC, 144, "setintrinsic", NULL, 5, 2, 1, JOF_ATOM|JOF_NAME|JOF_SET|JOF_DETECTING) \
macro(JSOP_BINDINTRINSIC, 145, "bindintrinsic", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_SET) \
\
/* Unused. */ \
macro(JSOP_UNUSED146, 146,"unused146", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED147, 147,"unused147", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED148, 148,"unused148", NULL, 1, 0, 0, JOF_BYTE) \
\
@ -485,10 +485,9 @@
macro(JSOP_UNUSED208, 208, "unused208", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED209, 209, "unused209", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED210, 210, "unused210", NULL, 1, 0, 0, JOF_BYTE) \
\
macro(JSOP_CALLGNAME, 211, "callgname", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_TYPESET|JOF_GNAME) \
macro(JSOP_CALLLOCAL, 212, "calllocal", NULL, 4, 0, 1, JOF_LOCAL|JOF_NAME) \
macro(JSOP_CALLARG, 213, "callarg", NULL, 3, 0, 1, JOF_QARG |JOF_NAME) \
macro(JSOP_UNUSED211, 211, "unused211", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED212, 212, "unused212", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_UNUSED213, 213, "unused213", NULL, 1, 0, 0, JOF_BYTE) \
macro(JSOP_BINDGNAME, 214, "bindgname", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_SET|JOF_GNAME) \
\
/* Opcodes to hold 8-bit and 32-bit immediate integer operands. */ \

View File

@ -2254,13 +2254,11 @@ RemoveReferencedNames(JSContext *cx, HandleScript script, PropertyNameSet &remai
switch (JSOp(*pc)) {
case JSOP_NAME:
case JSOP_CALLNAME:
case JSOP_SETNAME:
name = script->getName(pc);
break;
case JSOP_GETALIASEDVAR:
case JSOP_CALLALIASEDVAR:
case JSOP_SETALIASEDVAR:
name = ScopeCoordinateName(cx->runtime()->scopeCoordinateNameCache, script, pc);
break;

View File

@ -887,8 +887,8 @@ void
js::FillSelfHostingCompileOptions(CompileOptions &options)
{
/*
* In self-hosting mode, scripts emit JSOP_CALLINTRINSIC instead of
* JSOP_NAME or JSOP_GNAME to access unbound variables. JSOP_CALLINTRINSIC
* In self-hosting mode, scripts emit JSOP_GETINTRINSIC instead of
* JSOP_NAME or JSOP_GNAME to access unbound variables. JSOP_GETINTRINSIC
* does a name lookup in a special object, whose properties are filled in
* lazily upon first access for a given global.
*

View File

@ -23,7 +23,7 @@ namespace js {
* and saved versions. If deserialization fails, the data should be
* invalidated if possible.
*/
static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 171);
static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - 172);
class XDRBuffer {
public: