Bug 1428489 - Support JSOP_IMPLICITTHIS in Ion using VMCall. r=jandem

MozReview-Commit-ID: CJsNr6U1whs

--HG--
extra : rebase_source : 4cba9984b3a7bc6c2b1df07ad8c9c1f7cb9cdeb4
This commit is contained in:
Ted Campbell 2018-01-06 12:09:47 -05:00
Родитель 10a44a7717
Коммит 7ab0b8fca5
13 изменённых файлов: 96 добавлений и 5 удалений

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

@ -3549,7 +3549,7 @@ BaselineCompiler::emit_JSOP_OPTIMIZE_SPREADCALL()
typedef bool (*ImplicitThisFn)(JSContext*, HandleObject, HandlePropertyName,
MutableHandleValue);
static const VMFunction ImplicitThisInfo =
const VMFunction jit::ImplicitThisInfo =
FunctionInfo<ImplicitThisFn>(ImplicitThisOperation, "ImplicitThisOperation");
bool

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

@ -379,6 +379,7 @@ class BaselineCompiler : public BaselineCompilerSpecific
};
extern const VMFunction NewArrayCopyOnWriteInfo;
extern const VMFunction ImplicitThisInfo;
} // namespace jit
} // namespace js

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

@ -174,12 +174,14 @@ BytecodeAnalysis::init(TempAllocator& alloc, GSNCache& gsn)
case JSOP_DEFVAR:
case JSOP_PUSHLEXICALENV:
case JSOP_POPLEXICALENV:
case JSOP_IMPLICITTHIS:
usesEnvironmentChain_ = true;
break;
case JSOP_GETGNAME:
case JSOP_SETGNAME:
case JSOP_STRICTSETGNAME:
case JSOP_GIMPLICITTHIS:
if (script_->hasNonSyntacticScope())
usesEnvironmentChain_ = true;
break;

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

