Bug 1288944 - Baldr: mark all calls as preserving the TLS reg (r=jolesen)

MozReview-Commit-ID: 3WcKCPGRaFv

--HG--
extra : rebase_source : 96e8382d137c1a65570d97e0ba4401c6c1dfb45c
This commit is contained in:
Luke Wagner 2016-08-04 11:44:35 -05:00
Родитель c874b985e3
Коммит 0a6927911a
4 изменённых файлов: 20 добавлений и 37 удалений

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

@ -971,8 +971,8 @@ class FunctionCompiler
}
private:
bool callPrivate(MWasmCall::Callee callee, MWasmCall::PreservesTlsReg preservesTlsReg,
const CallCompileState& call, ExprType ret, MDefinition** def)
bool callPrivate(MWasmCall::Callee callee, const CallCompileState& call, ExprType ret,
MDefinition** def)
{
MOZ_ASSERT(!inDeadCode());
@ -984,9 +984,8 @@ class FunctionCompiler
case MWasmCall::Callee::Builtin: kind = CallSiteDesc::Register; break;
}
MWasmCall* ins =
MWasmCall::New(alloc(), CallSiteDesc(call.lineOrBytecode_, kind), callee, call.regArgs_,
ToMIRType(ret), call.spIncrement_, preservesTlsReg);
auto* ins = MWasmCall::New(alloc(), CallSiteDesc(call.lineOrBytecode_, kind), callee,
call.regArgs_, ToMIRType(ret), call.spIncrement_);
if (!ins)
return false;
@ -1005,7 +1004,7 @@ class FunctionCompiler
}
auto callee = MWasmCall::Callee::internal(funcIndex);
return callPrivate(callee, MWasmCall::PreservesTlsReg::True, call, sig.ret(), def);
return callPrivate(callee, call, sig.ret(), def);
}
bool funcPtrCall(uint32_t sigIndex, uint32_t length, uint32_t globalDataOffset,
@ -1033,8 +1032,7 @@ class FunctionCompiler
callee = MWasmCall::Callee(ptrFun, mg_.sigs[sigIndex].id);
}
return callPrivate(callee, MWasmCall::PreservesTlsReg::True, call,
mg_.sigs[sigIndex].ret(), def);
return callPrivate(callee, call, mg_.sigs[sigIndex].ret(), def);
}
bool callImport(unsigned globalDataOffset, const CallCompileState& call, ExprType ret,
@ -1048,7 +1046,7 @@ class FunctionCompiler
MOZ_ASSERT(call.tlsStackOffset_ != UINT32_MAX);
auto callee = MWasmCall::Callee::import(globalDataOffset, call.tlsStackOffset_);
return callPrivate(callee, MWasmCall::PreservesTlsReg::False, call, ret, def);
return callPrivate(callee, call, ret, def);
}
bool builtinCall(SymbolicAddress builtin, const CallCompileState& call, ValType type,
@ -1059,8 +1057,7 @@ class FunctionCompiler
return true;
}
return callPrivate(MWasmCall::Callee(builtin), MWasmCall::PreservesTlsReg::False,
call, ToExprType(type), def);
return callPrivate(MWasmCall::Callee(builtin), call, ToExprType(type), def);
}
/*********************************************** Control flow generation */

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

@ -5379,10 +5379,9 @@ MAsmJSUnsignedToFloat32::foldsTo(TempAllocator& alloc)
MWasmCall*
MWasmCall::New(TempAllocator& alloc, const wasm::CallSiteDesc& desc, Callee callee,
const Args& args, MIRType resultType, size_t spIncrement,
PreservesTlsReg preservesTlsReg)
const Args& args, MIRType resultType, size_t spIncrement)
{
MWasmCall* call = new(alloc) MWasmCall(desc, callee, spIncrement, preservesTlsReg);
MWasmCall* call = new(alloc) MWasmCall(desc, callee, spIncrement);
call->setResultType(resultType);
if (!call->argRegs_.init(alloc, args.length()))

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

@ -13586,24 +13586,16 @@ class MWasmCall final
}
};
enum PreservesTlsReg {
False = false,
True = true
};
private:
wasm::CallSiteDesc desc_;
Callee callee_;
FixedList<AnyRegister> argRegs_;
size_t spIncrement_;
bool preservesTlsReg_;
MWasmCall(const wasm::CallSiteDesc& desc, Callee callee, size_t spIncrement,
PreservesTlsReg preservesTlsReg)
: desc_(desc)
, callee_(callee)
, spIncrement_(spIncrement)
, preservesTlsReg_(bool(preservesTlsReg))
MWasmCall(const wasm::CallSiteDesc& desc, Callee callee, size_t spIncrement)
: desc_(desc),
callee_(callee),
spIncrement_(spIncrement)
{ }
public:
@ -13617,8 +13609,7 @@ class MWasmCall final
typedef Vector<Arg, 8, SystemAllocPolicy> Args;
static MWasmCall* New(TempAllocator& alloc, const wasm::CallSiteDesc& desc, Callee callee,
const Args& args, MIRType resultType, size_t spIncrement,
PreservesTlsReg preservesTlsReg);
const Args& args, MIRType resultType, size_t spIncrement);
size_t numArgs() const {
return argRegs_.length();
@ -13642,11 +13633,6 @@ class MWasmCall final
return spIncrement_;
}
// Does this call preserve the value of the TLS pointer register?
bool preservesTlsReg() const {
return preservesTlsReg_;
}
bool possiblyCalls() const override {
return true;
}

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

@ -8294,10 +8294,11 @@ class LWasmCallBase : public LInstruction
return true;
}
bool isCallPreserved(AnyRegister reg) const override {
// WebAssembly functions preserve the TLS pointer register.
if (reg.isFloat() || reg.gpr() != WasmTlsReg)
return false;
return mir()->preservesTlsReg();
// All MWasmCalls preserve the TLS register:
// - internal/indirect calls do by the internal wasm ABI
// - import calls do by explicitly saving/restoring at the callsite
// - builtin calls do because the TLS reg is non-volatile
return !reg.isFloat() && reg.gpr() == WasmTlsReg;
}
// LInstruction interface