Bug 1168753 - SharedStubs: Simplification to push BaselineFrame* in stubs, r=jandem

This commit is contained in:
Hannes Verschore 2015-06-08 16:38:55 +02:00
parent 831004c9ab
commit 3ece3a1cb6
3 changed files with 74 additions and 52 deletions

View File

@ -183,8 +183,8 @@ PrepareOsrTempData(JSContext* cx, ICWarmUpCounter_Fallback* stub, BaselineFrame*
}
static bool
DoWarmUpCounterFallback(JSContext* cx, ICWarmUpCounter_Fallback* stub, BaselineFrame* frame,
IonOsrTempData** infoPtr)
DoWarmUpCounterFallback(JSContext* cx, BaselineFrame* frame, ICWarmUpCounter_Fallback* stub,
IonOsrTempData** infoPtr)
{
MOZ_ASSERT(infoPtr);
*infoPtr = nullptr;
@ -244,8 +244,8 @@ DoWarmUpCounterFallback(JSContext* cx, ICWarmUpCounter_Fallback* stub, BaselineF
return true;
}
typedef bool (*DoWarmUpCounterFallbackFn)(JSContext*, ICWarmUpCounter_Fallback*, BaselineFrame* frame,
IonOsrTempData** infoPtr);
typedef bool (*DoWarmUpCounterFallbackFn)(JSContext*, BaselineFrame*,
ICWarmUpCounter_Fallback*, IonOsrTempData** infoPtr);
static const VMFunction DoWarmUpCounterFallbackInfo =
FunctionInfo<DoWarmUpCounterFallbackFn>(DoWarmUpCounterFallback);
@ -254,10 +254,6 @@ ICWarmUpCounter_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
{
MOZ_ASSERT(engine_ == Engine::Baseline);
// enterStubFrame is going to clobber the BaselineFrameReg, save it in R0.scratchReg()
// first.
masm.movePtr(BaselineFrameReg, R0.scratchReg());
// Push a stub frame so that we can perform a non-tail call.
enterStubFrame(masm, R1.scratchReg());
@ -268,13 +264,11 @@ ICWarmUpCounter_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.subPtr(Imm32(sizeof(void*)), BaselineStackReg);
masm.push(BaselineStackReg);
// Push JitFrameLayout pointer.
masm.loadBaselineFramePtr(R0.scratchReg(), R0.scratchReg());
masm.push(R0.scratchReg());
// Push stub pointer.
masm.push(ICStubReg);
pushFramePtr(masm, R0.scratchReg());
if (!callVM(DoWarmUpCounterFallbackInfo, masm))
return false;
@ -515,7 +509,7 @@ ICTypeMonitor_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoTypeMonitorFallbackInfo, masm);
}
@ -975,7 +969,7 @@ ICNewArray_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.push(R0.scratchReg()); // length
masm.push(ICStubReg); // stub.
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoNewArrayInfo, masm);
}
@ -1074,7 +1068,7 @@ ICNewObject_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
EmitRestoreTailCallReg(masm);
masm.push(ICStubReg); // stub.
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoNewObjectInfo, masm);
}
@ -1299,7 +1293,7 @@ ICCompare_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.pushValue(R1);
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoCompareFallbackInfo, masm);
}
@ -1641,7 +1635,7 @@ ICToBool_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
// Push arguments.
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(fun, masm);
}
@ -2068,7 +2062,7 @@ ICBinaryArith_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.pushValue(R1);
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoBinaryArithFallbackInfo, masm);
}
@ -2478,7 +2472,7 @@ ICUnaryArith_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
// Push arguments.
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoUnaryArithFallbackInfo, masm);
}
@ -3563,7 +3557,7 @@ ICGetElem_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.pushValue(R1);
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoGetElemFallbackInfo, masm);
}
@ -4770,7 +4764,7 @@ ICSetElem_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.push(R0.scratchReg());
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoSetElemFallbackInfo, masm);
}
@ -5512,7 +5506,7 @@ ICIn_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.pushValue(R1);
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoInFallbackInfo, masm);
}
@ -6098,7 +6092,7 @@ ICGetName_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.push(R0.scratchReg());
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoGetNameFallbackInfo, masm);
}
@ -6214,7 +6208,7 @@ ICBindName_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.push(R0.scratchReg());
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoBindNameFallbackInfo, masm);
}
@ -6273,7 +6267,7 @@ ICGetIntrinsic_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
EmitRestoreTailCallReg(masm);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoGetIntrinsicFallbackInfo, masm);
}
@ -7090,7 +7084,7 @@ ICGetProp_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
// Push arguments.
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
if (!tailCallVM(DoGetPropFallbackInfo, masm))
return false;
@ -7101,6 +7095,7 @@ ICGetProp_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
// Even though the fallback frame doesn't enter a stub frame, the CallScripted
// frame that we are emulating does. Again, we lie.
inStubFrame_ = true;
#ifdef DEBUG
entersStubFrame_ = true;
#endif
@ -7594,6 +7589,7 @@ ICGetProp_CallScripted::Compiler::generateStubCode(MacroAssembler& masm)
// Leave stub frame and go to next stub.
masm.bind(&failureLeaveStubFrame);
inStubFrame_ = true;
leaveStubFrame(masm, false);
// Failure case - jump to next stub
@ -7999,8 +7995,7 @@ ICGetProp_Generic::Compiler::generateStubCode(MacroAssembler& masm)
// Push arguments.
masm.pushValue(R0);
masm.push(ICStubReg);
masm.loadPtr(Address(BaselineFrameReg, 0), R0.scratchReg());
masm.pushBaselineFramePtr(R0.scratchReg(), R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
if(!callVM(DoGetPropGenericInfo, masm))
return false;
@ -8545,7 +8540,7 @@ ICSetProp_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.pushValue(R1);
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
if (!tailCallVM(DoSetPropFallbackInfo, masm))
return false;
@ -8556,6 +8551,7 @@ ICSetProp_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
// Even though the fallback frame doesn't enter a stub frame, the CallScripted
// frame that we are emulating does. Again, we lie.
inStubFrame_ = true;
#ifdef DEBUG
entersStubFrame_ = true;
#endif
@ -9123,6 +9119,7 @@ ICSetProp_CallScripted::Compiler::generateStubCode(MacroAssembler& masm)
// Leave stub frame and go to next stub.
masm.bind(&failureLeaveStubFrame);
inStubFrame_ = true;
leaveStubFrame(masm, false);
// Unstow R0 and R1
@ -10205,9 +10202,6 @@ ICCall_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
MOZ_ASSERT(R0 == JSReturnOperand);
// Push a stub frame so that we can perform a non-tail call.
enterStubFrame(masm, R1.scratchReg());
// Values are on the stack left-to-right. Calling convention wants them
// right-to-left so duplicate them on the stack in reverse order.
// |this| and callee are pushed last.
@ -10215,6 +10209,9 @@ ICCall_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
AllocatableGeneralRegisterSet regs(availableGeneralRegs(0));
if (MOZ_UNLIKELY(isSpread_)) {
// Push a stub frame so that we can perform a non-tail call.
enterStubFrame(masm, R1.scratchReg());
// Use BaselineFrameReg instead of BaselineStackReg, because
// BaselineFrameReg and BaselineStackReg hold the same value just after
// calling enterStubFrame.
@ -10236,8 +10233,7 @@ ICCall_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.push(BaselineStackReg);
masm.push(ICStubReg);
masm.loadPtr(Address(BaselineFrameReg, 0), R0.scratchReg());
masm.pushBaselineFramePtr(R0.scratchReg(), R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
if (!callVM(DoSpreadCallFallbackInfo, masm))
return false;
@ -10250,6 +10246,9 @@ ICCall_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
return true;
}
// Push a stub frame so that we can perform a non-tail call.
enterStubFrame(masm, R1.scratchReg());
regs.take(R0.scratchReg()); // argc.
pushCallArguments(masm, regs, R0.scratchReg(), /* isJitCall = */ false, isConstructing_);
@ -10258,9 +10257,7 @@ ICCall_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.push(R0.scratchReg());
masm.push(ICStubReg);
// Load previous frame pointer, push BaselineFrame*.
masm.loadPtr(Address(BaselineFrameReg, 0), R0.scratchReg());
masm.pushBaselineFramePtr(R0.scratchReg(), R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
if (!callVM(DoCallFallbackInfo, masm))
return false;
@ -10273,6 +10270,9 @@ ICCall_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
// reconstructed baseline stack points here.
returnOffset_ = masm.currentOffset();
// Here we are again in a stub frame. Marking as so.
inStubFrame_ = true;
// Load passed-in ThisV into R1 just in case it's needed. Need to do this before
// we leave the stub frame since that info will be lost.
// Current stack: [...., ThisV, ActualArgc, CalleeToken, Descriptor ]
@ -10585,6 +10585,7 @@ ICCallScriptedCompiler::generateStubCode(MacroAssembler& masm)
// Leave stub frame and restore argc for the next stub.
masm.bind(&failureLeaveStubFrame);
inStubFrame_ = true;
leaveStubFrame(masm, false);
if (argcReg != R0.scratchReg())
masm.mov(argcReg, R0.scratchReg());
@ -11407,7 +11408,7 @@ ICIteratorNew_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoIteratorNewFallbackInfo, masm);
}
@ -11463,7 +11464,7 @@ ICIteratorMore_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.unboxObject(R0, R0.scratchReg());
masm.push(R0.scratchReg());
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoIteratorMoreFallbackInfo, masm);
}
@ -11642,7 +11643,7 @@ ICInstanceOf_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.pushValue(R1);
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoInstanceOfFallbackInfo, masm);
}
@ -11765,7 +11766,7 @@ ICTypeOf_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
masm.pushValue(R0);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoTypeOfFallbackInfo, masm);
}
@ -11863,15 +11864,13 @@ ICRetSub_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
AllocatableGeneralRegisterSet regs(availableGeneralRegs(0));
regs.take(R1);
regs.takeUnchecked(ICTailCallReg);
Register scratch = regs.getAny();
Register frame = regs.takeAny();
masm.movePtr(BaselineFrameReg, frame);
enterStubFrame(masm, regs.getAny());
enterStubFrame(masm, scratch);
masm.pushValue(R1);
masm.push(ICStubReg);
masm.pushBaselineFramePtr(frame, frame);
pushFramePtr(masm, scratch);
if (!callVM(DoRetSubFallbackInfo, masm))
return false;
@ -12592,8 +12591,8 @@ ICGetProp_DOMProxyShadowed::Clone(JSContext* cx, ICStubSpace* space, ICStub* fir
// Rest_Fallback
//
static bool DoRestFallback(JSContext* cx, ICRest_Fallback* stub,
BaselineFrame* frame, MutableHandleValue res)
static bool DoRestFallback(JSContext* cx, BaselineFrame* frame, ICRest_Fallback* stub,
MutableHandleValue res)
{
unsigned numFormals = frame->numFormalArgs() - 1;
unsigned numActuals = frame->numActualArgs();
@ -12608,7 +12607,7 @@ static bool DoRestFallback(JSContext* cx, ICRest_Fallback* stub,
return true;
}
typedef bool (*DoRestFallbackFn)(JSContext*, ICRest_Fallback*, BaselineFrame*,
typedef bool (*DoRestFallbackFn)(JSContext*, BaselineFrame*, ICRest_Fallback*,
MutableHandleValue);
static const VMFunction DoRestFallbackInfo =
FunctionInfo<DoRestFallbackFn>(DoRestFallback, TailCall);
@ -12620,8 +12619,8 @@ ICRest_Fallback::Compiler::generateStubCode(MacroAssembler& masm)
EmitRestoreTailCallReg(masm);
masm.pushBaselineFramePtr(BaselineFrameReg, R0.scratchReg());
masm.push(ICStubReg);
pushFramePtr(masm, R0.scratchReg());
return tailCallVM(DoRestFallbackInfo, masm);
}

View File

@ -682,6 +682,7 @@ ICStubCompiler::getStubCode()
return nullptr;
MOZ_ASSERT(entersStubFrame_ == ICStub::CanMakeCalls(kind));
MOZ_ASSERT(!inStubFrame_);
#ifdef JS_ION_PERF
writePerfSpewerJitCodeProfile(newStubCode, "BaselineIC");
@ -706,6 +707,8 @@ ICStubCompiler::tailCallVM(const VMFunction& fun, MacroAssembler& masm)
bool
ICStubCompiler::callVM(const VMFunction& fun, MacroAssembler& masm)
{
MOZ_ASSERT(inStubFrame_);
JitCode* code = cx->runtime()->jitRuntime()->getVMWrapper(fun);
if (!code)
return false;
@ -730,6 +733,10 @@ void
ICStubCompiler::enterStubFrame(MacroAssembler& masm, Register scratch)
{
EmitEnterStubFrame(masm, scratch);
MOZ_ASSERT(!inStubFrame_);
inStubFrame_ = true;
#ifdef DEBUG
entersStubFrame_ = true;
#endif
@ -738,10 +745,22 @@ ICStubCompiler::enterStubFrame(MacroAssembler& masm, Register scratch)
void
ICStubCompiler::leaveStubFrame(MacroAssembler& masm, bool calledIntoIon)
{
MOZ_ASSERT(entersStubFrame_);
MOZ_ASSERT(entersStubFrame_ && inStubFrame_);
inStubFrame_ = false;
EmitLeaveStubFrame(masm, calledIntoIon);
}
void
ICStubCompiler::pushFramePtr(MacroAssembler& masm, Register scratch)
{
if (inStubFrame_) {
masm.loadPtr(Address(BaselineFrameReg, 0), scratch);
masm.pushBaselineFramePtr(scratch, scratch);
} else {
masm.pushBaselineFramePtr(BaselineFrameReg, scratch);
}
}
bool
ICStubCompiler::emitPostWriteBarrierSlot(MacroAssembler& masm, Register obj, ValueOperand val,
Register scratch, LiveGeneralRegisterSet saveRegs)

View File

@ -959,6 +959,7 @@ class ICStubCompiler
JSContext* cx;
ICStub::Kind kind;
Engine engine_;
bool inStubFrame_;
#ifdef DEBUG
bool entersStubFrame_;
@ -977,12 +978,15 @@ class ICStubCompiler
JitCode* getStubCode();
ICStubCompiler(JSContext* cx, ICStub::Kind kind, Engine engine)
: suppressGC(cx), cx(cx), kind(kind), engine_(engine)
: suppressGC(cx), cx(cx), kind(kind), engine_(engine), inStubFrame_(false)
#ifdef DEBUG
, entersStubFrame_(false)
#endif
{}
// Pushes the frame ptr.
void pushFramePtr(MacroAssembler& masm, Register scratch);
// Emits a tail call to a VMFunction wrapper.
bool tailCallVM(const VMFunction& fun, MacroAssembler& masm);