Skip to content

Commit 163b8ad

Browse files
committed
fixes for review
1 parent 1474a8d commit 163b8ad

4 files changed

Lines changed: 9 additions & 19 deletions

File tree

core/iwasm/compilation/aot_emit_control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ aot_emit_branch_hint(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
279279
hint = hint->next;
280280
}
281281
if (hint != NULL) {
282-
((struct WASMCompilationHintBranchHint *)hint)->used = true;
282+
hint->used = true;
283283
// same weight llvm MDBuilder::createLikelyBranchWeights assigns
284284
const uint32_t likely_weight = (1U << 20) - 1;
285285
const uint32_t unlikely_weight = 1;

core/iwasm/compilation/aot_emit_function.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ aot_emit_call_target_hint(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
120120
struct WASMCompilationHint *hint = func_ctx->function_hints;
121121
while (hint != NULL) {
122122
if (hint->type == WASM_COMPILATION_HINT_CALL_TARGETS
123-
&& ((struct WASMCompilationHintCallTargets *)hint)->offset
124-
== offset) {
123+
&& hint->offset == offset) {
125124
break;
126125
}
127126
hint = hint->next;

core/iwasm/interpreter/wasm.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -778,25 +778,15 @@ struct WASMCompilationHint {
778778
bool used;
779779
};
780780
struct WASMCompilationHintBranchHint {
781-
struct WASMCompilationHint *next;
782-
enum WASMCompilationHintType type;
783-
uint32 offset;
784-
bool used;
785-
786-
// custom field
781+
struct WASMCompilationHint common;
787782
bool is_likely;
788783
};
789784
struct WASMCompilationHintCallTargetsHint {
790785
uint32 func_idx;
791786
uint32 call_frequency;
792787
};
793788
struct WASMCompilationHintCallTargets {
794-
struct WASMCompilationHint *next;
795-
enum WASMCompilationHintType type;
796-
uint32 offset;
797-
bool used;
798-
799-
// custom fields
789+
struct WASMCompilationHint common;
800790
size_t target_count;
801791
struct WASMCompilationHintCallTargetsHint *hints;
802792
};

core/iwasm/interpreter/wasm_loader.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5648,7 +5648,7 @@ handle_compilation_hint_branch_hint_processor(const uint8 *buf,
56485648
{
56495649
(void)module;
56505650
struct WASMCompilationHintBranchHint *hint = hint_store;
5651-
hint->type = WASM_COMPILATION_HINT_BRANCH;
5651+
hint->common.type = WASM_COMPILATION_HINT_BRANCH;
56525652
if (hint_size != 1) {
56535653
set_error_buf_v(error_buf, error_buf_size,
56545654
"invalid branch hint size, expected 1, got %d.",
@@ -5671,6 +5671,7 @@ handle_compilation_hint_branch_hint_processor(const uint8 *buf,
56715671
fail:
56725672
return false;
56735673
}
5674+
56745675
static bool
56755676
handle_branch_hint_section(const uint8 *buf, const uint8 *buf_end,
56765677
WASMModule *module, char *error_buf,
@@ -5691,7 +5692,7 @@ handle_compilation_hint_call_targets_processor(
56915692
WASMModule *module)
56925693
{
56935694
struct WASMCompilationHintCallTargets *hint = hint_store;
5694-
hint->type = WASM_COMPILATION_HINT_CALL_TARGETS;
5695+
hint->common.type = WASM_COMPILATION_HINT_CALL_TARGETS;
56955696
CHECK_BUF(buf, buf_end, hint_size);
56965697
hint->target_count = 0;
56975698

@@ -7634,8 +7635,8 @@ wasm_loader_unload(WASMModule *module)
76347635
struct WASMCompilationHint *last_chain_start = curr;
76357636
while (curr != NULL) {
76367637
if (!curr->used) {
7637-
printf("Unused hint for function %u, offset: %x\n",
7638-
i + module->import_count, curr->offset);
7638+
LOG_WARNING("Unused hint for function %u, offset: %x\n",
7639+
i + module->import_count, curr->offset);
76397640
}
76407641
if (curr->type != last_chain_start->type) {
76417642
// we switched chains -> deallocate previous chain and reset

0 commit comments

Comments
 (0)