summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2024-05-10 16:33:38 -0700
committerGitHub <noreply@github.com>2024-05-10 23:33:38 +0000
commitabc430b617385f3e989f85e7bd1c2a9d838fd217 (patch)
tree5a7869083ae64cc59a04cb5512b3f175fade02d5 /src/wasm-interpreter.h
parent9975b56614d4a5560b35f009be20d51e360b69dc (diff)
downloadbinaryen-abc430b617385f3e989f85e7bd1c2a9d838fd217.tar.gz
binaryen-abc430b617385f3e989f85e7bd1c2a9d838fd217.tar.bz2
binaryen-abc430b617385f3e989f85e7bd1c2a9d838fd217.zip
[memory64] Add table64 to existing memory64 support (#6577)
Tests is still very limited. Hopefully we can use the upstream spec tests soon and avoid having to write our own tests for `.set/.set/.fill/etc`. See https://github.com/WebAssembly/memory64/issues/51
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index a9bba774b..bfc1a27c5 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -3086,8 +3086,11 @@ public:
return index;
}
auto info = getTableInterfaceInfo(curr->table);
- return info.interface->tableLoad(info.name,
- index.getSingleValue().geti32());
+ auto* table = wasm.getTable(info.name);
+ auto address = table->indexType == Type::i64
+ ? index.getSingleValue().geti64()
+ : index.getSingleValue().geti32();
+ return info.interface->tableLoad(info.name, address);
}
Flow visitTableSet(TableSet* curr) {
NOTE_ENTER("TableSet");
@@ -3100,17 +3103,20 @@ public:
return valueFlow;
}
auto info = getTableInterfaceInfo(curr->table);
- info.interface->tableStore(info.name,
- indexFlow.getSingleValue().geti32(),
- valueFlow.getSingleValue());
+ auto* table = wasm.getTable(info.name);
+ auto address = table->indexType == Type::i64
+ ? indexFlow.getSingleValue().geti64()
+ : indexFlow.getSingleValue().geti32();
+ info.interface->tableStore(info.name, address, valueFlow.getSingleValue());
return Flow();
}
Flow visitTableSize(TableSize* curr) {
NOTE_ENTER("TableSize");
auto info = getTableInterfaceInfo(curr->table);
+ auto* table = wasm.getTable(info.name);
Index tableSize = info.interface->tableSize(curr->table);
- return Literal::makeFromInt32(tableSize, Type::i32);
+ return Literal::makeFromInt64(tableSize, table->indexType);
}
Flow visitTableGrow(TableGrow* curr) {
@@ -3126,16 +3132,16 @@ public:
Name tableName = curr->table;
auto info = getTableInterfaceInfo(tableName);
- Index tableSize = info.interface->tableSize(tableName);
- Flow ret = Literal::makeFromInt32(tableSize, Type::i32);
- Flow fail = Literal::makeFromInt32(-1, Type::i32);
+ Index tableSize = info.interface->tableSize(info.name);
+ auto* table = self()->wasm.getTable(info.name);
+ Flow ret = Literal::makeFromInt64(tableSize, table->indexType);
+ Flow fail = Literal::makeFromInt64(-1, table->indexType);
Index delta = deltaFlow.getSingleValue().geti32();
if (tableSize >= uint32_t(-1) - delta) {
return fail;
}
- auto maxTableSize = self()->wasm.getTable(tableName)->max;
- if (uint64_t(tableSize) + uint64_t(delta) > uint64_t(maxTableSize)) {
+ if (uint64_t(tableSize) + uint64_t(delta) > uint64_t(table->max)) {
return fail;
}
Index newSize = tableSize + delta;
@@ -3168,9 +3174,14 @@ public:
Name tableName = curr->table;
auto info = getTableInterfaceInfo(tableName);
- Index dest = destFlow.getSingleValue().geti32();
+ auto* table = self()->wasm.getTable(info.name);
+ Index dest = table->indexType == Type::i64
+ ? destFlow.getSingleValue().geti64()
+ : destFlow.getSingleValue().geti32();
Literal value = valueFlow.getSingleValue();
- Index size = sizeFlow.getSingleValue().geti32();
+ Index size = table->indexType == Type::i64
+ ? sizeFlow.getSingleValue().geti64()
+ : sizeFlow.getSingleValue().geti32();
Index tableSize = info.interface->tableSize(tableName);
if (dest + size > tableSize) {