Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some information about 'j' and 'p' types and function signatures #22562

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

goldwaving
Copy link
Contributor

This information needs to be reviewed by someone with deeper knowledge about function signatures, __i53abi, and WASM_BIGINT.

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.
When using ``addFunction`` on the LLVM Wasm backend, you need to provide
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove on the LLVM Wasm backend here? there is no other backend anymore.

Instead how about When using ``addFunction`` with a JavaScript function, you need to...

For example, if you add a function that takes an integer and does not return
anything, the signature is ``'vi'``.

``'j'`` must be used with the ``__i53abi`` decorator. It simplifies passing 64-bit numbers in JavaScript libraries. It cannot be used with ``addFunction``. Here is an example of a library function that sets the size of a file using a 64-bit value and returns
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When j is used there are several ways in which the parameter value will be passed to JavaScript. By default the value will either be passed as a single bigint or a pair of JavaScript numbers (double) depending on whether the WASM_BIGINT settings is enabled. In addition, if you only require 53bits of precision you can add the __i53abi decorator, which will ignore the upper bits of the i64 and the value will be recieved as a single JavaScript number (double).

@@ -622,7 +622,7 @@ See `test_add_function in test/test_core.py`_ for an example.
You should build with ``-sALLOW_TABLE_GROWTH`` to allow new functions to be
added to the table. Otherwise by default the table has a fixed size.

When using ``addFunction`` on the LLVM Wasm backend, you need to provide
When using ``addFunction`` with JavaScript function, you need to provide
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with a JavaScript function?

@@ -647,8 +647,7 @@ parameter types.
For example, if you add a function that takes an integer and does not return
anything, the signature is ``'vi'``.

``'j'`` must be used with the ``__i53abi`` decorator. It simplifies passing 64-bit numbers in JavaScript libraries. It cannot be used with ``addFunction``. Here is an example of a library function that sets the size of a file using a 64-bit value and returns
an integer error code:
When ``'j'`` is used there are several ways in which the parameter value will be passed to JavaScript. By default the value will either be passed as a single BigInt or a pair of JavaScript numbers (double) depending on whether the ``WASM_BIGINT`` settings is enabled. In addition, if you only require 53 bits of precision you can add the ``__i53abi`` decorator, which will ignore the upper bits and the value will be received as a single JavaScript number (double). It cannot be used with ``addFunction``. Here is an example of a library function that sets the size of a file using a 64-bit value passed as a 53 bit (double) and returns an integer error code:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you format this paragraph with line breaks at 80 columns?

@@ -647,7 +647,15 @@ parameter types.
For example, if you add a function that takes an integer and does not return
anything, the signature is ``'vi'``.

When ``'j'`` is used there are several ways in which the parameter value will be passed to JavaScript. By default the value will either be passed as a single BigInt or a pair of JavaScript numbers (double) depending on whether the ``WASM_BIGINT`` settings is enabled. In addition, if you only require 53 bits of precision you can add the ``__i53abi`` decorator, which will ignore the upper bits and the value will be received as a single JavaScript number (double). It cannot be used with ``addFunction``. Here is an example of a library function that sets the size of a file using a 64-bit value passed as a 53 bit (double) and returns an integer error code:
When ``'j'`` is used there are several ways in which the parameter value will
be passed to JavaScript. By default the value will either be passed as a
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comma after "By default"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants