summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/shell-interface.h7
-rw-r--r--src/tools/execution-results.h4
-rw-r--r--src/tools/wasm-ctor-eval.cpp7
-rw-r--r--src/wasm-interpreter.h34
4 files changed, 23 insertions, 29 deletions
diff --git a/src/shell-interface.h b/src/shell-interface.h
index 6101df29a..35f5772cf 100644
--- a/src/shell-interface.h
+++ b/src/shell-interface.h
@@ -151,7 +151,7 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface {
}
Literals callTable(Name tableName,
- Index index,
+ Address index,
HeapType sig,
Literals& arguments,
Type results,
@@ -287,7 +287,8 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface {
return (Index)tables[tableName].size();
}
- void tableStore(Name tableName, Index index, const Literal& entry) override {
+ void
+ tableStore(Name tableName, Address index, const Literal& entry) override {
auto& table = tables[tableName];
if (index >= table.size()) {
trap("out of bounds table access");
@@ -296,7 +297,7 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface {
}
}
- Literal tableLoad(Name tableName, Index index) override {
+ Literal tableLoad(Name tableName, Address index) override {
auto it = tables.find(tableName);
if (it == tables.end()) {
trap("tableGet on non-existing table");
diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h
index eb302b4b2..78cc5af1f 100644
--- a/src/tools/execution-results.h
+++ b/src/tools/execution-results.h
@@ -84,7 +84,7 @@ public:
if (!exportedTable) {
throwEmptyException();
}
- Index index = arguments[0].geti32();
+ auto index = arguments[0].getUnsigned();
if (index >= tables[exportedTable].size()) {
throwEmptyException();
}
@@ -93,7 +93,7 @@ public:
if (!exportedTable) {
throwEmptyException();
}
- Index index = arguments[0].geti32();
+ auto index = arguments[0].getUnsigned();
if (index >= tables[exportedTable].size()) {
throwEmptyException();
}
diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp
index 499c1bf6c..52c83b053 100644
--- a/src/tools/wasm-ctor-eval.cpp
+++ b/src/tools/wasm-ctor-eval.cpp
@@ -290,7 +290,7 @@ struct CtorEvalExternalInterface : EvallingModuleRunner::ExternalInterface {
// We assume the table is not modified FIXME
Literals callTable(Name tableName,
- Index index,
+ Address index,
HeapType sig,
Literals& arguments,
Type result,
@@ -363,12 +363,13 @@ struct CtorEvalExternalInterface : EvallingModuleRunner::ExternalInterface {
return wasm->getTableOrNull(tableName)->initial;
}
- Literal tableLoad(Name tableName, Index index) override {
+ Literal tableLoad(Name tableName, Address index) override {
throw FailToEvalException("table.get: TODO");
}
// called during initialization
- void tableStore(Name tableName, Index index, const Literal& value) override {
+ void
+ tableStore(Name tableName, Address index, const Literal& value) override {
// We allow stores to the table during initialization, but not after, as we
// assume the table does not change at runtime.
// TODO: Allow table changes by updating the table later like we do with the
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 7f1cf9054..1513b8f45 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -2598,7 +2598,7 @@ public:
virtual Literals callImport(Function* import,
const Literals& arguments) = 0;
virtual Literals callTable(Name tableName,
- Index index,
+ Address index,
HeapType sig,
Literals& arguments,
Type result,
@@ -2789,10 +2789,11 @@ public:
virtual Index tableSize(Name tableName) = 0;
- virtual void tableStore(Name tableName, Index index, const Literal& entry) {
+ virtual void
+ tableStore(Name tableName, Address index, const Literal& entry) {
WASM_UNREACHABLE("unimp");
}
- virtual Literal tableLoad(Name tableName, Index index) {
+ virtual Literal tableLoad(Name tableName, Address index) {
WASM_UNREACHABLE("unimp");
}
};
@@ -3141,13 +3142,11 @@ public:
}
auto index = target.getSingleValue().getUnsigned();
-
auto info = getTableInstanceInfo(curr->table);
if (curr->isReturn) {
// Return calls are represented by their arguments followed by a reference
// to the function to be called.
- // TODO: switch tableLoad index from Index to Address, to support table64.
auto funcref = info.interface()->tableLoad(info.name, index);
if (!Type::isSubType(funcref.type, Type(curr->heapType, NonNullable))) {
trap("cast failure in call_indirect");
@@ -3201,29 +3200,22 @@ public:
return index;
}
auto info = getTableInstanceInfo(curr->table);
- auto* table = info.instance->wasm.getTable(info.name);
- auto address = table->indexType == Type::i64
- ? index.getSingleValue().geti64()
- : index.getSingleValue().geti32();
+ auto address = index.getSingleValue().getUnsigned();
return info.interface()->tableLoad(info.name, address);
}
Flow visitTableSet(TableSet* curr) {
NOTE_ENTER("TableSet");
- Flow indexFlow = self()->visit(curr->index);
- if (indexFlow.breaking()) {
- return indexFlow;
+ Flow index = self()->visit(curr->index);
+ if (index.breaking()) {
+ return index;
}
- Flow valueFlow = self()->visit(curr->value);
- if (valueFlow.breaking()) {
- return valueFlow;
+ Flow value = self()->visit(curr->value);
+ if (value.breaking()) {
+ return value;
}
auto info = getTableInstanceInfo(curr->table);
- auto* table = info.instance->wasm.getTable(info.name);
- auto address = table->indexType == Type::i64
- ? indexFlow.getSingleValue().geti64()
- : indexFlow.getSingleValue().geti32();
- info.interface()->tableStore(
- info.name, address, valueFlow.getSingleValue());
+ auto address = index.getSingleValue().getUnsigned();
+ info.interface()->tableStore(info.name, address, value.getSingleValue());
return Flow();
}