Bug 1169743 - Implement class decls with extends in Baseline (cont.) r=jandem

Add baseline support for
        JSOP_INITHOMEOBJECT
        JSOP_CLASSCONSTRUCTOR
        JSOP_DERIVEDCONSTRUCTOR

MozReview-Commit-ID: 1Vdfzq1DHuD
This commit is contained in:
Ted Campbell 2017-06-07 14:04:13 -04:00
Родитель 79318e1a8c
Коммит ca0e63927f
6 изменённых файлов: 90 добавлений и 3 удалений

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

@ -4714,6 +4714,40 @@ BaselineCompiler::emit_JSOP_CHECKCLASSHERITAGE()
return callVM(CheckClassHeritageOperationInfo);
}
bool
BaselineCompiler::emit_JSOP_INITHOMEOBJECT()
{
frame.syncStack(0);
// Load HomeObject off stack
unsigned skipOver = GET_UINT8(pc);
MOZ_ASSERT(frame.stackDepth() >= skipOver + 2);
masm.loadValue(frame.addressOfStackValue(frame.peek(-2 - skipOver)), R0);
// Load function off stack
Register func = R2.scratchReg();
masm.unboxObject(frame.addressOfStackValue(frame.peek(-1)), func);
// Set HOMEOBJECT_SLOT
Address addr(func, FunctionExtended::offsetOfMethodHomeObjectSlot());
#ifdef DEBUG
Label isUndefined;
masm.branchTestUndefined(Assembler::Equal, addr, &isUndefined);
masm.assumeUnreachable("INITHOMEOBJECT expects undefined slot");
masm.bind(&isUndefined);
#endif
masm.storeValue(R0, addr);
Register temp = R1.scratchReg();
Label skipBarrier;
masm.branchPtrInNurseryChunk(Assembler::Equal, func, temp, &skipBarrier);
masm.branchValueIsNurseryObject(Assembler::NotEqual, R0, temp, &skipBarrier);
masm.call(&postBarrierSlot_);
masm.bind(&skipBarrier);
return true;
}
bool
BaselineCompiler::emit_JSOP_BUILTINPROTO()
{
@ -4774,3 +4808,46 @@ BaselineCompiler::emit_JSOP_FUNWITHPROTO()
frame.push(R0);
return true;
}
typedef JSFunction* (*MakeDefaultConstructorFn)(JSContext*, HandleScript,
jsbytecode*, HandleObject);
static const VMFunction MakeDefaultConstructorInfo =
FunctionInfo<MakeDefaultConstructorFn>(js::MakeDefaultConstructor,
"MakeDefaultConstructor");
bool
BaselineCompiler::emit_JSOP_CLASSCONSTRUCTOR()
{
frame.syncStack(0);
// Pass nullptr as prototype to MakeDefaultConstructor
prepareVMCall();
pushArg(ImmPtr(nullptr));
pushArg(ImmPtr(pc));
pushArg(ImmGCPtr(script));
if (!callVM(MakeDefaultConstructorInfo))
return false;
masm.tagValue(JSVAL_TYPE_OBJECT, ReturnReg, R0);
frame.push(R0);
return true;
}
bool
BaselineCompiler::emit_JSOP_DERIVEDCONSTRUCTOR()
{
frame.popRegsAndSync(1);
masm.unboxObject(R0, R0.scratchReg());
prepareVMCall();
pushArg(R0.scratchReg());
pushArg(ImmPtr(pc));
pushArg(ImmGCPtr(script));
if (!callVM(MakeDefaultConstructorInfo))
return false;
masm.tagValue(JSVAL_TYPE_OBJECT, ReturnReg, R0);
frame.push(R0);
return true;
}

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

@ -243,9 +243,12 @@ namespace jit {
_(JSOP_IS_CONSTRUCTING) \
_(JSOP_TRY_DESTRUCTURING_ITERCLOSE) \
_(JSOP_CHECKCLASSHERITAGE) \
_(JSOP_INITHOMEOBJECT) \
_(JSOP_BUILTINPROTO) \
_(JSOP_OBJWITHPROTO) \
_(JSOP_FUNWITHPROTO)
_(JSOP_FUNWITHPROTO) \
_(JSOP_CLASSCONSTRUCTOR) \
_(JSOP_DERIVEDCONSTRUCTOR)
class BaselineCompiler : public BaselineCompilerSpecific
{

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

@ -275,6 +275,7 @@ struct VMFunction
template <class> struct TypeToDataType { /* Unexpected return type for a VMFunction. */ };
template <> struct TypeToDataType<bool> { static const DataType result = Type_Bool; };
template <> struct TypeToDataType<JSObject*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<JSFunction*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<NativeObject*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<PlainObject*> { static const DataType result = Type_Object; };
template <> struct TypeToDataType<InlineTypedObject*> { static const DataType result = Type_Object; };

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

@ -774,6 +774,9 @@ class FunctionExtended : public JSFunction
static inline size_t offsetOfArrowNewTargetSlot() {
return offsetOfExtendedSlot(ARROW_NEWTARGET_SLOT);
}
static inline size_t offsetOfMethodHomeObjectSlot() {
return offsetOfExtendedSlot(METHOD_HOMEOBJECT_SLOT);
}
private:
friend class JSFunction;

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

@ -245,8 +245,8 @@ SetPropertyOperation(JSContext* cx, JSOp op, HandleValue lval, HandleId id, Hand
result.checkStrictErrorOrWarning(cx, obj, id, op == JSOP_STRICTSETPROP);
}
static JSFunction*
MakeDefaultConstructor(JSContext* cx, HandleScript script, jsbytecode* pc, HandleObject proto)
JSFunction*
js::MakeDefaultConstructor(JSContext* cx, HandleScript script, jsbytecode* pc, HandleObject proto)
{
JSOp op = JSOp(*pc);
JSAtom* atom = script->getAtom(pc);

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

@ -586,6 +586,9 @@ ObjectWithProtoOperation(JSContext* cx, HandleValue proto);
JSObject*
FunWithProtoOperation(JSContext* cx, HandleFunction fun, HandleObject parent, HandleObject proto);
JSFunction*
MakeDefaultConstructor(JSContext* cx, HandleScript script, jsbytecode* pc, HandleObject proto);
} /* namespace js */
#endif /* vm_Interpreter_h */