Bug 1273858 - Ion-compile JSOP_FRESHENLEXICALENV/JSOP_RECREATELEXICALENV r=jandem

MozReview-Commit-ID: DHFceqW3YlD

--HG--
extra : rebase_source : 5ec23b06c9469934abe4ea5c34d798339ffe230c
This commit is contained in:
Ted Campbell 2017-02-15 15:28:15 -05:00
Родитель 8b4e69e220
Коммит 9f630025f0
12 изменённых файлов: 109 добавлений и 10 удалений

Просмотреть файл

@ -3449,6 +3449,19 @@ CodeGenerator::visitNewLexicalEnvironmentObject(LNewLexicalEnvironmentObject* li
callVM(NewLexicalEnvironmentObjectInfo, lir);
}
typedef JSObject* (*CopyLexicalEnvironmentObjectFn)(JSContext*, HandleObject, bool);
static const VMFunction CopyLexicalEnvironmentObjectInfo =
FunctionInfo<CopyLexicalEnvironmentObjectFn>(js::jit::CopyLexicalEnvironmentObject,
"js::jit::CopyLexicalEnvironmentObject");
void
CodeGenerator::visitCopyLexicalEnvironmentObject(LCopyLexicalEnvironmentObject* lir)
{
pushArg(Imm32(lir->mir()->copySlots()));
pushArg(ToRegister(lir->env()));
callVM(CopyLexicalEnvironmentObjectInfo, lir);
}
void
CodeGenerator::visitGuardObjectIdentity(LGuardObjectIdentity* guard)
{

Просмотреть файл

@ -288,6 +288,7 @@ class CodeGenerator final : public CodeGeneratorSpecific
void visitStringSplit(LStringSplit* lir);
void visitFunctionEnvironment(LFunctionEnvironment* lir);
void visitNewLexicalEnvironmentObject(LNewLexicalEnvironmentObject* lir);
void visitCopyLexicalEnvironmentObject(LCopyLexicalEnvironmentObject* lir);
void visitCallGetProperty(LCallGetProperty* lir);
void visitCallGetElement(LCallGetElement* lir);
void visitCallSetElement(LCallSetElement* lir);

Просмотреть файл

@ -2214,6 +2214,12 @@ IonBuilder::inspectOpcode(JSOp op)
current->setEnvironmentChain(walkEnvironmentChain(1));
return Ok();
case JSOP_FRESHENLEXICALENV:
return jsop_copylexicalenv(true);
case JSOP_RECREATELEXICALENV:
return jsop_copylexicalenv(false);
case JSOP_ITER:
return jsop_iter(GET_INT8(pc));
@ -2276,16 +2282,6 @@ IonBuilder::inspectOpcode(JSOp op)
pushConstant(MagicValue(JS_IS_CONSTRUCTING));
return Ok();
#ifdef DEBUG
case JSOP_FRESHENLEXICALENV:
case JSOP_RECREATELEXICALENV:
// These opcodes are currently unhandled by Ion, but in principle
// there's no reason they couldn't be. Whenever this happens, OSR
// will have to consider that JSOP_{FRESHEN,RECREATE}LEXICALENV
// mutates the env chain -- right now MBasicBlock::environmentChain()
// caches the env chain. JSOP_{FRESHEN,RECREATE}LEXICALENV must
// update that stale value.
#endif
default:
break;
}
@ -11869,6 +11865,20 @@ IonBuilder::jsop_pushlexicalenv(uint32_t index)
return resumeAfter(ins);
}
AbortReasonOr<Ok>
IonBuilder::jsop_copylexicalenv(bool copySlots)
{
MOZ_ASSERT(analysis().usesEnvironmentChain());
MCopyLexicalEnvironmentObject* ins =
MCopyLexicalEnvironmentObject::New(alloc(), current->environmentChain(), copySlots);
current->add(ins);
current->setEnvironmentChain(ins);
return resumeAfter(ins);
}
AbortReasonOr<Ok>
IonBuilder::jsop_setarg(uint32_t arg)
{

Просмотреть файл

@ -562,6 +562,7 @@ class IonBuilder
AbortReasonOr<Ok> jsop_lambda_arrow(JSFunction* fun);
AbortReasonOr<Ok> jsop_setfunname(uint8_t prefixKind);
AbortReasonOr<Ok> jsop_pushlexicalenv(uint32_t index);
AbortReasonOr<Ok> jsop_copylexicalenv(bool copySlots);
AbortReasonOr<Ok> jsop_functionthis();
AbortReasonOr<Ok> jsop_globalthis();
AbortReasonOr<Ok> jsop_typeof();

Просмотреть файл

@ -2530,6 +2530,19 @@ LIRGenerator::visitNewLexicalEnvironmentObject(MNewLexicalEnvironmentObject* ins
assignSafepoint(lir, ins);
}
void
LIRGenerator::visitCopyLexicalEnvironmentObject(MCopyLexicalEnvironmentObject* ins)
{
MDefinition* env = ins->env();
MOZ_ASSERT(env->type() == MIRType::Object);
LCopyLexicalEnvironmentObject* lir =
new(alloc()) LCopyLexicalEnvironmentObject(useRegisterAtStart(env));
defineReturn(lir, ins);
assignSafepoint(lir, ins);
}
void
LIRGenerator::visitKeepAliveObject(MKeepAliveObject* ins)
{

Просмотреть файл

@ -187,6 +187,7 @@ class LIRGenerator : public LIRGeneratorSpecific
void visitLambdaArrow(MLambdaArrow* ins);
void visitSetFunName(MSetFunName* ins);
void visitNewLexicalEnvironmentObject(MNewLexicalEnvironmentObject* ins);
void visitCopyLexicalEnvironmentObject(MCopyLexicalEnvironmentObject* ins);
void visitKeepAliveObject(MKeepAliveObject* ins);
void visitSlots(MSlots* ins);
void visitElements(MElements* ins);

Просмотреть файл

@ -11560,6 +11560,33 @@ class MNewLexicalEnvironmentObject
}
};
// Allocate a new LexicalEnvironmentObject from existing one
class MCopyLexicalEnvironmentObject
: public MUnaryInstruction,
public SingleObjectPolicy::Data
{
bool copySlots_;
MCopyLexicalEnvironmentObject(MDefinition* env, bool copySlots)
: MUnaryInstruction(env),
copySlots_(copySlots)
{
setResultType(MIRType::Object);
}
public:
INSTRUCTION_HEADER(CopyLexicalEnvironmentObject)
TRIVIAL_NEW_WRAPPERS
NAMED_OPERANDS((0, env))
bool copySlots() const {
return copySlots_;
}
bool possiblyCalls() const override {
return true;
}
};
// Store to vp[slot] (slots that are not inline in an object).
class MStoreSlot
: public MBinaryInstruction,

Просмотреть файл

@ -173,6 +173,7 @@ namespace jit {
_(StoreSlot) \
_(FunctionEnvironment) \
_(NewLexicalEnvironmentObject) \
_(CopyLexicalEnvironmentObject) \
_(FilterTypeSet) \
_(TypeBarrier) \
_(MonitorTypes) \

Просмотреть файл

@ -924,6 +924,17 @@ NewArgumentsObject(JSContext* cx, BaselineFrame* frame, MutableHandleValue res)
return true;
}
JSObject*
CopyLexicalEnvironmentObject(JSContext* cx, HandleObject env, bool copySlots)
{
Handle<LexicalEnvironmentObject*> lexicalEnv = env.as<LexicalEnvironmentObject>();
if (copySlots)
return LexicalEnvironmentObject::clone(cx, lexicalEnv);
return LexicalEnvironmentObject::recreate(cx, lexicalEnv);
}
JSObject*
InitRestParameter(JSContext* cx, uint32_t length, Value* rest, HandleObject templateObj,
HandleObject objRes)

Просмотреть файл

@ -714,6 +714,8 @@ InitFunctionEnvironmentObjects(JSContext* cx, BaselineFrame* frame);
MOZ_MUST_USE bool
NewArgumentsObject(JSContext* cx, BaselineFrame* frame, MutableHandleValue res);
JSObject* CopyLexicalEnvironmentObject(JSContext* cx, HandleObject env, bool copySlots);
JSObject* InitRestParameter(JSContext* cx, uint32_t length, Value* rest, HandleObject templateObj,
HandleObject res);

Просмотреть файл

@ -7068,6 +7068,24 @@ class LNewLexicalEnvironmentObject : public LCallInstructionHelper<1, 1, 0>
}
};
// Copy a LexicalEnvironmentObject.
class LCopyLexicalEnvironmentObject : public LCallInstructionHelper<1, 1, 0>
{
public:
LIR_HEADER(CopyLexicalEnvironmentObject)
explicit LCopyLexicalEnvironmentObject(const LAllocation& env) {
setOperand(0, env);
}
const LAllocation* env() {
return getOperand(0);
}
MCopyLexicalEnvironmentObject* mir() const {
return mir_->toCopyLexicalEnvironmentObject();
}
};
class LCallGetProperty : public LCallInstructionHelper<BOX_PIECES, BOX_PIECES, 0>
{
public:

Просмотреть файл

@ -320,6 +320,7 @@
_(StoreFixedSlotT) \
_(FunctionEnvironment) \
_(NewLexicalEnvironmentObject) \
_(CopyLexicalEnvironmentObject) \
_(GetPropertyCacheV) \
_(GetPropertyCacheT) \
_(GetPropertyPolymorphicV) \