Skip to content

Commit

Permalink
[WASM] Add back the NormalizeInstantiation pass to the modular pipeli…
Browse files Browse the repository at this point in the history
…ne now that it does not need global information.

PiperOrigin-RevId: 587087736
  • Loading branch information
rluble authored and copybara-github committed Dec 1, 2023
1 parent 7c03f54 commit c9bbe69
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ public ImmutableList<Supplier<NormalizationPass>> getPassFactories(BackendOption
NormalizeFieldInitialization::new,
ImplementInstanceInitialization::new,
NormalizeLabels::new,
NormalizeInstantiationThroughFactoryMethods::new,
ImplementStaticInitializationViaConditionChecks::new,
ImplementClassMetadataViaGetters::new,
ImplementStringCompileTimeConstants::new,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@

;;; Code for emptymethod.EmptyMethod [methods]

;;; EmptyMethod()
(func $m_<init>[email protected]
(param $this (ref null $emptymethod.EmptyMethod))
;;; EmptyMethod EmptyMethod.$create()
(func [email protected]
(result (ref null $emptymethod.EmptyMethod))
;;@ emptymethod/EmptyMethod.java:18:13
(local $$instance (ref null $emptymethod.EmptyMethod))
(block
;;@ emptymethod/EmptyMethod.java:18:13
(call [email protected] )
;;@ emptymethod/EmptyMethod.java:18:13
(local.set $$instance (struct.new $emptymethod.EmptyMethod (ref.as_non_null (global.get $emptymethod.EmptyMethod.vtable)) (ref.as_non_null (global.get $itable.empty)) (i32.const 0)))
;;@ emptymethod/EmptyMethod.java:18:13
(call [email protected] (ref.as_non_null (local.get $$instance)))
;;@ emptymethod/EmptyMethod.java:18:13
(return (local.get $$instance))
)
)

;;; void EmptyMethod.$ctor()
(func [email protected]
(param $this (ref null $emptymethod.EmptyMethod))
;;@ emptymethod/EmptyMethod.java:18:13
(block
;;@ emptymethod/EmptyMethod.java:18:13
(drop (call $m_<init>__@java.lang.Object ))
(call $$ctor__void_$p_java_lang_Object@java.lang.Object (ref.as_non_null (local.get $this)))
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,30 @@
;;; End of code for interfaces.Main.SubInterface [methods]
;;; Code for interfaces.Main [methods]

;;; Main()
(func $m_<init>[email protected]
(param $this (ref null $interfaces.Main))
;;; Main Main.$create()
(func [email protected]
(result (ref null $interfaces.Main))
;;@ interfaces/Main.java:18:13
(local $$instance (ref null $interfaces.Main))
(block
;;@ interfaces/Main.java:18:13
(call [email protected] )
;;@ interfaces/Main.java:18:13
(local.set $$instance (struct.new $interfaces.Main (ref.as_non_null (global.get $interfaces.Main.vtable)) (ref.as_non_null (global.get $itable.empty)) (i32.const 0)))
;;@ interfaces/Main.java:18:13
(call [email protected] (ref.as_non_null (local.get $$instance)))
;;@ interfaces/Main.java:18:13
(return (local.get $$instance))
)
)

;;; void Main.$ctor()
(func [email protected]
(param $this (ref null $interfaces.Main))
;;@ interfaces/Main.java:18:13
(block
;;@ interfaces/Main.java:18:13
(drop (call $m_<init>__@java.lang.Object ))
(call $$ctor__void_$p_java_lang_Object@java.lang.Object (ref.as_non_null (local.get $this)))
)
)

Expand All @@ -155,7 +171,7 @@
(local.set $this (ref.cast (ref $interfaces.Main) (local.get $this.untyped)))
(block
;;@ interfaces/Main.java:50:4
(local.set $i (struct.new $interfaces.Main.Implementor (ref.as_non_null (global.get $interfaces.Main.Implementor.vtable)) (ref.as_non_null (global.get $interfaces.Main.Implementor.itable)) (i32.const 0) (ref.null $interfaces.Main)))
(local.set $i (call $$create__interfaces_Main@interfaces.Main.Implementor (local.get $this)))
;;@ interfaces/Main.java:51:4
(call_ref $function.m_interfaceMethod__void (ref.as_non_null (local.get $i))(struct.get $interfaces.Main.Interface.vtable $m_interfaceMethod__void (ref.cast (ref $interfaces.Main.Interface.vtable) (struct.get $itable $interfaces.Main.Interface (struct.get $java.lang.Object $itable (local.get $i))))))
;;@ interfaces/Main.java:52:4
Expand All @@ -164,7 +180,7 @@
(call [email protected] )
;;@ interfaces/Main.java:54:4
(local.set $x (i32.add (block (result i32)
(drop (struct.new $interfaces.Main.Implementor (ref.as_non_null (global.get $interfaces.Main.Implementor.vtable)) (ref.as_non_null (global.get $interfaces.Main.Implementor.itable)) (i32.const 0) (ref.null $interfaces.Main)))
(drop (call $$create__interfaces_Main@interfaces.Main.Implementor (local.get $this)))
(i32.const 1)
) (i32.const 2)))
)
Expand Down Expand Up @@ -230,17 +246,34 @@
;;; End of code for interfaces.Main [methods]
;;; Code for interfaces.Main.Implementor [methods]

;;; Implementor(Main $outer_this)
(func $m_<init>[email protected]
(param $this (ref null $interfaces.Main.Implementor))
;;; Implementor Implementor.$create(Main $outer_this)
(func [email protected]
(param $$outer_this (ref null $interfaces.Main))
(result (ref null $interfaces.Main.Implementor))
;;@ interfaces/Main.java:41:8
(local $$instance (ref null $interfaces.Main.Implementor))
(block
;;@ interfaces/Main.java:41:8
(call [email protected] )
;;@ interfaces/Main.java:41:8
(local.set $$instance (struct.new $interfaces.Main.Implementor (ref.as_non_null (global.get $interfaces.Main.Implementor.vtable)) (ref.as_non_null (global.get $interfaces.Main.Implementor.itable)) (i32.const 0) (ref.null $interfaces.Main)))
;;@ interfaces/Main.java:41:8
(call $$ctor__interfaces_Main__void_$p_interfaces_Main_Implementor@interfaces.Main.Implementor (ref.as_non_null (local.get $$instance))(local.get $$outer_this))
;;@ interfaces/Main.java:41:8
(return (local.get $$instance))
)
)

;;; void Implementor.$ctor(Main $outer_this)
(func $$ctor__interfaces_Main__void_$p_interfaces_Main_Implementor@interfaces.Main.Implementor
(param $this (ref null $interfaces.Main.Implementor))
(param $$outer_this (ref null $interfaces.Main))
;;@ interfaces/Main.java:41:8
(block
;;@ interfaces/Main.java:41:8
(struct.set $interfaces.Main.Implementor $$outer_this__interfaces_Main_Implementor (local.get $this) (local.get $$outer_this))
;;@ interfaces/Main.java:41:8
(drop (call $m_<init>__@java.lang.Object ))
(call $$ctor__void_$p_java_lang_Object@java.lang.Object (ref.as_non_null (local.get $this)))
)
)

Expand Down Expand Up @@ -349,17 +382,16 @@
;;; End of code for interfaces.Main.Implementor [methods]
;;; Code for interfaces.Main.AbstractImplementor [methods]

;;; AbstractImplementor(Main $outer_this)
(func $m_<init>__interfaces_Main@interfaces.Main.AbstractImplementor
;;; void AbstractImplementor.$ctor(Main $outer_this)
(func $$ctor__interfaces_Main__void_$p_interfaces_Main_AbstractImplementor@interfaces.Main.AbstractImplementor
(param $this (ref null $interfaces.Main.AbstractImplementor))
(param $$outer_this (ref null $interfaces.Main))
(result (ref null $interfaces.Main.AbstractImplementor))
;;@ interfaces/Main.java:47:17
(block
;;@ interfaces/Main.java:47:17
(struct.set $interfaces.Main.AbstractImplementor $$outer_this__interfaces_Main_AbstractImplementor (local.get $this) (local.get $$outer_this))
;;@ interfaces/Main.java:47:17
(drop (call $m_<init>__@java.lang.Object ))
(call $$ctor__void_$p_java_lang_Object@java.lang.Object (ref.as_non_null (local.get $this)))
)
)

Expand Down

0 comments on commit c9bbe69

Please sign in to comment.