alexcrichton opened PR #4347 from component-lift-then-lower
to main
:
This commit implements the "degenerate" logic for implementing a
function within a component that is lifted and then immediately lowered
again. In this situation the lowered function will immediately generate
a trap and doesn't need to implement anything else.The implementation in this commit is somewhat heavyweight but I think is
probably justified moreso in future additions to the component model
rather than what exactly is here right now. It's not expected that this
"always trap" functionality will really be used all that often since it
would generally mean a buggy component, but the functionality plumbed
through here is hopefully going to be useful for implementing
component-to-component adapter trampolines.Specifically this commit implements a strategy where the
canon.lower
'd
function is generated by Cranelift and simply has a single trap
instruction when called, doing nothing else. The main complexity comes
from juggling around all the data associated with these functions,
primarily plumbing through the traps into theModuleRegistry
to
ensure that the globalis_wasm_trap_pc
function returnstrue
and at
runtime when we lookup information about the trap it's all readily
available (e.g. translating the trapping pc to aTrapCode
).<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton requested fitzgen for a review on PR #4347.
alexcrichton updated PR #4347 from component-lift-then-lower
to main
.
alexcrichton updated PR #4347 from component-lift-then-lower
to main
.
fitzgen submitted PR review.
fitzgen submitted PR review.
fitzgen created PR review comment:
I guess this is a pretty rare edge case, most components will have zero, not somthing we need to worry about optimizing.
fitzgen created PR review comment:
Can we compile a single always-trap function per signature?
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Nah yeah that makes sense and is easy enough to do. I've added deduplication at the "inliner" layer so byt the time it reaches the compilation in cranelift everything is already deduplicated.
alexcrichton updated PR #4347 from component-lift-then-lower
to main
.
alexcrichton has enabled auto merge for PR #4347.
alexcrichton merged PR #4347.
Last updated: Nov 22 2024 at 17:03 UTC