mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-17 01:38:15 +00:00
Fix static code analyzing issues (#2371)
This commit is contained in:
parent
f906585b56
commit
6a868173f8
|
@ -276,6 +276,8 @@ wasm_defined_type_equal(WASMType *const def_type1, WASMType *const def_type2,
|
|||
/* TODO */
|
||||
#endif
|
||||
|
||||
bh_assert(types);
|
||||
|
||||
return wasm_type_equal(def_type1, def_type2, types, type_count);
|
||||
}
|
||||
|
||||
|
@ -299,6 +301,8 @@ wasm_defined_type_is_subtype_of(WASMType *const def_type1,
|
|||
/* TODO */
|
||||
#endif
|
||||
|
||||
bh_assert(types);
|
||||
|
||||
return wasm_type_is_subtype_of(def_type1, def_type2, types, type_count);
|
||||
}
|
||||
|
||||
|
@ -404,6 +408,8 @@ wasm_ref_type_is_subtype_of(const wasm_ref_type_t *ref_type1,
|
|||
/* TODO */
|
||||
#endif
|
||||
|
||||
bh_assert(types);
|
||||
|
||||
return wasm_reftype_is_subtype_of(type1, (WASMRefType *)&ref_type1_norm,
|
||||
type2, (WASMRefType *)&ref_type2_norm,
|
||||
types, type_count);
|
||||
|
@ -712,6 +718,8 @@ wasm_obj_is_instance_of_type_idx(WASMObjectRef obj, uint32 type_idx,
|
|||
/* TODO */
|
||||
#endif
|
||||
|
||||
bh_assert(types);
|
||||
|
||||
return wasm_obj_is_instance_of(obj, type_idx, types, type_count);
|
||||
}
|
||||
|
||||
|
|
|
@ -754,7 +754,7 @@ wasm_is_reftype_supers_of_none(uint8 type, const WASMRefType *ref_type,
|
|||
|| wasm_is_reftype_supers_of_eq(type))
|
||||
return true;
|
||||
|
||||
if (type == REF_TYPE_HT_NULLABLE
|
||||
if (type == REF_TYPE_HT_NULLABLE && ref_type != NULL
|
||||
&& wasm_is_refheaptype_typeidx(&ref_type->ref_ht_common)
|
||||
&& (types[ref_type->ref_ht_typeidx.type_idx]->type_flag
|
||||
== WASM_TYPE_STRUCT
|
||||
|
@ -772,7 +772,7 @@ wasm_is_reftype_supers_of_nofunc(uint8 type, const WASMRefType *ref_type,
|
|||
if (type == REF_TYPE_NULLFUNCREF || type == REF_TYPE_FUNCREF)
|
||||
return true;
|
||||
|
||||
if (type == REF_TYPE_HT_NULLABLE
|
||||
if (type == REF_TYPE_HT_NULLABLE && ref_type != NULL
|
||||
&& wasm_is_refheaptype_typeidx(&ref_type->ref_ht_common)
|
||||
&& (types[ref_type->ref_ht_typeidx.type_idx]->type_flag
|
||||
== WASM_TYPE_FUNC))
|
||||
|
@ -878,7 +878,7 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
|
|||
else if (type1 == REF_TYPE_HT_NULLABLE) {
|
||||
if (wasm_is_refheaptype_typeidx(&ref_type1->ref_ht_common)) {
|
||||
/* reftype1 is (ref null $t) */
|
||||
if (type2 == REF_TYPE_HT_NULLABLE
|
||||
if (type2 == REF_TYPE_HT_NULLABLE && ref_type2 != NULL
|
||||
&& wasm_is_refheaptype_typeidx(&ref_type2->ref_ht_common)) {
|
||||
return type_idx_equal(ref_type1->ref_ht_typeidx.type_idx,
|
||||
ref_type2->ref_ht_typeidx.type_idx)
|
||||
|
@ -907,10 +907,12 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
|
|||
}
|
||||
}
|
||||
else if (type1 == REF_TYPE_HT_NON_NULLABLE) {
|
||||
bh_assert(ref_type1);
|
||||
if (wasm_is_refheaptype_typeidx(&ref_type1->ref_ht_common)) {
|
||||
/* reftype1 is (ref $t) */
|
||||
if ((type2 == REF_TYPE_HT_NULLABLE
|
||||
|| type2 == REF_TYPE_HT_NON_NULLABLE)
|
||||
&& ref_type2 != NULL
|
||||
&& wasm_is_refheaptype_typeidx(&ref_type2->ref_ht_common)) {
|
||||
return type_idx_equal(ref_type1->ref_ht_typeidx.type_idx,
|
||||
ref_type2->ref_ht_typeidx.type_idx)
|
||||
|
@ -923,6 +925,7 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
|
|||
/* the super type is (ref null struct) or (ref struct) */
|
||||
if (type2 == REF_TYPE_HT_NULLABLE
|
||||
|| type2 == REF_TYPE_HT_NON_NULLABLE) {
|
||||
bh_assert(ref_type2);
|
||||
uint8 ref_type =
|
||||
(uint8)(ref_type2->ref_ht_common.heap_type
|
||||
+ REF_TYPE_FUNCREF - HEAP_TYPE_FUNC);
|
||||
|
@ -937,6 +940,7 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
|
|||
/* the super type is (ref null array) or (ref array) */
|
||||
if (type2 == REF_TYPE_HT_NULLABLE
|
||||
|| type2 == REF_TYPE_HT_NON_NULLABLE) {
|
||||
bh_assert(ref_type2);
|
||||
uint8 ref_type =
|
||||
(uint8)(ref_type2->ref_ht_common.heap_type
|
||||
+ REF_TYPE_FUNCREF - HEAP_TYPE_FUNC);
|
||||
|
@ -951,6 +955,7 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
|
|||
/* the super type is (ref null func) or (ref func) */
|
||||
if (type2 == REF_TYPE_HT_NULLABLE
|
||||
|| type2 == REF_TYPE_HT_NON_NULLABLE) {
|
||||
bh_assert(ref_type2);
|
||||
uint8 ref_type =
|
||||
(uint8)(ref_type2->ref_ht_common.heap_type
|
||||
+ REF_TYPE_FUNCREF - HEAP_TYPE_FUNC);
|
||||
|
@ -965,6 +970,7 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
|
|||
/* the super type is (ref null i31) or (ref i31) */
|
||||
if (type2 == REF_TYPE_HT_NULLABLE
|
||||
|| type2 == REF_TYPE_HT_NON_NULLABLE) {
|
||||
bh_assert(ref_type2);
|
||||
uint8 ref_type =
|
||||
(uint8)(ref_type2->ref_ht_common.heap_type
|
||||
+ REF_TYPE_FUNCREF - HEAP_TYPE_FUNC);
|
||||
|
|
|
@ -689,7 +689,7 @@ execute_func(WASMModuleInstanceCommon *module_inst, const char *name,
|
|||
(WASMExternrefObjectRef)gc_obj);
|
||||
if (wasm_obj_is_anyref_obj(obj))
|
||||
os_printf("0x%" PRIxPTR ":ref.extern",
|
||||
wasm_anyref_obj_get_value(
|
||||
(uintptr_t)wasm_anyref_obj_get_value(
|
||||
(WASMAnyrefObjectRef)obj));
|
||||
else
|
||||
os_printf("ref.extern");
|
||||
|
@ -704,7 +704,7 @@ execute_func(WASMModuleInstanceCommon *module_inst, const char *name,
|
|||
os_printf("ref.eq");
|
||||
else if (wasm_obj_is_anyref_obj(gc_obj))
|
||||
os_printf("0x%" PRIxPTR ":ref.host",
|
||||
wasm_anyref_obj_get_value(
|
||||
(uintptr_t)wasm_anyref_obj_get_value(
|
||||
(WASMAnyrefObjectRef)gc_obj));
|
||||
else if (wasm_obj_is_internal_obj(gc_obj))
|
||||
os_printf("ref.any");
|
||||
|
|
|
@ -181,6 +181,7 @@ wasm_exec_env_create(struct WASMModuleInstanceCommon *module_inst,
|
|||
#endif
|
||||
#else
|
||||
#if WASM_ENABLE_GC != 0
|
||||
bh_assert(gc_heap_handle);
|
||||
mem_allocator_enable_gc_reclaim(gc_heap_handle, exec_env);
|
||||
#endif
|
||||
#endif /* end of WASM_ENABLE_THREAD_MGR */
|
||||
|
|
|
@ -622,7 +622,7 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
|
|||
|
||||
init_expr->u.ref_index = NULL_REF;
|
||||
#else
|
||||
WASMRefType ref_type1;
|
||||
WASMRefType ref_type1 = { 0 };
|
||||
|
||||
type1 = read_uint8(p);
|
||||
if (!is_byte_a_type(type1)) {
|
||||
|
@ -8631,8 +8631,12 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
|
|||
for (i = (int32)arity - 1; i >= 0; i--) {
|
||||
type = types[i];
|
||||
#if WASM_ENABLE_GC != 0
|
||||
ref_type = NULL;
|
||||
is_type_multi_byte = wasm_is_type_multi_byte_type(type);
|
||||
ref_type = is_type_multi_byte ? reftype_map->ref_type : NULL;
|
||||
if (is_type_multi_byte) {
|
||||
bh_assert(reftype_map);
|
||||
ref_type = reftype_map->ref_type;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (available_stack_cell <= 0 && cur_block->is_stack_polymorphic)
|
||||
|
@ -8802,7 +8806,11 @@ check_block_stack(WASMLoaderContext *loader_ctx, BranchBlock *block,
|
|||
uint8 type = return_types[i];
|
||||
#if WASM_ENABLE_GC != 0
|
||||
bool is_type_multi_byte = wasm_is_type_multi_byte_type(type);
|
||||
ref_type = is_type_multi_byte ? return_reftype_map->ref_type : NULL;
|
||||
ref_type = NULL;
|
||||
if (is_type_multi_byte) {
|
||||
bh_assert(return_reftype_map);
|
||||
ref_type = return_reftype_map->ref_type;
|
||||
}
|
||||
#endif
|
||||
if (!check_stack_top_values(loader_ctx, frame_ref, available_stack_cell,
|
||||
#if WASM_ENABLE_GC != 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user