mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-21 20:50:51 +00:00
Previously `wasm-bindgen` would take its `breaks_if_inlined` shims and attempt to remove them entirely, replacing calls to `breaks_if_inlined` to the imported closure factories. This worked great in that it would remove the `breaks_if_inlined` funtion entirely, removing the "cost" of the `#[inline(never)]`. Unfortunately as #864 discovered this is "too clever by half". LLVM's aggressive optimizations won't inline `breaks_if_inlined`, but it may still change the ABI! We can't replace calls to `breaks_if_inlined` if the signature changes, because the function its calling has a fixed signature. This commit cops out a bit and instead of replacing calls to `breaks_if_inlined` to the imported closure factories, we instead rewrite calls to `__wbindgen_describe_closure` to the closure factories. This means that the `breaks_if_inlined` shims do not get removed. It also means that the closure factory shims have a third and final argument (what would be the function pointer of the descriptor function) which is dead and unused. This should be a functional solution for now and let us iterate on a true fix later on (if needed). For now the cost of this `#[inline(never)]` and the extra unused argument should be quite small. Closes #864