Bug 1360263: Move WasmActivation::resumePC to the Runtime; r=luke

--HG--
extra : rebase_source : ad02eb061057dec3cff4d2408803c0e47450d5fc
This commit is contained in:
Benjamin Bouvier 2017-04-27 18:22:05 +02:00
Родитель 9332f7b6ca
Коммит 1560f3b506
4 изменённых файлов: 40 добавлений и 7 удалений

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

@ -1060,6 +1060,23 @@ struct JSRuntime : public js::MallocProvider<JSRuntime>
js::ActiveThreadData<js::RuntimeCaches> caches_;
public:
js::RuntimeCaches& caches() { return caches_.ref(); }
private:
// When wasm is interrupted, the pc at which we should return if the
// interrupt hasn't stopped execution of the current running code. Since
// this is used only by the interrupt handler and the latter is not
// reentrant, this value can't be clobbered so there is at most one
// resume PC at a time.
js::ActiveThreadData<void*> wasmResumePC_;
public:
void* wasmResumePC() const {
return wasmResumePC_;
}
void setWasmResumePC(void* resumePC) {
MOZ_ASSERT(!!resumePC == !wasmResumePC_);
wasmResumePC_ = resumePC;
}
};
namespace js {

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

@ -1645,7 +1645,6 @@ jit::JitActivation::traceIonRecovery(JSTracer* trc)
WasmActivation::WasmActivation(JSContext* cx)
: Activation(cx, Wasm),
entrySP_(nullptr),
resumePC_(nullptr),
exitFP_(nullptr),
exitReason_(wasm::ExitReason::Fixed::None)
{
@ -1691,7 +1690,7 @@ WasmActivation::startInterrupt(void* pc, uint8_t* fp)
MOZ_ASSERT(!interrupted());
MOZ_ASSERT(compartment()->wasm.lookupCode(pc)->lookupRange(pc)->isFunction());
resumePC_ = pc;
cx_->runtime()->setWasmResumePC(pc);
exitFP_ = fp;
MOZ_ASSERT(interrupted());
@ -1703,10 +1702,23 @@ WasmActivation::finishInterrupt()
MOZ_ASSERT(interrupted());
MOZ_ASSERT(exitFP_);
resumePC_ = nullptr;
cx_->runtime()->setWasmResumePC(nullptr);
exitFP_ = nullptr;
}
bool
WasmActivation::interrupted() const
{
return !!cx_->runtime()->wasmResumePC();
}
void*
WasmActivation::resumePC() const
{
MOZ_ASSERT(interrupted());
return cx_->runtime()->wasmResumePC();
}
InterpreterFrameIterator&
InterpreterFrameIterator::operator++()
{

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

@ -1734,7 +1734,6 @@ class WasmActivation : public Activation
{
WasmActivation* prevWasm_;
void* entrySP_;
void* resumePC_;
uint8_t* exitFP_;
wasm::ExitReason exitReason_;
@ -1765,8 +1764,8 @@ class WasmActivation : public Activation
// when the interrupt is handled.
void startInterrupt(void* pc, uint8_t* fp);
void finishInterrupt();
bool interrupted() const { return !!resumePC_; }
void* resumePC() const { MOZ_ASSERT(interrupted()); return resumePC_; }
bool interrupted() const;
void* resumePC() const;
// Used by wasm::FrameIterator during stack unwinding.
void unwindExitFP(uint8_t* exitFP);

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

@ -1027,7 +1027,12 @@ HandleMachException(JSContext* cx, const ExceptionRequest& request)
if (!IsHeapAccessAddress(*instance, faultingAddress))
return false;
HandleMemoryAccess(&context, pc, faultingAddress, *instance, activation, ppc);
{
// HandleMemoryAccess may call startInterrupt, which sets the wasm
// resume PC in the runtime.
AutoNoteSingleThreadedRegion anstr;
HandleMemoryAccess(&context, pc, faultingAddress, *instance, activation, ppc);
}
// Update the thread state with the new pc and register values.
kret = thread_set_state(cxThread, float_state, (thread_state_t)&context.float_, float_state_count);