Skip to content

Commit 3f30223

Browse files
committed
[dart2wasm] Cleanup some code in RTT
Instead of carrying around the instance constants and their type, we make an extension method allowing one to access the type of an instance constant. Change-Id: Ia5c718d4c8779abf154c095a64a967df70b22ced Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392941 Reviewed-by: Ömer Ağacan <[email protected]> Commit-Queue: Martin Kustermann <[email protected]>
1 parent c854870 commit 3f30223

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

pkg/dart2wasm/lib/intrinsics.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -803,28 +803,32 @@ class Intrinsifier {
803803
return w.NumType.i32;
804804
case "_typeRowDisplacementOffsets":
805805
final type = translator
806-
.translateStorageType(types.rtt.typeRowDisplacementOffsetsType)
806+
.translateStorageType(
807+
types.rtt.typeRowDisplacementOffsets.interfaceType)
807808
.unpacked;
808809
translator.constants.instantiateConstant(
809810
b, types.rtt.typeRowDisplacementOffsets, type);
810811
return type;
811812
case "_typeRowDisplacementTable":
812813
final type = translator
813-
.translateStorageType(types.rtt.typeRowDisplacementTableType)
814+
.translateStorageType(
815+
types.rtt.typeRowDisplacementTable.interfaceType)
814816
.unpacked;
815817
translator.constants
816818
.instantiateConstant(b, types.rtt.typeRowDisplacementTable, type);
817819
return type;
818820
case "_typeRowDisplacementSubstTable":
819821
final type = translator
820-
.translateStorageType(types.rtt.typeRowDisplacementSubstTableType)
822+
.translateStorageType(
823+
types.rtt.typeRowDisplacementSubstTable.interfaceType)
821824
.unpacked;
822825
translator.constants.instantiateConstant(
823826
b, types.rtt.typeRowDisplacementSubstTable, type);
824827
return type;
825828
case "_typeNames":
826-
final type =
827-
translator.translateStorageType(types.rtt.typeNamesType).unpacked;
829+
final type = translator
830+
.translateStorageType(types.rtt.typeNames.interfaceType)
831+
.unpacked;
828832
if (translator.options.minify) {
829833
b.ref_null((type as w.RefType).heapType);
830834
} else {

pkg/dart2wasm/lib/types.dart

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,16 +1041,12 @@ class RuntimeTypeInformation {
10411041

10421042
/// Table of type names indexed by class id.
10431043
late final InstanceConstant typeNames;
1044-
late final DartType typeNamesType;
10451044

10461045
/// See sdk/lib/_internal/wasm/lib/type.dart:_typeRowDisplacement*
10471046
/// for what this contains and how it's used for substitution.
10481047
late final InstanceConstant typeRowDisplacementOffsets;
1049-
late final DartType typeRowDisplacementOffsetsType;
10501048
late final InstanceConstant typeRowDisplacementTable;
1051-
late final DartType typeRowDisplacementTableType;
10521049
late final InstanceConstant typeRowDisplacementSubstTable;
1053-
late final DartType typeRowDisplacementSubstTableType;
10541050

10551051
CoreTypes get coreTypes => translator.coreTypes;
10561052
Types get types => translator.types;
@@ -1210,12 +1206,8 @@ class RuntimeTypeInformation {
12101206
InterfaceType(translator.typeClass, Nullability.nonNullable);
12111207
final arrayOfType = InterfaceType(
12121208
translator.wasmArrayClass, Nullability.nonNullable, [typeType]);
1213-
final arrayOfArrayOfType = InterfaceType(
1214-
translator.wasmArrayClass, Nullability.nonNullable, [arrayOfType]);
12151209
final wasmI32 =
12161210
InterfaceType(translator.wasmI32Class, Nullability.nonNullable);
1217-
final arrayOfI32 = InterfaceType(
1218-
translator.wasmArrayClass, Nullability.nonNullable, [wasmI32]);
12191211

12201212
final maxId = translator.classIdNumbering.maxClassId;
12211213
int normalize(int value) => (100 * value) ~/ maxId;
@@ -1231,20 +1223,18 @@ class RuntimeTypeInformation {
12311223
? 0
12321224
: (entry.$2 == noSubstitutionIndex ? -entry.$1 : entry.$1)),
12331225
]);
1234-
typeRowDisplacementTableType = arrayOfI32;
1226+
12351227
typeRowDisplacementSubstTable =
12361228
translator.constants.makeArrayOf(arrayOfType, [
12371229
for (final entry in table)
12381230
_substitutionTableByIndex[
12391231
entry == null ? noSubstitutionIndex : entry.$2],
12401232
]);
1241-
typeRowDisplacementSubstTableType = arrayOfArrayOfType;
12421233

12431234
typeRowDisplacementOffsets = translator.constants.makeArrayOf(wasmI32, [
12441235
for (int classId = 0; classId < translator.classes.length; ++classId)
12451236
IntConstant(rowForSuperclass[classId]?.offset ?? -1),
12461237
]);
1247-
typeRowDisplacementOffsetsType = arrayOfI32;
12481238
}
12491239

12501240
void _initTypeNames() {
@@ -1262,8 +1252,6 @@ class RuntimeTypeInformation {
12621252
}
12631253
}
12641254
typeNames = translator.constants.makeArrayOf(stringType, nameConstants);
1265-
typeNamesType = InterfaceType(
1266-
translator.wasmArrayClass, Nullability.nonNullable, [stringType]);
12671255
}
12681256

12691257
Map<int, List<(Range, int)>> _buildRanges(Map<int, Map<int, int>> map) {
@@ -1355,3 +1343,8 @@ class _FunctionTypeParameterOffsetCollector extends RecursiveVisitor {
13551343
}
13561344
}
13571345
}
1346+
1347+
extension InstanceConstantInterfaceType on InstanceConstant {
1348+
InterfaceType get interfaceType =>
1349+
InterfaceType(classNode, Nullability.nonNullable, typeArguments);
1350+
}

0 commit comments

Comments
 (0)