diff --git a/core/src/main/java/org/teavm/backend/wasm/intrinsics/LongIntrinsic.java b/core/src/main/java/org/teavm/backend/wasm/intrinsics/LongIntrinsic.java index a05771c67..6db12665b 100644 --- a/core/src/main/java/org/teavm/backend/wasm/intrinsics/LongIntrinsic.java +++ b/core/src/main/java/org/teavm/backend/wasm/intrinsics/LongIntrinsic.java @@ -16,6 +16,8 @@ package org.teavm.backend.wasm.intrinsics; import org.teavm.ast.InvocationExpr; +import org.teavm.backend.wasm.WasmRuntime; +import org.teavm.backend.wasm.model.expression.WasmCall; import org.teavm.backend.wasm.model.expression.WasmExpression; import org.teavm.backend.wasm.model.expression.WasmIntBinary; import org.teavm.backend.wasm.model.expression.WasmIntBinaryOperation; @@ -23,6 +25,9 @@ import org.teavm.backend.wasm.model.expression.WasmIntType; import org.teavm.model.MethodReference; public class LongIntrinsic implements WasmIntrinsic { + private static final MethodReference COMPARE_UNSIGNED = new MethodReference(WasmRuntime.class, + "compareUnsigned", long.class, long.class, int.class); + @Override public boolean isApplicable(MethodReference methodReference) { if (!methodReference.getClassName().equals(Long.class.getName())) { @@ -32,6 +37,7 @@ public class LongIntrinsic implements WasmIntrinsic { switch (methodReference.getName()) { case "divideUnsigned": case "remainderUnsigned": + case "compareUnsigned": return true; default: return false; @@ -49,6 +55,10 @@ public class LongIntrinsic implements WasmIntrinsic { return new WasmIntBinary(WasmIntType.INT64, WasmIntBinaryOperation.REM_UNSIGNED, manager.generate(invocation.getArguments().get(0)), manager.generate(invocation.getArguments().get(1))); + case "compareUnsigned": + return new WasmCall(manager.getNames().forMethod(COMPARE_UNSIGNED), + manager.generate(invocation.getArguments().get(0)), + manager.generate(invocation.getArguments().get(1))); default: throw new AssertionError(); }