emscripten-core / emscripten-core/emscripten

wasm64 + EM_JS requires special handling for pointer types (and long and size_t)

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

Description

Under wasm64 pointer types (and long and size_t) get passed as BigInt.

This means that EM_JS functions that take or return pointers will most likely need modifications (since BigInt and Number in JS are not generally compatible).

Should we try to find a way to avoid this type of thing:

```
EM_JS(char*, return_ptr, (void), {
#if __wasm64__
return BigInt(addressAsNumber);
#else
return addressAsNumber;
#endif
});
```

For JS library functions have use the `__sig` metadata to encode certain arguments and return values are being "pointers" which means that get cooerced to Number/int53 in the JS glue code.

Should we do that same for EM_JS?

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.