Skip to content

Commit 1f4d3dd

Browse files
author
Georgii Rylov
committed
clang-format
1 parent d0c6da1 commit 1f4d3dd

7 files changed

Lines changed: 94 additions & 75 deletions

File tree

core/iwasm/aot/aot_runtime.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4104,37 +4104,41 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame)
41044104
#endif /* end of WASM_ENABLE_AOT_STACK_FRAME != 0 */
41054105

41064106
#if WASM_ENABLE_DUMP_CALL_STACK != 0
4107-
void
4108-
aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data)
4107+
void
4108+
aot_iterate_callstack(WASMExecEnv *exec_env,
4109+
const wasm_frame_callback frame_handler, void *user_data)
41094110
{
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-
*/
4111+
/*
4112+
* Note for devs: please refrain from such modifications inside of
4113+
* aot_iterate_callstack
4114+
* - any allocations/freeing memory
4115+
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4116+
* exec_env->module_inst->module, pointers between stack's bottom and
4117+
* top_boundary For more details check wasm_iterate_callstack in
4118+
* wasm_export.h
4119+
*/
41174120
if (!is_tiny_frame(exec_env)) {
4118-
//TODO: support standard frames
4121+
// TODO: support standard frames
41194122
return;
41204123
}
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+
uint8 *top_boundary = exec_env->wasm_stack.top_boundary;
4125+
uint8 *top = exec_env->wasm_stack.top;
4126+
uint8 *bottom = exec_env->wasm_stack.bottom;
41244127

4125-
bool is_top_index_in_range = top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame));
4128+
bool is_top_index_in_range =
4129+
top_boundary >= top && top >= (bottom + sizeof(AOTTinyFrame));
41264130
if (!is_top_index_in_range) {
41274131
return;
41284132
}
4129-
bool is_top_aligned_with_bottom = (unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0;
4133+
bool is_top_aligned_with_bottom =
4134+
(unsigned long)(top - bottom) % sizeof(AOTTinyFrame) == 0;
41304135
if (!is_top_aligned_with_bottom) {
41314136
return;
41324137
}
41334138

4134-
AOTTinyFrame* frame = (AOTTinyFrame*)(top - sizeof(AOTTinyFrame));
4139+
AOTTinyFrame *frame = (AOTTinyFrame *)(top - sizeof(AOTTinyFrame));
41354140
WASMCApiFrame record_frame;
4136-
while (frame &&
4137-
(uint8_t*)frame >= bottom) {
4141+
while (frame && (uint8_t *)frame >= bottom) {
41384142
record_frame.instance = exec_env->module_inst;
41394143
record_frame.module_offset = 0;
41404144
record_frame.func_index = frame->func_index;

core/iwasm/aot/aot_runtime.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,9 @@ aot_frame_update_profile_info(WASMExecEnv *exec_env, bool alloc_frame);
777777
bool
778778
aot_create_call_stack(struct WASMExecEnv *exec_env);
779779

780-
void
781-
aot_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data);
780+
void
781+
aot_iterate_callstack(WASMExecEnv *exec_env,
782+
const wasm_frame_callback frame_handler, void *user_data);
782783

783784
/**
784785
* @brief Dump wasm call stack or get the size

core/iwasm/common/wasm_runtime_common.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,31 +1741,36 @@ wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env)
17411741
wasm_exec_env_destroy(exec_env);
17421742
}
17431743

1744-
void
1745-
wasm_iterate_callstack(const wasm_exec_env_t exec_env, const wasm_frame_callback frame_callback, void* user_data)
1744+
void
1745+
wasm_iterate_callstack(const wasm_exec_env_t exec_env,
1746+
const wasm_frame_callback frame_callback,
1747+
void *user_data)
17461748
{
1747-
/*
1748-
* Note for devs: please refrain from such modifications inside of wasm_iterate_callstack
1749-
* - any allocations/freeing memory
1750-
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
1751-
* exec_env->module_inst->module, pointers between stack's bottom and top_boundary
1752-
* For more details check wasm_iterate_callstack in wasm_export.h
1753-
*/
1754-
#if WASM_ENABLE_DUMP_CALL_STACK
1755-
WASMModuleInstance* module_inst = (WASMModuleInstance *)get_module_inst(exec_env);
1756-
1757-
#if WASM_ENABLE_INTERP != 0
1749+
/*
1750+
* Note for devs: please refrain from such modifications inside of
1751+
* wasm_iterate_callstack
1752+
* - any allocations/freeing memory
1753+
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
1754+
* exec_env->module_inst->module, pointers between stack's bottom and
1755+
* top_boundary For more details check wasm_iterate_callstack in
1756+
* wasm_export.h
1757+
*/
1758+
#if WASM_ENABLE_DUMP_CALL_STACK
1759+
WASMModuleInstance *module_inst =
1760+
(WASMModuleInstance *)get_module_inst(exec_env);
1761+
1762+
#if WASM_ENABLE_INTERP != 0
17581763
if (module_inst->module_type == Wasm_Module_Bytecode) {
17591764
wasm_interp_iterate_callstack(exec_env, frame_callback, user_data);
17601765
}
1761-
#endif
1766+
#endif
17621767

1763-
#if WASM_ENABLE_AOT != 0
1768+
#if WASM_ENABLE_AOT != 0
17641769
if (module_inst->module_type == Wasm_Module_AoT) {
17651770
aot_iterate_callstack(exec_env, frame_callback, user_data);
17661771
}
1767-
#endif
1768-
#endif
1772+
#endif
1773+
#endif
17691774
}
17701775

17711776
bool

core/iwasm/common/wasm_runtime_common.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,10 @@ wasm_runtime_create_exec_env(WASMModuleInstanceCommon *module_inst,
652652
WASM_RUNTIME_API_EXTERN void
653653
wasm_runtime_destroy_exec_env(WASMExecEnv *exec_env);
654654

655-
WASM_RUNTIME_API_EXTERN void
656-
wasm_iterate_callstack(const wasm_exec_env_t exec_env, const wasm_frame_callback frame_handler, void* user_data);
655+
WASM_RUNTIME_API_EXTERN void
656+
wasm_iterate_callstack(const wasm_exec_env_t exec_env,
657+
const wasm_frame_callback frame_handler,
658+
void *user_data);
657659

658660
/* See wasm_export.h for description */
659661
WASM_RUNTIME_API_EXTERN WASMModuleInstanceCommon *

core/iwasm/include/wasm_export.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct WASMMemoryInstance;
127127
typedef struct WASMMemoryInstance *wasm_memory_inst_t;
128128

129129
struct wasm_frame_t;
130-
typedef struct wasm_frame_t * wasm_frame_ptr_t;
130+
typedef struct wasm_frame_t *wasm_frame_ptr_t;
131131

132132
/* WASM section */
133133
typedef struct wasm_section_t {
@@ -867,36 +867,37 @@ wasm_runtime_create_exec_env(wasm_module_inst_t module_inst,
867867
WASM_RUNTIME_API_EXTERN void
868868
wasm_runtime_destroy_exec_env(wasm_exec_env_t exec_env);
869869

870-
871-
typedef bool (*wasm_frame_callback)(void*, wasm_frame_ptr_t);
870+
typedef bool (*wasm_frame_callback)(void *, wasm_frame_ptr_t);
872871

873872
/**
874873
* @brief Iterate over callstack frames and execute callback on it.
875874
*
876-
* Caution: This is not a thread-safe function. Ensure the exec_env
875+
* Caution: This is not a thread-safe function. Ensure the exec_env
877876
* is suspended before calling it from another thread.
878877
*
879-
* Usage: In the callback to read frames fields use APIs
878+
* Usage: In the callback to read frames fields use APIs
880879
* for wasm_frame_t from wasm_c_api.h
881880
*
882-
* Note: The function is async-signal-safe if called with verified arguments.
883-
* Meaning it's safe to call it from a signal handler even on a signal interruption
884-
* from another thread if next variables hold valid pointers
881+
* Note: The function is async-signal-safe if called with verified arguments.
882+
* Meaning it's safe to call it from a signal handler even on a signal
883+
* interruption from another thread if next variables hold valid pointers
885884
* - exec_env
886885
* - exec_env->module_inst
887886
* - exec_env->module_inst->module
888887
*
889888
* Note for devs: please refrain from such modifications inside of this call
890889
* - any allocations/freeing memory
891890
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
892-
* exec_env->module_inst->module, pointers between stack's bottom and top_boundary
891+
* exec_env->module_inst->module, pointers between stack's bottom and
892+
* top_boundary
893893
*
894894
* @param exec_env the execution environment that containes frames
895895
* @param callback the callback function provided by the user
896896
* @param user_data context for callback provided by the user
897897
*/
898-
WASM_RUNTIME_API_EXTERN void
899-
wasm_iterate_callstack(const wasm_exec_env_t exec_env, const wasm_frame_callback callback, void *user_data);
898+
WASM_RUNTIME_API_EXTERN void
899+
wasm_iterate_callstack(const wasm_exec_env_t exec_env,
900+
const wasm_frame_callback callback, void *user_data);
900901

901902
/**
902903
* Get the singleton execution environment for the instance.

core/iwasm/interpreter/wasm_runtime.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4197,32 +4197,36 @@ wasm_get_module_inst_mem_consumption(const WASMModuleInstance *module_inst,
41974197
|| (WASM_ENABLE_MEMORY_TRACING != 0) */
41984198

41994199
#if WASM_ENABLE_DUMP_CALL_STACK != 0
4200-
uint32
4201-
wasm_interp_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data)
4200+
uint32
4201+
wasm_interp_iterate_callstack(WASMExecEnv *exec_env,
4202+
const wasm_frame_callback frame_handler,
4203+
void *user_data)
42024204
{
4203-
/*
4204-
* Note for devs: please refrain from such modifications inside of wasm_interp_iterate_callstack
4205-
* - any allocations/freeing memory
4206-
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4207-
* exec_env->module_inst->module, pointers between stack's bottom and top_boundary
4208-
* For more details check wasm_iterate_callstack in wasm_export.h
4209-
*/
4210-
WASMModuleInstance *module_inst = (WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env);
4211-
WASMInterpFrame* cur_frame = wasm_exec_env_get_cur_frame(exec_env);
4212-
uint8* top_boundary = exec_env->wasm_stack.top_boundary;
4213-
uint8* bottom = exec_env->wasm_stack.bottom;
4205+
/*
4206+
* Note for devs: please refrain from such modifications inside of
4207+
* wasm_interp_iterate_callstack
4208+
* - any allocations/freeing memory
4209+
* - dereferencing any pointers other than: exec_env, exec_env->module_inst,
4210+
* exec_env->module_inst->module, pointers between stack's bottom and
4211+
* top_boundary For more details check wasm_iterate_callstack in
4212+
* wasm_export.h
4213+
*/
4214+
WASMModuleInstance *module_inst =
4215+
(WASMModuleInstance *)wasm_exec_env_get_module_inst(exec_env);
4216+
WASMInterpFrame *cur_frame = wasm_exec_env_get_cur_frame(exec_env);
4217+
uint8 *top_boundary = exec_env->wasm_stack.top_boundary;
4218+
uint8 *bottom = exec_env->wasm_stack.bottom;
42144219

42154220
WASMCApiFrame record_frame;
4216-
while (cur_frame &&
4217-
(uint8_t*)cur_frame >= bottom &&
4218-
(uint8_t*)cur_frame + sizeof(WASMInterpFrame) <= top_boundary) {
4219-
record_frame.instance = module_inst;
4220-
record_frame.module_offset = 0;
4221-
record_frame.func_index = cur_frame->func_index;
4222-
if (!frame_handler(user_data, &record_frame)) {
4223-
break;
4224-
}
4225-
cur_frame = cur_frame->prev_frame;
4221+
while (cur_frame && (uint8_t *)cur_frame >= bottom
4222+
&& (uint8_t *)cur_frame + sizeof(WASMInterpFrame) <= top_boundary) {
4223+
record_frame.instance = module_inst;
4224+
record_frame.module_offset = 0;
4225+
record_frame.func_index = cur_frame->func_index;
4226+
if (!frame_handler(user_data, &record_frame)) {
4227+
break;
4228+
}
4229+
cur_frame = cur_frame->prev_frame;
42264230
}
42274231
}
42284232

core/iwasm/interpreter/wasm_runtime.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,10 @@ wasm_get_table_inst(const WASMModuleInstance *module_inst, uint32 tbl_idx)
731731

732732
#if WASM_ENABLE_DUMP_CALL_STACK != 0
733733

734-
uint32
735-
wasm_interp_iterate_callstack(WASMExecEnv *exec_env, const wasm_frame_callback frame_handler, void* user_data);
734+
uint32
735+
wasm_interp_iterate_callstack(WASMExecEnv *exec_env,
736+
const wasm_frame_callback frame_handler,
737+
void *user_data);
736738

737739
bool
738740
wasm_interp_create_call_stack(struct WASMExecEnv *exec_env);

0 commit comments

Comments
 (0)