Bug 1567438 part 5 - Change IsIonInlinablePC to IsIonInlinableOp. r=tcampbell,iain

We need this for the next patch because we have a JSOp instead of a pc when
generating the interpreter. (In general it's nicer for functions to take a JSOp
instead of a PC because it can be used in strictly more contexts.)

Differential Revision: https://phabricator.services.mozilla.com/D38864

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan de Mooij 2019-07-30 12:09:51 +00:00
Родитель 4afa4e1369
Коммит d3397e90fe
6 изменённых файлов: 52 добавлений и 41 удалений

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

@ -445,23 +445,23 @@ static inline bool IsInlinableFallback(ICFallbackStub* icEntry) {
}
#endif
static inline void* GetStubReturnAddress(JSContext* cx, jsbytecode* pc) {
static inline void* GetStubReturnAddress(JSContext* cx, JSOp op) {
const BaselineICFallbackCode& code =
cx->runtime()->jitRuntime()->baselineICFallbackCode();
if (IsGetPropPC(pc)) {
if (IsGetPropOp(op)) {
return code.bailoutReturnAddr(BailoutReturnKind::GetProp);
}
if (IsSetPropPC(pc)) {
if (IsSetPropOp(op)) {
return code.bailoutReturnAddr(BailoutReturnKind::SetProp);
}
if (IsGetElemPC(pc)) {
if (IsGetElemOp(op)) {
return code.bailoutReturnAddr(BailoutReturnKind::GetElem);
}
// This should be a call op of some kind, now.
MOZ_ASSERT(IsCallPC(pc) && !IsSpreadCallPC(pc));
if (IsConstructorCallPC(pc)) {
MOZ_ASSERT(IsCallOp(op) && !IsSpreadCallOp(op));
if (IsConstructorCallOp(op)) {
return code.bailoutReturnAddr(BailoutReturnKind::New);
}
return code.bailoutReturnAddr(BailoutReturnKind::Call);
@ -903,7 +903,7 @@ static bool InitFromBailout(JSContext* cx, size_t frameNo, HandleFunction fun,
JSOp op = JSOp(*pc);
// Inlining of SPREADCALL-like frames not currently supported.
MOZ_ASSERT_IF(IsSpreadCallPC(pc), !iter.moreFrames());
MOZ_ASSERT_IF(IsSpreadCallOp(op), !iter.moreFrames());
// Fixup inlined JSOP_FUNCALL, JSOP_FUNAPPLY, and accessors on the caller
// side. On the caller side this must represent like the function wasn't
@ -911,7 +911,7 @@ static bool InitFromBailout(JSContext* cx, size_t frameNo, HandleFunction fun,
uint32_t pushedSlots = 0;
RootedValueVector savedCallerArgs(cx);
bool needToSaveArgs =
op == JSOP_FUNAPPLY || IsIonInlinableGetterOrSetterPC(pc);
op == JSOP_FUNAPPLY || IsIonInlinableGetterOrSetterOp(op);
if (iter.moreFrames() && (op == JSOP_FUNCALL || needToSaveArgs)) {
uint32_t inlined_args = 0;
if (op == JSOP_FUNCALL) {
@ -919,8 +919,8 @@ static bool InitFromBailout(JSContext* cx, size_t frameNo, HandleFunction fun,
} else if (op == JSOP_FUNAPPLY) {
inlined_args = 2 + blFrame->numActualArgs();
} else {
MOZ_ASSERT(IsIonInlinableGetterOrSetterPC(pc));
inlined_args = 2 + IsSetPropPC(pc);
MOZ_ASSERT(IsIonInlinableGetterOrSetterOp(op));
inlined_args = 2 + IsSetPropOp(op);
}
MOZ_ASSERT(exprStackSlots >= inlined_args);
@ -986,7 +986,7 @@ static bool InitFromBailout(JSContext* cx, size_t frameNo, HandleFunction fun,
savedCallerArgs[i].set(iter.read());
}
if (IsSetPropPC(pc)) {
if (IsSetPropOp(op)) {
// We would love to just save all the arguments and leave them
// in the stub frame pushed below, but we will lose the inital
// argument which the function was called with, which we must
@ -1095,7 +1095,7 @@ static bool InitFromBailout(JSContext* cx, size_t frameNo, HandleFunction fun,
// include the this. When inlining that is not included.
// So the exprStackSlots will be one less.
MOZ_ASSERT(expectedDepth - exprStackSlots <= 1);
} else if (iter.moreFrames() && IsIonInlinableGetterOrSetterPC(pc)) {
} else if (iter.moreFrames() && IsIonInlinableGetterOrSetterOp(op)) {
// Accessors coming out of ion are inlined via a complete
// lie perpetrated by the compiler internally. Ion just rearranges
// the stack, and pretends that it looked like a call all along.
@ -1106,7 +1106,7 @@ static bool InitFromBailout(JSContext* cx, size_t frameNo, HandleFunction fun,
// but that's just because getelem expects one more item on the stack.
// Note that none of that was pushed, but it's still reflected
// in exprStackSlots.
MOZ_ASSERT(exprStackSlots - expectedDepth == (IsGetElemPC(pc) ? 0 : 1));
MOZ_ASSERT(exprStackSlots - expectedDepth == (IsGetElemOp(op) ? 0 : 1));
} else {
// For fun.apply({}, arguments) the reconstructStackDepth will
// have stackdepth 4, but it could be that we inlined the
@ -1298,7 +1298,7 @@ static bool InitFromBailout(JSContext* cx, size_t frameNo, HandleFunction fun,
// Write out actual arguments (and thisv), copied from unpacked stack of
// BaselineJS frame. Arguments are reversed on the BaselineJS frame's stack
// values.
MOZ_ASSERT(IsIonInlinablePC(pc));
MOZ_ASSERT(IsIonInlinableOp(op));
bool pushedNewTarget = IsConstructorCallPC(pc);
unsigned actualArgc;
Value callee;
@ -1308,7 +1308,7 @@ static bool InitFromBailout(JSContext* cx, size_t frameNo, HandleFunction fun,
if (op == JSOP_FUNAPPLY) {
actualArgc = blFrame->numActualArgs();
} else {
actualArgc = IsSetPropPC(pc);
actualArgc = IsSetPropOp(op);
}
callee = savedCallerArgs[0];
@ -1401,7 +1401,7 @@ static bool InitFromBailout(JSContext* cx, size_t frameNo, HandleFunction fun,
}
// Push return address into ICCall_Scripted stub, immediately after the call.
void* baselineCallReturnAddr = GetStubReturnAddress(cx, pc);
void* baselineCallReturnAddr = GetStubReturnAddress(cx, op);
MOZ_ASSERT(baselineCallReturnAddr);
if (!builder.writePtr(baselineCallReturnAddr, "ReturnAddr")) {
return false;

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

@ -163,17 +163,17 @@ void FreeIonBuilder(IonBuilder* builder);
void LinkIonScript(JSContext* cx, HandleScript calleescript);
uint8_t* LazyLinkTopActivation(JSContext* cx, LazyLinkExitFrameLayout* frame);
inline bool IsIonInlinableGetterOrSetterPC(jsbytecode* pc) {
inline bool IsIonInlinableGetterOrSetterOp(JSOp op) {
// GETPROP, CALLPROP, LENGTH, GETELEM, and JSOP_CALLELEM. (Inlined Getters)
// SETPROP, SETNAME, SETGNAME (Inlined Setters)
return IsGetPropPC(pc) || IsGetElemPC(pc) || IsSetPropPC(pc);
return IsGetPropOp(op) || IsGetElemOp(op) || IsSetPropOp(op);
}
inline bool IsIonInlinablePC(jsbytecode* pc) {
inline bool IsIonInlinableOp(JSOp op) {
// CALL, FUNCALL, FUNAPPLY, EVAL, NEW (Normal Callsites)
// or an inlinable getter or setter.
return (IsCallPC(pc) && !IsSpreadCallPC(pc)) ||
IsIonInlinableGetterOrSetterPC(pc);
return (IsCallOp(op) && !IsSpreadCallOp(op)) ||
IsIonInlinableGetterOrSetterOp(op);
}
inline bool TooManyActualArguments(unsigned nargs) {

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

@ -4025,7 +4025,7 @@ class AutoAccumulateReturns {
IonBuilder::InliningResult IonBuilder::inlineScriptedCall(CallInfo& callInfo,
JSFunction* target) {
MOZ_ASSERT(target->hasScript());
MOZ_ASSERT(IsIonInlinablePC(pc));
MOZ_ASSERT(IsIonInlinableOp(JSOp(*pc)));
MBasicBlock::BackupPoint backup(current);
if (!backup.init(alloc())) {
@ -4896,7 +4896,7 @@ AbortReasonOr<Ok> IonBuilder::inlineCalls(CallInfo& callInfo,
BoolVector& choiceSet,
MGetPropertyCache* maybeCache) {
// Only handle polymorphic inlining.
MOZ_ASSERT(IsIonInlinablePC(pc));
MOZ_ASSERT(IsIonInlinableOp(JSOp(*pc)));
MOZ_ASSERT(choiceSet.length() == targets.length());
MOZ_ASSERT_IF(!maybeCache, targets.length() >= 2);
MOZ_ASSERT_IF(maybeCache, targets.length() >= 1);

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

@ -2035,7 +2035,7 @@ void InlineFrameIterator::findNextFrame() {
size_t i = 1;
for (; i <= remaining && si_.moreFrames(); i++) {
MOZ_ASSERT(IsIonInlinablePC(pc_));
MOZ_ASSERT(IsIonInlinableOp(JSOp(*pc_)));
// Recover the number of actual arguments from the script.
if (JSOp(*pc_) != JSOP_FUNAPPLY) {
@ -2218,14 +2218,15 @@ bool InlineFrameIterator::isConstructing() const {
++parent;
// Inlined Getters and Setters are never constructing.
if (IsIonInlinableGetterOrSetterPC(parent.pc())) {
JSOp parentOp = JSOp(*parent.pc());
if (IsIonInlinableGetterOrSetterOp(parentOp)) {
return false;
}
// In the case of a JS frame, look up the pc from the snapshot.
MOZ_ASSERT(IsCallPC(parent.pc()) && !IsSpreadCallPC(parent.pc()));
MOZ_ASSERT(IsCallOp(parentOp) && !IsSpreadCallOp(parentOp));
return IsConstructorCallPC(parent.pc());
return IsConstructorCallOp(parentOp);
}
return frame_->isConstructing();

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

@ -83,13 +83,14 @@ bool MResumePoint::writeRecoverData(CompactBufferWriter& writer) const {
}
if (reachablePC) {
if (JSOp(*bailPC) == JSOP_FUNCALL) {
JSOp bailOp = JSOp(*bailPC);
if (bailOp == JSOP_FUNCALL) {
// For fun.call(this, ...); the reconstructStackDepth will
// include the this. When inlining that is not included. So the
// exprStackSlots will be one less.
MOZ_ASSERT(stackDepth - exprStack <= 1);
} else if (JSOp(*bailPC) != JSOP_FUNAPPLY &&
!IsIonInlinableGetterOrSetterPC(bailPC)) {
} else if (bailOp != JSOP_FUNAPPLY &&
!IsIonInlinableGetterOrSetterOp(bailOp)) {
// For fun.apply({}, arguments) the reconstructStackDepth will
// have stackdepth 4, but it could be that we inlined the
// funapply. In that case exprStackSlots, will have the real

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

@ -543,11 +543,12 @@ inline bool IsCheckSloppyOp(JSOp op) {
inline bool IsAtomOp(JSOp op) { return JOF_OPTYPE(op) == JOF_ATOM; }
inline bool IsGetPropPC(jsbytecode* pc) {
JSOp op = JSOp(*pc);
inline bool IsGetPropOp(JSOp op) {
return op == JSOP_LENGTH || op == JSOP_GETPROP || op == JSOP_CALLPROP;
}
inline bool IsGetPropPC(const jsbytecode* pc) { return IsGetPropOp(JSOp(*pc)); }
inline bool IsHiddenInitOp(JSOp op) {
return op == JSOP_INITHIDDENPROP || op == JSOP_INITHIDDENELEM ||
op == JSOP_INITHIDDENPROP_GETTER || op == JSOP_INITHIDDENELEM_GETTER ||
@ -560,24 +561,29 @@ inline bool IsStrictSetPC(jsbytecode* pc) {
op == JSOP_STRICTSETGNAME || op == JSOP_STRICTSETELEM;
}
inline bool IsSetPropPC(jsbytecode* pc) {
JSOp op = JSOp(*pc);
inline bool IsSetPropOp(JSOp op) {
return op == JSOP_SETPROP || op == JSOP_STRICTSETPROP || op == JSOP_SETNAME ||
op == JSOP_STRICTSETNAME || op == JSOP_SETGNAME ||
op == JSOP_STRICTSETGNAME;
}
inline bool IsGetElemPC(jsbytecode* pc) {
JSOp op = JSOp(*pc);
inline bool IsSetPropPC(const jsbytecode* pc) { return IsSetPropOp(JSOp(*pc)); }
inline bool IsGetElemOp(JSOp op) {
return op == JSOP_GETELEM || op == JSOP_CALLELEM;
}
inline bool IsSetElemPC(jsbytecode* pc) {
JSOp op = JSOp(*pc);
inline bool IsGetElemPC(const jsbytecode* pc) { return IsGetElemOp(JSOp(*pc)); }
inline bool IsSetElemOp(JSOp op) {
return op == JSOP_SETELEM || op == JSOP_STRICTSETELEM;
}
inline bool IsElemPC(jsbytecode* pc) { return CodeSpec[*pc].format & JOF_ELEM; }
inline bool IsSetElemPC(const jsbytecode* pc) { return IsSetElemOp(JSOp(*pc)); }
inline bool IsElemPC(const jsbytecode* pc) {
return CodeSpec[*pc].format & JOF_ELEM;
}
inline bool IsCallOp(JSOp op) { return CodeSpec[op].format & JOF_INVOKE; }
@ -596,13 +602,16 @@ inline bool IsConstructorCallPC(const jsbytecode* pc) {
return IsConstructorCallOp(JSOp(*pc));
}
inline bool IsSpreadCallPC(jsbytecode* pc) {
JSOp op = JSOp(*pc);
inline bool IsSpreadCallOp(JSOp op) {
return op == JSOP_SPREADCALL || op == JSOP_SPREADNEW ||
op == JSOP_SPREADSUPERCALL || op == JSOP_SPREADEVAL ||
op == JSOP_STRICTSPREADEVAL;
}
inline bool IsSpreadCallPC(const jsbytecode* pc) {
return IsSpreadCallOp(JSOp(*pc));
}
static inline int32_t GetBytecodeInteger(jsbytecode* pc) {
switch (JSOp(*pc)) {
case JSOP_ZERO: