Skip to content

[exception-optimizer] Mark functions as noexcept if sad path always leads to terminate #8

Description

@kammce

The idea would be, after generating the final binary, the exception analyzer can provide a list of functions that, when an exception is thrown, will always result in termination. So for example, consider main calls A() -> B() -> C(). There are not try/catch blocks in main for when A is called, and A does not have a try catch block. B and C can throw. If the exception unwinder sees its in C or B, is there a way to tell it that there is no use in proceeding, ensuring that we terminate very fast.

Those functions were not declared as "strongly" noexcept in the source code, but the function itself is de-facto noexcept given what I stated above. Noexcept includes main or functions passed to std::thread. If such functions are spotted, mark them as noexcept (0x1) in the exception index. When performing the re-ordering of the functions, ensure that the noexcept functions are merged into a single section to ensure that only one exception index entry is required for all noexcept functions. This should greatly reduce the exception index if enough functions are found with this property, which helps to reduce the cost of using a binary search to find the entry in the table, and likely will cause the lookup of the noexcept functions to be and immediate near point estimation.

This is a bit of a flow of consciousness but I wanted to ensure that I got this down before I forgot. Thanks to Mark for giving me the idea of this optimization.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions