-
Notifications
You must be signed in to change notification settings - Fork 623
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
Enhance wasm with checkpoint and restore support (#2333) #3289
Open
victoryang00
wants to merge
19
commits into
bytecodealliance:dev/checkpoint_and_restore
Choose a base branch
from
victoryang00:main
base: dev/checkpoint_and_restore
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0f7ec2e
Enhance wasm with checkpoint and restore support (#2333)
victoryang00 5070370
Merge branch 'dev/checkpoint_and_restore' into main
victoryang00 8aee5a7
lldb_function_to_function_dbi: A hack to avoid crashing on C++ method…
yamt 71cb447
Revert PR #3194 (#3199)
lum1n0us 62a1a18
Get location info from function indexes in addr2line script (#3206)
eloparco 5eb4ebf
Refactor APIs and data structures as preliminary work for Memory64 (#…
wenyongh defcae8
trans_wasm_func_name.py: Correct function index during translation (#…
lum1n0us e55babb
Add CodeQL Workflow for Code Security Analysis (#2812)
b4yuan 90a5976
CodeQL: Add more build combinations and disable run on PR (#3246)
wenyongh de59190
Implement memory64 for classic interpreter (#3266)
wenyongh 96ffe8f
Revert "lldb_function_to_function_dbi: A hack to avoid crashing on C+…
yamt 6956e0a
Enhance wasm loading with LoadArgs and support module names (#3265)
lum1n0us ce83313
thread mgr: Free aux stack only when it was allocated (#3282)
wenyongh 5839425
Update version number to 2.0.0 and update release notes (#3327)
wenyongh 1acd123
Add wasm_runtime_detect_native_stack_overflow_size (#3355)
yamt 6952a12
Enhance wasm with checkpoint and restore support (#2333)
victoryang00 9096c84
Merge branch 'dev/checkpoint_and_restore' into main
victoryang00 beb9858
Merge branch 'dev/checkpoint_and_restore' into main
victoryang00 b7a26c2
fix staging error
victoryang00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ | |
#if WASM_ENABLE_THREAD_MGR != 0 | ||
#include "../libraries/thread-mgr/thread_manager.h" | ||
#endif | ||
#if WASM_ENABLE_CHECKPOINT_RESTORE != 0 | ||
#include "../libraries/ckpt-restore/ckpt_restore.h" | ||
#endif | ||
|
||
/* | ||
* Note: These offsets need to match the values hardcoded in | ||
|
@@ -2857,6 +2860,15 @@ aot_call_indirect(WASMExecEnv *exec_env, uint32 tbl_idx, uint32 table_elem_idx, | |
} | ||
|
||
tbl_elem_val = ((table_elem_type_t *)tbl_inst->elems)[table_elem_idx]; | ||
#if WASM_ENABLE_CHECKPOINT_RESTORE != 0 | ||
if (exec_env->is_restore && exec_env->restore_call_chain) { | ||
struct AOTFrame *rcc = *(exec_env->restore_call_chain); | ||
while (rcc->prev_frame) { | ||
rcc = rcc->prev_frame; | ||
} | ||
func_idx = rcc->func_index; | ||
} | ||
#endif | ||
if (tbl_elem_val == NULL_REF) { | ||
aot_set_exception_with_id(module_inst, EXCE_UNINITIALIZED_ELEMENT); | ||
goto fail; | ||
|
@@ -3529,6 +3541,12 @@ get_func_name_from_index(const AOTModuleInstance *module_inst, | |
#endif /* end of WASM_ENABLE_DUMP_CALL_STACK != 0 || \ | ||
WASM_ENABLE_PERF_PROFILING != 0 */ | ||
|
||
void | ||
aot_raise(WASMExecEnv *exec_env, int sig) | ||
{ | ||
raise(sig); | ||
} | ||
|
||
#if WASM_ENABLE_GC == 0 | ||
bool | ||
aot_alloc_frame(WASMExecEnv *exec_env, uint32 func_index) | ||
|
@@ -3608,6 +3626,9 @@ aot_free_frame(WASMExecEnv *exec_env) | |
bool | ||
aot_alloc_frame(WASMExecEnv *exec_env, uint32 func_index) | ||
{ | ||
#if WASM_ENABLE_CHECKPOINT_RESTORE != 0 | ||
LOG_DEBUG("aot_alloc_frame %u thread %d\n", func_index, exec_env->handle); | ||
#endif | ||
AOTModuleInstance *module_inst = (AOTModuleInstance *)exec_env->module_inst; | ||
AOTModule *module = (AOTModule *)module_inst->module; | ||
#if WASM_ENABLE_PERF_PROFILING != 0 | ||
|
@@ -3617,6 +3638,27 @@ aot_alloc_frame(WASMExecEnv *exec_env, uint32 func_index) | |
AOTFrame *frame; | ||
uint32 max_local_cell_num, max_stack_cell_num, all_cell_num; | ||
uint32 aot_func_idx, frame_size; | ||
#if WASM_ENABLE_CHECKPOINT_RESTORE != 0 | ||
if (exec_env->restore_call_chain) { | ||
frame = exec_env->restore_call_chain[exec_env->call_chain_size - 1]; | ||
LOG_DEBUG("frame restored, func idx %zu\n", frame->func_index); | ||
exec_env->call_chain_size--; | ||
frame->prev_frame = (AOTFrame *)exec_env->cur_frame; | ||
exec_env->cur_frame = (struct WASMInterpFrame *)frame; | ||
if (exec_env->call_chain_size == 0) { | ||
// TODO: fix memory leak | ||
exec_env->restore_call_chain = NULL; | ||
} | ||
LOG_DEBUG("restore call chain %zu==%u, %p, %p, %d\n", | ||
((AOTFrame *)exec_env->cur_frame)->func_index, func_index, | ||
exec_env, exec_env->restore_call_chain, exec_env->handle); | ||
if (((AOTFrame *)exec_env->cur_frame)->func_index != func_index) { | ||
LOG_DEBUG("NOT MATCH!!!\n"); | ||
exit(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had better not exit, can we just |
||
} | ||
return true; | ||
} | ||
#endif | ||
|
||
if (func_index >= module->import_func_count) { | ||
aot_func_idx = func_index - module->import_func_count; | ||
|
@@ -3648,6 +3690,11 @@ aot_alloc_frame(WASMExecEnv *exec_env, uint32 func_index) | |
frame->time_started = (uintptr_t)os_time_thread_cputime_us(); | ||
frame->func_perf_prof_info = func_perf_prof; | ||
#endif | ||
frame->ip_offset = 0; | ||
frame->sp = frame->lp + max_local_cell_num; | ||
#if WASM_ENABLE_GC != 0 | ||
frame->frame_ref = frame->sp + max_stack_cell_num; | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated code as below, how about: #if WASM_ENABLE_GC != 0 || WASM_ENALBE_CHECKPOINT_RESTORE != 0
frame->sp = frame->lp + max_local_cell_num;
frame->frame_ref = (uint8 *)(frame->sp + max_stack_cell_num);
#endif |
||
|
||
#if WASM_ENABLE_GC != 0 | ||
frame->sp = frame->lp + max_local_cell_num; | ||
|
@@ -3664,6 +3711,10 @@ aot_alloc_frame(WASMExecEnv *exec_env, uint32 func_index) | |
static inline void | ||
aot_free_frame_internal(WASMExecEnv *exec_env) | ||
{ | ||
#if WASM_ENABLE_CHECKPOINT_RESTORE != 0 | ||
int func_index = ((AOTFrame *)exec_env->cur_frame)->func_index; | ||
LOG_DEBUG("aot_free_frame %zu %d\n", func_index, exec_env->handle); | ||
#endif | ||
AOTFrame *cur_frame = (AOTFrame *)exec_env->cur_frame; | ||
AOTFrame *prev_frame = cur_frame->prev_frame; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Had better wrapp a function named
os_raise
in the platform layer in core/shared/platform/xxx, and if it isn't implemented, we can just#define os_raise(sig) (void)0
, so as to avoid compilation error in some platforms.