Skip to content

Implement unwinding #244

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

Merged
merged 14 commits into from
Jan 11, 2023
Merged

Implement unwinding #244

merged 14 commits into from
Jan 11, 2023

Conversation

antoyo
Copy link
Contributor

@antoyo antoyo commented Jan 8, 2023

No description provided.

src/builder.rs Outdated

let current_block = self.block.clone();
self.block = try_block;
let call = self.call(typ, func, args, None); // TODO: use funclet here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funclets are only for implementing SEH unwinding on Windows. GCC may or may not generate them automatically behind the scenes (in which case cg_ssa should be changed to not use funclets with GCC), but LLVM requires explicitly using them instead of landing pads when using SEH. In case you didn't know, funclets are kind of functions, except that they share the stack frame with another function. In SEH a funclet is called by the unwinder for every frame that needs cleanup, unlike on Unix where the unwinder moves the IP to a landingpad and then returns, the landingpad then tail calls back into the unwinder to continue with the next frame.

// TODO(bjorn3): Properly implement unwinding.
fn resume(&mut self, exn: RValue<'gcc>) {
// TODO: check if this is normal that we need to dereference the value.
let exn = exn.dereference(None).to_rvalue();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exn here should be a struct forming a pair with the same values as the landing pad returned. By the way in the latest rustc I changed cleanup_landing_pad and resume to return/accept two separate values rather than a single pair value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I haven't sync with rustc for a while because I was having issues. I'll try to do it soon.

@antoyo antoyo force-pushed the feature/unwinding branch from 081c63a to ea75295 Compare January 10, 2023 00:41
@antoyo antoyo merged commit 6c5a70d into master Jan 11, 2023
@antoyo antoyo deleted the feature/unwinding branch January 11, 2023 05:24
@bjorn3
Copy link
Member

bjorn3 commented Jan 11, 2023

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants