Bug 1639153 - Part 4: Untie frame iteration from Frame::tls. r=lth

Here we replace usage of Frame::tls in frame iteration with GetNearestEffectiveTls.
We also maintain current tls for frame iteration object to not to call GetNearestEffectiveTls everytime.

Depends on D83044

Differential Revision: https://phabricator.services.mozilla.com/D83045
This commit is contained in:
Dmitry Bezhetskov 2020-10-20 10:24:40 +00:00
Родитель 600b56e2a5
Коммит 08c174ff4e
4 изменённых файлов: 34 добавлений и 18 удалений

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

@ -4618,19 +4618,22 @@ void AutoGenericRegisterScope<RegisterType>::reacquire() {
template void AutoGenericRegisterScope<Register>::reacquire();
template void AutoGenericRegisterScope<FloatRegister>::reacquire();
wasm::TlsData* ExtractCallerTlsFromFrameWithTls(wasm::Frame* fp) {
return *reinterpret_cast<wasm::TlsData**>(
reinterpret_cast<uint8_t*>(fp) + sizeof(wasm::Frame) + ShadowStackSpace +
wasm::FrameWithTls::callerTLSOffset());
}
wasm::TlsData* ExtractCalleeTlsFromFrameWithTls(wasm::Frame* fp) {
return *reinterpret_cast<wasm::TlsData**>(
reinterpret_cast<uint8_t*>(fp) + sizeof(wasm::Frame) + ShadowStackSpace +
wasm::FrameWithTls::calleeTLSOffset());
}
#endif // DEBUG
} // namespace jit
namespace wasm {
TlsData* ExtractCallerTlsFromFrameWithTls(Frame* fp) {
return *reinterpret_cast<TlsData**>(reinterpret_cast<uint8_t*>(fp) +
sizeof(Frame) + ShadowStackSpace +
FrameWithTls::callerTLSOffset());
}
TlsData* ExtractCalleeTlsFromFrameWithTls(Frame* fp) {
return *reinterpret_cast<TlsData**>(reinterpret_cast<uint8_t*>(fp) +
sizeof(Frame) + ShadowStackSpace +
FrameWithTls::calleeTLSOffset());
}
} // namespace wasm
} // namespace js

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

@ -4420,10 +4420,13 @@ class WasmABIArgIter : public ABIArgIterBase<VecT, WasmABIArgGenerator> {
: ABIArgIterBase<VecT, WasmABIArgGenerator>(types) {}
};
wasm::TlsData* ExtractCalleeTlsFromFrameWithTls(wasm::Frame* fp);
wasm::TlsData* ExtractCallerTlsFromFrameWithTls(wasm::Frame* fp);
} // namespace jit
namespace wasm {
TlsData* ExtractCalleeTlsFromFrameWithTls(Frame* fp);
TlsData* ExtractCallerTlsFromFrameWithTls(Frame* fp);
} // namespace wasm
} // namespace js
#endif /* jit_MacroAssembler_h */

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

@ -42,12 +42,14 @@ WasmFrameIter::WasmFrameIter(JitActivation* activation, wasm::Frame* fp)
codeRange_(nullptr),
lineOrBytecode_(0),
fp_(fp ? fp : activation->wasmExitFP()),
tls_(nullptr),
unwoundIonCallerFP_(nullptr),
unwoundIonFrameType_(jit::FrameType(-1)),
unwind_(Unwind::False),
unwoundAddressOfReturnAddress_(nullptr),
resumePCinCurrentFrame_(nullptr) {
MOZ_ASSERT(fp_);
tls_ = GetNearestEffectiveTls(fp_);
// When the stack is captured during a trap (viz., to create the .stack
// for an Error object), use the pc/bytecode information captured by the
@ -59,7 +61,7 @@ WasmFrameIter::WasmFrameIter(JitActivation* activation, wasm::Frame* fp)
const TrapData& trapData = activation->wasmTrapData();
void* unwoundPC = trapData.unwoundPC;
code_ = &fp_->instance()->code();
code_ = &tls_->instance->code();
MOZ_ASSERT(code_ == LookupCode(unwoundPC));
codeRange_ = code_->lookupFuncRange(unwoundPC);
@ -196,12 +198,18 @@ void WasmFrameIter::popFrame() {
return;
}
MOZ_ASSERT(code_ == &fp_->instance()->code());
MOZ_ASSERT(codeRange_->kind() == CodeRange::Function);
const CallSite* callsite = code_->lookupCallSite(returnAddress);
MOZ_ASSERT(callsite);
if (callsite->mightBeCrossInstance()) {
tls_ = ExtractCallerTlsFromFrameWithTls(prevFP);
}
MOZ_ASSERT(code_ == &fp_->instance()->code());
MOZ_ASSERT(fp_->instance() == tls()->instance);
lineOrBytecode_ = callsite->lineOrBytecode();
MOZ_ASSERT(!done());
@ -274,7 +282,7 @@ unsigned WasmFrameIter::computeLine(uint32_t* column) const {
Instance* WasmFrameIter::instance() const {
MOZ_ASSERT(!done());
return fp_->instance();
return tls_->instance;
}
void** WasmFrameIter::unwoundAddressOfReturnAddress() const {

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

@ -65,6 +65,7 @@ class WasmFrameIter {
const CodeRange* codeRange_;
unsigned lineOrBytecode_;
Frame* fp_;
TlsData* tls_;
uint8_t* unwoundIonCallerFP_;
jit::FrameType unwoundIonFrameType_;
Unwind unwind_;
@ -95,6 +96,7 @@ class WasmFrameIter {
jit::FrameType unwoundIonFrameType() const;
uint8_t* unwoundIonCallerFP() const { return unwoundIonCallerFP_; }
Frame* frame() const { return fp_; }
TlsData* tls() const { return tls_; }
// Returns the address of the next instruction that will execute in this
// frame, once control returns to this frame.