Commit edb38fb6 authored by Iain Ireland's avatar Iain Ireland
Browse files

Bug 1531841: Make callVM/tailCallVM infallible in CacheIR compilers r=mgaudet

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

--HG--
extra : moz-landing-system : lando
parent 8fdb652c
......@@ -38,8 +38,8 @@ class MOZ_RAII BaselineCacheIRCompiler : public CacheIRCompiler {
bool makesGCCalls_;
BaselineCacheIRStubKind kind_;
MOZ_MUST_USE bool callVM(MacroAssembler& masm, const VMFunction& fun);
MOZ_MUST_USE bool tailCallVM(MacroAssembler& masm, const VMFunction& fun);
void callVM(MacroAssembler& masm, const VMFunction& fun);
void tailCallVM(MacroAssembler& masm, const VMFunction& fun);
MOZ_MUST_USE bool callTypeUpdateIC(Register obj, ValueOperand val,
Register scratch,
......@@ -141,7 +141,7 @@ class MOZ_RAII AutoStubFrame {
#endif
};
bool BaselineCacheIRCompiler::callVM(MacroAssembler& masm,
void BaselineCacheIRCompiler::callVM(MacroAssembler& masm,
const VMFunction& fun) {
MOZ_ASSERT(inStubFrame_);
......@@ -149,10 +149,9 @@ bool BaselineCacheIRCompiler::callVM(MacroAssembler& masm,
MOZ_ASSERT(fun.expectTailCall == NonTailCall);
EmitBaselineCallVM(code, masm);
return true;
}
bool BaselineCacheIRCompiler::tailCallVM(MacroAssembler& masm,
void BaselineCacheIRCompiler::tailCallVM(MacroAssembler& masm,
const VMFunction& fun) {
MOZ_ASSERT(!inStubFrame_);
......@@ -161,7 +160,6 @@ bool BaselineCacheIRCompiler::tailCallVM(MacroAssembler& masm,
size_t argSize = fun.explicitStackSlots() * sizeof(void*);
EmitBaselineTailCallVM(code, masm, argSize);
return true;
}
static size_t GetEnteredOffset(BaselineCacheIRStubKind kind) {
......@@ -604,9 +602,7 @@ bool BaselineCacheIRCompiler::emitCallNativeGetterResult() {
masm.Push(obj);
masm.Push(scratch);
if (!callVM(masm, CallNativeGetterInfo)) {
return false;
}
callVM(masm, CallNativeGetterInfo);
stubFrame.leave(masm);
return true;
......@@ -630,9 +626,7 @@ bool BaselineCacheIRCompiler::emitCallProxyGetResult() {
masm.Push(scratch);
masm.Push(obj);
if (!callVM(masm, ProxyGetPropertyInfo)) {
return false;
}
callVM(masm, ProxyGetPropertyInfo);
stubFrame.leave(masm);
return true;
......@@ -653,9 +647,7 @@ bool BaselineCacheIRCompiler::emitCallProxyGetByValueResult() {
masm.Push(idVal);
masm.Push(obj);
if (!callVM(masm, ProxyGetPropertyByValueInfo)) {
return false;
}
callVM(masm, ProxyGetPropertyByValueInfo);
stubFrame.leave(masm);
return true;
......@@ -678,13 +670,9 @@ bool BaselineCacheIRCompiler::emitCallProxyHasPropResult() {
masm.Push(obj);
if (hasOwn) {
if (!callVM(masm, ProxyHasOwnInfo)) {
return false;
}
callVM(masm, ProxyHasOwnInfo);
} else {
if (!callVM(masm, ProxyHasInfo)) {
return false;
}
callVM(masm, ProxyHasInfo);
}
stubFrame.leave(masm);
......@@ -707,9 +695,7 @@ bool BaselineCacheIRCompiler::emitCallNativeGetElementResult() {
masm.Push(TypedOrValueRegister(MIRType::Object, AnyRegister(obj)));
masm.Push(obj);
if (!callVM(masm, NativeGetElementInfo)) {
return false;
}
callVM(masm, NativeGetElementInfo);
stubFrame.leave(masm);
return true;
......@@ -889,9 +875,7 @@ bool BaselineCacheIRCompiler::emitCallStringSplitResult() {
masm.Push(sep);
masm.Push(str);
if (!callVM(masm, StringSplitHelperInfo)) {
return false;
}
callVM(masm, StringSplitHelperInfo);
stubFrame.leave(masm);
return true;
......@@ -925,11 +909,8 @@ bool BaselineCacheIRCompiler::emitCompareStringResult() {
masm.Push(right);
masm.Push(left);
if (!callVM(masm, (op == JSOP_EQ || op == JSOP_STRICTEQ)
? StringsEqualInfo
: StringsNotEqualInfo)) {
return false;
}
callVM(masm, (op == JSOP_EQ || op == JSOP_STRICTEQ) ? StringsEqualInfo
: StringsNotEqualInfo);
stubFrame.leave(masm);
masm.mov(ReturnReg, scratch);
}
......@@ -985,9 +966,7 @@ bool BaselineCacheIRCompiler::callTypeUpdateIC(
masm.loadPtr(Address(BaselineFrameReg, 0), scratch);
masm.pushBaselineFramePtr(scratch, scratch);
if (!callVM(masm, DoTypeUpdateFallbackInfo)) {
return false;
}
callVM(masm, DoTypeUpdateFallbackInfo);
masm.PopRegsInMask(saveRegs);
......@@ -1680,9 +1659,7 @@ bool BaselineCacheIRCompiler::emitCallNativeSetter() {
masm.Push(obj);
masm.Push(scratch);
if (!callVM(masm, CallNativeSetterInfo)) {
return false;
}
callVM(masm, CallNativeSetterInfo);
stubFrame.leave(masm);
return true;
......@@ -1784,9 +1761,7 @@ bool BaselineCacheIRCompiler::emitCallSetArrayLength() {
masm.Push(val);
masm.Push(obj);
if (!callVM(masm, SetArrayLengthInfo)) {
return false;
}
callVM(masm, SetArrayLengthInfo);
stubFrame.leave(masm);
return true;
......@@ -1814,9 +1789,7 @@ bool BaselineCacheIRCompiler::emitCallProxySet() {
masm.Push(scratch);
masm.Push(obj);
if (!callVM(masm, ProxySetPropertyInfo)) {
return false;
}
callVM(masm, ProxySetPropertyInfo);
stubFrame.leave(masm);
return true;
......@@ -1849,9 +1822,7 @@ bool BaselineCacheIRCompiler::emitCallProxySetByValue() {
masm.Push(idVal);
masm.Push(obj);
if (!callVM(masm, ProxySetPropertyByValueInfo)) {
return false;
}
callVM(masm, ProxySetPropertyByValueInfo);
stubFrame.leave(masm);
return true;
......@@ -1875,9 +1846,8 @@ bool BaselineCacheIRCompiler::emitCallAddOrUpdateSparseElementHelper() {
masm.Push(id);
masm.Push(obj);
if (!callVM(masm, AddOrUpdateSparseElementHelperInfo)) {
return false;
}
callVM(masm, AddOrUpdateSparseElementHelperInfo);
stubFrame.leave(masm);
return true;
}
......@@ -1896,9 +1866,8 @@ bool BaselineCacheIRCompiler::emitCallGetSparseElementResult() {
masm.Push(id);
masm.Push(obj);
if (!callVM(masm, GetSparseElementHelperInfo)) {
return false;
}
callVM(masm, GetSparseElementHelperInfo);
stubFrame.leave(masm);
return true;
}
......@@ -1931,9 +1900,7 @@ bool BaselineCacheIRCompiler::emitMegamorphicSetElement() {
masm.Push(idVal);
masm.Push(obj);
if (!callVM(masm, SetObjectElementInfo)) {
return false;
}
callVM(masm, SetObjectElementInfo);
stubFrame.leave(masm);
return true;
......@@ -2398,9 +2365,7 @@ bool BaselineCacheIRCompiler::emitCallStringConcatResult() {
masm.push(rhs);
masm.push(lhs);
if (!callVM(masm, ConcatStringsInfo)) {
return false;
}
callVM(masm, ConcatStringsInfo);
masm.tagValue(JSVAL_TYPE_STRING, ReturnReg, output.valueReg());
......@@ -2423,9 +2388,7 @@ bool BaselineCacheIRCompiler::emitCallStringObjectConcatResult() {
masm.pushValue(rhs);
masm.pushValue(lhs);
if (!tailCallVM(masm, DoConcatStringObjectInfo)) {
return false;
}
tailCallVM(masm, DoConcatStringObjectInfo);
return true;
}
......@@ -103,7 +103,7 @@ class MOZ_RAII IonCacheIRCompiler : public CacheIRCompiler {
}
void prepareVMCall(MacroAssembler& masm, const AutoSaveLiveRegisters&);
MOZ_MUST_USE bool callVM(MacroAssembler& masm, const VMFunction& fun);
void callVM(MacroAssembler& masm, const VMFunction& fun);
MOZ_MUST_USE bool emitAddAndStoreSlotShared(CacheOp op);
......@@ -324,7 +324,7 @@ void IonCacheIRCompiler::prepareVMCall(MacroAssembler& masm,
#endif
}
bool IonCacheIRCompiler::callVM(MacroAssembler& masm, const VMFunction& fun) {
void IonCacheIRCompiler::callVM(MacroAssembler& masm, const VMFunction& fun) {
MOZ_ASSERT(calledPrepareVMCall_);
TrampolinePtr code = cx_->runtime()->jitRuntime()->getVMWrapper(fun);
......@@ -336,13 +336,12 @@ bool IonCacheIRCompiler::callVM(MacroAssembler& masm, const VMFunction& fun) {
masm.callJit(code);
// Remove rest of the frame left on the stack. We remove the return address
// which is implicitly poped when returning.
// which is implicitly popped when returning.
int framePop = sizeof(ExitFrameLayout) - sizeof(void*);
// Pop arguments from framePushed.
masm.implicitPop(frameSize + framePop);
masm.freeStack(IonICCallFrameLayout::Size());
return true;
}
bool IonCacheIRCompiler::init() {
......@@ -1146,9 +1145,7 @@ bool IonCacheIRCompiler::emitCallProxyGetByValueResult() {
masm.Push(idVal);
masm.Push(obj);
if (!callVM(masm, ProxyGetPropertyByValueInfo)) {
return false;
}
callVM(masm, ProxyGetPropertyByValueInfo);
masm.storeCallResultValue(output);
return true;
......@@ -1171,13 +1168,9 @@ bool IonCacheIRCompiler::emitCallProxyHasPropResult() {
masm.Push(obj);
if (hasOwn) {
if (!callVM(masm, ProxyHasOwnInfo)) {
return false;
}
callVM(masm, ProxyHasOwnInfo);
} else {
if (!callVM(masm, ProxyHasInfo)) {
return false;
}
callVM(masm, ProxyHasInfo);
}
masm.storeCallResultValue(output);
......@@ -1200,9 +1193,7 @@ bool IonCacheIRCompiler::emitCallNativeGetElementResult() {
masm.Push(TypedOrValueRegister(MIRType::Object, AnyRegister(obj)));
masm.Push(obj);
if (!callVM(masm, NativeGetElementInfo)) {
return false;
}
callVM(masm, NativeGetElementInfo);
masm.storeCallResultValue(output);
return true;
......@@ -1301,9 +1292,7 @@ bool IonCacheIRCompiler::emitCallStringSplitResult() {
masm.Push(ImmGCPtr(group));
masm.Push(Imm32(INT32_MAX));
if (!callVM(masm, StringSplitHelperInfo)) {
return false;
}
callVM(masm, StringSplitHelperInfo);
masm.storeCallResultValue(output);
return true;
......@@ -1331,11 +1320,8 @@ bool IonCacheIRCompiler::emitCompareStringResult() {
masm.Push(right);
masm.Push(left);
if (!callVM(masm, (op == JSOP_EQ || op == JSOP_STRICTEQ)
? StringsEqualInfo
: StringsNotEqualInfo)) {
return false;
}
callVM(masm, (op == JSOP_EQ || op == JSOP_STRICTEQ) ? StringsEqualInfo
: StringsNotEqualInfo);
masm.storeCallBoolResult(output.typedReg().gpr());
masm.bind(&done);
......@@ -2203,7 +2189,8 @@ bool IonCacheIRCompiler::emitCallSetArrayLength() {
masm.Push(val);
masm.Push(obj);
return callVM(masm, SetArrayLengthInfo);
callVM(masm, SetArrayLengthInfo);
return true;
}
bool IonCacheIRCompiler::emitCallProxySet() {
......@@ -2226,7 +2213,8 @@ bool IonCacheIRCompiler::emitCallProxySet() {
masm.Push(id, scratch);
masm.Push(obj);
return callVM(masm, ProxySetPropertyInfo);
callVM(masm, ProxySetPropertyInfo);
return true;
}
bool IonCacheIRCompiler::emitCallProxySetByValue() {
......@@ -2248,7 +2236,8 @@ bool IonCacheIRCompiler::emitCallProxySetByValue() {
masm.Push(idVal);
masm.Push(obj);
return callVM(masm, ProxySetPropertyByValueInfo);
callVM(masm, ProxySetPropertyByValueInfo);
return true;
}
bool IonCacheIRCompiler::emitCallAddOrUpdateSparseElementHelper() {
......@@ -2268,7 +2257,8 @@ bool IonCacheIRCompiler::emitCallAddOrUpdateSparseElementHelper() {
masm.Push(id);
masm.Push(obj);
return callVM(masm, AddOrUpdateSparseElementHelperInfo);
callVM(masm, AddOrUpdateSparseElementHelperInfo);
return true;
}
bool IonCacheIRCompiler::emitCallGetSparseElementResult() {
......@@ -2284,9 +2274,7 @@ bool IonCacheIRCompiler::emitCallGetSparseElementResult() {
masm.Push(id);
masm.Push(obj);
if (!callVM(masm, GetSparseElementHelperInfo)) {
return false;
}
callVM(masm, GetSparseElementHelperInfo);
masm.storeCallResultValue(output);
return true;
......@@ -2312,7 +2300,8 @@ bool IonCacheIRCompiler::emitMegamorphicSetElement() {
masm.Push(idVal);
masm.Push(obj);
return callVM(masm, SetObjectElementInfo);
callVM(masm, SetObjectElementInfo);
return true;
}
bool IonCacheIRCompiler::emitLoadTypedObjectResult() {
......@@ -2590,9 +2579,7 @@ bool IonCacheIRCompiler::emitCallStringConcatResult() {
masm.Push(rhs);
masm.Push(lhs);
if (!callVM(masm, ConcatStringsInfo)) {
return false;
}
callVM(masm, ConcatStringsInfo);
masm.tagValue(JSVAL_TYPE_STRING, ReturnReg, output.valueReg());
return true;
......@@ -2618,9 +2605,7 @@ bool IonCacheIRCompiler::emitCallStringObjectConcatResult() {
masm.Push(rhs);
masm.Push(lhs);
if (!callVM(masm, DoIonConcatStringObjectInfo)) {
return false;
}
callVM(masm, DoIonConcatStringObjectInfo);
masm.storeCallResultValue(output);
return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment