Bug 1071646 - Support JSOP_BINDVAR in Ion. (r=jandem)

This commit is contained in:
Shu-yu Guo 2015-12-18 13:18:20 -08:00 committed by Cameron Kaiser
parent c283022810
commit d05f77998c
11 changed files with 88 additions and 0 deletions

View File

@ -158,6 +158,7 @@ BytecodeAnalysis::init(TempAllocator& alloc, GSNCache& gsn)
case JSOP_GETNAME:
case JSOP_BINDNAME:
case JSOP_BINDVAR:
case JSOP_SETNAME:
case JSOP_STRICTSETNAME:
case JSOP_DELNAME:

View File

@ -9050,6 +9050,16 @@ CodeGenerator::visitOutOfLineUnboxFloatingPoint(OutOfLineUnboxFloatingPoint* ool
masm.jump(ool->rejoin());
}
typedef JSObject* (*BindVarFn)(JSContext*, HandleObject);
static const VMFunction BindVarInfo = FunctionInfo<BindVarFn>(jit::BindVar);
void
CodeGenerator::visitCallBindVar(LCallBindVar* lir)
{
pushArg(ToRegister(lir->scopeChain()));
callVM(BindVarInfo, lir);
}
typedef bool (*GetPropertyFn)(JSContext*, HandleValue, HandlePropertyName, MutableHandleValue);
static const VMFunction GetPropertyInfo = FunctionInfo<GetPropertyFn>(GetProperty);

View File

@ -331,6 +331,7 @@ class CodeGenerator : public CodeGeneratorSpecific
void visitSetDOMProperty(LSetDOMProperty* lir);
void visitCallDOMNative(LCallDOMNative* lir);
void visitCallGetIntrinsicValue(LCallGetIntrinsicValue* lir);
void visitCallBindVar(LCallBindVar* lir);
void visitIsCallable(LIsCallable* lir);
void visitOutOfLineIsCallable(OutOfLineIsCallable* ool);
void visitIsObject(LIsObject* lir);

View File

@ -1947,6 +1947,9 @@ IonBuilder::inspectOpcode(JSOp op)
case JSOP_BINDNAME:
return jsop_bindname(info().getName(pc));
case JSOP_BINDVAR:
return jsop_bindvar();
case JSOP_DUP:
current->pushSlot(current->stackDepth() - 1);
return true;
@ -8425,6 +8428,16 @@ IonBuilder::jsop_bindname(PropertyName* name)
return resumeAfter(ins);
}
bool
IonBuilder::jsop_bindvar()
{
MOZ_ASSERT(analysis().usesScopeChain());
MCallBindVar* ins = MCallBindVar::New(alloc(), current->scopeChain());
current->add(ins);
current->push(ins);
return true;
}
static MIRType
GetElemKnownType(bool needsHoleCheck, TemporaryTypeSet* types)
{

View File

@ -3368,6 +3368,16 @@ LIRGenerator::visitBindNameCache(MBindNameCache* ins)
assignSafepoint(lir, ins);
}
void
LIRGenerator::visitCallBindVar(MCallBindVar* ins)
{
MOZ_ASSERT(ins->scopeChain()->type() == MIRType_Object);
MOZ_ASSERT(ins->type() == MIRType_Object);
LCallBindVar* lir = new(alloc()) LCallBindVar(useRegister(ins->scopeChain()));
define(lir, ins);
}
void
LIRGenerator::visitGuardObjectIdentity(MGuardObjectIdentity* ins)
{

View File

@ -232,6 +232,7 @@ class LIRGenerator : public LIRGeneratorSpecific
void visitGetPropertyPolymorphic(MGetPropertyPolymorphic* ins);
void visitSetPropertyPolymorphic(MSetPropertyPolymorphic* ins);
void visitBindNameCache(MBindNameCache* ins);
void visitCallBindVar(MCallBindVar* ins);
void visitGuardObjectIdentity(MGuardObjectIdentity* ins);
void visitGuardClass(MGuardClass* ins);
void visitGuardObject(MGuardObject* ins);

View File

@ -10819,6 +10819,39 @@ class MBindNameCache
}
};
class MCallBindVar
: public MUnaryInstruction,
public SingleObjectPolicy::Data
{
explicit MCallBindVar(MDefinition* scopeChain)
: MUnaryInstruction(scopeChain)
{
setResultType(MIRType_Object);
setMovable();
}
public:
INSTRUCTION_HEADER(CallBindVar)
static MCallBindVar* New(TempAllocator& alloc, MDefinition* scopeChain) {
return new(alloc) MCallBindVar(scopeChain);
}
MDefinition* scopeChain() const {
return getOperand(0);
}
bool congruentTo(const MDefinition* ins) const override {
if (!ins->isCallBindVar())
return false;
return congruentIfOperandsEqual(ins);
}
AliasSet getAliasSet() const override {
return AliasSet::None();
}
};
// Guard on an object's shape.
class MGuardShape
: public MUnaryInstruction,

View File

@ -162,6 +162,7 @@ namespace jit {
_(GetPropertyPolymorphic) \
_(SetPropertyPolymorphic) \
_(BindNameCache) \
_(CallBindVar) \
_(GuardShape) \
_(GuardReceiverPolymorphic) \
_(GuardObjectGroup) \

View File

@ -173,6 +173,7 @@ BindVar(JSContext* cx, HandleObject scopeChain)
JSObject* obj = scopeChain;
while (!obj->isQualifiedVarObj())
obj = obj->enclosingScope();
MOZ_ASSERT(obj);
return obj;
}

View File

@ -5774,6 +5774,22 @@ class LBindNameCache : public LInstructionHelper<1, 1, 0>
}
};
class LCallBindVar : public LInstructionHelper<1, 1, 0>
{
public:
LIR_HEADER(CallBindVar)
explicit LCallBindVar(const LAllocation& scopeChain) {
setOperand(0, scopeChain);
}
const LAllocation* scopeChain() {
return getOperand(0);
}
const MCallBindVar* mir() const {
return mir_->toCallBindVar();
}
};
// Load a value from an object's dslots or a slots vector.
class LLoadSlotV : public LInstructionHelper<BOX_PIECES, 1, 0>
{

View File

@ -277,6 +277,7 @@
_(GetPropertyPolymorphicV) \
_(GetPropertyPolymorphicT) \
_(BindNameCache) \
_(CallBindVar) \
_(CallGetProperty) \
_(GetNameCache) \
_(CallGetIntrinsicValue) \