Skip to content

Remove exception check after calling func in AOTed code when hw bound check is enabled #1715

@wenyongh

Description

@wenyongh

In current design, after calling a function in LLVM JITed/AOTed code, the caller will check whether the exception was thrown, no matter whether hw bound check is enabled or not, this introduces the compare and condition jump instructions. Theoretically we can disable it and use guard page for the exception check instead when hw bound check is enabled:

  • Create a guard page for the module_inst or exec_env, when wasm_set_exception, after setting the module_inst->cur_exception, let runtime access the guard page, so as to trigger the signal handler
  • In the signal handler, handle the exception, and longjmp into to the setjmp place to exit

By this way, we can reduce the check instructions in the caller, normally it can improve the performance. Experiments show that many cases can get performance improvement and few cases get a little perf drop, e.g. CoreMark.

Another benefit is that it can speedup the LLVM JIT/AOT compilation.

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