-
Notifications
You must be signed in to change notification settings - Fork 17
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
Feature/m0081 meja 2367 linear mem and sni review #1186
base: feature/M0081MEJA-2367_managedc
Are you sure you want to change the base?
Feature/m0081 meja 2367 linear mem and sni review #1186
Conversation
… by its module name
Co-authored-by: agazardMicroeJ <[email protected]>
Co-authored-by: agazardMicroeJ <[email protected]>
Co-authored-by: agazardMicroeJ <[email protected]>
put back the "call" Java to C and C to Java that can be directly linked
Co-authored-by: agazardMicroeJ <[email protected]>
…tdlib linker option
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.
overall, it is unclear to me how to configure the linear memory for microej
|
||
Given the following Wasm module: | ||
|
||
.. code:: wat |
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 possible, I prefer to keep managed C here instead of wat file.
how to we define the number of pages using clang ?
|
||
Wasm linear memory is a contiguous, byte-addressable memory region used in Wasm programs. | ||
It is the main mechanism through which a Wasm module manages its memory and exchanges data with :ref:`the host <managedc.communication.managedc_memory>`. | ||
This memory is represented as an array of bytes, indexed starting at zero, and is :ref:`dynamically resizable <managedc.instructions.partially_supported>`. |
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.
In our case this is false (see memory.grow), and maybe this is in fact a feature and we will let it as-is.
To be reworded in this direction.
|
||
To minimize the size of allocated memory, a Wasm module should: | ||
|
||
* Export the the Wasm global ``__heap_base``, using the linker option ``-Wl,--export=__heap_base`` like the following Wasm module, |
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.
Same, how to we reduce the page with clang ?
Is it using the clang compiler: -z stack-size=n
, but in this case does it only affect the first page ?
(export "__heap_base" (global $heap_base)) | ||
) | ||
|
||
* Avoid using the ``memory.size`` and ``memory.grow`` instructions (do not use malloc/free function in the Managed C 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.
really ? OK maybe only for this example
|
||
The boundary between the auxiliary stack + the Static Data regions and the heap region is marked by the special Wasm global ``__heap_base`` | ||
|
||
Wasm Linear Memory Size |
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.
Wasm Linear Memory Size | |
Configure the Wasm Linear Memory Size |
(export "memory" (memory $mem)) | ||
) | ||
|
||
This linear memory of this module should have an initial Size of **2 pages** (128 KiB), and a maximum Size of **10 pages** (640 KiB). |
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.
This linear memory of this module should have an initial Size of **2 pages** (128 KiB), and a maximum Size of **10 pages** (640 KiB). | |
This linear memory of this module should have an initial size of **2 pages** (128 KB), and a maximum Size of **10 pages** (640 KB). |
Wasm Linear Memory Size | ||
----------------------- | ||
|
||
WebAssembly organizes linear memory in pages, where each page is **64 KiB** (65,536 bytes). |
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.
WebAssembly organizes linear memory in pages, where each page is **64 KiB** (65,536 bytes). | |
WebAssembly organizes linear memory in pages, where each page is **64 KB** (65,536 bytes). |
"updated": 1736414807618, | ||
"link": null, | ||
"locked": false, | ||
"text": "Grow downward", |
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.
"text": "Grow downward", | |
"text": "Grows downward", |
"updated": 1736414789926, | ||
"link": null, | ||
"locked": false, | ||
"text": "Grow upward", |
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.
"text": "Grow upward", | |
"text": "Grows upward", |
Build Without The Standard Library | ||
---------------------------------- | ||
|
||
The ``-nostdlib`` flag is a linker option used to exclude the standard library when building a program. |
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.
-nostdlib is not enough
We should put back the full compilet command line here
[path_to_wasi_sdk]/bin/clang -Wl,--no-entry -Wl,--export-all -Wl,--allow-undefined -nostdlib -o my_app.wasm my_app.o
@@ -34,14 +36,14 @@ In the terminal, navigate to the ``src/main/c`` directory and execute the follow | |||
|
|||
.. code:: console | |||
|
|||
[path_to_wasi_sdk]/bin/clang -Wl,--no-entry -Wl,--export-all -Wl,--allow-undefined -nostdlib -o my_app.wasm my_app.o | |||
[path_to_wasi_sdk]/bin/clang -Wl,--export-all -o my_app.wasm my_app.o |
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.
put back --no-entry
and -Wl,--allow-undefined
No description provided.