Skip to content

Refactor interpreter/AOT module instance layout #1559

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

Merged
merged 9 commits into from
Oct 18, 2022

Conversation

wenyongh
Copy link
Contributor

@wenyongh wenyongh commented Oct 6, 2022

Refactor the layout of interpreter and AOT module instance:

  • Unify the interp/AOT module instance, use the same WASMModuleInstance/
    WASMMemoryInstance/WASMTableInstance data structures for both interpreter
    and AOT
  • Make the offset of most fields the same in module instance for both interpreter
    and AOT, append memory instance structure, global data and table instances to
    the end of module instance for interpreter mode (like AOT mode)
  • For extra fields in WASM module instance, use WASMModuleInstanceExtra to
    create a field e for interpreter
  • Change the LLVM JIT module instance creating process, LLVM JIT uses the WASM
    module and module instance same as interpreter/Fast-JIT mode. So that Fast JIT
    and LLVM JIT can access the same data structures, and make it possible to
    implement the Multi-tier JIT (tier-up from Fast JIT to LLVM JIT) in the future
  • Unify some APIs: merge some APIs for module instance and memory instance's
    related operations (only implement one copy)

Note that the AOT ABI is same, the AOT file format, AOT relocation types, how AOT
code accesses the AOT module instance and so on are kept unchanged.

Refer to:
#1384

wenyongh and others added 9 commits September 7, 2022 16:48
Refactor layout of interpreter module instance, memory instance,
table instance and so on. Create the interpreter module instance
like aot module instance.
Let LLVM JIT use the interpreter's data structures instead of
aot's data structures, so as to make preparation for the next
multi-tier JIT.
Merge main into dev/refactor_interp_module_inst
Unify the data structure of wasm module instance and aot module instance:
- Use the same structure WASMModuleInstance for both interpreter and AOT
- For the extra fields, store them into WASMModuleInstanceExtra structure and
  add a field `e` in module instance
- For field which has different meaning for interpreter and AOT, use the structure
  of interpreter to define it, and convert it to actual type in AOT before using it

Refer to #1384.
Make AOT module instance's tables member same as interpreter module instance's,
so as to unify this field and prepare for the API unifying.
Decide to use the .aot content as the .wasm precompiled result:
- `wasm_module_serialize(...)` will return it
- `wasm_module_deserialize(...)` will load the precompiled content
as normal .aot file
Refer to #1384.
To unify the memory instantiate process for interpreter/AOT in the future.
Use a clone example to show
- cold start and warm start
- how to clone from wasm_module_t and bypass loading phase

It turns out that there is a strong requirement of almost everything in
wasm_instantiate() except funciton related if do a clone of
wasm_instance_t.

Since we tend to isolate user data in threads, it needs to malloc and initialie
  - global. WASMGlobalIntance and global data
  - memory. WAAMMemoryInstance, memory_data and heap
  - table. WASMTableInstance, table_data
  - exports. all global, memory and table
@wenyongh wenyongh merged commit a182926 into main Oct 18, 2022
wenyongh added a commit to wenyongh/wasm-micro-runtime that referenced this pull request Oct 18, 2022
Refactor interpreter/AOT module instance layout (bytecodealliance#1559)
@wenyongh wenyongh deleted the dev/refactor_interp_module_inst branch October 27, 2022 04:25
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
Refactor the layout of interpreter and AOT module instance:
- Unify the interp/AOT module instance, use the same WASMModuleInstance/
  WASMMemoryInstance/WASMTableInstance data structures for both interpreter
  and AOT
- Make the offset of most fields the same in module instance for both interpreter
  and AOT, append memory instance structure, global data and table instances to
  the end of module instance for interpreter mode (like AOT mode)
- For extra fields in WASM module instance, use WASMModuleInstanceExtra to
  create a field `e` for interpreter
- Change the LLVM JIT module instance creating process, LLVM JIT uses the WASM
  module and module instance same as interpreter/Fast-JIT mode. So that Fast JIT
  and LLVM JIT can access the same data structures, and make it possible to
  implement the Multi-tier JIT (tier-up from Fast JIT to LLVM JIT) in the future
- Unify some APIs: merge some APIs for module instance and memory instance's
  related operations (only implement one copy)

Note that the AOT ABI is same, the AOT file format, AOT relocation types, how AOT
code accesses the AOT module instance and so on are kept unchanged.

Refer to:
bytecodealliance#1384
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