@@ -107,10 +107,27 @@ struct TypeSCCs
107107// provides an infinite sequence of possible brand types, prioritizing those
108108// with the most compact encoding.
109109struct BrandTypeIterator {
110- // See `initFieldOptions` for the 18 options.
111110 static constexpr Index optionCount = 18 ;
112- static std::array<Field, optionCount> fieldOptions;
113- static void initFieldOptions ();
111+ static constexpr std::array<Field, optionCount> fieldOptions = {{
112+ Field (Field::i8 , Mutable),
113+ Field (Field::i16 , Mutable),
114+ Field (Type::i32 , Mutable),
115+ Field (Type::i64 , Mutable),
116+ Field (Type::f32 , Mutable),
117+ Field (Type::f64 , Mutable),
118+ Field (Type (HeapType::any, Nullable), Mutable),
119+ Field (Type (HeapType::func, Nullable), Mutable),
120+ Field (Type (HeapType::ext, Nullable), Mutable),
121+ Field (Type (HeapType::none, Nullable), Mutable),
122+ Field (Type (HeapType::nofunc, Nullable), Mutable),
123+ Field (Type (HeapType::noext, Nullable), Mutable),
124+ Field (Type (HeapType::any, NonNullable), Mutable),
125+ Field (Type (HeapType::func, NonNullable), Mutable),
126+ Field (Type (HeapType::ext, NonNullable), Mutable),
127+ Field (Type (HeapType::none, NonNullable), Mutable),
128+ Field (Type (HeapType::nofunc, NonNullable), Mutable),
129+ Field (Type (HeapType::noext, NonNullable), Mutable),
130+ }};
114131
115132 struct FieldInfo {
116133 uint8_t index = 0 ;
@@ -316,32 +333,6 @@ void GroupClassInfo::permute(RecGroupInfo& info) {
316333 }
317334}
318335
319- std::array<Field, BrandTypeIterator::optionCount>
320- BrandTypeIterator::fieldOptions = {{}};
321-
322- void BrandTypeIterator::initFieldOptions () {
323- BrandTypeIterator::fieldOptions = {{
324- Field (Field::i8 , Mutable),
325- Field (Field::i16 , Mutable),
326- Field (Type::i32 , Mutable),
327- Field (Type::i64 , Mutable),
328- Field (Type::f32 , Mutable),
329- Field (Type::f64 , Mutable),
330- Field (Type (HeapType::any, Nullable), Mutable),
331- Field (Type (HeapType::func, Nullable), Mutable),
332- Field (Type (HeapType::ext, Nullable), Mutable),
333- Field (Type (HeapType::none, Nullable), Mutable),
334- Field (Type (HeapType::nofunc, Nullable), Mutable),
335- Field (Type (HeapType::noext, Nullable), Mutable),
336- Field (Type (HeapType::any, NonNullable), Mutable),
337- Field (Type (HeapType::func, NonNullable), Mutable),
338- Field (Type (HeapType::ext, NonNullable), Mutable),
339- Field (Type (HeapType::none, NonNullable), Mutable),
340- Field (Type (HeapType::nofunc, NonNullable), Mutable),
341- Field (Type (HeapType::noext, NonNullable), Mutable),
342- }};
343- }
344-
345336struct MinimizeRecGroups : Pass {
346337 // The types we are optimizing and their indices in this list.
347338 std::vector<HeapType> types;
@@ -387,8 +378,6 @@ struct MinimizeRecGroups : Pass {
387378 return ;
388379 }
389380
390- initBrandOptions ();
391-
392381 auto typeInfo = ModuleUtils::collectHeapTypeInfo (
393382 *module ,
394383 ModuleUtils::TypeInclusion::AllTypes,
@@ -445,15 +434,6 @@ struct MinimizeRecGroups : Pass {
445434 rewriteTypes (*module );
446435 }
447436
448- void initBrandOptions () {
449- // Initialize the field options for brand types lazily here to avoid
450- // depending on global constructor ordering.
451- [[maybe_unused]] static bool fieldsInitialized = []() {
452- BrandTypeIterator::initFieldOptions ();
453- return true ;
454- }();
455- }
456-
457437 void updateShapes () {
458438 while (!shapesToUpdate.empty ()) {
459439 auto index = shapesToUpdate.back ();
0 commit comments