@@ -40,15 +40,6 @@ GlobalTypeRewriter::TypeMap GlobalTypeRewriter::rebuildTypes(
40
40
// world scenario, don't modify public types because we assume that they may
41
41
// be reflected on or used for linking. Figure out where each private type
42
42
// will be located in the builder.
43
- //
44
- // There are two code paths here: a new one that is used when there are type
45
- // indices to preserve and an old one that is used otherwise. The old code
46
- // path is kept around to avoid unnecessary changes to test outputs while we
47
- // incrementally add --preserve-type-order to tests that could benefit from
48
- // it. Once we are done adding --preserve-type-order to tests, we should
49
- // remove the old code path here since the new code path is strictly better.
50
- if (wasm.typeIndices .size ()) {
51
- // New code path, currently used only with --preserve-type-order.
52
43
auto typeInfo = ModuleUtils::collectHeapTypeInfo (
53
44
wasm,
54
45
ModuleUtils::TypeInclusion::UsedIRTypes,
@@ -57,8 +48,7 @@ GlobalTypeRewriter::TypeMap GlobalTypeRewriter::rebuildTypes(
57
48
std::unordered_set<HeapType> additionalSet (additionalPrivateTypes.begin (),
58
49
additionalPrivateTypes.end ());
59
50
60
- std::vector<std::pair<HeapType, SmallVector<HeapType, 1 >>>
61
- privateSupertypes;
51
+ std::vector<std::pair<HeapType, SmallVector<HeapType, 1 >>> privateSupertypes;
62
52
privateSupertypes.reserve (typeInfo.size ());
63
53
for (auto & [type, info] : typeInfo) {
64
54
if (info.visibility != ModuleUtils::Visibility::Private &&
@@ -117,42 +107,6 @@ GlobalTypeRewriter::TypeMap GlobalTypeRewriter::rebuildTypes(
117
107
for (auto type : sorted) {
118
108
typeIndices[type] = i++;
119
109
}
120
- } else {
121
- // Old code path.
122
-
123
- auto privateTypes = ModuleUtils::getPrivateHeapTypes (wasm);
124
-
125
- if (!additionalPrivateTypes.empty ()) {
126
- // Only add additional private types that are not already in the list.
127
- std::unordered_set<HeapType> privateTypesSet (privateTypes.begin (),
128
- privateTypes.end ());
129
-
130
- for (auto t : additionalPrivateTypes) {
131
- if (!privateTypesSet.count (t)) {
132
- privateTypes.push_back (t);
133
- privateTypesSet.insert (t);
134
- }
135
- }
136
- }
137
-
138
- // Topological sort to have supertypes first, but we have to account for the
139
- // fact that we may be replacing the supertypes to get the order correct.
140
- struct SupertypesFirst
141
- : HeapTypeOrdering::SupertypesFirstBase<SupertypesFirst> {
142
- GlobalTypeRewriter& parent;
143
-
144
- SupertypesFirst (GlobalTypeRewriter& parent) : parent(parent) {}
145
- std::optional<HeapType> getDeclaredSuperType (HeapType type) {
146
- return parent.getDeclaredSuperType (type);
147
- }
148
- };
149
-
150
- SupertypesFirst sortedTypes (*this );
151
- Index i = 0 ;
152
- for (auto type : sortedTypes.sort (privateTypes)) {
153
- typeIndices[type] = i++;
154
- }
155
- }
156
110
157
111
if (typeIndices.size () == 0 ) {
158
112
return {};
@@ -168,7 +122,7 @@ GlobalTypeRewriter::TypeMap GlobalTypeRewriter::rebuildTypes(
168
122
typeBuilder.createRecGroup (0 , typeBuilder.size ());
169
123
170
124
// Create the temporary heap types.
171
- Index i = 0 ;
125
+ i = 0 ;
172
126
auto map = [&](HeapType type) -> HeapType {
173
127
if (auto it = typeIndices.find (type); it != typeIndices.end ()) {
174
128
return typeBuilder[it->second ];
0 commit comments