@ -6581,6 +6581,14 @@ CodeGenerator::visitComputeThis(LComputeThis* lir)
masm.bind(ool->rejoin());
}
void
CodeGenerator::visitImplicitThis(LImplicitThis* lir)
{
pushArg(ImmGCPtr(lir->mir()->name()));
pushArg(ToRegister(lir->env()));
callVM(ImplicitThisInfo, lir);
}
void
CodeGenerator::visitArrowNewTarget(LArrowNewTarget* lir)
{

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

@ -232,6 +232,7 @@ class CodeGenerator final : public CodeGeneratorSpecific
void visitSetArgumentsObjectArg(LSetArgumentsObjectArg* lir) override;
void visitReturnFromCtor(LReturnFromCtor* lir) override;
void visitComputeThis(LComputeThis* lir) override;
void visitImplicitThis(LImplicitThis* lir) override;
void visitArrayLength(LArrayLength* lir) override;
void visitSetArrayLength(LSetArrayLength* lir) override;
void visitGetNextEntryForIterator(LGetNextEntryForIterator* lir) override;

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

@ -2341,9 +2341,13 @@ IonBuilder::inspectOpcode(JSOp op)
pushConstant(UndefinedValue());
return Ok();
}
// Just fall through to the unsupported bytecode case.
break;
// Fallthrough to IMPLICITTHIS in non-syntactic scope case
MOZ_FALLTHROUGH;
case JSOP_IMPLICITTHIS:
{
PropertyName* name = info().getAtom(pc)->asPropertyName();
return jsop_implicitthis(name);
}
case JSOP_NEWTARGET:
return jsop_newtarget();
@ -2443,7 +2447,6 @@ IonBuilder::inspectOpcode(JSOp op)
case JSOP_FINALLY:
case JSOP_GETRVAL:
case JSOP_GOSUB:
case JSOP_IMPLICITTHIS:
case JSOP_RETSUB:
case JSOP_SETINTRINSIC:
case JSOP_THROWMSG:
@ -13212,6 +13215,18 @@ IonBuilder::jsop_debugger()
return resumeAt(debugger, pc);
}
AbortReasonOr<Ok>
IonBuilder::jsop_implicitthis(PropertyName* name)
{
MOZ_ASSERT(usesEnvironmentChain());
MImplicitThis* implicitThis = MImplicitThis::New(alloc(), current->environmentChain(), name);
current->add(implicitThis);
current->push(implicitThis);
return resumeAfter(implicitThis);
}
MInstruction*
IonBuilder::addConvertElementsToDoubles(MDefinition* elements)
{

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

@ -594,6 +594,7 @@ class IonBuilder
AbortReasonOr<Ok> jsop_checkiscallable(uint8_t kind);
AbortReasonOr<Ok> jsop_checkobjcoercible();
AbortReasonOr<Ok> jsop_pushcallobj();
AbortReasonOr<Ok> jsop_implicitthis(PropertyName* name);
/* Inlining. */

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

@ -449,6 +449,17 @@ LIRGenerator::visitComputeThis(MComputeThis* ins)
assignSafepoint(lir, ins);
}
void
LIRGenerator::visitImplicitThis(MImplicitThis* ins)
{
MDefinition* env = ins->envChain();
MOZ_ASSERT(env->type() == MIRType::Object);
LImplicitThis* lir = new(alloc()) LImplicitThis(useRegisterAtStart(env));
defineReturn(lir, ins);
assignSafepoint(lir, ins);
}
void
LIRGenerator::visitArrowNewTarget(MArrowNewTarget* ins)
{

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

@ -104,6 +104,7 @@ class LIRGenerator : public LIRGeneratorSpecific
void visitSetArgumentsObjectArg(MSetArgumentsObjectArg* ins) override;
void visitReturnFromCtor(MReturnFromCtor* ins) override;
void visitComputeThis(MComputeThis* ins) override;
void visitImplicitThis(MImplicitThis* ins) override;
void visitCall(MCall* call) override;
void visitApplyArgs(MApplyArgs* apply) override;
void visitApplyArray(MApplyArray* apply) override;

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

@ -7751,6 +7751,37 @@ class MComputeThis
// Note: don't override getAliasSet: the thisValue hook can be effectful.
};
class MImplicitThis
: public MUnaryInstruction,
public SingleObjectPolicy::Data
{
CompilerPropertyName name_;
MImplicitThis(MDefinition* envChain, PropertyName* name)
: MUnaryInstruction(classOpcode, envChain),
name_(name)
{
setResultType(MIRType::Value);
}
public:
INSTRUCTION_HEADER(ImplicitThis)
TRIVIAL_NEW_WRAPPERS
NAMED_OPERANDS((0, envChain))
PropertyName* name() const {
return name_;
}
bool appendRoots(MRootList& roots) const override {
return roots.append(name_);
}
bool possiblyCalls() const override {
return true;
}
};
// Load an arrow function's |new.target| value.
class MArrowNewTarget
: public MUnaryInstruction,

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

@ -66,6 +66,7 @@ namespace jit {
_(GetArgumentsObjectArg) \
_(SetArgumentsObjectArg) \
_(ComputeThis) \
_(ImplicitThis) \
_(Call) \
_(ApplyArgs) \
_(ApplyArray) \

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

@ -1855,6 +1855,24 @@ class LComputeThis : public LInstructionHelper<BOX_PIECES, BOX_PIECES, 0>
}
};
class LImplicitThis : public LCallInstructionHelper<BOX_PIECES, 1, 0>
{
public:
LIR_HEADER(ImplicitThis)
explicit LImplicitThis(const LAllocation& env) {
setOperand(0, env);
}
const LAllocation* env() {
return getOperand(0);
}
MImplicitThis* mir() const {
return mir_->toImplicitThis();
}
};
// Writes a typed argument for a function call to the frame's argument vector.
class LStackArgT : public LInstructionHelper<0, 1, 0>
{

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

@ -105,6 +105,7 @@
_(SetArgumentsObjectArg) \
_(ReturnFromCtor) \
_(ComputeThis) \
_(ImplicitThis) \
_(BitNotI) \
_(BitNotV) \
_(BitOpI) \