-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
base: main
Are you sure you want to change the base?
Conversation
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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"
This information needs to be reviewed by someone with deeper knowledge about function signatures, __i53abi, and WASM_BIGINT.