diff options
author | Alon Zakai <azakai@google.com> | 2021-11-18 16:16:19 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-18 16:16:19 -0800 |
commit | be672c057bcb39b27f34f4031eea747bd72161d2 (patch) | |
tree | d3696677f15f23818be29b1bb0856a47fbe8b5f3 /src/passes/pass.cpp | |
parent | cba41cc227346c8a8357aa06bb1d916663c29dfe (diff) | |
download | binaryen-be672c057bcb39b27f34f4031eea747bd72161d2.tar.gz binaryen-be672c057bcb39b27f34f4031eea747bd72161d2.tar.bz2 binaryen-be672c057bcb39b27f34f4031eea747bd72161d2.zip |
[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.
Diffstat (limited to 'src/passes/pass.cpp')
-rw-r--r-- | src/passes/pass.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
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 @@ -155,6 +155,8 @@ void PassRegistry::registerPasses() { 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", "apply more specific subtypes to type fields where possible", @@ -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, |