2222#define wasm_shell_interface_h
2323
2424#include " asmjs/shared-constants.h"
25+ #include " interpreter/exception.h"
2526#include " ir/module-utils.h"
2627#include " shared-constants.h"
2728#include " support/name.h"
3132
3233namespace wasm {
3334
34- // An exception emitted when exit() is called.
35- struct ExitException {};
36-
37- // An exception emitted when a wasm trap occurs.
38- struct TrapException {};
39-
40- // An exception emitted when a host limitation is hit. (These are not wasm traps
41- // as they are not in the spec; for example, the spec has no limit on how much
42- // GC memory may be allocated, but hosts have limits.)
43- struct HostLimitException {};
44-
4535struct ShellExternalInterface : ModuleRunner::ExternalInterface {
4636 // The underlying memory can be accessed through unaligned pointers which
4737 // isn't well-behaved in C++. WebAssembly nonetheless expects it to behave
@@ -93,7 +83,6 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface {
9383 };
9484
9585 std::map<Name, Memory> memories;
96- std::unordered_map<Name, std::vector<Literal>> tables;
9786 std::map<Name, std::shared_ptr<ModuleRunner>> linkedInstances;
9887
9988 ShellExternalInterface (
@@ -125,8 +114,6 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface {
125114 shellMemory.resize (memory->initial * wasm::Memory::kPageSize );
126115 memories[memory->name ] = shellMemory;
127116 });
128- ModuleUtils::iterDefinedTables (
129- wasm, [&](Table* table) { tables[table->name ].resize (table->initial ); });
130117 }
131118
132119 Literal getImportedFunction (Function* import ) override {
@@ -255,35 +242,6 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface {
255242 auto & memory = it->second ;
256243 memory.set <std::array<uint8_t , 16 >>(addr, value);
257244 }
258-
259- Index tableSize (Name tableName) override {
260- return (Index)tables[tableName].size ();
261- }
262-
263- void
264- tableStore (Name tableName, Address index, const Literal& entry) override {
265- auto & table = tables[tableName];
266- if (index >= table.size ()) {
267- trap (" out of bounds table access" );
268- } else {
269- table[index] = entry;
270- }
271- }
272-
273- Literal tableLoad (Name tableName, Address index) override {
274- auto it = tables.find (tableName);
275- if (it == tables.end ()) {
276- trap (" tableGet on non-existing table" );
277- }
278-
279- auto & table = it->second ;
280- if (index >= table.size ()) {
281- trap (" out of bounds table access" );
282- }
283-
284- return table[index];
285- }
286-
287245 bool
288246 growMemory (Name memoryName, Address /* oldSize*/ , Address newSize) override {
289247 // Apply a reasonable limit on memory size, 1GB, to avoid DOS on the
@@ -299,20 +257,6 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface {
299257 memory.resize (newSize);
300258 return true ;
301259 }
302-
303- bool growTable (Name name,
304- const Literal& value,
305- Index /* oldSize*/ ,
306- Index newSize) override {
307- // Apply a reasonable limit on table size, 1GB, to avoid DOS on the
308- // interpreter.
309- if (newSize > 1024 * 1024 * 1024 ) {
310- return false ;
311- }
312- tables[name].resize (newSize, value);
313- return true ;
314- }
315-
316260 void trap (std::string_view why) override {
317261 std::cout << " [trap " << why << " ]\n " ;
318262 throw TrapException ();
0 commit comments