wasm gc: add support for string pools over 10000 strings (#977)

Due to limit in spec that allows `ref.array_new_fixed` to take up to 10000 arguments
This commit is contained in:
lax1dude 2024-12-02 00:35:28 -08:00 committed by GitHub
parent bf15f0e299
commit 516602d32d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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