Skip to content

Nontrapping variants of certain instructions? #986

Open
@juj

Description

@juj

In Emscripten, having the ability to build libraries that avoid trapping in certain common situations is an important ability (emscripten-core/emscripten#4625 for some background). Currently integer division and modulus operations as well as float to int conversion can cause traps to occur.

Emscripten features a build mode which adds checks for the trap conditions before doing the potentially trapping operation. However this has both a runtime performance impact and a generated code size impact. The performance impact is currently showing as a few % hotspot in compiled Unreal Engine 4 pages, especially in the float->int conversion, and the engine has a relatively large number of locations in its third party libraries where they benignly do casting of out of range floats to integers, which would trap, and changing all the code locations is not feasible.

It would be useful to have non-trapping variants of these instructions in the language itself, so a Wasm implementation could help efficiently implement this support. (This is btw the only so far noticed performance regression when migrating from asm.js to wasm)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions