-
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
Migrate libcalls to checking for traps #9710
Migrate libcalls to checking for traps #9710
Conversation
// Under fuel limits branch. | ||
self.masm.bind(continuation); | ||
self.context.free_reg(fuel_var); |
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.
Similarly @saulecabrera I had to move this up since fuel_var
was assigned rax but rax was needed as the return value of the hostcall, so this was needed to fix some panics during compilation.
Subscribe to Label Actioncc @fitzgen
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:ref-types"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
065edd4
to
c10f692
Compare
Does this significantly change overall code size of Cranelift-generated code, due to needing inline trap check code at each libcall callsite? |
Yes as-is all libcalls that can trap have a check after them, so it's inflating code by at least that much. In thinking though this can be pretty easily optimized. We already generate a trampoline-per-libcall so I'll move the check-for-trap logic to the trampoline instead of the callsite of the trampoline. |
Ok I've updated this where the trampoline itself now checks for a trap, so the code size impact on wasm itself should be minimal. |
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.
LGTM modulo one comment below
This commit is the equivalent of bytecodealliance#9675 for libcalls used in core wasm. All libcalls now communicate whether or not they trapped through their return value instead of implicitly calling `longjmp` to exit from the libcall. This is to make integration with Pulley easier to avoid the need to `longjmp` over Pulley execution. Libcall definitions have changed where appropriate and the `catch_unwind_and_record_trap` function introduced in bytecodealliance#9675 was refactored to better support multiple types of values being returned from libcalls (instead of just `Result<()>`). Note that changes have been made to both the Cranelift translation layer and the Winch translation layer for this as the ABI of various libcalls are all changing.
5e10e06
to
6470dfd
Compare
This PR is the equivalent of #9675 for libcalls used in core wasm and components.
All libcalls now communicate whether or not they trapped through their
return value instead of implicitly calling
longjmp
to exit from thelibcall. This is to make integration with Pulley easier to avoid the
need to
longjmp
over Pulley execution.Libcall definitions have changed where appropriate and the
catch_unwind_and_record_trap
function introduced in #9675 wasrefactored to better support multiple types of values being returned
from libcalls (instead of just
Result<()>
).Note that changes have been made to both the Cranelift translation layer
and the Winch translation layer for this as the ABI of various libcalls
are all changing.