@@ -891,15 +891,25 @@ struct InfoCollector
891891 handleIndirectCall (curr, curr->target ->type );
892892 }
893893
894- // Creates a location for a null of a particular type and adds a root for it.
895- // Such roots are where the default value of an i32 local comes from, or the
896- // value in a ref.null.
897- Location getNullLocation (Type type) {
898- auto location = NullLocation{type};
899- addRoot (location, PossibleContents::literal (Literal::makeZero (type)));
894+ // Creates a location for a root of a particular type, creating a RootLocation
895+ // and marking it as a root.
896+ Location getRootLocation (Type type, PossibleContents rootValue) {
897+ auto location = RootLocation{type};
898+ addRoot (location, rootValue);
900899 return location;
901900 }
902901
902+ // Creates a root location, settings its value by the type.
903+ Location getRootLocation (Type type) {
904+ return getRootLocation (type, PossibleContents::fromType (type));
905+ }
906+
907+ // Makes a root location containing a null.
908+ Location getNullLocation (Type type) {
909+ return getRootLocation (type,
910+ PossibleContents::literal (Literal::makeZero (type)));
911+ }
912+
903913 // Iterates over a list of children and adds links from them. The target of
904914 // those link is created using a function that is passed in, which receives
905915 // the index of the child.
@@ -1220,9 +1230,7 @@ struct InfoCollector
12201230 }
12211231
12221232 if (curr->catchRefs [tagIndex]) {
1223- auto location = CaughtExnRefLocation{};
1224- addRoot (location,
1225- PossibleContents::fromType (Type (HeapType::exn, NonNullable)));
1233+ auto location = getRootLocation (Type (HeapType::exn, NonNullable));
12261234 info.links .push_back (
12271235 {location, getBreakTargetLocation (target, exnrefIndex)});
12281236 }
@@ -3062,8 +3070,8 @@ void Flower::dump(Location location) {
30623070 std::cout << " sigparamloc " << ' \n ' ;
30633071 } else if (auto * loc = std::get_if<SignatureResultLocation>(&location)) {
30643072 std::cout << " sigresultloc " << loc->type << " : " << loc->index << ' \n ' ;
3065- } else if (auto * loc = std::get_if<NullLocation >(&location)) {
3066- std::cout << " Nullloc " << loc->type << ' \n ' ;
3073+ } else if (auto * loc = std::get_if<RootLocation >(&location)) {
3074+ std::cout << " rootloc " << loc->type << ' \n ' ;
30673075 } else {
30683076 std::cout << " (other)\n " ;
30693077 }
0 commit comments