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

store wasm globals in execution context such that a single parsed module can be shared by multiple threads #16

Merged
merged 4 commits into from
Jul 26, 2023

Conversation

linh2931
Copy link
Member

Resolves #7.
A part of eosnetworkfoundation/product#149.

Currently globals are stored in a compiled module. This prevents the module from being shared by multiple execution threads, as multiple threads can modify the same global. To enable the same compiled module to be shared,
globals are moved out of module and into the execution context.

This opens possibilities for further parallelism and memory reduction for cached instantiated modules.

Change Description

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

include/eosio/vm/execution_context.hpp Show resolved Hide resolved
include/eosio/vm/execution_context.hpp Show resolved Hide resolved
auto& gl = _mod.globals[globalidx];
void *ptr = &gl.current.value;
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for using get_global_* and set_global_* instead of just _globals[globalidx].value ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there a reason for using get_global_* and set_global_* instead of just _globals[globalidx].value ?

At the time when emit_get_global and emit_set_global are called, execution_conetxt is not constructed yet; we don't have access to _globals. We also want to decouple the generated instructions from physical address of execution_context.

include/eosio/vm/execution_context.hpp Show resolved Hide resolved
@linh2931 linh2931 merged commit 4d5415f into main Jul 26, 2023
10 checks passed
@linh2931 linh2931 deleted the make_globals_threaded_safe branch July 26, 2023 21:18
@linh2931 linh2931 mentioned this pull request Jul 27, 2023
2 tasks
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.

Make compiled module sharable in multi-threaded EOS-VM-Interpreter and EOS-VM-Jit execution
3 participants