From 717bbe620aa36bc7b85040eade18b1a0300bcec4 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 11 Oct 2016 11:51:05 -0700 Subject: use wasmTableSize when provided --- src/js/wasm.js-post.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index e7d461642..cc1f29c10 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -290,7 +290,7 @@ function integrateWasmJS(Module) { // import table if (!env['table']) { - var TABLE_SIZE = 1024; // TODO + var TABLE_SIZE = Module['wasmTableSize'] || 1024; if (typeof WebAssembly === 'object' && typeof WebAssembly.Table === 'function') { env['table'] = new WebAssembly.Table({ initial: TABLE_SIZE, maximum: TABLE_SIZE, element: 'anyfunc' }); } else { -- cgit v1.2.3 From a3dc8bf8cba7cd1b5ece8abf0489a9dcacfa3f2e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 11 Oct 2016 13:51:34 -0700 Subject: refactor memoryBase and tableBase init to a shared location, so it affects native builds too --- src/js/wasm.js-post.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index cc1f29c10..58e4c75cd 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -223,13 +223,6 @@ function integrateWasmJS(Module) { env['memory'] = providedBuffer; assert(env['memory'] instanceof ArrayBuffer); - if (!('memoryBase' in env)) { - env['memoryBase'] = STATIC_BASE; // tell the memory segments where to place themselves - } - if (!('tableBase' in env)) { - env['tableBase'] = 0; // tell the memory segments where to place themselves - } - wasmJS['providedTotalMemory'] = Module['buffer'].byteLength; // Prepare to generate wasm, using either asm2wasm or s-exprs @@ -297,6 +290,13 @@ function integrateWasmJS(Module) { env['table'] = new Array(TABLE_SIZE); // works in binaryen interpreter at least } } + + if (!env['memoryBase']) { + env['memoryBase'] = STATIC_BASE; // tell the memory segments where to place themselves + } + if (!env['tableBase']) { + env['tableBase'] = 0; // table starts at 0 by default, in dynamic linking this will change + } // try the methods. each should return the exports if it succeeded -- cgit v1.2.3 From 1e783f3e96f904b88b692522de04f786feaf41a0 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 11 Oct 2016 14:40:23 -0700 Subject: allow a maximum 0 size for a table --- src/passes/Print.cpp | 2 +- src/wasm-binary.h | 36 ++++++++++++++-------------- test/empty_table.wast | 4 ++++ test/empty_table.wast.fromBinary | 5 ++++ test/empty_table.wast.fromBinary.noDebugInfo | 5 ++++ 5 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 test/empty_table.wast create mode 100644 test/empty_table.wast.fromBinary create mode 100644 test/empty_table.wast.fromBinary.noDebugInfo (limited to 'src') diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 33b5f5d16..075d013e5 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -615,7 +615,7 @@ struct PrintSExpression : public Visitor { void printTableHeader(Table* curr) { printOpening(o, "table") << ' '; o << curr->initial; - if (curr->max && curr->max != Table::kMaxSize) o << ' ' << curr->max; + if (curr->max != Table::kMaxSize) o << ' ' << curr->max; o << " anyfunc)"; } void visitTable(Table *curr) { diff --git a/src/wasm-binary.h b/src/wasm-binary.h index eef315fda..43a43b5c4 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -558,11 +558,11 @@ public: return ret; } - void writeResizableLimits(Address initial, Address maximum) { - uint32_t flags = maximum ? 1 : 0; + void writeResizableLimits(Address initial, Address maximum, bool hasMaximum) { + uint32_t flags = hasMaximum ? 1 : 0; o << U32LEB(flags); o << U32LEB(initial); - if (flags) { + if (hasMaximum) { o << U32LEB(maximum); } } @@ -590,8 +590,7 @@ public: if (debug) std::cerr << "== writeMemory" << std::endl; auto start = startSection(BinaryConsts::Section::Memory); o << U32LEB(1); // Define 1 memory - Address max = wasm->memory.max == Memory::kMaxSize ? Address(0) : wasm->memory.max; - writeResizableLimits(wasm->memory.initial, max); + writeResizableLimits(wasm->memory.initial, wasm->memory.max, wasm->memory.max != Memory::kMaxSize); finishSection(start); } @@ -639,13 +638,12 @@ public: case ExternalKind::Function: o << U32LEB(getFunctionTypeIndex(import->functionType->name)); break; case ExternalKind::Table: { o << U32LEB(BinaryConsts::ElementType::AnyFunc); - auto max = wasm->table.max == Table::kMaxSize ? Address(0) : wasm->table.max; - writeResizableLimits(wasm->table.initial, max); + writeResizableLimits(wasm->table.initial, wasm->table.max, wasm->table.max != Table::kMaxSize); break; } case ExternalKind::Memory: { - auto max = wasm->memory.max == Memory::kMaxSize ? Address(0) : wasm->memory.max; - writeResizableLimits(wasm->memory.initial, max); break; + writeResizableLimits(wasm->memory.initial, wasm->memory.max, wasm->memory.max != Memory::kMaxSize); + break; } case ExternalKind::Global: o << binaryWasmType(import->globalType); @@ -850,8 +848,7 @@ public: auto start = startSection(BinaryConsts::Section::Table); o << U32LEB(1); // Declare 1 table. o << U32LEB(BinaryConsts::ElementType::AnyFunc); - Address max = wasm->table.max == Table::kMaxSize ? Address(0) : wasm->table.max; - writeResizableLimits(wasm->table.initial, max); + writeResizableLimits(wasm->table.initial, wasm->table.max, wasm->table.max != Table::kMaxSize); finishSection(start); } @@ -1562,7 +1559,7 @@ public: auto numMemories = getU32LEB(); if (!numMemories) return; assert(numMemories == 1); - getResizableLimits(wasm.memory.initial, &wasm.memory.max); + getResizableLimits(wasm.memory.initial, wasm.memory.max, Memory::kMaxSize); } void readSignatures() { @@ -1606,12 +1603,12 @@ public: } } - void getResizableLimits(Address& initial, Address* max) { + void getResizableLimits(Address& initial, Address& max, Address defaultIfNoMax) { auto flags = getU32LEB(); initial = getU32LEB(); bool hasMax = flags & 0x1; - assert(max || !hasMax); - if (hasMax) *max = getU32LEB(); + if (hasMax) max = getU32LEB(); + else max = defaultIfNoMax; } void readImports() { @@ -1640,10 +1637,13 @@ public: if (elementType != BinaryConsts::ElementType::AnyFunc) throw ParseException("Imported table type is not AnyFunc"); wasm.table.exists = true; wasm.table.imported = true; - getResizableLimits(wasm.table.initial, &wasm.table.max); + getResizableLimits(wasm.table.initial, wasm.table.max, Table::kMaxSize); + break; + } + case ExternalKind::Memory: { + getResizableLimits(wasm.memory.initial, wasm.memory.max, Memory::kMaxSize); break; } - case ExternalKind::Memory: getResizableLimits(wasm.memory.initial, &wasm.memory.max); break; case ExternalKind::Global: { curr->globalType = getWasmType(); auto globalMutable = getU32LEB(); @@ -1897,7 +1897,7 @@ public: wasm.table.exists = true; auto elemType = getU32LEB(); if (elemType != BinaryConsts::ElementType::AnyFunc) throw ParseException("ElementType must be AnyFunc in MVP"); - getResizableLimits(wasm.table.initial, &wasm.table.max); + getResizableLimits(wasm.table.initial, wasm.table.max, Table::kMaxSize); } void readTableElements() { diff --git a/test/empty_table.wast b/test/empty_table.wast new file mode 100644 index 000000000..17ce9d6b2 --- /dev/null +++ b/test/empty_table.wast @@ -0,0 +1,4 @@ +(module + (table 0 0 anyfunc) + (memory $0 0) +) diff --git a/test/empty_table.wast.fromBinary b/test/empty_table.wast.fromBinary new file mode 100644 index 000000000..219d2388c --- /dev/null +++ b/test/empty_table.wast.fromBinary @@ -0,0 +1,5 @@ +(module + (table 0 0 anyfunc) + (memory $0 0) +) + diff --git a/test/empty_table.wast.fromBinary.noDebugInfo b/test/empty_table.wast.fromBinary.noDebugInfo new file mode 100644 index 000000000..219d2388c --- /dev/null +++ b/test/empty_table.wast.fromBinary.noDebugInfo @@ -0,0 +1,5 @@ +(module + (table 0 0 anyfunc) + (memory $0 0) +) + -- cgit v1.2.3 From 6e04c61c78cdf8196b6944c290041611d1f68d2d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 11 Oct 2016 14:48:12 -0700 Subject: if we see no asm.js function tables, the table size is 0 --- src/asm2wasm.h | 5 ++++- test/empty.fromasm | 2 +- test/empty.fromasm.imprecise | 2 +- test/empty.fromasm.imprecise.no-opts | 2 +- test/empty.fromasm.no-opts | 2 +- test/hello_world.fromasm | 2 +- test/hello_world.fromasm.imprecise | 2 +- test/hello_world.fromasm.imprecise.no-opts | 2 +- test/hello_world.fromasm.no-opts | 2 +- test/i64-setTempRet0.fromasm | 2 +- test/i64-setTempRet0.fromasm.imprecise | 2 +- test/i64-setTempRet0.fromasm.imprecise.no-opts | 2 +- test/i64-setTempRet0.fromasm.no-opts | 2 +- test/min.fromasm | 2 +- test/min.fromasm.imprecise | 2 +- test/min.fromasm.imprecise.no-opts | 2 +- test/min.fromasm.no-opts | 2 +- test/two_sides.fromasm | 2 +- test/two_sides.fromasm.imprecise | 2 +- test/two_sides.fromasm.imprecise.no-opts | 2 +- test/two_sides.fromasm.no-opts | 2 +- test/wasm-only.fromasm | 2 +- test/wasm-only.fromasm.imprecise | 2 +- test/wasm-only.fromasm.imprecise.no-opts | 2 +- test/wasm-only.fromasm.no-opts | 2 +- 25 files changed, 28 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/asm2wasm.h b/src/asm2wasm.h index b2e7f5512..9b503c84d 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -664,6 +664,10 @@ void Asm2WasmBuilder::processAsm(Ref ast) { }, debug, false /* do not validate globally yet */); } + // if we see no function tables in the processing below, then the table still exists and has size 0 + + wasm.table.initial = wasm.table.max = 0; + // first pass - do almost everything, but function imports and indirect calls for (unsigned i = 1; i < body->size(); i++) { @@ -784,7 +788,6 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // TODO: when not using aliasing function pointers, we could merge them by noticing that // index 0 in each table is the null func, and each other index should only have one // non-null func. However, that breaks down when function pointer casts are emulated. - wasm.table.exists = true; if (wasm.table.segments.size() == 0) { wasm.table.segments.emplace_back(wasm.allocator.alloc()->set(Literal(uint32_t(0)))); } diff --git a/test/empty.fromasm b/test/empty.fromasm index 055939559..a8d289e29 100644 --- a/test/empty.fromasm +++ b/test/empty.fromasm @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (data (get_global $memoryBase) "empty.asm.js") diff --git a/test/empty.fromasm.imprecise b/test/empty.fromasm.imprecise index ea0f983fc..cc8aa47c3 100644 --- a/test/empty.fromasm.imprecise +++ b/test/empty.fromasm.imprecise @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) ) diff --git a/test/empty.fromasm.imprecise.no-opts b/test/empty.fromasm.imprecise.no-opts index ea0f983fc..cc8aa47c3 100644 --- a/test/empty.fromasm.imprecise.no-opts +++ b/test/empty.fromasm.imprecise.no-opts @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) ) diff --git a/test/empty.fromasm.no-opts b/test/empty.fromasm.no-opts index ea0f983fc..cc8aa47c3 100644 --- a/test/empty.fromasm.no-opts +++ b/test/empty.fromasm.no-opts @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) ) diff --git a/test/hello_world.fromasm b/test/hello_world.fromasm index f88f3e94a..160736cd1 100644 --- a/test/hello_world.fromasm +++ b/test/hello_world.fromasm @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (data (get_global $memoryBase) "hello_world.asm.js") diff --git a/test/hello_world.fromasm.imprecise b/test/hello_world.fromasm.imprecise index fd9a167c6..2c544bd65 100644 --- a/test/hello_world.fromasm.imprecise +++ b/test/hello_world.fromasm.imprecise @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (export "add" (func $add)) diff --git a/test/hello_world.fromasm.imprecise.no-opts b/test/hello_world.fromasm.imprecise.no-opts index 64ddcb01d..dae1480b7 100644 --- a/test/hello_world.fromasm.imprecise.no-opts +++ b/test/hello_world.fromasm.imprecise.no-opts @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (export "add" (func $add)) diff --git a/test/hello_world.fromasm.no-opts b/test/hello_world.fromasm.no-opts index 64ddcb01d..dae1480b7 100644 --- a/test/hello_world.fromasm.no-opts +++ b/test/hello_world.fromasm.no-opts @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (export "add" (func $add)) diff --git a/test/i64-setTempRet0.fromasm b/test/i64-setTempRet0.fromasm index 52710e5cc..c0fe551c8 100644 --- a/test/i64-setTempRet0.fromasm +++ b/test/i64-setTempRet0.fromasm @@ -4,7 +4,7 @@ (import "env" "illegalImportResult" (func $illegalImportResult (result i64))) (import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (data (get_global $memoryBase) "i64-setTempRet0.asm.js") diff --git a/test/i64-setTempRet0.fromasm.imprecise b/test/i64-setTempRet0.fromasm.imprecise index 6151e53d4..ca78b824b 100644 --- a/test/i64-setTempRet0.fromasm.imprecise +++ b/test/i64-setTempRet0.fromasm.imprecise @@ -4,7 +4,7 @@ (import "env" "illegalImportResult" (func $illegalImportResult (result i64))) (import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (global $tempRet0 (mut i32) (i32.const 0)) diff --git a/test/i64-setTempRet0.fromasm.imprecise.no-opts b/test/i64-setTempRet0.fromasm.imprecise.no-opts index 7d8ea6e3a..3c26a29bd 100644 --- a/test/i64-setTempRet0.fromasm.imprecise.no-opts +++ b/test/i64-setTempRet0.fromasm.imprecise.no-opts @@ -4,7 +4,7 @@ (import "env" "illegalImportResult" (func $illegalImportResult (result i64))) (import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (global $tempRet0 (mut i32) (i32.const 0)) diff --git a/test/i64-setTempRet0.fromasm.no-opts b/test/i64-setTempRet0.fromasm.no-opts index 7d8ea6e3a..3c26a29bd 100644 --- a/test/i64-setTempRet0.fromasm.no-opts +++ b/test/i64-setTempRet0.fromasm.no-opts @@ -4,7 +4,7 @@ (import "env" "illegalImportResult" (func $illegalImportResult (result i64))) (import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (global $tempRet0 (mut i32) (i32.const 0)) diff --git a/test/min.fromasm b/test/min.fromasm index 0ce8573af..96a40e52b 100644 --- a/test/min.fromasm +++ b/test/min.fromasm @@ -1,7 +1,7 @@ (module (import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32)) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (data (get_global $memoryBase) "min.asm.js") diff --git a/test/min.fromasm.imprecise b/test/min.fromasm.imprecise index 30f58d884..219c77609 100644 --- a/test/min.fromasm.imprecise +++ b/test/min.fromasm.imprecise @@ -1,7 +1,7 @@ (module (import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32)) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (global $tDP (mut i32) (get_global $tDP$asm2wasm$import)) diff --git a/test/min.fromasm.imprecise.no-opts b/test/min.fromasm.imprecise.no-opts index 8244c4c70..b6c55dd2d 100644 --- a/test/min.fromasm.imprecise.no-opts +++ b/test/min.fromasm.imprecise.no-opts @@ -1,7 +1,7 @@ (module (import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32)) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (global $tDP (mut i32) (get_global $tDP$asm2wasm$import)) diff --git a/test/min.fromasm.no-opts b/test/min.fromasm.no-opts index 8244c4c70..b6c55dd2d 100644 --- a/test/min.fromasm.no-opts +++ b/test/min.fromasm.no-opts @@ -1,7 +1,7 @@ (module (import "env" "tempDoublePtr" (global $tDP$asm2wasm$import i32)) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (global $tDP (mut i32) (get_global $tDP$asm2wasm$import)) diff --git a/test/two_sides.fromasm b/test/two_sides.fromasm index 8b8886727..2b9bcaf46 100644 --- a/test/two_sides.fromasm +++ b/test/two_sides.fromasm @@ -2,7 +2,7 @@ (type $FUNCSIG$id (func (param f64) (result i32))) (import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (data (get_global $memoryBase) "two_sides.asm.js") diff --git a/test/two_sides.fromasm.imprecise b/test/two_sides.fromasm.imprecise index f0b5af618..386e2ebd9 100644 --- a/test/two_sides.fromasm.imprecise +++ b/test/two_sides.fromasm.imprecise @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (export "_test" (func $_test)) diff --git a/test/two_sides.fromasm.imprecise.no-opts b/test/two_sides.fromasm.imprecise.no-opts index 6c489599c..2abda5dca 100644 --- a/test/two_sides.fromasm.imprecise.no-opts +++ b/test/two_sides.fromasm.imprecise.no-opts @@ -1,6 +1,6 @@ (module (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (export "_test" (func $_test)) diff --git a/test/two_sides.fromasm.no-opts b/test/two_sides.fromasm.no-opts index 46d36938a..f49fc79b3 100644 --- a/test/two_sides.fromasm.no-opts +++ b/test/two_sides.fromasm.no-opts @@ -2,7 +2,7 @@ (type $FUNCSIG$id (func (param f64) (result i32))) (import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (export "_test" (func $_test)) diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm index a2c335b1c..64a30a03b 100644 --- a/test/wasm-only.fromasm +++ b/test/wasm-only.fromasm @@ -8,7 +8,7 @@ (import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32))) (import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (data (get_global $memoryBase) "wasm-only.asm.js") diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise index 8a9115ff9..77dc70050 100644 --- a/test/wasm-only.fromasm.imprecise +++ b/test/wasm-only.fromasm.imprecise @@ -8,7 +8,7 @@ (import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32))) (import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (export "test64" (func $test64)) diff --git a/test/wasm-only.fromasm.imprecise.no-opts b/test/wasm-only.fromasm.imprecise.no-opts index c2000c5b1..51b93cf67 100644 --- a/test/wasm-only.fromasm.imprecise.no-opts +++ b/test/wasm-only.fromasm.imprecise.no-opts @@ -8,7 +8,7 @@ (import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32))) (import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (export "test64" (func $test64)) diff --git a/test/wasm-only.fromasm.no-opts b/test/wasm-only.fromasm.no-opts index 43b9ba4cd..4d52a2eab 100644 --- a/test/wasm-only.fromasm.no-opts +++ b/test/wasm-only.fromasm.no-opts @@ -8,7 +8,7 @@ (import "env" "illegalImport" (func $legalimport$illegalImport (param f64 i32 i32 i32))) (import "env" "illegalImportResult" (func $legalimport$illegalImportResult (result i32))) (import "env" "memory" (memory $0 256 256)) - (import "env" "table" (table 0 anyfunc)) + (import "env" "table" (table 0 0 anyfunc)) (import "env" "memoryBase" (global $memoryBase i32)) (import "env" "tableBase" (global $tableBase i32)) (export "test64" (func $test64)) -- cgit v1.2.3 From 943fd287247f9d23d463a24e8eb4b0f666900c43 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 11 Oct 2016 14:50:34 -0700 Subject: wasmTableSize of 0 is allowed --- src/js/wasm.js-post.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/js/wasm.js-post.js b/src/js/wasm.js-post.js index 58e4c75cd..f093ff64d 100644 --- a/src/js/wasm.js-post.js +++ b/src/js/wasm.js-post.js @@ -283,7 +283,8 @@ function integrateWasmJS(Module) { // import table if (!env['table']) { - var TABLE_SIZE = Module['wasmTableSize'] || 1024; + var TABLE_SIZE = Module['wasmTableSize']; + if (TABLE_SIZE === undefined) TABLE_SIZE = 1024; // works in binaryen interpreter at least if (typeof WebAssembly === 'object' && typeof WebAssembly.Table === 'function') { env['table'] = new WebAssembly.Table({ initial: TABLE_SIZE, maximum: TABLE_SIZE, element: 'anyfunc' }); } else { -- cgit v1.2.3