From ab507bb22b40dfd19ce352d997ba734f564da3a5 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Wed, 27 Sep 2023 20:28:09 +0200 Subject: [PATCH] wasm: fix bugs in coroutine support --- .../backend/lowlevel/transform/CoroutineTransformation.java | 2 +- core/src/main/java/org/teavm/backend/wasm/WasmTarget.java | 2 +- .../org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java | 4 ---- .../src/main/resources/org/teavm/backend/wasm/wasm-runtime.js | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/teavm/backend/lowlevel/transform/CoroutineTransformation.java b/core/src/main/java/org/teavm/backend/lowlevel/transform/CoroutineTransformation.java index 3f70d46b7..0ba70c232 100644 --- a/core/src/main/java/org/teavm/backend/lowlevel/transform/CoroutineTransformation.java +++ b/core/src/main/java/org/teavm/backend/lowlevel/transform/CoroutineTransformation.java @@ -126,6 +126,7 @@ public class CoroutineTransformation { splitter.fixProgram(); processIrreducibleCfg(); RedundantJumpElimination.optimize(program); + new PhiUpdater().updatePhis(program, parameterCount + 1); } private void createSplitPrologue() { @@ -479,7 +480,6 @@ public class CoroutineTransformation { weights[i] = program.basicBlockAt(i).instructionCount(); } GraphUtils.splitIrreducibleGraph(graph, weights, splittingBackend); - new PhiUpdater().updatePhis(program, parameterCount + 1); } class SplittingBackend implements GraphSplittingBackend { 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 b95820650..40526d592 100644 --- a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java +++ b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java @@ -1114,7 +1114,7 @@ public class WasmTarget implements TeaVMTarget, TeaVMWasmHost { @Override public boolean isAsyncSupported() { - return false; + return true; } @Override diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java index 826a173a3..ae7826cc1 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/PlatformIntrinsic.java @@ -17,7 +17,6 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; import org.teavm.backend.wasm.model.expression.WasmExpression; -import org.teavm.backend.wasm.model.expression.WasmInt32Constant; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodReference; @@ -34,7 +33,6 @@ public class PlatformIntrinsic implements WasmIntrinsic { switch (methodDescriptor.getName()) { case "getPlatformObject": case "asJavaClass": - case "createQueue": return true; default: return false; @@ -47,8 +45,6 @@ public class PlatformIntrinsic implements WasmIntrinsic { case "getPlatformObject": case "asJavaClass": return manager.generate(invocation.getArguments().get(0)); - case "createQueue": - return new WasmInt32Constant(0); default: throw new IllegalArgumentException(invocation.getMethod().toString()); } diff --git a/core/src/main/resources/org/teavm/backend/wasm/wasm-runtime.js b/core/src/main/resources/org/teavm/backend/wasm/wasm-runtime.js index dac22a5f6..c3ea3b587 100644 --- a/core/src/main/resources/org/teavm/backend/wasm/wasm-runtime.js +++ b/core/src/main/resources/org/teavm/backend/wasm/wasm-runtime.js @@ -88,7 +88,7 @@ TeaVM.wasm = function() { } } if (result >= 0) { - controller.timer = setTimeout(() => process(controller), result) + controller.timer = setTimeout(() => process(controller), Number(result)) } }