-
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
Refactor unwind generation in Cranelift. #1466
Refactor unwind generation in Cranelift. #1466
Conversation
Subscribe to Label ActionThis issue or pull request has been labeled: "cranelift", "wasmtime:api" Users Subscribed to "cranelift"Users Subscribed to "wasmtime:api"To subscribe or unsubscribe from this label, edit the |
06b1982
to
b8fd0c9
Compare
Refactoring to fix the arm64 build error in the file test utility. |
913fce4
to
6c4e0a3
Compare
This will need some additional changes with recently merged PRs to get working again. I'll see to it on Monday. |
6c4e0a3
to
f85840a
Compare
This should now be ready for review again after merging in the FPR changes for Windows unwind information. |
de9c612
to
0604841
Compare
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.
Overall, it looks fine, except __register_frame piece. @alexcrichton and I talked about using perhaps __register_frame_table
where it is available (?), e.g. macosx source code says it is not available there.
I'll see about implementing |
(Redirecting review to @yurydelendik who seemed to have a first look already; please let me know if I need to look at this as well!) |
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
The change is required around __deregister_frame
as well.
@yurydelendik is it required around |
This commit makes the following changes to unwind information generation in Cranelift: * Remove frame layout change implementation in favor of processing the prologue and epilogue instructions when unwind information is requested. This also means this work is no longer performed for Windows, which didn't utilize it. It also helps simplify the prologue and epilogue generation code. * Remove the unwind sink implementation that required each unwind information to be represented in final form. For FDEs, this meant writing a complete frame table per function, which wastes 20 bytes or so for each function with duplicate CIEs. This also enables Cranelift users to collect the unwind information and write it as a single frame table. * For System V calling convention, the unwind information is no longer stored in code memory (it's only a requirement for Windows ABI to do so). This allows for more compact code memory for modules with a lot of functions. * Deletes some duplicate code relating to frame table generation. Users can now simply use gimli to create a frame table from each function's unwind information. Fixes bytecodealliance#1181.
This commit moves the opaque definition of Windows x64 UnwindInfo out of the ISA and into a location that can be easily used by the top level `UnwindInfo` enum. This allows the `unwind` feature to be independent of the individual ISAs supported.
This commit removes a panic when a register mapping fails and instead returns an error from creating the unwind information.
8415d6f
to
6207a43
Compare
Good question. I would expect the api be "symmetrical", means that if whatever is fed to __register_frame shall be passed to __deregister_frame. (FWIW this hole API confusing) Is it possible to check if 1) the current __deregister_frame code de-registers FDEs; 2) does not add additional O(n^2) complexity for gcc unwind ? |
I agree that the underlying API here is a mess. The code I have now should cause symmetrical invocations of From what I can decipher of the registration code in libgcc, What libgcc is calling a "frame table" for use with |
This commit calls `__register_frame` once for the entire frame table on Linux. On macOS, it still manually walks the frame table and registers each frame with `__register_frame`.
6207a43
to
4d7a283
Compare
Yeah, that confirms my analysis as well. Thanks. I guess we good to go. 👍 |
use serde::{Deserialize, Serialize}; | ||
|
||
type Register = u16; | ||
type Expression = Vec<u8>; |
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.
FYI, gimli::write::Expression
is no longer a simple Vec<u8>
after gimli-rs/gimli#479, so this isn't going to work.
It seems like you don't actually need impl From<gimli::write::CallFrameInstruction> for CallFrameInstruction
though, so it would be possible to simply delete all the Expression
support. If you do need to support expressions, then you'll need to come up with your own serializable version of them. gimli's expressions are used for other debug sections too, thus they potentially have references to DIEs and can't be individually serialized.
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.
See philipc@103d68d for the changes I think are needed. I can open a PR once a new gimli version is released.
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.
@philipc thanks for the heads up! When we update gimli, I think we can work around this by removing expression support from this representation since we don't need it to describe our frames currently.
This PR makes the following changes to unwind information generation in
Cranelift:
Remove frame layout change implementation in favor of processing the prologue
and epilogue instructions when unwind information is requested. This also
means this work is no longer performed for Windows, which didn't utilize it.
It also helps simplify the prologue and epilogue generation code.
Remove the unwind sink implementation that required each unwind information
to be represented in final form. For FDEs, this meant writing a
complete frame table per function, which wastes 20 bytes or so for each
function with duplicate CIEs. This also enables Cranelift users to collect the
unwind information and write it as a single frame table.
For System V calling convention in Wasmtime, the unwind information is no longer stored
in code memory (it's only a requirement for Windows ABI to do so). This allows
for more compact code memory for modules with a lot of functions.
Deletes some duplicate code relating to frame table generation. Users can
now simply use gimli to create a frame table from each function's unwind
information.
Fixes #1181.