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