forked from mirrors/gecko-dev
Bug 1888614 - Fix exception handler to restore realm for trampoline native frames too. r=iain
Differential Revision: https://phabricator.services.mozilla.com/D206330
This commit is contained in:
parent
b8f399d747
commit
7a6d8fd713
5 changed files with 28 additions and 4 deletions
|
|
@ -135,3 +135,19 @@ function testBailout() {
|
|||
assertEq(arr.map(x => x.n).join(""), "0135");
|
||||
}
|
||||
testBailout();
|
||||
|
||||
function testExceptionHandlerSwitchRealm() {
|
||||
var g = newGlobal({sameCompartmentAs: this});
|
||||
for (var i = 0; i < 25; i++) {
|
||||
var ex = null;
|
||||
try {
|
||||
g.Array.prototype.toSorted.call([2, 3], () => {
|
||||
throw "fit";
|
||||
});
|
||||
} catch (e) {
|
||||
ex = e;
|
||||
}
|
||||
assertEq(ex, "fit");
|
||||
}
|
||||
}
|
||||
testExceptionHandlerSwitchRealm();
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ CalleeToken JSJitFrameIter::calleeToken() const {
|
|||
}
|
||||
|
||||
JSFunction* JSJitFrameIter::callee() const {
|
||||
MOZ_ASSERT(isScripted());
|
||||
MOZ_ASSERT(isScripted() || isTrampolineNative());
|
||||
MOZ_ASSERT(isFunctionFrame());
|
||||
return CalleeTokenToFunction(calleeToken());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,6 +177,9 @@ class JSJitFrameIter {
|
|||
return type_ == FrameType::BaselineInterpreterEntry;
|
||||
}
|
||||
bool isRectifier() const { return type_ == FrameType::Rectifier; }
|
||||
bool isTrampolineNative() const {
|
||||
return type_ == FrameType::TrampolineNative;
|
||||
}
|
||||
bool isBareExit() const;
|
||||
bool isUnwoundJitExit() const;
|
||||
template <typename T>
|
||||
|
|
|
|||
|
|
@ -760,7 +760,7 @@ void HandleException(ResumeFromException* rfe) {
|
|||
|
||||
// JIT code can enter same-compartment realms, so reset cx->realm to
|
||||
// this frame's realm.
|
||||
if (frame.isScripted()) {
|
||||
if (frame.isScripted() || frame.isTrampolineNative()) {
|
||||
cx->setRealmForJitExceptionHandler(iter.realm());
|
||||
}
|
||||
|
||||
|
|
@ -830,7 +830,7 @@ void HandleException(ResumeFromException* rfe) {
|
|||
if (rfe->kind == ExceptionResumeKind::ForcedReturnBaseline) {
|
||||
return;
|
||||
}
|
||||
} else if (frame.type() == FrameType::TrampolineNative) {
|
||||
} else if (frame.isTrampolineNative()) {
|
||||
UnwindTrampolineNativeFrame(cx->runtime(), frame);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,12 @@ JS::Realm* JitFrameIter::realm() const {
|
|||
return asWasm().instance()->realm();
|
||||
}
|
||||
|
||||
return asJSJit().script()->realm();
|
||||
if (asJSJit().isScripted()) {
|
||||
return asJSJit().script()->realm();
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(asJSJit().isTrampolineNative());
|
||||
return asJSJit().callee()->realm();
|
||||
}
|
||||
|
||||
uint8_t* JitFrameIter::resumePCinCurrentFrame() const {
|
||||
|
|
|
|||
Loading…
Reference in a new issue