From 89c16b98076a98aac78af3e4191b8a384aeef757 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 28 Jul 2016 19:57:16 +0300 Subject: [PATCH] Fixing bugs in WASM emitter --- .idea/compiler.xml | 21 +---- .idea/encodings.xml | 1 + .idea/misc.xml | 1 + .idea/modules.xml | 5 +- classlib/teavm-classlib.iml | 16 +--- core/pom.xml | 2 +- .../org/teavm/model/util/TypeInferer.java | 19 +++- .../org/teavm/model/util/VariableType.java | 4 - .../java/org/teavm/vm/TeaVMEntryPoint.java | 2 +- .../wasm/generate/WasmGenerationContext.java | 70 +++++++++++++++ .../wasm/generate/WasmGenerationVisitor.java | 30 +++++-- .../teavm/wasm/generate/WasmGenerator.java | 21 ++++- .../org/teavm/wasm/generate/WasmMangling.java | 14 ++- .../org/teavm/wasm/model/WasmFunction.java | 10 +-- .../java/org/teavm/wasm/model/WasmModule.java | 6 ++ .../org/teavm/wasm/render/WasmRenderer.java | 90 ++++++++++++++++--- .../wasm/render/WasmRenderingVisitor.java | 23 ++--- .../org/teavm/wasm/runtime/WasmRuntime.java | 3 + core/teavm-core.iml | 3 +- extras-slf4j/teavm-extras-slf4j.iml | 2 +- html4j/teavm-html4j.iml | 11 +-- interop/core/pom.xml | 68 ++++++++++++++ .../main/java/org/teavm/interop/Import.java | 29 ++++++ interop/core/teavm-interop.iml | 13 +++ jso/apis/teavm-jso-apis.iml | 1 - jso/impl/teavm-jso-impl.iml | 2 +- .../api/teavm-metaprogramming-api.iml | 1 - .../impl/teavm-metaprogramming-impl.iml | 3 +- platform/teavm-platform.iml | 3 +- samples/async/teavm-samples-async.iml | 4 +- samples/benchmark/teavm-samples-benchmark.iml | 10 +-- samples/hello/teavm-samples-hello.iml | 14 ++- samples/kotlin/teavm-samples-kotlin.iml | 4 +- samples/scala/teavm-samples-scala.iml | 6 +- samples/storage/teavm-samples-storage.iml | 4 +- samples/video/teavm-samples-video.iml | 4 +- teavm.iml | 10 +-- tests/teavm-tests.iml | 39 ++++---- tools/chrome-rdp/teavm-chrome-rdp.iml | 11 ++- tools/cli/teavm-cli.iml | 2 +- .../java/org/teavm/tooling/BaseTeaVMTool.java | 4 - .../java/org/teavm/tooling/ClassAlias.java | 4 - .../org/teavm/tooling/EmptyTeaVMToolLog.java | 4 - .../tooling/InstructionLocationReader.java | 4 - .../java/org/teavm/tooling/MethodAlias.java | 4 - .../teavm/tooling/RuntimeCopyOperation.java | 4 - .../teavm/tooling/TeaVMProblemRenderer.java | 4 - .../org/teavm/tooling/TeaVMToolException.java | 4 - .../java/org/teavm/tooling/TeaVMToolLog.java | 4 - tools/core/teavm-tooling.iml | 5 +- tools/junit/teavm-junit.iml | 27 +++--- tools/maven/plugin/teavm-maven-plugin.iml | 45 +++++----- tools/maven/webapp/teavm-maven-webapp.iml | 12 --- 53 files changed, 457 insertions(+), 250 deletions(-) create mode 100644 core/src/main/java/org/teavm/wasm/generate/WasmGenerationContext.java create mode 100644 interop/core/pom.xml create mode 100644 interop/core/src/main/java/org/teavm/interop/Import.java create mode 100644 interop/core/teavm-interop.iml diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 1dab4bc59..1a58b7f65 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,31 +1,14 @@ - - - \ No newline at end of file diff --git a/samples/kotlin/teavm-samples-kotlin.iml b/samples/kotlin/teavm-samples-kotlin.iml index bc264de3b..a85a09e4a 100644 --- a/samples/kotlin/teavm-samples-kotlin.iml +++ b/samples/kotlin/teavm-samples-kotlin.iml @@ -29,17 +29,17 @@ + + - - \ No newline at end of file diff --git a/samples/scala/teavm-samples-scala.iml b/samples/scala/teavm-samples-scala.iml index 9e12cf33d..e4c68b885 100644 --- a/samples/scala/teavm-samples-scala.iml +++ b/samples/scala/teavm-samples-scala.iml @@ -25,18 +25,18 @@ + + - + - - \ No newline at end of file diff --git a/samples/storage/teavm-samples-storage.iml b/samples/storage/teavm-samples-storage.iml index 071b1a57f..fa88bfc84 100644 --- a/samples/storage/teavm-samples-storage.iml +++ b/samples/storage/teavm-samples-storage.iml @@ -25,18 +25,18 @@ + + - - \ No newline at end of file diff --git a/samples/video/teavm-samples-video.iml b/samples/video/teavm-samples-video.iml index 071b1a57f..fa88bfc84 100644 --- a/samples/video/teavm-samples-video.iml +++ b/samples/video/teavm-samples-video.iml @@ -25,18 +25,18 @@ + + - - \ No newline at end of file diff --git a/teavm.iml b/teavm.iml index 3c52d870a..66b3d797e 100644 --- a/teavm.iml +++ b/teavm.iml @@ -1,20 +1,12 @@ - - - - - + \ No newline at end of file diff --git a/tests/teavm-tests.iml b/tests/teavm-tests.iml index d806c3b07..857d16271 100644 --- a/tests/teavm-tests.iml +++ b/tests/teavm-tests.iml @@ -11,62 +11,63 @@ - + + + - - + - - - - - - - - - - + + - - + + + + + + + + + + + + + - + - - - diff --git a/tools/chrome-rdp/teavm-chrome-rdp.iml b/tools/chrome-rdp/teavm-chrome-rdp.iml index d50747558..ced1fa45a 100644 --- a/tools/chrome-rdp/teavm-chrome-rdp.iml +++ b/tools/chrome-rdp/teavm-chrome-rdp.iml @@ -4,7 +4,6 @@ - @@ -29,29 +28,29 @@ - + + - + + - - + - diff --git a/tools/cli/teavm-cli.iml b/tools/cli/teavm-cli.iml index 431354a90..9449af91d 100644 --- a/tools/cli/teavm-cli.iml +++ b/tools/cli/teavm-cli.iml @@ -11,7 +11,7 @@ - + diff --git a/tools/core/src/main/java/org/teavm/tooling/BaseTeaVMTool.java b/tools/core/src/main/java/org/teavm/tooling/BaseTeaVMTool.java index b279ff85b..cf1e0ca28 100644 --- a/tools/core/src/main/java/org/teavm/tooling/BaseTeaVMTool.java +++ b/tools/core/src/main/java/org/teavm/tooling/BaseTeaVMTool.java @@ -21,10 +21,6 @@ import java.util.Properties; import org.teavm.model.ClassHolderTransformer; import org.teavm.tooling.sources.SourceFileProvider; -/** - * - * @author Alexey Andreev - */ public interface BaseTeaVMTool { void setTargetDirectory(File targetDirectory); diff --git a/tools/core/src/main/java/org/teavm/tooling/ClassAlias.java b/tools/core/src/main/java/org/teavm/tooling/ClassAlias.java index f5fe8a5e9..4b55bda8e 100644 --- a/tools/core/src/main/java/org/teavm/tooling/ClassAlias.java +++ b/tools/core/src/main/java/org/teavm/tooling/ClassAlias.java @@ -15,10 +15,6 @@ */ package org.teavm.tooling; -/** - * - * @author Alexey Andreev - */ public class ClassAlias { private String className; private String alias; diff --git a/tools/core/src/main/java/org/teavm/tooling/EmptyTeaVMToolLog.java b/tools/core/src/main/java/org/teavm/tooling/EmptyTeaVMToolLog.java index 1a87b689d..4c67319c7 100644 --- a/tools/core/src/main/java/org/teavm/tooling/EmptyTeaVMToolLog.java +++ b/tools/core/src/main/java/org/teavm/tooling/EmptyTeaVMToolLog.java @@ -15,10 +15,6 @@ */ package org.teavm.tooling; -/** - * - * @author Alexey Andreev - */ public class EmptyTeaVMToolLog implements TeaVMToolLog { @Override public void info(String text) { diff --git a/tools/core/src/main/java/org/teavm/tooling/InstructionLocationReader.java b/tools/core/src/main/java/org/teavm/tooling/InstructionLocationReader.java index 8876bb2c9..94acdbc4c 100644 --- a/tools/core/src/main/java/org/teavm/tooling/InstructionLocationReader.java +++ b/tools/core/src/main/java/org/teavm/tooling/InstructionLocationReader.java @@ -29,10 +29,6 @@ import org.teavm.model.instructions.InvocationType; import org.teavm.model.instructions.NumericOperandType; import org.teavm.model.instructions.SwitchTableEntryReader; -/** - * - * @author Alexey Andreev - */ class InstructionLocationReader implements InstructionReader { private Set resources; diff --git a/tools/core/src/main/java/org/teavm/tooling/MethodAlias.java b/tools/core/src/main/java/org/teavm/tooling/MethodAlias.java index 58a6bdadb..9431bc69b 100644 --- a/tools/core/src/main/java/org/teavm/tooling/MethodAlias.java +++ b/tools/core/src/main/java/org/teavm/tooling/MethodAlias.java @@ -15,10 +15,6 @@ */ package org.teavm.tooling; -/** - * - * @author Alexey Andreev - */ public class MethodAlias { private String alias; private String className; diff --git a/tools/core/src/main/java/org/teavm/tooling/RuntimeCopyOperation.java b/tools/core/src/main/java/org/teavm/tooling/RuntimeCopyOperation.java index aa3b493d7..9d037fdec 100644 --- a/tools/core/src/main/java/org/teavm/tooling/RuntimeCopyOperation.java +++ b/tools/core/src/main/java/org/teavm/tooling/RuntimeCopyOperation.java @@ -15,10 +15,6 @@ */ package org.teavm.tooling; -/** - * - * @author Alexey Andreev - */ public enum RuntimeCopyOperation { SEPARATE, MERGED, diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java index 18a056d96..10cf1e52a 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMProblemRenderer.java @@ -26,10 +26,6 @@ import org.teavm.model.InstructionLocation; import org.teavm.model.MethodReference; import org.teavm.vm.TeaVM; -/** - * - * @author Alexey Andreev - */ public final class TeaVMProblemRenderer { private TeaVMProblemRenderer() { } diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMToolException.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMToolException.java index 3045b5bad..da8557078 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMToolException.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMToolException.java @@ -15,10 +15,6 @@ */ package org.teavm.tooling; -/** - * - * @author Alexey Andreev - */ public class TeaVMToolException extends Exception { private static final long serialVersionUID = 579149191624783241L; diff --git a/tools/core/src/main/java/org/teavm/tooling/TeaVMToolLog.java b/tools/core/src/main/java/org/teavm/tooling/TeaVMToolLog.java index 079bcf1bb..a1fd66d78 100644 --- a/tools/core/src/main/java/org/teavm/tooling/TeaVMToolLog.java +++ b/tools/core/src/main/java/org/teavm/tooling/TeaVMToolLog.java @@ -15,10 +15,6 @@ */ package org.teavm.tooling; -/** - * - * @author Alexey Andreev - */ public interface TeaVMToolLog { void info(String text); diff --git a/tools/core/teavm-tooling.iml b/tools/core/teavm-tooling.iml index 45225ea38..189842508 100644 --- a/tools/core/teavm-tooling.iml +++ b/tools/core/teavm-tooling.iml @@ -4,10 +4,9 @@ - - + @@ -24,7 +23,7 @@ - + diff --git a/tools/junit/teavm-junit.iml b/tools/junit/teavm-junit.iml index b99d88a1a..27f92f31d 100644 --- a/tools/junit/teavm-junit.iml +++ b/tools/junit/teavm-junit.iml @@ -6,7 +6,6 @@ - @@ -15,48 +14,48 @@ - + + + + + + + + - + - - - - - - + + + - + - - - - diff --git a/tools/maven/plugin/teavm-maven-plugin.iml b/tools/maven/plugin/teavm-maven-plugin.iml index f65ba1b46..5e3cc1337 100644 --- a/tools/maven/plugin/teavm-maven-plugin.iml +++ b/tools/maven/plugin/teavm-maven-plugin.iml @@ -5,7 +5,6 @@ - @@ -14,76 +13,76 @@ + + + + + + + + - - + + - - - - - - - - + + - + + + + + + - + - - - - - - + + - + - - - diff --git a/tools/maven/webapp/teavm-maven-webapp.iml b/tools/maven/webapp/teavm-maven-webapp.iml index 41632c8c2..0fa2e18ed 100644 --- a/tools/maven/webapp/teavm-maven-webapp.iml +++ b/tools/maven/webapp/teavm-maven-webapp.iml @@ -1,17 +1,5 @@ - - - - - - - - - - - -