Skip to content

Use only one personality function instead of 2 on Unix #34786

Closed
@alexcrichton

Description

@alexcrichton

Right now we have two personality functions:

  • rust_eh_personality
  • rust_eh_personality_catch

The rationale is described in length here, but the gist is that we're currently "too lazy" to parse DWARF metadata, so we use rust_eh_personality for "all Rust functions in the world" and rust_eh_personality_catch for the one function allowed to catch a panic. The former personality simply runs all cleanups, and the latter personality simply catches all Rust exceptions.

This split makes it easy for us to define, but when a personality is run it should also have access to DWARF metadata about the call site it's running for. This metadata should indicate whether it's intended to catch or not, so we should in theory be able to read out the DWARF metadata and figure out what to do, allowing us to have one personality function instead of two.

The major downside of having two personality functions is that LLVM is unable to inline two functions that have different personalities. This unfortunately means that catch_unwind can have performance problems if we don't inline enough. We're currently using zero-cost exceptions on Unix, but what we're actually doing unfortunately isn't zero cost!

This is only one piece of the puzzle towards fixing the performance issues mentioned, but it's an important one!

cc @vadimcn

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions