-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JSC] exception from handleHostCall for tail-call should be handled correctly #22528
Conversation
EWS run on previous version of this PR (hash 3629fca) |
3629fca
to
f757fe3
Compare
EWS run on previous version of this PR (hash f757fe3) |
@@ -96,6 +96,13 @@ inline bool CallFrame::isStackOverflowFrame() const | |||
return jsCallee() == jsCallee()->globalObject()->stackOverflowFrameCallee(); | |||
} | |||
|
|||
inline bool CallFrame::isHandleHostCallExceptionFrame() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: based on this patch, I don't see a need to distinguish handleHostCallExceptionCallee
from stackOverflowFrameCallee
. We could just rename stackOverflowFrameCallee
to partiallyInitializedFrameCallee
and just use that instead. This way, we don't have to spend time, code, and memory instantiating and checking for a second instance of this callee per global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me
jit.copyCalleeSavesToEntryFrameCalleeSavesBuffer(vm.topEntryFrame, GPRInfo::argumentGPR0); | ||
jit.setupArguments<decltype(operationLookupExceptionHandler)>(CCallHelpers::TrustedImmPtr(&vm)); | ||
jit.prepareCallOperation(vm); | ||
jit.move(CCallHelpers::TrustedImmPtr(tagCFunction<OperationPtrTag>(operationLookupExceptionHandler)), GPRInfo::nonArgGPR0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you convert isStackOverflowFrame
to isPartiallyInitializedFrame
(which is used both by you here and by stack overflow), you can use operationLookupExceptionHandlerFromCallerFrame
here. It is semantically the same except for the extra ASSERTs. However, it communicates more clearly that we intend to throw from the caller, and that the current frame is a partially initialized frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can be used for non partially initialized frame case (calling a function caused an error). So we should use operationLookupExceptionHandler
f757fe3
to
69e7f7c
Compare
EWS run on current version of this PR (hash 69e7f7c) |
EWS run on previous version of this PR (hash 69e7f7c) |
69e7f7c
to
fd65834
Compare
EWS run on current version of this PR (hash fd65834) |
EWS run on previous version of this PR (hash fd65834) |
fd65834
to
c3a7c4a
Compare
EWS run on previous version of this PR (hash c3a7c4a) |
c3a7c4a
to
eb6ff6e
Compare
EWS run on previous version of this PR (hash eb6ff6e) |
eb6ff6e
to
62231e0
Compare
EWS run on previous version of this PR (hash 62231e0) |
62231e0
to
36f1eab
Compare
EWS run on previous version of this PR (hash 36f1eab) |
36f1eab
to
16d6732
Compare
EWS run on previous version of this PR (hash 16d6732) |
16d6732
to
49b120d
Compare
EWS run on current version of this PR (hash 49b120d) |
β¦orrectly https://bugs.webkit.org/show_bug.cgi?id=267249 rdar://120662635 Reviewed by Mark Lam. 272580@main introduced failing in the fast path in polymorphic thunk (calling operationLinkPolymorphicFromRegularCall etc.). In this case, 1. We should anyway use the top-most CallFrame* for NativeCallFrameTracer since it confuses StackVisitor (It assumes vm.topCallFrame is the top-most CallFrame*). We use calleeFrame instead of callerFrame. 2. Then, we should make StackVisitor work with CallFrame* which has non-cell JSCallee (when calling a non-function value). We rename stackOverflowFrameCallee to partiallyInitializedFrameCallee and use it. This tells StackVisitor that it should skip the first frame since it is pre-baked one. Also, make it possible to throw exception from this frame since exception catching code assumes that Callee is some cells. 3. To throw an exception from the current calleeFrame, this patch adds throwExceptionFromCallGenerator thunk, which throws an exception from the current frame when it is called as a normal JS function. * JSTests/stress/tail-call-callee-frame-polymorphic.js: Added. * Source/JavaScriptCore/bytecode/RepatchInlines.h: (JSC::handleHostCall): * Source/JavaScriptCore/interpreter/CallFrame.h: * Source/JavaScriptCore/interpreter/CallFrameInlines.h: (JSC::CallFrame::isHandleHostCallExceptionFrame const): * Source/JavaScriptCore/interpreter/FrameTracers.h: (JSC::NativeCallFrameTracerForTailCall::NativeCallFrameTracerForTailCall): Deleted. * Source/JavaScriptCore/interpreter/StackVisitor.cpp: (JSC::StackVisitor::StackVisitor): * Source/JavaScriptCore/jit/JITOperations.cpp: (JSC::JSC_DEFINE_JIT_OPERATION): * Source/JavaScriptCore/jit/JITThunks.h: * Source/JavaScriptCore/jit/ThunkGenerators.cpp: (JSC::throwExceptionFromCallGenerator): (JSC::polymorphicThunkFor): * Source/JavaScriptCore/jit/ThunkGenerators.h: * Source/JavaScriptCore/runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildrenImpl): * Source/JavaScriptCore/runtime/JSGlobalObject.h: (JSC::JSGlobalObject::handleHostCallExceptionCallee const): * Source/JavaScriptCore/runtime/VMInlines.h: (JSC::VM::topJSCallFrame const): Canonical link: https://commits.webkit.org/272816@main
49b120d
to
e94a54e
Compare
Committed 272816@main (e94a54e): https://commits.webkit.org/272816@main Reviewed commits have been landed. Closing PR #22528 and removing active labels. |
e94a54e
49b120d
π§ͺ mac-wk2