diff --git a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java index b252c996d..e02f7718b 100644 --- a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java +++ b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java @@ -353,13 +353,12 @@ public class WasmTarget implements TeaVMTarget { initFunction.getBody().add(new WasmCall(WasmMangling.mangleInitializer(className))); } module.add(initFunction); - //module.setStartFunction(initFunction); + module.setStartFunction(initFunction); for (TeaVMEntryPoint entryPoint : controller.getEntryPoints().values()) { String mangledName = WasmMangling.mangleMethod(entryPoint.getReference()); WasmFunction function = module.getFunctions().get(mangledName); if (function != null) { - function.getBody().add(0, new WasmCall(initFunction.getName())); function.setExportName(entryPoint.getPublicName()); } } diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java index 94b3ab7cd..52006a788 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/WasmGenerationVisitor.java @@ -1226,7 +1226,6 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor { WasmIntBinaryOperation.GT_SIGNED, new WasmGetLocal(tagVar), new WasmInt32Constant(ranges.get(i - 1).upper)); WasmConditional conditional = new WasmConditional(upperThanExcluded); - conditional.setType(WasmType.INT32); WasmExpression lowerThanExcluded = new WasmIntBinary(WasmIntType.INT32, WasmIntBinaryOperation.LT_SIGNED, new WasmGetLocal(tagVar), new WasmInt32Constant(ranges.get(i).lower)); diff --git a/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java b/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java index 98a240c6f..6b1aee78e 100644 --- a/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java +++ b/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java @@ -70,16 +70,17 @@ class WasmBinaryRenderingVisitor implements WasmExpressionVisitor { @Override public void visit(WasmBlock expression) { - depth += expression.isLoop() ? 2 : 1; + int blockDepth = expression.isLoop() & version == WasmBinaryVersion.V_0xB ? 2 : 1; + depth += blockDepth; blockDepths.put(expression, depth); - writer.writeByte(expression.isLoop() ? 0x02 : 0x01); + writer.writeByte(expression.isLoop() ? 0x02 : 0x01); writeBlockType(expression.getType()); for (WasmExpression part : expression.getBody()) { part.acceptVisitor(this); } writer.writeByte(0x0F); blockDepths.remove(expression); - depth -= expression.isLoop() ? 2 : 1; + depth -= blockDepth; } private void writeBlockType(WasmType type) {