Skip to content

Commit

Permalink
cr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
TianlongLiang committed Jan 11, 2024
1 parent 3598378 commit e795c76
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
13 changes: 7 additions & 6 deletions core/iwasm/aot/aot_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2575,6 +2575,9 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, AOTModule *module,
}

#if WASM_ENABLE_GC != 0
/* Local(params and locals) ref flags for all import and non-imported
* functions. The flags indicate whether each cell in the AOTFrame local
* area is a GC reference. */
size = sizeof(LocalRefFlag)
* (uint64)(module->import_func_count + module->func_count);
if (size > 0) {
Expand All @@ -2584,7 +2587,7 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, AOTModule *module,
}

for (i = 0; i < module->import_func_count + module->func_count; i++) {
uint32 j, local_ref_flag_cell_num;
uint32 local_ref_flag_cell_num;

buf = (uint8 *)align_ptr(buf, sizeof(uint32));
read_uint32(
Expand All @@ -2599,11 +2602,9 @@ load_function_section(const uint8 *buf, const uint8 *buf_end, AOTModule *module,
loader_malloc(size, error_buf, error_buf_size))) {
return false;
}
for (j = 0; j < local_ref_flag_cell_num; j++) {
read_uint8(
p, p_end,
module->func_local_ref_flags[i].local_ref_flags[j]);
}
read_byte_array(p, p_end,
module->func_local_ref_flags[i].local_ref_flags,
local_ref_flag_cell_num);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions core/iwasm/aot/aot_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ typedef struct AOTModule {

#if WASM_ENABLE_GC != 0
/* params + locals ref flags of (both import and AOTed) functions */
struct LocalRefFlag *func_local_ref_flags;
LocalRefFlag *func_local_ref_flags;
#endif

/* export info */
Expand Down Expand Up @@ -374,9 +374,9 @@ typedef struct AOTFrame {
* local area: parameters and local variables
* stack area: wasm operand stack
* frame ref flags (GC only):
* whether each cell in local(LLVM JIT) and stack area is a GC obj
* paddings(AOT)
* actual ref flags for local are in AOT module
* whether each cell in local and stack area is a GC obj
* currently local's ref flags are stored in AOTModule,
* here we only reserve the padding bytes
*/
uint32 lp[1];
} AOTFrame;
Expand Down
12 changes: 7 additions & 5 deletions core/iwasm/compilation/aot_compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,12 @@ aot_gen_commit_values(AOTCompFrame *frame)
LLVMValueRef value;
uint32 n;

/* First, commit reference flags, ignore local(params + locals) ref flags */
for (p = frame->lp + frame->max_local_cell_num; p < frame->sp; p++) {
/* First, commit reference flags
* For LLVM JIT, iterate all local and stack ref flags
* For AOT, ignore local(params + locals) ref flags */
for (p = comp_ctx->is_jit_mode ? frame->lp
: frame->lp + frame->max_local_cell_num;
p < frame->sp; p++) {
if (!p->dirty)
continue;

Expand Down Expand Up @@ -366,9 +370,7 @@ aot_gen_commit_values(AOTCompFrame *frame)
(p + 2)->committed_ref = (p + 3)->committed_ref =
p->ref + 1;
}
p++;
p++;
p++;
p += 3;
break;

case REF_TYPE_NULLFUNCREF:
Expand Down

0 comments on commit e795c76

Please sign in to comment.