Skip to content

Commit 9ff8052

Browse files
author
Georgii Rylov
committed
format
1 parent c8b8731 commit 9ff8052

1 file changed

Lines changed: 64 additions & 50 deletions

File tree

core/iwasm/aot/aot_runtime.c

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,32 +4105,37 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
41054105

41064106
#if WASM_ENABLE_DUMP_CALL_STACK != 0
41074107
void
4108-
aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data)
4108+
aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env,
4109+
const wasm_frame_callback frame_handler,
4110+
void *user_data)
41094111
{
4110-
/*
4111-
* Note for devs: please refrain from such modifications inside of aot_iterate_callstack
4112-
* - any allocations/freeing memory
4113-
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4114-
* exec_env->module_inst->module, pointers between stack's bottom and top_boundary
4115-
* For more details check wasm_iterate_callstack in wasm_export.h
4116-
*/
4117-
uint8* top_boundary = exec_env->wasm_stack.top_boundary;
4118-
uint8* top = exec_env->wasm_stack.top;
4119-
uint8* bottom = exec_env->wasm_stack.bottom;
4120-
4121-
bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame));
4112+
/*
4113+
* Note for devs: please refrain from such modifications inside of
4114+
* aot_iterate_callstack
4115+
* - any allocations/freeing memory
4116+
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4117+
* exec_env->module_inst->module, pointers between stack's bottom and
4118+
* top_boundary For more details check wasm_iterate_callstack in
4119+
* wasm_export.h
4120+
*/
4121+
uint8 *top_boundary = exec_env->wasm_stack.top_boundary;
4122+
uint8 *top = exec_env->wasm_stack.top;
4123+
uint8 *bottom = exec_env->wasm_stack.bottom;
4124+
4125+
bool is_top_index_in_range =
4126+
top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame));
41224127
if (!is_top_index_in_range) {
41234128
return;
41244129
}
4125-
bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0;
4130+
bool is_top_aligned_with_bottom =
4131+
(unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0;
41264132
if (!is_top_aligned_with_bottom) {
41274133
return;
41284134
}
41294135

4130-
AOTTinyFrame* frame = (AOTTinyFrame*)(top - sizeof(AOTTinyFrame));
4136+
AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame));
41314137
WASMCApiFrame record_frame;
4132-
while (frame &&
4133-
(uint8_t*)frame >= bottom) {
4138+
while (frame && (uint8_t *)frame >= bottom) {
41344139
record_frame.instance = exec_env->module_inst;
41354140
record_frame.module_offset = 0;
41364141
record_frame.func_index = frame->func_index;
@@ -4143,48 +4148,57 @@ aot_iterate_callstack_tiny_frame(WASMExecEnv *exec_env, const wasm_frame_callbac
41434148
}
41444149

41454150
void
4146-
aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data)
4151+
aot_iterate_callstack_standard_frame(WASMExecEnv *exec_env,
4152+
const wasm_frame_callback frame_handler,
4153+
void *user_data)
41474154
{
4148-
/*
4149-
* Note for devs: please refrain from such modifications inside of aot_iterate_callstack
4150-
* - any allocations/freeing memory
4151-
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4152-
* exec_env->module_inst->module, pointers between stack's bottom and top_boundary
4153-
* For more details check wasm_iterate_callstack in wasm_export.h
4154-
*/
4155-
WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env);
4156-
AOTFrame* cur_frame = (AOTFrame *)wasm_exec_env_get_cur_frame(exec_env);
4157-
uint8* top_boundary = exec_env->wasm_stack.top_boundary;
4158-
uint8* bottom = exec_env->wasm_stack.bottom;
4155+
/*
4156+
* Note for devs: please refrain from such modifications inside of
4157+
* aot_iterate_callstack
4158+
* - any allocations/freeing memory
4159+
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4160+
* exec_env->module_inst->module, pointers between stack's bottom and
4161+
* top_boundary For more details check wasm_iterate_callstack in
4162+
* wasm_export.h
4163+
*/
4164+
WASMModuleInstance *module_inst =
4165+
(WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env);
4166+
AOTFrame *cur_frame = (AOTFrame *)wasm_exec_env_get_cur_frame(exec_env);
4167+
uint8 *top_boundary = exec_env->wasm_stack.top_boundary;
4168+
uint8 *bottom = exec_env->wasm_stack.bottom;
41594169

41604170
WASMCApiFrame record_frame;
4161-
while (cur_frame &&
4162-
(uint8_t*)cur_frame >= bottom &&
4163-
(uint8_t*)cur_frame + sizeof(AOTFrame) <= top_boundary) {
4164-
record_frame.instance = module_inst;
4165-
record_frame.module_offset = 0;
4166-
record_frame.func_index = (uint32)cur_frame->func_index;
4167-
record_frame.func_offset = (uint32)cur_frame->ip_offset;
4168-
if (!frame_handler(user_data, &record_frame)) {
4169-
break;
4170-
}
4171-
cur_frame = cur_frame->prev_frame;
4171+
while (cur_frame && (uint8_t *)cur_frame >= bottom
4172+
&& (uint8_t *)cur_frame + sizeof(AOTFrame) <= top_boundary) {
4173+
record_frame.instance = module_inst;
4174+
record_frame.module_offset = 0;
4175+
record_frame.func_index = (uint32)cur_frame->func_index;
4176+
record_frame.func_offset = (uint32)cur_frame->ip_offset;
4177+
if (!frame_handler(user_data, &record_frame)) {
4178+
break;
4179+
}
4180+
cur_frame = cur_frame->prev_frame;
41724181
}
41734182
}
41744183

41754184
void
4176-
aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data)
4185+
aot_iterate_callstack(WASMExecEnv *exec_env,
4186+
const wasm_frame_callback frame_handler, void *user_data)
41774187
{
4178-
/*
4179-
* Note for devs: please refrain from such modifications inside of aot_iterate_callstack
4180-
* - any allocations/freeing memory
4181-
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4182-
* exec_env->module_inst->module, pointers between stack's bottom and top_boundary
4183-
* For more details check wasm_iterate_callstack in wasm_export.h
4184-
*/
4188+
/*
4189+
* Note for devs: please refrain from such modifications inside of
4190+
* aot_iterate_callstack
4191+
* - any allocations/freeing memory
4192+
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4193+
* exec_env->module_inst->module, pointers between stack's bottom and
4194+
* top_boundary For more details check wasm_iterate_callstack in
4195+
* wasm_export.h
4196+
*/
41854197
if (!is_tiny_frame(exec_env)) {
4186-
aot_iterate_callstack_standard_frame(exec_env, frame_handler, user_data);
4187-
} else {
4198+
aot_iterate_callstack_standard_frame(exec_env, frame_handler,
4199+
user_data);
4200+
}
4201+
else {
41884202
aot_iterate_callstack_tiny_frame(exec_env, frame_handler, user_data);
41894203
}
41904204
}

0 commit comments

Comments
 (0)