eh_artiq: handle catch clauses appropriately #161
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/artiq-zynq#161
Loading…
Reference in New Issue
No description provided.
Delete Branch "pca006132/artiq-zynq:master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Should be used together with https://github.com/m-labs/artiq/tree/landingpad
The code for the personality function and some of the DWARF decoding code is modified from gcc eh personality https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/libsupc%2B%2B/eh_personality.cc#L359
Previously, we always emit
cleanup=True
, executing every catch block when we unwind the stack. With this patch, we only emitcleanup=True
when we really have a cleanup, i.e. a finally block. The personality function will compare the clauses and determine when to execute the catch block, resulting in about 20% performance improvement in a microbenchmark with a 1000 level of nested try catch (that does not match the raised exception).There are still some part that I am not sure for this patch, but at least this passed all tests. I am not sure if this can be simply ported to riscv or requires some modification, as the exception handlings ABI should be different (this is EHABI). But I guess the overall code should be similar.
Is it backward compatible though?
Why the "libunwind: enable lto" commit?
The compiler change: Yes, it should be. The original firmware will run the clause anyway during unwind, so the behavior should be the same.
These two changes (both compiler and firmware) would enable more efficient and idiomatic unwinding behavior, matching the LLVM documentation regarding exception handling.
Using the old compiler with this firmware would have issue due to differences in handling the
except
clause: the old one would emit a name but this patch expects a null pointer.Enabling LTO improves the performance a bit, I thought this is a separate thing to do so I separated it into another commit.
And what about new compiler (i.e. with the landingpad change) with old firmware (i.e. without this change)?
If that doesn't work, we cannot merge until RISC-V is fixed.
New compiler with old firmware should be fine. I haven't yet tested it though.
OK, let's merge after testing.