Bug 251289 - vmEntryToJavaScript does not need to use the arity check entry.
Summary: vmEntryToJavaScript does not need to use the arity check entry.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Lam
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-01-27 13:30 PST by Mark Lam
Modified: 2023-01-27 19:42 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2023-01-27 13:30:37 PST
This is because we can tell the ProtoCallFrame to ensure that there is enough argument space to meet arity requirements instead.

With this, we can also make the following changes:

1. We no longer need to look up the arity check entry in JITCode.  Instead, we'll add a m_addressForCall CodePtr in the base JITCode which is common across all JITCode subclasses, and therefore can be accessed without a virtual call.  To enable this, we also change JITCodeWithCodeRef to not use a CodeRef.  Instead, we use the m_addressForCall CodePtr along with a m_executableMemory RefPtr in JITCodeWithCodeRef itself to track the equivalent information.

2. Remove JITCode::execute().  Clients will not call vmEntryToJavaScript directly instead.  Other than calling vmEntryToJavaScript, the other things that JITCode::execute() does are:

   a. Set vm.didEnterVM on exit.  The only client that doesn't already do this is Interpreter::executeCachedCall.  So, we'll just add it there.

   b. Change the return value of vmEntryToJavaScript to jsNull if an exception is present on exit.  I believe this was in to ensure that checkedReturn() does not complain.  The purpose of checkeReturn() is for a legacy reason: back then, we didn't have exception check validation to ensure that exceptions are checked in all the right places.  checkedReturn() adds an ASSERT to help ensure that we don't return a nullptr.  However, a null check doesn't really provide much of a guarantee that the return value is valid.  So, we'll just remove checkedReturn() especially since we now have exception check validation.

3. We also change the return paths in vmEntrytoJavaScript for errors and unhandled exceptions to always return jsUndefined.  This is not strictly needed but it is extremely low cost, and helps make debugging an unchecked exception easier (as opposed to returning whatever random value was in the register).
Comment 1 Radar WebKit Bug Importer 2023-01-27 13:30:59 PST
<rdar://problem/104759274>
Comment 2 Mark Lam 2023-01-27 13:51:29 PST
Pull request: https://github.com/WebKit/WebKit/pull/9254
Comment 3 EWS 2023-01-27 19:42:03 PST
Committed 259520@main (d814f4a60054): <https://commits.webkit.org/259520@main>

Reviewed commits have been landed. Closing PR #9254 and removing active labels.