@@ -80,6 +80,11 @@ class EvallingImportResolver : public ImportResolver {
8080 return &stubLiteral;
8181 }
8282
83+ RuntimeTable* getTableOrNull (ImportNames name,
84+ const Table& type) const override {
85+ throw FailToEvalException{" Imported table access." };
86+ }
87+
8388private:
8489 mutable Literals stubLiteral;
8590};
@@ -156,17 +161,6 @@ std::unique_ptr<Module> buildEnvModule(Module& wasm) {
156161 }
157162 });
158163
159- // create tables with similar initial and max values
160- ModuleUtils::iterImportedTables (wasm, [&](Table* table) {
161- if (table->module == env->name ) {
162- auto * copied = ModuleUtils::copyTable (table, *env);
163- copied->module = Name ();
164- copied->base = Name ();
165- env->addExport (Builder (*env).makeExport (
166- table->base , copied->name , ExternalKind::Table));
167- }
168- });
169-
170164 // create an exported memory with the same initial and max size
171165 ModuleUtils::iterImportedMemories (wasm, [&](Memory* memory) {
172166 if (memory->module == env->name ) {
@@ -316,68 +310,6 @@ struct CtorEvalExternalInterface : EvallingModuleRunner::ExternalInterface {
316310 }
317311
318312 // We assume the table is not modified FIXME
319- Literal tableLoad (Name tableName, Address index) override {
320- auto * table = wasm->getTableOrNull (tableName);
321- if (!table) {
322- throw FailToEvalException (" tableLoad on non-existing table" );
323- }
324-
325- // Look through the segments and find the value. Segments can overlap,
326- // so we want the last one.
327- Expression* value = nullptr ;
328- for (auto & segment : wasm->elementSegments ) {
329- if (segment->table != tableName) {
330- continue ;
331- }
332-
333- Index start;
334- // look for the index in this segment. if it has a constant offset, we
335- // look in the proper range. if it instead gets a global, we rely on the
336- // fact that when not dynamically linking then the table is loaded at
337- // offset 0.
338- if (auto * c = segment->offset ->dynCast <Const>()) {
339- start = c->value .getInteger ();
340- } else if (segment->offset ->is <GlobalGet>()) {
341- start = 0 ;
342- } else {
343- // wasm spec only allows const and global.get there
344- WASM_UNREACHABLE (" invalid expr type" );
345- }
346- auto end = start + segment->data .size ();
347- if (start <= index && index < end) {
348- value = segment->data [index - start];
349- }
350- }
351-
352- if (!value) {
353- // No segment had a value for this.
354- return Literal::makeNull (HeapTypes::func);
355- }
356- if (!Properties::isConstantExpression (value)) {
357- throw FailToEvalException (" tableLoad of non-literal" );
358- }
359- if (auto * r = value->dynCast <RefFunc>()) {
360- return instance->makeFuncData (r->func , r->type );
361- }
362- return Properties::getLiteral (value);
363- }
364-
365- Index tableSize (Name tableName) override {
366- // See tableLoad above, we assume the table is not modified FIXME
367- return wasm->getTableOrNull (tableName)->initial ;
368- }
369-
370- // called during initialization
371- void
372- tableStore (Name tableName, Address index, const Literal& value) override {
373- // We allow stores to the table during initialization, but not after, as we
374- // assume the table does not change at runtime.
375- // TODO: Allow table changes by updating the table later like we do with the
376- // memory, by tracking and serializing them.
377- if (instanceInitialized) {
378- throw FailToEvalException (" tableStore after init: TODO" );
379- }
380- }
381313
382314 int8_t load8s (Address addr, Name memoryName) override {
383315 return doLoad<int8_t >(addr, memoryName);
@@ -431,13 +363,6 @@ struct CtorEvalExternalInterface : EvallingModuleRunner::ExternalInterface {
431363 throw FailToEvalException (" grow memory" );
432364 }
433365
434- bool growTable (Name /* name*/ ,
435- const Literal& /* value*/ ,
436- Index /* oldSize*/ ,
437- Index /* newSize*/ ) override {
438- throw FailToEvalException (" grow table" );
439- }
440-
441366 void trap (std::string_view why) override {
442367 throw FailToEvalException (std::string (" trap: " ) + std::string (why));
443368 }
@@ -1145,6 +1070,9 @@ EvalCtorOutcome evalCtor(EvallingModuleRunner& instance,
11451070 std::cout << " ...stopping due to non-constant func\n " ;
11461071 }
11471072 break ;
1073+ } catch (TrapException trap) {
1074+ std::cout << " ...stopping due to trap" ;
1075+ break ;
11481076 }
11491077
11501078 if (flow.breakTo == NONCONSTANT_FLOW) {
0 commit comments