From 4f431f4170a7753492eb9a46ca250d80b6e4aa92 Mon Sep 17 00:00:00 2001 From: lax1dude Date: Sat, 30 Nov 2024 12:45:26 -0800 Subject: [PATCH] Add support for string pools over 10000 strings --- .../wasm/generate/gc/strings/WasmGCStringPool.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/gc/strings/WasmGCStringPool.java b/core/src/main/java/org/teavm/backend/wasm/generate/gc/strings/WasmGCStringPool.java index 3784b12ef..0204afead 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/gc/strings/WasmGCStringPool.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/gc/strings/WasmGCStringPool.java @@ -93,11 +93,17 @@ public class WasmGCStringPool implements WasmGCStringProvider, WasmGCInitializer void.class)); function.getBody().add(new WasmCall(internInit)); } - var array = new WasmArrayNewFixed(stringsArray); - for (var str : stringMap.values()) { - array.getElements().add(new WasmGetGlobal(str.global)); + var stringIterator = stringMap.values().iterator(); + while (stringIterator.hasNext()) { + var elementCount = 0; + var array = new WasmArrayNewFixed(stringsArray); + // WasmArrayNewFixed cannot be larger than 10000 elements + while (elementCount < 10000 && stringIterator.hasNext()) { + array.getElements().add(new WasmGetGlobal(stringIterator.next().global)); + ++elementCount; + } + function.getBody().add(new WasmCall(initStringsFunction, array)); } - function.getBody().add(new WasmCall(initStringsFunction, array)); } @Override