-
Notifications
You must be signed in to change notification settings - Fork 65
Understand the Compiler
If you want contribute or you want solve a problem it can be helpful to understand the compiler and how it work.
-
Before starting JWebAssembly, the compiler from Java or another JVM language must compile the code. This has the advantages that it support any JVM languages, libraries and that it can compile classes of the Java runtime to WebAssembly code. The downside is that a lot of information is lost.
-
In the first phase (prepare phase)JWebAssembly scan all sources (source class files) and the libraries for the JWebAssembly annotations.
-
In the next step (scan phase), the required methods are recursively scanned, beginning from all methods using @Export annotation. This creates a list of necessary methods, classes and fields. If you enable the debug log then you can see which method find which reference. This can be helpful to find the cause why a method that failed to compile is needed.
-
In the last step (finish phase) all needed methods are read again and compiled to the WebAssembly code.