mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 15:05:19 +00:00
Add architecture diagram for wasm globals and classic-interp stack frame (#2058)
This commit is contained in:
parent
09a2698bba
commit
b0f614d77a
|
@ -70,8 +70,8 @@ The following platforms are supported, click each link below for how to build iw
|
||||||
|
|
||||||
|
|
||||||
### Performance and memory
|
### Performance and memory
|
||||||
- [Blog: Understand WAMR heap](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-heap/)
|
- [Blog: The WAMR memory model](https://bytecodealliance.github.io/wamr.dev/blog/the-wamr-memory-model/)
|
||||||
- [Blog: Understand WAMR stacks](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-stacks/)
|
- [Blog: Understand WAMR heaps](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-heaps/) and [stacks](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-stacks/)
|
||||||
- [Blog: Introduction to WAMR running modes](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-running-modes/)
|
- [Blog: Introduction to WAMR running modes](https://bytecodealliance.github.io/wamr.dev/blog/introduction-to-wamr-running-modes/)
|
||||||
- [Memory usage tunning](./doc/memory_tune.md): the memory model and how to tune the memory usage
|
- [Memory usage tunning](./doc/memory_tune.md): the memory model and how to tune the memory usage
|
||||||
- [Memory usage profiling](./doc/build_wamr.md#enable-memory-profiling-experiment): how to profile the memory usage
|
- [Memory usage profiling](./doc/build_wamr.md#enable-memory-profiling-experiment): how to profile the memory usage
|
||||||
|
|
|
@ -6,3 +6,9 @@
|
||||||
|
|
||||||
## Exports
|
## Exports
|
||||||
- [Wasm export architecture](./doc/wasm_exports.MD)
|
- [Wasm export architecture](./doc/wasm_exports.MD)
|
||||||
|
|
||||||
|
## globals
|
||||||
|
- [Wasm globals architecture](./doc/wasm_globals.MD)
|
||||||
|
|
||||||
|
## classic interpreter
|
||||||
|
- [classic interpreter](./doc/classic_interpreter.MD)
|
5
core/iwasm/doc/classic_interpreter.MD
Normal file
5
core/iwasm/doc/classic_interpreter.MD
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Classic interpreter
|
||||||
|
|
||||||
|
## stack format
|
||||||
|
|
||||||
|
![](./images/stack_format_ci.svg)
|
2643
core/iwasm/doc/images/stack_format_ci.excalidraw
Normal file
2643
core/iwasm/doc/images/stack_format_ci.excalidraw
Normal file
File diff suppressed because it is too large
Load Diff
16
core/iwasm/doc/images/stack_format_ci.svg
Normal file
16
core/iwasm/doc/images/stack_format_ci.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 112 KiB |
2313
core/iwasm/doc/images/wasm_globals.excalidraw
Normal file
2313
core/iwasm/doc/images/wasm_globals.excalidraw
Normal file
File diff suppressed because it is too large
Load Diff
16
core/iwasm/doc/images/wasm_globals.svg
Normal file
16
core/iwasm/doc/images/wasm_globals.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 53 KiB |
|
@ -3,3 +3,45 @@
|
||||||
## Internal data structure
|
## Internal data structure
|
||||||
|
|
||||||
![](./images/wasm_function.svg)
|
![](./images/wasm_function.svg)
|
||||||
|
|
||||||
|
## Module level data (function)
|
||||||
|
**WASMModule**: Data structure created for loading a module.
|
||||||
|
- `WASMImport *import_functions`: initialized from the Wasm file function section
|
||||||
|
- `WASMImport *import_functions`: initialized from the Wasm file import section. The runtime will try to solve the imports from the native API registration, refer to [Export native API to WASM application](../../../doc/export_native_api.md).
|
||||||
|
|
||||||
|
**WASMFunction**: represent a Wasm function located in Wasm file code section. Track the links to the compiled function body.
|
||||||
|
**WASMImport**: represent a imported Wasm function which can be a solved as a native function or another Wasm module exported function.
|
||||||
|
|
||||||
|
## Instance level data (function)
|
||||||
|
**WASMModuleInstance**: Data structure created for instantiating a module
|
||||||
|
- `WASMModuleInstanceExtra::functions`: combined the imported and internal functions into single array of structure `WASMFunctionInstance`
|
||||||
|
- `WASMModuleInstance::import_func_ptrs`: pointer array for solved function imports. This array is referred during calling imported native function. Note it is initialzed with the module level solved imports, but may points to different native function later due to c-api calls.
|
||||||
|
|
||||||
|
## Execution paths
|
||||||
|
**Interpreter**:
|
||||||
|
- Execute internal bytecode function:
|
||||||
|
```
|
||||||
|
WASMModuleInstance::e
|
||||||
|
-> WASMModuleInstanceExtra::functions[..]
|
||||||
|
-> WASMFunctionInstance::func
|
||||||
|
-> WASMFunction::code
|
||||||
|
```
|
||||||
|
|
||||||
|
- Execute imported function from other module:
|
||||||
|
```
|
||||||
|
WASMModuleInstance::e
|
||||||
|
-> WASMModuleInstanceExtra::functions[..]
|
||||||
|
(WASMFunctionInstance flag indicates an import)
|
||||||
|
-> WASMFunctionInstance::import_func_inst
|
||||||
|
-> WASMModuleInstance(second)::func
|
||||||
|
-> WASMFunction (second module)::code
|
||||||
|
```
|
||||||
|
|
||||||
|
- Execute imported native function:
|
||||||
|
```
|
||||||
|
WASMModuleInstance::e
|
||||||
|
-> WASMModuleInstanceExtra::functions[..]
|
||||||
|
(flag indicates imported native)
|
||||||
|
WASMModuleInstance::import_func_ptrs[..]
|
||||||
|
-> native function
|
||||||
|
```
|
4
core/iwasm/doc/wasm_globals.MD
Normal file
4
core/iwasm/doc/wasm_globals.MD
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# Wasm globals
|
||||||
|
|
||||||
|
![](./images/wasm_globals.svg)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Memory model and memory usage tunning
|
# Memory model and memory usage tunning
|
||||||
|
|
||||||
References:
|
References:
|
||||||
- [Blog: Understand WAMR heap](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-heap/)
|
- [Blog: Understand WAMR heap](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-heaps/)
|
||||||
- [Blog: Understand WAMR stacks](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-stacks/)
|
- [Blog: Understand WAMR stacks](https://bytecodealliance.github.io/wamr.dev/blog/understand-the-wamr-stacks/)
|
||||||
|
|
||||||
## The memory model
|
## The memory model
|
||||||
|
|
Loading…
Reference in New Issue
Block a user