Skip to content

Commit

Permalink
wasm gc: add support for string pools over 10000 strings (#977)
Browse files Browse the repository at this point in the history
Due to limit in spec that allows `ref.array_new_fixed` to take up to 10000 arguments
  • Loading branch information
lax1dude authored Dec 2, 2024
1 parent bf15f0e commit 516602d
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,17 @@ public void contributeToInitializer(WasmFunction function) {
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
Expand Down

0 comments on commit 516602d

Please sign in to comment.