From d09affce8547edc9c496a535fded1315126bee08 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 10 Apr 2017 21:35:02 +0300 Subject: [PATCH] WASM: fix translation of lookupswitch when min and max values differ by more than 2^31 --- .../teavm/backend/wasm/generate/WasmGenerationVisitor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 c76c6f934..ae43064c1 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 @@ -745,7 +745,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor { WasmBlock defaultTarget = wrapper; wrapper = defaultBlock; - if (max - min >= SWITCH_TABLE_THRESHOLD) { + if ((long) max - (long) min >= SWITCH_TABLE_THRESHOLD) { translateSwitchToBinarySearch(statement, condition, initialWrapper, defaultTarget, targets); } else { translateSwitchToWasmSwitch(statement, condition, initialWrapper, defaultTarget, targets, min, max); @@ -804,7 +804,7 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor { final int label; final WasmBlock target; - public TableEntry(int label, WasmBlock target) { + TableEntry(int label, WasmBlock target) { this.label = label; this.target = target; }