emscripten-core / emscripten-core/emscripten

Directly export functions with i64 in parameter list

Open
#20,122 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I'm writing a dynamic recompiler that targets WebAssembly, and a particular problem that I have is that exported functions (i.e., callable from JavaScript) taking or receiving an i64 within their parameter lists are converted into ones that take in i32. I understand this is desirable behavior if you're calling from JS, but I'm curious if there's a way to expose these functions in their original state.

My use case is that the WASM modules that I create sometime need to call back into compiled C code to perform some complicated operation. In native code, this would be achieved by a direct call, but in the WASM world I need to use a function import (which are Emscripten's exports). The problem is that while Emscripten does in fact emit those functions in their original state, they aren't exported.

To my knowledge, this "legalization" is performed [here](https://github.com/WebAssembly/binaryen/blob/main/src/passes/LegalizeJSInterface.cpp), within Binaryen. Is there a way to control the `exportOriginals` option from the command line?

My questions are:
- Is this possible?
- Does this incur overhead? (even though the call is wasm-->wasm, does it force the creation of BigInts anyways?)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.