From be672c057bcb39b27f34f4031eea747bd72161d2 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 18 Nov 2021 16:16:19 -0800 Subject: [Wasm GC] Global Refining pass (#4344) Fairly simple, this uses the existing infrastructure to find opportunities to refine the type of a global variable. This a common pattern in j2wasm for example, where a global begins as a null of $java.lang.Object (the least specific type) but it is in practice always assigned an object of some specific type. --- src/passes/pass.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/passes/pass.cpp') diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 49615d81b..d20a5edcd 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -154,6 +154,8 @@ void PassRegistry::registerPasses() { createGenerateI64DynCallsPass); registerPass( "generate-stack-ir", "generate Stack IR", createGenerateStackIRPass); + registerPass( + "global-refining", "refine the types of globals", createGlobalRefiningPass); registerPass( "gto", "globally optimize GC types", createGlobalTypeOptimizationPass); registerPass("type-refining", @@ -528,6 +530,7 @@ void PassRunner::addDefaultGlobalOptimizationPrePasses() { if (wasm->features.hasGC() && getTypeSystem() == TypeSystem::Nominal && options.optimizeLevel >= 2) { addIfNoDWARFIssues("type-refining"); + addIfNoDWARFIssues("global-refining"); // Global type optimization can remove fields that are not needed, which can // remove ref.funcs that were once assigned to vtables but are no longer // needed, which can allow more code to be removed globally. After those, -- cgit v1.2.3