mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Bug 1334504 - Baldr: remove SymbolicAddress::ContextPtr (r=lth)
MozReview-Commit-ID: HZOVOhq8pdv --HG-- extra : rebase_source : 2e882f46991077e8bc828e69be64ae41d447b562
This commit is contained in:
parent
4fbe090e6e
commit
2bf1fbb0cc
@ -2971,14 +2971,6 @@ MacroAssembler::loadWasmActivationFromTls(Register dest)
|
||||
loadPtr(Address(dest, JSContext::offsetOfWasmActivation()), dest);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::loadWasmActivationFromSymbolicAddress(Register dest)
|
||||
{
|
||||
movePtr(wasm::SymbolicAddress::ContextPtr, dest);
|
||||
loadPtr(Address(dest, 0), dest);
|
||||
loadPtr(Address(dest, JSContext::offsetOfWasmActivation()), dest);
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::loadWasmTlsRegFromFrame(Register dest)
|
||||
{
|
||||
|
@ -447,6 +447,7 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
void Push(const ImmPtr imm) PER_SHARED_ARCH;
|
||||
void Push(const ImmGCPtr ptr) PER_SHARED_ARCH;
|
||||
void Push(FloatRegister reg) PER_SHARED_ARCH;
|
||||
void PushFlags() DEFINED_ON(x86_shared);
|
||||
void Push(jsid id, Register scratchReg);
|
||||
void Push(TypedOrValueRegister v);
|
||||
void Push(const ConstantOrRegister& v);
|
||||
@ -462,6 +463,7 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
void Pop(Register reg) PER_SHARED_ARCH;
|
||||
void Pop(FloatRegister t) PER_SHARED_ARCH;
|
||||
void Pop(const ValueOperand& val) PER_SHARED_ARCH;
|
||||
void PopFlags() DEFINED_ON(x86_shared);
|
||||
void popRooted(VMFunction::RootType rootType, Register cellReg, const ValueOperand& valueReg);
|
||||
|
||||
// Move the stack pointer based on the requested amount.
|
||||
@ -1519,7 +1521,6 @@ class MacroAssembler : public MacroAssemblerSpecific
|
||||
}
|
||||
|
||||
void loadWasmActivationFromTls(Register dest);
|
||||
void loadWasmActivationFromSymbolicAddress(Register dest);
|
||||
void loadWasmTlsRegFromFrame(Register dest = WasmTlsReg);
|
||||
|
||||
template<typename T>
|
||||
|
@ -168,6 +168,7 @@ static constexpr Register WasmIonExitRegE1 = r1;
|
||||
// None of these may be the second scratch register (lr).
|
||||
static constexpr Register WasmIonExitRegReturnData = r2;
|
||||
static constexpr Register WasmIonExitRegReturnType = r3;
|
||||
static constexpr Register WasmIonExitTlsReg = r9;
|
||||
static constexpr Register WasmIonExitRegD0 = r0;
|
||||
static constexpr Register WasmIonExitRegD1 = r1;
|
||||
static constexpr Register WasmIonExitRegD2 = r4;
|
||||
|
@ -126,6 +126,7 @@ static constexpr Register WasmIonExitRegE1 = r1;
|
||||
// None of these may be the second scratch register.
|
||||
static constexpr Register WasmIonExitRegReturnData = r2;
|
||||
static constexpr Register WasmIonExitRegReturnType = r3;
|
||||
static constexpr Register WasmIonExitTlsReg = r17;
|
||||
static constexpr Register WasmIonExitRegD0 = r0;
|
||||
static constexpr Register WasmIonExitRegD1 = r1;
|
||||
static constexpr Register WasmIonExitRegD2 = r4;
|
||||
|
@ -77,6 +77,7 @@ static constexpr FloatRegister SecondScratchDoubleReg = { FloatRegisters::f16, F
|
||||
// None of these may be the second scratch register (t8).
|
||||
static constexpr Register WasmIonExitRegReturnData = JSReturnReg_Data;
|
||||
static constexpr Register WasmIonExitRegReturnType = JSReturnReg_Type;
|
||||
static constexpr Register WasmIonExitTlsReg = s5;
|
||||
|
||||
static constexpr FloatRegister f0 = { FloatRegisters::f0, FloatRegister::Double };
|
||||
static constexpr FloatRegister f2 = { FloatRegisters::f2, FloatRegister::Double };
|
||||
|
@ -71,6 +71,7 @@ static constexpr FloatRegister SecondScratchDoubleReg = { FloatRegisters::f21, F
|
||||
// None of these may be the second scratch register (t8).
|
||||
static constexpr Register WasmIonExitRegReturnData = JSReturnReg_Data;
|
||||
static constexpr Register WasmIonExitRegReturnType = JSReturnReg_Type;
|
||||
static constexpr Register WasmIonExitTlsReg = s5;
|
||||
|
||||
static constexpr FloatRegister f0 = { FloatRegisters::f0, FloatRegisters::Double };
|
||||
static constexpr FloatRegister f1 = { FloatRegisters::f1, FloatRegisters::Double };
|
||||
|
@ -48,6 +48,7 @@ static constexpr Register WasmIonExitRegE1 { Registers::invalid_reg };
|
||||
|
||||
static constexpr Register WasmIonExitRegReturnData { Registers::invalid_reg };
|
||||
static constexpr Register WasmIonExitRegReturnType { Registers::invalid_reg };
|
||||
static constexpr Register WasmIonExitTlsReg = { Registers::invalid_reg };
|
||||
static constexpr Register WasmIonExitRegD0 { Registers::invalid_reg };
|
||||
static constexpr Register WasmIonExitRegD1 { Registers::invalid_reg };
|
||||
static constexpr Register WasmIonExitRegD2 { Registers::invalid_reg };
|
||||
@ -415,7 +416,6 @@ class MacroAssemblerNone : public Assembler
|
||||
bool buildOOLFakeExitFrame(void*) { MOZ_CRASH(); }
|
||||
void loadWasmGlobalPtr(uint32_t, Register) { MOZ_CRASH(); }
|
||||
void loadWasmActivationFromTls(Register) { MOZ_CRASH(); }
|
||||
void loadWasmActivationFromSymbolicAddress(Register) { MOZ_CRASH(); }
|
||||
void loadWasmPinnedRegsFromTls() { MOZ_CRASH(); }
|
||||
|
||||
void setPrinter(Sprinter*) { MOZ_CRASH(); }
|
||||
|
@ -157,6 +157,7 @@ static constexpr Register WasmIonExitRegE1 = rdi;
|
||||
// Registers used in the GenerateFFIIonExit Disable Activation block.
|
||||
static constexpr Register WasmIonExitRegReturnData = ecx;
|
||||
static constexpr Register WasmIonExitRegReturnType = ecx;
|
||||
static constexpr Register WasmIonExitTlsReg = r14;
|
||||
static constexpr Register WasmIonExitRegD0 = rax;
|
||||
static constexpr Register WasmIonExitRegD1 = rdi;
|
||||
static constexpr Register WasmIonExitRegD2 = rbx;
|
||||
|
@ -600,6 +600,13 @@ MacroAssembler::Push(FloatRegister t)
|
||||
adjustFrame(sizeof(double));
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::PushFlags()
|
||||
{
|
||||
pushFlags();
|
||||
adjustFrame(sizeof(intptr_t));
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::Pop(const Operand op)
|
||||
{
|
||||
@ -628,6 +635,13 @@ MacroAssembler::Pop(const ValueOperand& val)
|
||||
implicitPop(sizeof(Value));
|
||||
}
|
||||
|
||||
void
|
||||
MacroAssembler::PopFlags()
|
||||
{
|
||||
popFlags();
|
||||
implicitPop(sizeof(intptr_t));
|
||||
}
|
||||
|
||||
// ===============================================================
|
||||
// Simple call functions.
|
||||
|
||||
|
@ -112,9 +112,10 @@ static constexpr Register WasmIonExitRegE1 = eax;
|
||||
// Registers used in the GenerateFFIIonExit Disable Activation block.
|
||||
static constexpr Register WasmIonExitRegReturnData = edx;
|
||||
static constexpr Register WasmIonExitRegReturnType = ecx;
|
||||
static constexpr Register WasmIonExitTlsReg = esi;
|
||||
static constexpr Register WasmIonExitRegD0 = edi;
|
||||
static constexpr Register WasmIonExitRegD1 = eax;
|
||||
static constexpr Register WasmIonExitRegD2 = esi;
|
||||
static constexpr Register WasmIonExitRegD2 = ebx;
|
||||
|
||||
// Registerd used in RegExpMatcher instruction (do not use JSReturnOperand).
|
||||
static constexpr Register RegExpMatcherRegExpReg = CallTempReg0;
|
||||
|
@ -1755,10 +1755,6 @@ class WasmActivation : public Activation
|
||||
// Returns the reason why wasm code called out of wasm code.
|
||||
wasm::ExitReason exitReason() const { return exitReason_; }
|
||||
|
||||
// Read by JIT code:
|
||||
static unsigned offsetOfContext() { return offsetof(WasmActivation, cx_); }
|
||||
static unsigned offsetOfResumePC() { return offsetof(WasmActivation, resumePC_); }
|
||||
|
||||
// Written by JIT code:
|
||||
static unsigned offsetOfEntrySP() { return offsetof(WasmActivation, entrySP_); }
|
||||
static unsigned offsetOfFP() { return offsetof(WasmActivation, fp_); }
|
||||
|
@ -111,7 +111,7 @@ StaticallyLink(CodeSegment& cs, const LinkData& linkData, JSContext* cx)
|
||||
const Uint32Vector& offsets = linkData.symbolicLinks[imm];
|
||||
for (size_t i = 0; i < offsets.length(); i++) {
|
||||
uint8_t* patchAt = cs.base() + offsets[i];
|
||||
void* target = AddressOf(imm, cx);
|
||||
void* target = AddressOf(imm);
|
||||
Assembler::PatchDataWithValueCheck(CodeLocationLabel(patchAt),
|
||||
PatchedImmPtr(target),
|
||||
PatchedImmPtr((void*)-1));
|
||||
|
@ -78,7 +78,7 @@ class Instance
|
||||
TableTls& tableTls(const TableDesc& td) const;
|
||||
|
||||
// Import call slow paths which are called directly from wasm code.
|
||||
friend void* AddressOf(SymbolicAddress, JSContext*);
|
||||
friend void* AddressOf(SymbolicAddress);
|
||||
static int32_t callImport_void(Instance*, int32_t, int32_t, uint64_t*);
|
||||
static int32_t callImport_i32(Instance*, int32_t, int32_t, uint64_t*);
|
||||
static int32_t callImport_i64(Instance*, int32_t, int32_t, uint64_t*);
|
||||
|
@ -687,8 +687,7 @@ wasm::GenerateImportJitExit(MacroAssembler& masm, const FuncImport& fi, Label* t
|
||||
Register act = WasmIonExitRegE1;
|
||||
|
||||
// JitActivation* act = cx->activation();
|
||||
masm.movePtr(SymbolicAddress::ContextPtr, cx);
|
||||
masm.loadPtr(Address(cx, 0), cx);
|
||||
masm.loadPtr(Address(WasmTlsReg, offsetof(TlsData, cx)), cx);
|
||||
masm.loadPtr(Address(cx, JSContext::offsetOfActivation()), act);
|
||||
|
||||
// act.active_ = true;
|
||||
@ -705,20 +704,24 @@ wasm::GenerateImportJitExit(MacroAssembler& masm, const FuncImport& fi, Label* t
|
||||
masm.callJitNoProfiler(callee);
|
||||
AssertStackAlignment(masm, JitStackAlignment, sizeOfRetAddr);
|
||||
|
||||
// Reload the TLS reg which has been clobbered by Ion code. The TLS reg is
|
||||
// non-volatile and so preserved by the native-ABI calls below.
|
||||
masm.loadWasmTlsRegFromFrame();
|
||||
|
||||
{
|
||||
// Disable Activation.
|
||||
//
|
||||
// This sequence needs three registers, and must preserve the JSReturnReg_Data and
|
||||
// JSReturnReg_Type, so there are five live registers.
|
||||
// This sequence needs three registers and must preserve WasmTlsReg,
|
||||
// JSReturnReg_Data and JSReturnReg_Type.
|
||||
MOZ_ASSERT(JSReturnReg_Data == WasmIonExitRegReturnData);
|
||||
MOZ_ASSERT(JSReturnReg_Type == WasmIonExitRegReturnType);
|
||||
MOZ_ASSERT(WasmTlsReg == WasmIonExitTlsReg);
|
||||
Register cx = WasmIonExitRegD0;
|
||||
Register act = WasmIonExitRegD1;
|
||||
Register tmp = WasmIonExitRegD2;
|
||||
|
||||
// JitActivation* act = cx->activation();
|
||||
masm.movePtr(SymbolicAddress::ContextPtr, cx);
|
||||
masm.loadPtr(Address(cx, 0), cx);
|
||||
masm.loadPtr(Address(WasmTlsReg, offsetof(TlsData, cx)), cx);
|
||||
masm.loadPtr(Address(cx, JSContext::offsetOfActivation()), act);
|
||||
|
||||
// cx->jitTop = act->prevJitTop_;
|
||||
@ -782,10 +785,6 @@ wasm::GenerateImportJitExit(MacroAssembler& masm, const FuncImport& fi, Label* t
|
||||
Label done;
|
||||
masm.bind(&done);
|
||||
|
||||
// The epilogue requires WasmTlsReg and Ion code clobbers all registers,
|
||||
// even ABI non-volatiles.
|
||||
masm.loadWasmTlsRegFromFrame();
|
||||
|
||||
GenerateExitEpilogue(masm, masm.framePushed(), ExitReason::ImportJit, &offsets);
|
||||
|
||||
if (oolConvert.used()) {
|
||||
@ -928,13 +927,17 @@ wasm::GenerateUnalignedExit(MacroAssembler& masm, Label* throwLabel)
|
||||
return GenerateGenericMemoryAccessTrap(masm, SymbolicAddress::ReportUnalignedAccess, throwLabel);
|
||||
}
|
||||
|
||||
#if defined(JS_CODEGEN_ARM)
|
||||
static const LiveRegisterSet AllRegsExceptPCSP(
|
||||
GeneralRegisterSet(Registers::AllMask & ~((uint32_t(1) << Registers::sp) |
|
||||
(uint32_t(1) << Registers::pc))),
|
||||
FloatRegisterSet(FloatRegisters::AllDoubleMask));
|
||||
static_assert(!SupportsSimd, "high lanes of SIMD registers need to be saved too.");
|
||||
#else
|
||||
static const LiveRegisterSet AllRegsExceptSP(
|
||||
GeneralRegisterSet(Registers::AllMask & ~(uint32_t(1) << Registers::StackPointer)),
|
||||
FloatRegisterSet(FloatRegisters::AllMask));
|
||||
|
||||
static const LiveRegisterSet AllAllocatableRegs = LiveRegisterSet(
|
||||
GeneralRegisterSet(Registers::AllocatableMask),
|
||||
FloatRegisterSet(FloatRegisters::AllMask));
|
||||
#endif
|
||||
|
||||
// The async interrupt-callback exit is called from arbitrarily-interrupted wasm
|
||||
// code. That means we must first save *all* registers and restore *all*
|
||||
@ -956,18 +959,11 @@ wasm::GenerateInterruptExit(MacroAssembler& masm, Label* throwLabel)
|
||||
// Be very careful here not to perturb the machine state before saving it
|
||||
// to the stack. In particular, add/sub instructions may set conditions in
|
||||
// the flags register.
|
||||
masm.push(Imm32(0)); // space for resumePC
|
||||
masm.pushFlags(); // after this we are safe to use sub
|
||||
masm.setFramePushed(0); // set to zero so we can use masm.framePushed() below
|
||||
masm.push(Imm32(0)); // space used as return address, updated below
|
||||
masm.setFramePushed(0); // set to 0 now so that framePushed is offset of return address
|
||||
masm.PushFlags(); // after this we are safe to use sub
|
||||
masm.PushRegsInMask(AllRegsExceptSP); // save all GP/FP registers (except SP)
|
||||
|
||||
Register scratch = ABINonArgReturnReg0;
|
||||
|
||||
// Store resumePC into the reserved space.
|
||||
masm.loadWasmActivationFromSymbolicAddress(scratch);
|
||||
masm.loadPtr(Address(scratch, WasmActivation::offsetOfResumePC()), scratch);
|
||||
masm.storePtr(scratch, Address(masm.getStackPointer(), masm.framePushed() + sizeof(void*)));
|
||||
|
||||
// We know that StackPointer is word-aligned, but not necessarily
|
||||
// stack-aligned, so we need to align it dynamically.
|
||||
masm.moveStackPtrTo(ABINonVolatileReg);
|
||||
@ -975,18 +971,27 @@ wasm::GenerateInterruptExit(MacroAssembler& masm, Label* throwLabel)
|
||||
if (ShadowStackSpace)
|
||||
masm.subFromStackPtr(Imm32(ShadowStackSpace));
|
||||
|
||||
// Make the call to C++, which preserves ABINonVolatileReg.
|
||||
masm.assertStackAlignment(ABIStackAlignment);
|
||||
masm.call(SymbolicAddress::HandleExecutionInterrupt);
|
||||
|
||||
masm.branchIfFalseBool(ReturnReg, throwLabel);
|
||||
// HandleExecutionInterrupt returns null if execution is interrupted and
|
||||
// the resumption pc otherwise.
|
||||
masm.branchTestPtr(Assembler::Zero, ReturnReg, ReturnReg, throwLabel);
|
||||
|
||||
// Restore the StackPointer to its position before the call.
|
||||
// Restore the stack pointer then store resumePC into the stack slow that
|
||||
// will be popped by the 'ret' below.
|
||||
masm.moveToStackPtr(ABINonVolatileReg);
|
||||
masm.storePtr(ReturnReg, Address(StackPointer, masm.framePushed()));
|
||||
|
||||
// Restore the machine state to before the interrupt.
|
||||
masm.PopRegsInMask(AllRegsExceptSP); // restore all GP/FP registers (except SP)
|
||||
masm.popFlags(); // after this, nothing that sets conditions
|
||||
masm.ret(); // pop resumePC into PC
|
||||
// Restore the machine state to before the interrupt. After popping flags,
|
||||
// no instructions can be executed which set flags.
|
||||
masm.PopRegsInMask(AllRegsExceptSP);
|
||||
masm.PopFlags();
|
||||
|
||||
// Return to the resumePC stored into this stack slot above.
|
||||
MOZ_ASSERT(masm.framePushed() == 0);
|
||||
masm.ret();
|
||||
#elif defined(JS_CODEGEN_MIPS32) || defined(JS_CODEGEN_MIPS64)
|
||||
// Reserve space to store resumePC and HeapReg.
|
||||
masm.subFromStackPtr(Imm32(2 * sizeof(intptr_t)));
|
||||
@ -1034,61 +1039,40 @@ wasm::GenerateInterruptExit(MacroAssembler& masm, Label* throwLabel)
|
||||
masm.as_jr(HeapReg);
|
||||
masm.loadPtr(Address(StackPointer, -sizeof(intptr_t)), HeapReg);
|
||||
#elif defined(JS_CODEGEN_ARM)
|
||||
masm.setFramePushed(0); // set to zero so we can use masm.framePushed() below
|
||||
masm.push(Imm32(0)); // space used as return address, updated below
|
||||
masm.setFramePushed(0); // set to 0 now so that framePushed is offset of return address
|
||||
masm.PushRegsInMask(AllRegsExceptPCSP); // save all GP/FP registers (except PC and SP)
|
||||
|
||||
// Save all GPR, except the stack pointer.
|
||||
masm.PushRegsInMask(LiveRegisterSet(
|
||||
GeneralRegisterSet(Registers::AllMask & ~(1<<Registers::sp)),
|
||||
FloatRegisterSet(uint32_t(0))));
|
||||
|
||||
// Save both the APSR and FPSCR in non-volatile registers.
|
||||
// Save SP, APSR and FPSCR in non-volatile registers.
|
||||
masm.as_mrs(r4);
|
||||
masm.as_vmrs(r5);
|
||||
// Save the stack pointer in a non-volatile register.
|
||||
masm.mov(sp,r6);
|
||||
// Align the stack.
|
||||
masm.as_bic(sp, sp, Imm8(7));
|
||||
masm.mov(sp, r6);
|
||||
|
||||
// Store resumePC into the return PC stack slot.
|
||||
masm.loadWasmActivationFromSymbolicAddress(IntArgReg0);
|
||||
masm.loadPtr(Address(IntArgReg0, WasmActivation::offsetOfResumePC()), IntArgReg1);
|
||||
masm.storePtr(IntArgReg1, Address(r6, 14 * sizeof(uint32_t*)));
|
||||
|
||||
// Save all FP registers
|
||||
static_assert(!SupportsSimd, "high lanes of SIMD registers need to be saved too.");
|
||||
masm.PushRegsInMask(LiveRegisterSet(GeneralRegisterSet(0),
|
||||
FloatRegisterSet(FloatRegisters::AllDoubleMask)));
|
||||
// We know that StackPointer is word-aligned, but not necessarily
|
||||
// stack-aligned, so we need to align it dynamically.
|
||||
masm.andToStackPtr(Imm32(~(ABIStackAlignment - 1)));
|
||||
|
||||
// Make the call to C++, which preserves the non-volatile registers.
|
||||
masm.assertStackAlignment(ABIStackAlignment);
|
||||
masm.call(SymbolicAddress::HandleExecutionInterrupt);
|
||||
|
||||
masm.branchIfFalseBool(ReturnReg, throwLabel);
|
||||
// HandleExecutionInterrupt returns null if execution is interrupted and
|
||||
// the resumption pc otherwise.
|
||||
masm.branchTestPtr(Assembler::Zero, ReturnReg, ReturnReg, throwLabel);
|
||||
|
||||
// Restore the machine state to before the interrupt. this will set the pc!
|
||||
// Restore the stack pointer then store resumePC into the stack slow that
|
||||
// will be popped by the 'ret' below.
|
||||
masm.mov(r6, sp);
|
||||
masm.storePtr(ReturnReg, Address(sp, masm.framePushed()));
|
||||
|
||||
// Restore all FP registers
|
||||
masm.PopRegsInMask(LiveRegisterSet(GeneralRegisterSet(0),
|
||||
FloatRegisterSet(FloatRegisters::AllDoubleMask)));
|
||||
masm.mov(r6,sp);
|
||||
// Restore the machine state to before the interrupt. After popping flags,
|
||||
// no instructions can be executed which set flags.
|
||||
masm.as_vmsr(r5);
|
||||
masm.as_msr(r4);
|
||||
// Restore all GP registers
|
||||
masm.startDataTransferM(IsLoad, sp, IA, WriteBack);
|
||||
masm.transferReg(r0);
|
||||
masm.transferReg(r1);
|
||||
masm.transferReg(r2);
|
||||
masm.transferReg(r3);
|
||||
masm.transferReg(r4);
|
||||
masm.transferReg(r5);
|
||||
masm.transferReg(r6);
|
||||
masm.transferReg(r7);
|
||||
masm.transferReg(r8);
|
||||
masm.transferReg(r9);
|
||||
masm.transferReg(r10);
|
||||
masm.transferReg(r11);
|
||||
masm.transferReg(r12);
|
||||
masm.transferReg(lr);
|
||||
masm.finishDataTransfer();
|
||||
masm.PopRegsInMask(AllRegsExceptPCSP);
|
||||
|
||||
// Return to the resumePC stored into this stack slot above.
|
||||
MOZ_ASSERT(masm.framePushed() == 0);
|
||||
masm.ret();
|
||||
#elif defined(JS_CODEGEN_ARM64)
|
||||
MOZ_CRASH();
|
||||
@ -1123,22 +1107,22 @@ wasm::GenerateThrowStub(MacroAssembler& masm, Label* throwLabel)
|
||||
masm.subFromStackPtr(Imm32(ShadowStackSpace));
|
||||
masm.call(SymbolicAddress::HandleThrow);
|
||||
|
||||
Register scratch = ABINonArgReturnReg0;
|
||||
masm.loadWasmActivationFromSymbolicAddress(scratch);
|
||||
// HandleThrow returns the innermost WasmActivation* in ReturnReg.
|
||||
Register act = ReturnReg;
|
||||
|
||||
#ifdef DEBUG
|
||||
// We are about to pop all frames in this WasmActivation. Checking if fp is
|
||||
// set to null to maintain the invariant that fp is either null or pointing
|
||||
// to a valid frame.
|
||||
Label ok;
|
||||
masm.branchPtr(Assembler::Equal, Address(scratch, WasmActivation::offsetOfFP()), ImmWord(0), &ok);
|
||||
masm.branchPtr(Assembler::Equal, Address(act, WasmActivation::offsetOfFP()), ImmWord(0), &ok);
|
||||
masm.breakpoint();
|
||||
masm.bind(&ok);
|
||||
#endif
|
||||
|
||||
masm.setFramePushed(FramePushedForEntrySP);
|
||||
masm.loadStackPtr(Address(scratch, WasmActivation::offsetOfEntrySP()));
|
||||
masm.Pop(scratch);
|
||||
masm.loadStackPtr(Address(act, WasmActivation::offsetOfEntrySP()));
|
||||
masm.Pop(ReturnReg);
|
||||
masm.PopRegsInMask(NonVolatileRegs);
|
||||
MOZ_ASSERT(masm.framePushed() == 0);
|
||||
|
||||
@ -1149,6 +1133,10 @@ wasm::GenerateThrowStub(MacroAssembler& masm, Label* throwLabel)
|
||||
return offsets;
|
||||
}
|
||||
|
||||
static const LiveRegisterSet AllAllocatableRegs = LiveRegisterSet(
|
||||
GeneralRegisterSet(Registers::AllocatableMask),
|
||||
FloatRegisterSet(FloatRegisters::AllMask));
|
||||
|
||||
// Generate a stub that handle toggable enter/leave frame traps or breakpoints.
|
||||
// The trap records frame pointer (via GenerateExitPrologue) and saves most of
|
||||
// registers to not affect the code generated by WasmBaselineCompile.
|
||||
|
@ -79,13 +79,7 @@ __aeabi_uidivmod(int, int);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
WasmReportOverRecursed()
|
||||
{
|
||||
ReportOverRecursed(JSContext::innermostWasmActivation()->cx());
|
||||
}
|
||||
|
||||
static bool
|
||||
static void*
|
||||
WasmHandleExecutionInterrupt()
|
||||
{
|
||||
WasmActivation* activation = JSContext::innermostWasmActivation();
|
||||
@ -98,12 +92,13 @@ WasmHandleExecutionInterrupt()
|
||||
activation->compartment()->wasm.setInterrupted(false);
|
||||
|
||||
// Preserve the invariant that having a non-null resumePC means that we are
|
||||
// handling an interrupt. Note that resumePC has already been copied onto
|
||||
// the stack by the interrupt stub, so we can clear it before returning
|
||||
// to the stub.
|
||||
// handling an interrupt.
|
||||
void* resumePC = activation->resumePC();
|
||||
activation->setResumePC(nullptr);
|
||||
|
||||
return success;
|
||||
// Return the resumePC if execution can continue or null if execution should
|
||||
// jump to the throw stub.
|
||||
return success ? resumePC : nullptr;
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -170,7 +165,7 @@ WasmHandleDebugTrap()
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
static WasmActivation*
|
||||
WasmHandleThrow()
|
||||
{
|
||||
JSContext* cx = TlsContext.get();
|
||||
@ -187,7 +182,7 @@ WasmHandleThrow()
|
||||
// right as it becomes trash).
|
||||
FrameIterator iter(activation, FrameIterator::Unwind::True);
|
||||
if (iter.done())
|
||||
return;
|
||||
return activation;
|
||||
|
||||
// Live wasm code on the stack is kept alive (in wasm::TraceActivations) by
|
||||
// marking the instance of every wasm::Frame found by FrameIterator.
|
||||
@ -227,6 +222,8 @@ WasmHandleThrow()
|
||||
}
|
||||
frame->leave(cx);
|
||||
}
|
||||
|
||||
return activation;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -436,13 +433,9 @@ wasm::IsRoundingFunction(SymbolicAddress callee, jit::RoundingMode* mode)
|
||||
}
|
||||
|
||||
void*
|
||||
wasm::AddressOf(SymbolicAddress imm, JSContext* cx)
|
||||
wasm::AddressOf(SymbolicAddress imm)
|
||||
{
|
||||
switch (imm) {
|
||||
case SymbolicAddress::ContextPtr:
|
||||
return cx->zone()->group()->addressOfOwnerContext();
|
||||
case SymbolicAddress::ReportOverRecursed:
|
||||
return FuncCast(WasmReportOverRecursed, Args_General0);
|
||||
case SymbolicAddress::HandleExecutionInterrupt:
|
||||
return FuncCast(WasmHandleExecutionInterrupt, Args_General0);
|
||||
case SymbolicAddress::HandleDebugTrap:
|
||||
|
@ -41,6 +41,7 @@
|
||||
namespace js {
|
||||
|
||||
class PropertyName;
|
||||
class WasmActivation;
|
||||
class WasmFunctionCallObject;
|
||||
namespace jit {
|
||||
struct BaselineScript;
|
||||
@ -948,12 +949,12 @@ class CallSiteAndTarget : public CallSite
|
||||
|
||||
typedef Vector<CallSiteAndTarget, 0, SystemAllocPolicy> CallSiteAndTargetVector;
|
||||
|
||||
// A wasm::SymbolicAddress represents a pointer to a well-known function or
|
||||
// object that is embedded in wasm code. Since wasm code is serialized and
|
||||
// later deserialized into a different address space, symbolic addresses must be
|
||||
// used for *all* pointers into the address space. The MacroAssembler records a
|
||||
// list of all SymbolicAddresses and the offsets of their use in the code for
|
||||
// later patching during static linking.
|
||||
// A wasm::SymbolicAddress represents a pointer to a well-known function that is
|
||||
// embedded in wasm code. Since wasm code is serialized and later deserialized
|
||||
// into a different address space, symbolic addresses must be used for *all*
|
||||
// pointers into the address space. The MacroAssembler records a list of all
|
||||
// SymbolicAddresses and the offsets of their use in the code for later patching
|
||||
// during static linking.
|
||||
|
||||
enum class SymbolicAddress
|
||||
{
|
||||
@ -988,8 +989,6 @@ enum class SymbolicAddress
|
||||
LogD,
|
||||
PowD,
|
||||
ATan2D,
|
||||
ContextPtr,
|
||||
ReportOverRecursed,
|
||||
HandleExecutionInterrupt,
|
||||
HandleDebugTrap,
|
||||
HandleThrow,
|
||||
@ -1021,7 +1020,7 @@ bool
|
||||
IsRoundingFunction(SymbolicAddress callee, jit::RoundingMode* mode);
|
||||
|
||||
void*
|
||||
AddressOf(SymbolicAddress imm, JSContext* cx);
|
||||
AddressOf(SymbolicAddress imm);
|
||||
|
||||
// Assumptions captures ambient state that must be the same when compiling and
|
||||
// deserializing a module for the compiled code to be valid. If it's not, then
|
||||
|
Loading…
Reference in New Issue
Block a user