@@ -800,6 +800,7 @@ void MemoryGrow::finalize() {
800
800
801
801
void RefNull::finalize (HeapType heapType) {
802
802
assert (heapType.isBottom ());
803
+ // TODO: Make this exact.
803
804
type = Type (heapType, Nullable);
804
805
}
805
806
@@ -922,6 +923,7 @@ static void populateTryTableSentTypes(TryTable* curr, Module* wasm) {
922
923
// wasm spec defines when GC is enabled (=== non-nullable types are allowed).
923
924
// If GC is not enabled then we emit a nullable type in the binary format in
924
925
// WasmBinaryWriter::writeType.
926
+ // TODO: Make this exact.
925
927
Type exnref = Type (HeapType::exn, NonNullable);
926
928
for (Index i = 0 ; i < curr->catchTags .size (); i++) {
927
929
auto tagName = curr->catchTags [i];
@@ -976,6 +978,7 @@ void RefI31::finalize() {
976
978
if (value->type == Type::unreachable) {
977
979
type = Type::unreachable;
978
980
} else {
981
+ // TODO: Make this exact.
979
982
assert (type.isRef () && type.getHeapType ().isMaybeShared (HeapType::i31));
980
983
}
981
984
}
@@ -1011,10 +1014,12 @@ void CallRef::finalize() {
1011
1014
// unreachable instead (and similar in other GC accessors), although this
1012
1015
// would currently cause the parser to admit more invalid modules.
1013
1016
if (type.isRef ()) {
1017
+ // TODO: Make this exact.
1014
1018
type = Type (type.getHeapType ().getBottom (), NonNullable);
1015
1019
} else if (type.isTuple ()) {
1016
1020
Tuple elems;
1017
1021
for (auto t : type) {
1022
+ // TODO: Make this exact.
1018
1023
elems.push_back (
1019
1024
t.isRef () ? Type (t.getHeapType ().getBottom (), NonNullable) : t);
1020
1025
}
@@ -1071,7 +1076,8 @@ void BrOn::finalize() {
1071
1076
switch (op) {
1072
1077
case BrOnNull:
1073
1078
// If we do not branch, we flow out the existing value as non-null.
1074
- type = Type (ref->type .getHeapType (), NonNullable);
1079
+ type =
1080
+ Type (ref->type .getHeapType (), NonNullable, ref->type .getExactness ());
1075
1081
break ;
1076
1082
case BrOnNonNull:
1077
1083
// If we do not branch, we flow out nothing (the spec could also have had
@@ -1081,7 +1087,8 @@ void BrOn::finalize() {
1081
1087
case BrOnCast:
1082
1088
if (castType.isNullable ()) {
1083
1089
// Nulls take the branch, so the result is non-nullable.
1084
- type = Type (ref->type .getHeapType (), NonNullable);
1090
+ type =
1091
+ Type (ref->type .getHeapType (), NonNullable, ref->type .getExactness ());
1085
1092
} else {
1086
1093
// Nulls do not take the branch, so the result is non-nullable only if
1087
1094
// the input is.
@@ -1092,7 +1099,9 @@ void BrOn::finalize() {
1092
1099
if (castType.isNullable ()) {
1093
1100
// Nulls do not take the branch, so the result is non-nullable only if
1094
1101
// the input is.
1095
- type = Type (castType.getHeapType (), ref->type .getNullability ());
1102
+ type = Type (castType.getHeapType (),
1103
+ ref->type .getNullability (),
1104
+ castType.getExactness ());
1096
1105
} else {
1097
1106
// Nulls take the branch, so the result is non-nullable.
1098
1107
type = castType;
@@ -1115,11 +1124,14 @@ Type BrOn::getSentType() {
1115
1124
return Type::unreachable;
1116
1125
}
1117
1126
// BrOnNonNull sends the non-nullable type on the branch.
1118
- return Type (ref->type .getHeapType (), NonNullable);
1127
+ return Type (
1128
+ ref->type .getHeapType (), NonNullable, ref->type .getExactness ());
1119
1129
case BrOnCast:
1120
1130
// The same as the result type of br_on_cast_fail.
1121
1131
if (castType.isNullable ()) {
1122
- return Type (castType.getHeapType (), ref->type .getNullability ());
1132
+ return Type (castType.getHeapType (),
1133
+ ref->type .getNullability (),
1134
+ castType.getExactness ());
1123
1135
} else {
1124
1136
return castType;
1125
1137
}
@@ -1129,7 +1141,8 @@ Type BrOn::getSentType() {
1129
1141
return Type::unreachable;
1130
1142
}
1131
1143
if (castType.isNullable ()) {
1132
- return Type (ref->type .getHeapType (), NonNullable);
1144
+ return Type (
1145
+ ref->type .getHeapType (), NonNullable, ref->type .getExactness ());
1133
1146
} else {
1134
1147
return ref->type ;
1135
1148
}
@@ -1150,6 +1163,7 @@ void StructGet::finalize() {
1150
1163
} else if (ref->type .isNull ()) {
1151
1164
// See comment on CallRef for explanation.
1152
1165
if (type.isRef ()) {
1166
+ // TODO: Make this exact.
1153
1167
type = Type (type.getHeapType ().getBottom (), NonNullable);
1154
1168
}
1155
1169
} else {
@@ -1225,6 +1239,7 @@ void ArrayGet::finalize() {
1225
1239
} else if (ref->type .isNull ()) {
1226
1240
// See comment on CallRef for explanation.
1227
1241
if (type.isRef ()) {
1242
+ // TODO: Make this exact.
1228
1243
type = Type (type.getHeapType ().getBottom (), NonNullable);
1229
1244
}
1230
1245
} else {
@@ -1302,15 +1317,17 @@ void RefAs::finalize() {
1302
1317
auto valHeapType = value->type .getHeapType ();
1303
1318
switch (op) {
1304
1319
case RefAsNonNull:
1305
- type = Type (valHeapType, NonNullable);
1320
+ type = Type (valHeapType, NonNullable, value-> type . getExactness () );
1306
1321
break ;
1307
1322
case AnyConvertExtern:
1308
1323
type = Type (HeapTypes::any.getBasic (valHeapType.getShared ()),
1309
- value->type .getNullability ());
1324
+ value->type .getNullability (),
1325
+ Inexact);
1310
1326
break ;
1311
1327
case ExternConvertAny:
1312
1328
type = Type (HeapTypes::ext.getBasic (valHeapType.getShared ()),
1313
- value->type .getNullability ());
1329
+ value->type .getNullability (),
1330
+ Inexact);
1314
1331
break ;
1315
1332
default :
1316
1333
WASM_UNREACHABLE (" invalid ref.as_*" );
@@ -1323,11 +1340,15 @@ void StringNew::finalize() {
1323
1340
(end && end->type == Type::unreachable)) {
1324
1341
type = Type::unreachable;
1325
1342
} else {
1343
+ // TODO: Make this exact.
1326
1344
type = Type (HeapType::string, NonNullable);
1327
1345
}
1328
1346
}
1329
1347
1330
- void StringConst::finalize () { type = Type (HeapType::string, NonNullable); }
1348
+ void StringConst::finalize () {
1349
+ // TODO: Make this exact.
1350
+ type = Type (HeapType::string, NonNullable);
1351
+ }
1331
1352
1332
1353
void StringMeasure::finalize () {
1333
1354
if (ref->type == Type::unreachable) {
@@ -1350,6 +1371,7 @@ void StringConcat::finalize() {
1350
1371
if (left->type == Type::unreachable || right->type == Type::unreachable) {
1351
1372
type = Type::unreachable;
1352
1373
} else {
1374
+ // TODO: Make this exact.
1353
1375
type = Type (HeapType::string, NonNullable);
1354
1376
}
1355
1377
}
@@ -1375,6 +1397,7 @@ void StringSliceWTF::finalize() {
1375
1397
end->type == Type::unreachable) {
1376
1398
type = Type::unreachable;
1377
1399
} else {
1400
+ // TODO: Make this exact.
1378
1401
type = Type (HeapType::string, NonNullable);
1379
1402
}
1380
1403
}
0 commit comments