Skip to content

Commit 159f589

Browse files
authored
[gc] Subtyping fix (#4075)
1 parent 1971cac commit 159f589

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

core/iwasm/common/gc/gc_type.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,14 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
11451145
return true;
11461146
else {
11471147
int32 heap_type = ref_type1->ref_ht_common.heap_type;
1148+
// We dont care whether type2 is nullable or not. So
1149+
// we normalize it into its related one-byte type.
1150+
if (type2 == REF_TYPE_HT_NULLABLE
1151+
|| type2 == REF_TYPE_HT_NON_NULLABLE) {
1152+
bh_assert(ref_type2);
1153+
type2 = (uint8)(ref_type2->ref_ht_common.heap_type
1154+
+ REF_TYPE_FUNCREF - HEAP_TYPE_FUNC);
1155+
}
11481156
if (heap_type == HEAP_TYPE_ANY) {
11491157
/* (ref any) <: anyref */
11501158
return type2 == REF_TYPE_ANYREF ? true : false;
@@ -1188,19 +1196,15 @@ wasm_reftype_is_subtype_of(uint8 type1, const WASMRefType *ref_type1,
11881196
}
11891197
#endif
11901198
else if (heap_type == HEAP_TYPE_NONE) {
1191-
/* (ref none) */
1192-
/* TODO */
1193-
bh_assert(0);
1199+
return wasm_is_reftype_supers_of_none(type2, NULL, types,
1200+
type_count);
11941201
}
11951202
else if (heap_type == HEAP_TYPE_NOEXTERN) {
1196-
/* (ref noextern) */
1197-
/* TODO */
1198-
bh_assert(0);
1203+
return wasm_is_reftype_supers_of_noextern(type2);
11991204
}
12001205
else if (heap_type == HEAP_TYPE_NOFUNC) {
1201-
/* (ref nofunc) */
1202-
/* TODO */
1203-
bh_assert(0);
1206+
return wasm_is_reftype_supers_of_nofunc(type2, NULL, types,
1207+
type_count);
12041208
}
12051209
else {
12061210
bh_assert(0);

core/iwasm/interpreter/wasm_loader.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ type2str(uint8 type)
246246
"", /* reserved */
247247
"arrayref",
248248
"structref",
249-
"i32ref",
249+
"i31ref",
250250
"eqref",
251251
"anyref",
252252
"externref",

0 commit comments

Comments
 (0)