Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -631,10 +631,24 @@ below. See `test/interop/test_add_function_post.js <https://github.com/emscripte
Function Signatures
===================

The LLVM Wasm backend requires a Wasm function signature string when using
``addFunction`` and in JavaScript libraries. Each character within a signature
string represents a type. The first character represents the return type of a
function, and remaining characters are for parameter types.
In JavaScript, signatures of functions can be declared with the ``__sig``
decorator. This is optional by default, but is required in the following
scenarios:

- When the function uses the ``__i53abi`` decorator.
- When the function uses the ``__async`` decorator with a list of variants
(e.g. ``__async: ['auto', 'promise']``).
- When building for wasm64 (``-m64``) or with more than 2GB of memory (e.g.
``-sMAXIMUM_MEMORY=4GB``), so that pointer arguments and return values are
converted correctly (when not manually converting pointers to indices).
- When the function is used from dynamically linked code (``-sMAIN_MODULE``).

A signature string is also required as the second argument when passing a
JavaScript function to ``addFunction``.

Each character within a signature string represents a type. The first
character represents the return type of a function, and remaining characters
are for parameter types.

- ``'v'``: void type
- ``'i'``: 32-bit integer type
Expand Down
Loading