Backed out changeset 7a39a87c6bb9 (bug 1308056)

This commit is contained in:
Sebastian Hengst 2016-10-11 14:25:17 +02:00
Родитель 19f705d5d8
Коммит 2742cc30e9
12 изменённых файлов: 71 добавлений и 175 удалений

Просмотреть файл

@ -1170,7 +1170,7 @@ RenderTableSection(WasmRenderContext& c, const AstModule& module)
if (!RenderIndent(c))
return false;
if (!c.buffer.append("(table anyfunc (elem "))
if (!c.buffer.append("(table"))
return false;
for (const AstRef& elem : segment.elems()) {
@ -1189,7 +1189,7 @@ RenderTableSection(WasmRenderContext& c, const AstModule& module)
}
}
if (!c.buffer.append("))\n"))
if (!c.buffer.append(")\n"))
return false;
return true;

Просмотреть файл

@ -65,7 +65,6 @@ class WasmToken
enum Kind
{
Align,
AnyFunc,
BinaryOpcode,
Block,
Br,
@ -107,6 +106,7 @@ class WasmToken
Offset,
OpenParen,
Param,
Resizable,
Result,
Return,
Segment,
@ -283,7 +283,6 @@ class WasmToken
case Unreachable:
return true;
case Align:
case AnyFunc:
case CloseParen:
case Data:
case Elem:
@ -307,6 +306,7 @@ class WasmToken
case Offset:
case OpenParen:
case Param:
case Resizable:
case Result:
case Segment:
case SignedInteger:
@ -323,12 +323,6 @@ class WasmToken
}
};
struct InlineImport
{
WasmToken module;
WasmToken field;
};
} // end anonymous namespace
static bool
@ -828,8 +822,6 @@ WasmTokenStream::next()
case 'a':
if (consume(u"align"))
return WasmToken(WasmToken::Align, begin, cur_);
if (consume(u"anyfunc"))
return WasmToken(WasmToken::AnyFunc, begin, cur_);
break;
case 'b':
@ -1419,6 +1411,8 @@ WasmTokenStream::next()
break;
case 'r':
if (consume(u"resizable"))
return WasmToken(WasmToken::Resizable, begin, cur_);
if (consume(u"result"))
return WasmToken(WasmToken::Result, begin, cur_);
if (consume(u"return"))
@ -2745,20 +2739,6 @@ ParseGlobalType(WasmParseContext& c, WasmToken* typeToken, uint32_t* flags)
return true;
}
static bool
ParseElemType(WasmParseContext& c)
{
// Only AnyFunc is allowed at the moment.
return c.ts.match(WasmToken::AnyFunc, c.error);
}
static bool
ParseTableSig(WasmParseContext& c, Limits* table)
{
return ParseLimits(c, table) &&
ParseElemType(c);
}
static AstImport*
ParseImport(WasmParseContext& c, AstModule* module)
{
@ -2785,11 +2765,8 @@ ParseImport(WasmParseContext& c, AstModule* module)
DefinitionKind::Memory, memory);
}
if (c.ts.getIf(WasmToken::Table)) {
if (name.empty())
name = c.ts.getIfName();
Limits table;
if (!ParseTableSig(c, &table))
if (!ParseLimits(c, &table))
return nullptr;
if (!c.ts.match(WasmToken::CloseParen, c.error))
return nullptr;
@ -2928,67 +2905,20 @@ ParseExport(WasmParseContext& c)
c.ts.generateError(exportee, c.error);
return nullptr;
}
static bool
ParseInlineImport(WasmParseContext& c, InlineImport* import)
{
return c.ts.match(WasmToken::Text, &import->module, c.error) &&
c.ts.match(WasmToken::Text, &import->field, c.error);
}
static bool
ParseInlineExport(WasmParseContext& c, DefinitionKind kind, AstModule* module)
{
WasmToken name;
if (!c.ts.match(WasmToken::Text, &name, c.error))
return false;
auto* exp = new(c.lifo) AstExport(name.text(), kind);
if (!exp || !module->append(exp))
return false;
return true;
}
static bool
ParseTable(WasmParseContext& c, WasmToken token, AstModule* module)
{
AstName name = c.ts.getIfName();
if (c.ts.getIf(WasmToken::OpenParen)) {
// Either an import and we're done, or an export and continue.
if (c.ts.getIf(WasmToken::Import)) {
InlineImport names;
if (!ParseInlineImport(c, &names))
return false;
if (!c.ts.match(WasmToken::CloseParen, c.error))
return false;
Limits table;
if (!ParseTableSig(c, &table))
return false;
auto* import = new(c.lifo) AstImport(name, names.module.text(), names.field.text(),
DefinitionKind::Table, table);
return import && module->append(import);
}
if (!c.ts.match(WasmToken::Export, c.error)) {
c.ts.generateError(token, c.error);
if (!c.ts.match(WasmToken::Resizable, c.error))
return false;
}
if (!ParseInlineExport(c, DefinitionKind::Table, module))
Limits table;
if (!ParseLimits(c, &table))
return false;
if (!c.ts.match(WasmToken::CloseParen, c.error))
return false;
}
// Either: min max? anyfunc
if (c.ts.peek().kind() == WasmToken::Index) {
Limits table;
if (!ParseTableSig(c, &table))
return false;
if (!module->setTable(table)) {
c.ts.generateError(token, c.error);
return false;
@ -2996,15 +2926,6 @@ ParseTable(WasmParseContext& c, WasmToken token, AstModule* module)
return true;
}
// Or: anyfunc (elem 1 2 ...)
if (!ParseElemType(c))
return false;
if (!c.ts.match(WasmToken::OpenParen, c.error))
return false;
if (!c.ts.match(WasmToken::Elem, c.error))
return false;
AstRefVector elems(c.lifo);
AstRef elem;
@ -3013,9 +2934,6 @@ ParseTable(WasmParseContext& c, WasmToken token, AstModule* module)
return false;
}
if (!c.ts.match(WasmToken::CloseParen, c.error))
return false;
uint32_t numElements = uint32_t(elems.length());
if (numElements != elems.length())
return false;
@ -3079,7 +2997,7 @@ ParseModule(const char16_t* text, LifoAlloc& lifo, UniqueChars* error)
if (!c.ts.match(WasmToken::Module, c.error))
return nullptr;
auto* module = new(c.lifo) AstModule(c.lifo);
auto module = new(c.lifo) AstModule(c.lifo);
if (!module || !module->init())
return nullptr;

Просмотреть файл

@ -375,7 +375,7 @@ var {v2i, i2i, i2v} = wasmEvalText(`(module
(func (type 1) (i32.add (get_local 0) (i32.const 2)))
(func (type 1) (i32.add (get_local 0) (i32.const 3)))
(func (type 1) (i32.add (get_local 0) (i32.const 4)))
(table anyfunc (elem 0 1 2 3 4 5))
(table 0 1 2 3 4 5)
(func (param i32) (result i32) (call_indirect 0 (get_local 0)))
(func (param i32) (param i32) (result i32) (call_indirect 1 (get_local 1) (get_local 0)))
(func (param i32) (call_indirect 2 (i32.const 0) (get_local 0)))
@ -417,7 +417,7 @@ assertErrorMessage(() => i2v(5), Error, signatureMismatch);
(import $foo "" "f")
(func $a (call_import $foo))
(func $b (result i32) (i32.const 0))
(table anyfunc (elem $a $b))
(table $a $b)
(func $bar (call_indirect $v2v (i32.const 0)))
(export "" $bar)
)`,

Просмотреть файл

@ -93,14 +93,15 @@ for (let i = 0; i < 5; i++) {
}
// Initializer expressions can also be used in elem section initializers.
wasmFailValidateText(`(module (import "globals" "a" (global f32 immutable)) (table 4 anyfunc) (elem (get_global 0) $f) (func $f))`, /type mismatch/);
wasmFailValidateText(`(module (import "globals" "a" (global f32 immutable)) (table (resizable 4)) (elem (get_global 0) $f) (func $f))`, /type mismatch/);
module = wasmEvalText(`(module
(import "globals" "a" (global i32 immutable))
(table (export "tbl") 4 anyfunc)
(table (resizable 4))
(elem (get_global 0) $f)
(func $f)
(export "f" $f)
(export "tbl" table)
)`, {
globals: {
a: 1

Просмотреть файл

@ -70,13 +70,13 @@ assertEq(new Instance(m5, {a:{b:mem2Page}}) instanceof Instance, true);
assertEq(new Instance(m5, {a:{b:mem3Page}}) instanceof Instance, true);
assertEq(new Instance(m5, {a:{b:mem4Page}}) instanceof Instance, true);
const m6 = new Module(wasmTextToBinary('(module (import "a" "b" (table 2 anyfunc)))'));
const m6 = new Module(wasmTextToBinary('(module (import "a" "b" (table 2)))'));
assertErrorMessage(() => new Instance(m6, {a:{b:tab1Elem}}), TypeError, /imported Table with incompatible size/);
assertEq(new Instance(m6, {a:{b:tab2Elem}}) instanceof Instance, true);
assertEq(new Instance(m6, {a:{b:tab3Elem}}) instanceof Instance, true);
assertEq(new Instance(m6, {a:{b:tab4Elem}}) instanceof Instance, true);
const m7 = new Module(wasmTextToBinary('(module (import "a" "b" (table 2 3 anyfunc)))'));
const m7 = new Module(wasmTextToBinary('(module (import "a" "b" (table 2 3)))'));
assertErrorMessage(() => new Instance(m7, {a:{b:tab1Elem}}), TypeError, /imported Table with incompatible size/);
assertErrorMessage(() => new Instance(m7, {a:{b:tab2Elem}}), TypeError, /imported Table with incompatible maximum size/);
assertErrorMessage(() => new Instance(m7, {a:{b:tab3Elem}}), TypeError, /imported Table with incompatible maximum size/);
@ -84,8 +84,8 @@ assertErrorMessage(() => new Instance(m7, {a:{b:tab4Elem}}), TypeError, /importe
wasmFailValidateText('(module (memory 2 1))', /maximum length 1 is less than initial length 2/);
wasmFailValidateText('(module (import "a" "b" (memory 2 1)))', /maximum length 1 is less than initial length 2/);
wasmFailValidateText('(module (table 2 1 anyfunc))', /maximum length 1 is less than initial length 2/);
wasmFailValidateText('(module (import "a" "b" (table 2 1 anyfunc)))', /maximum length 1 is less than initial length 2/);
wasmFailValidateText('(module (table (resizable 2 1)))', /maximum length 1 is less than initial length 2/);
wasmFailValidateText('(module (import "a" "b" (table 2 1)))', /maximum length 1 is less than initial length 2/);
// Import wasm-wasm type mismatch
@ -198,13 +198,13 @@ assertEq(Object.keys(e).length, 1);
assertEq(String(Object.keys(e)), "");
assertEq(e[""] instanceof Memory, true);
var code = wasmTextToBinary('(module (table 0 anyfunc) (export "tbl" table))');
var code = wasmTextToBinary('(module (table) (export "tbl" table))');
var e = new Instance(new Module(code)).exports;
assertEq(Object.keys(e).join(), "tbl");
assertEq(e.tbl instanceof Table, true);
assertEq(e.tbl.length, 0);
var code = wasmTextToBinary('(module (table 2 anyfunc) (export "t1" table) (export "t2" table))');
var code = wasmTextToBinary('(module (table (resizable 2)) (export "t1" table) (export "t2" table))');
var e = new Instance(new Module(code)).exports;
assertEq(Object.keys(e).join(), "t1,t2");
assertEq(e.t1 instanceof Table, true);
@ -212,7 +212,7 @@ assertEq(e.t2 instanceof Table, true);
assertEq(e.t1, e.t2);
assertEq(e.t1.length, 2);
var code = wasmTextToBinary('(module (table 2 anyfunc) (memory 1 1) (func) (export "t" table) (export "m" memory) (export "f" 0))');
var code = wasmTextToBinary('(module (table (resizable 2)) (memory 1 1) (func) (export "t" table) (export "m" memory) (export "f" 0))');
var e = new Instance(new Module(code)).exports;
assertEq(Object.keys(e).join(), "t,m,f");
assertEq(e.f(), undefined);
@ -220,7 +220,7 @@ assertEq(e.t instanceof Table, true);
assertEq(e.m instanceof Memory, true);
assertEq(e.t.length, 2);
var code = wasmTextToBinary('(module (table 1 anyfunc) (memory 1 1) (func) (export "m" memory) (export "f" 0) (export "t" table))');
var code = wasmTextToBinary('(module (table (resizable 1)) (memory 1 1) (func) (export "m" memory) (export "f" 0) (export "t" table))');
var e = new Instance(new Module(code)).exports;
assertEq(Object.keys(e).join(), "m,f,t");
assertEq(e.f(), undefined);
@ -228,7 +228,7 @@ assertEq(e.t instanceof Table, true);
assertEq(e.m instanceof Memory, true);
+assertEq(e.t.length, 1);
var code = wasmTextToBinary('(module (table 0 anyfunc) (export "" table))');
var code = wasmTextToBinary('(module (table) (export "" table))');
var e = new Instance(new Module(code)).exports;
assertEq(Object.keys(e).length, 1);
assertEq(String(Object.keys(e)), "");
@ -241,7 +241,7 @@ var code = wasmTextToBinary(`(module
(func $f (result i32) (i32.const 1))
(func $g (result i32) (i32.const 2))
(func $h (result i32) (i32.const 3))
(table 4 anyfunc)
(table (resizable 4))
(elem (i32.const 0) $f)
(elem (i32.const 2) $g)
(export "f1" $f)
@ -280,13 +280,13 @@ var e = new Instance(new Module(code), {a:{b:mem}}).exports;
assertEq(mem, e.foo);
assertEq(mem, e.bar);
var code = wasmTextToBinary('(module (import "a" "b" (table 1 1 anyfunc)) (export "foo" table) (export "bar" table))');
var code = wasmTextToBinary('(module (import "a" "b" (table 1 1)) (export "foo" table) (export "bar" table))');
var tbl = new Table({initial:1, maximum:1, element:"anyfunc"});
var e = new Instance(new Module(code), {a:{b:tbl}}).exports;
assertEq(tbl, e.foo);
assertEq(tbl, e.bar);
var code = wasmTextToBinary('(module (import "a" "b" (table 2 2 anyfunc)) (func $foo) (elem (i32.const 0) $foo) (export "foo" $foo))');
var code = wasmTextToBinary('(module (import "a" "b" (table 2 2)) (func $foo) (elem (i32.const 0) $foo) (export "foo" $foo))');
var tbl = new Table({initial:2, maximum:2, element:"anyfunc"});
var e1 = new Instance(new Module(code), {a:{b:tbl}}).exports;
assertEq(e1.foo, tbl.get(0));
@ -298,7 +298,7 @@ assertEq(e1.foo, tbl.get(1));
assertEq(tbl.get(0) === e1.foo, false);
assertEq(e1.foo === e2.foo, false);
var code = wasmTextToBinary('(module (table 2 2 anyfunc) (import $foo "a" "b" (result i32)) (func $bar (result i32) (i32.const 13)) (elem (i32.const 0) $foo $bar) (export "foo" $foo) (export "bar" $bar) (export "tbl" table))');
var code = wasmTextToBinary('(module (table (resizable 2 2)) (import $foo "a" "b" (result i32)) (func $bar (result i32) (i32.const 13)) (elem (i32.const 0) $foo $bar) (export "foo" $foo) (export "bar" $bar) (export "tbl" table))');
var foo = new Instance(new Module(wasmTextToBinary('(module (func (result i32) (i32.const 42)) (export "foo" 0))'))).exports.foo;
var e1 = new Instance(new Module(code), {a:{b:foo}}).exports;
assertEq(foo, e1.foo);
@ -332,8 +332,8 @@ wasmFailValidateText('(module (export "a" table))', /exported table index out of
wasmFailValidateText('(module (import "a" "b" (memory 1 1)) (memory 1 1))', /already have default memory/);
wasmFailValidateText('(module (import "a" "b" (memory 1 1)) (import "x" "y" (memory 2 2)))', /already have default memory/);
wasmFailValidateText('(module (import "a" "b" (table 1 1 anyfunc)) (table 1 1 anyfunc))', /already have default table/);
wasmFailValidateText('(module (import "a" "b" (table 1 1 anyfunc)) (import "x" "y" (table 2 2 anyfunc)))', /already have default table/);
wasmFailValidateText('(module (import "a" "b" (table 1 1)) (table 1 1))', /already have default table/);
wasmFailValidateText('(module (import "a" "b" (table 1 1)) (import "x" "y" (table 2 2)))', /already have default table/);
// Data segments on imports
@ -382,7 +382,7 @@ assertErrorMessage(() => new Instance(m, {glob:{a:64*1024}}), RangeError, /data
var m = new Module(wasmTextToBinary(`
(module
(import "a" "mem" (memory 1))
(import "a" "tbl" (table 1 anyfunc))
(import "a" "tbl" (table 1))
(import $memOff "a" "memOff" (global i32 immutable))
(import $tblOff "a" "tblOff" (global i32 immutable))
(func $f)
@ -420,7 +420,7 @@ assertEq(tbl.get(1), i.exports.g);
var m = new Module(wasmTextToBinary(`
(module
(import "a" "b" (table 10 anyfunc))
(import "a" "b" (table 10))
(elem (i32.const 0) $one $two)
(elem (i32.const 3) $three $four)
(func $one (result i32) (i32.const 1))
@ -454,7 +454,7 @@ var i2 = new Instance(new Module(wasmTextToBinary(`(module
(import $imp "a" "b" (result i32))
(memory 1 1)
(data (i32.const 0) "\\13")
(table 2 2 anyfunc)
(table (resizable 2 2))
(elem (i32.const 0) $imp $def)
(func $def (result i32) (i32.load (i32.const 0)))
(type $v2i (func (result i32)))

Просмотреть файл

@ -64,7 +64,7 @@ var exports1 = wasmEvalText(`(module
(export "grow" $grow)
)`, {"":{mem}}).exports;
var exports2 = wasmEvalText(`(module
(import "" "tbl" (table 1 anyfunc))
(import "" "tbl" (table 1))
(import "" "mem" (memory 1))
(type $v2v (func))
(func $test (result i32)
@ -128,7 +128,7 @@ assertEq(new Int32Array(mem.buffer)[3*64*1024/4], 99);
var exports = wasmEvalText(`(module
(type $v2i (func (result i32)))
(import $grow "" "grow")
(table (export "tbl") 1 anyfunc)
(table (resizable 1))
(func $test (result i32)
(i32.add
(call_indirect $v2i (i32.const 0))
@ -138,6 +138,7 @@ var exports = wasmEvalText(`(module
(func $one (result i32) (i32.const 1))
(elem (i32.const 0) $one)
(func $two (result i32) (i32.const 2))
(export "tbl" table)
(export "test" $test)
(export "two" $two)
)`, {"":{grow() { exports.tbl.grow(1); exports.tbl.set(1, exports.two) }}}).exports;
@ -159,7 +160,7 @@ var exports2 = wasmEvalText(`(module
(type $v2i (func (result i32)))
(import $imp "" "imp")
(elem (i32.const 0) $imp)
(table 2 anyfunc)
(table (resizable 2))
(func $test (result i32)
(i32.add
(call_indirect $v2i (i32.const 1))
@ -190,7 +191,7 @@ tbl.set(0, src.one);
var mod = new Module(wasmTextToBinary(`(module
(type $v2i (func (result i32)))
(table (import "" "tbl") 1 anyfunc)
(import "" "tbl" (table 1))
(func $ci (param i32) (result i32) (call_indirect $v2i (get_local 0)))
(export "call_indirect" $ci)
)`));

Просмотреть файл

@ -1,2 +1,4 @@
// |jit-test| test-also-wasm-baseline
// TODO: ion compile bug with loop return values
quit();
var importedArgs = ['labels.wast']; load(scriptdir + '../spec.js');

Просмотреть файл

@ -16,7 +16,7 @@ var callee = i => `(func $f${i} (type $v2i) (result i32) (i32.const ${i}))`;
// hold instances alive and instances hold imported tables alive. Nothing
// should hold the export object alive.
resetFinalizeCount();
var i = wasmEvalText(`(module (table 2 anyfunc) (export "tbl" table) (elem (i32.const 0) $f0) ${callee(0)} ${caller})`);
var i = wasmEvalText(`(module (table (resizable 2)) (export "tbl" table) (elem (i32.const 0) $f0) ${callee(0)} ${caller})`);
var e = i.exports;
var t = e.tbl;
var f = t.get(0);
@ -54,7 +54,7 @@ assertEq(finalizeCount(), 5);
// A table should hold the instance of any of its elements alive.
resetFinalizeCount();
var i = wasmEvalText(`(module (table 1 anyfunc) (export "tbl" table) (elem (i32.const 0) $f0) ${callee(0)} ${caller})`);
var i = wasmEvalText(`(module (table (resizable 1)) (export "tbl" table) (elem (i32.const 0) $f0) ${callee(0)} ${caller})`);
var e = i.exports;
var t = e.tbl;
var f = t.get(0);
@ -80,7 +80,7 @@ assertEq(finalizeCount(), 4);
// Null elements shouldn't keep anything alive.
resetFinalizeCount();
var i = wasmEvalText(`(module (table 2 anyfunc) (export "tbl" table) ${caller})`);
var i = wasmEvalText(`(module (table (resizable 2)) (export "tbl" table) ${caller})`);
var e = i.exports;
var t = e.tbl;
i.edge = makeFinalizeObserver();
@ -203,7 +203,7 @@ var i = wasmEvalText(
i.edge = makeFinalizeObserver();
tbl.set(0, i.exports.f);
var m = new Module(wasmTextToBinary(`(module
(import "a" "b" (table ${N} anyfunc))
(import "a" "b" (table ${N}))
(type $i2i (func (param i32) (result i32)))
(func $f (param $i i32) (result i32)
(set_local $i (i32.sub (get_local $i) (i32.const 1)))

Просмотреть файл

@ -9,24 +9,24 @@ const Memory = WebAssembly.Memory;
var callee = i => `(func $f${i} (result i32) (i32.const ${i}))`;
wasmFailValidateText(`(module (elem (i32.const 0) $f0) ${callee(0)})`, /table index out of range/);
wasmFailValidateText(`(module (table 10 anyfunc) (elem (i32.const 0) 0))`, /table element out of range/);
wasmFailValidateText(`(module (table 10 anyfunc) (func) (elem (i32.const 0) 0 1))`, /table element out of range/);
wasmFailValidateText(`(module (table 10 anyfunc) (func) (elem (f32.const 0) 0) ${callee(0)})`, /type mismatch/);
wasmFailValidateText(`(module (table (resizable 10)) (elem (i32.const 0) 0))`, /table element out of range/);
wasmFailValidateText(`(module (table (resizable 10)) (func) (elem (i32.const 0) 0 1))`, /table element out of range/);
wasmFailValidateText(`(module (table (resizable 10)) (func) (elem (f32.const 0) 0) ${callee(0)})`, /type mismatch/);
wasmFailValidateText(`(module (table 10 anyfunc) (elem (i32.const 10) $f0) ${callee(0)})`, /element segment does not fit/);
wasmFailValidateText(`(module (table 10 anyfunc) (elem (i32.const 8) $f0 $f0 $f0) ${callee(0)})`, /element segment does not fit/);
wasmFailValidateText(`(module (table (resizable 10)) (elem (i32.const 10) $f0) ${callee(0)})`, /element segment does not fit/);
wasmFailValidateText(`(module (table (resizable 10)) (elem (i32.const 8) $f0 $f0 $f0) ${callee(0)})`, /element segment does not fit/);
assertErrorMessage(() => wasmEvalText(`(module (table 10 anyfunc) (import "globals" "a" (global i32 immutable)) (elem (get_global 0) $f0) ${callee(0)})`, {globals:{a:10}}), RangeError, /elem segment does not fit/);
assertErrorMessage(() => wasmEvalText(`(module (table 10 anyfunc) (import "globals" "a" (global i32 immutable)) (elem (get_global 0) $f0 $f0 $f0) ${callee(0)})`, {globals:{a:8}}), RangeError, /elem segment does not fit/);
assertErrorMessage(() => wasmEvalText(`(module (table (resizable 10)) (import "globals" "a" (global i32 immutable)) (elem (get_global 0) $f0) ${callee(0)})`, {globals:{a:10}}), RangeError, /elem segment does not fit/);
assertErrorMessage(() => wasmEvalText(`(module (table (resizable 10)) (import "globals" "a" (global i32 immutable)) (elem (get_global 0) $f0 $f0 $f0) ${callee(0)})`, {globals:{a:8}}), RangeError, /elem segment does not fit/);
assertEq(new Module(wasmTextToBinary(`(module (table 10 anyfunc) (elem (i32.const 1) $f0 $f0) (elem (i32.const 0) $f0) ${callee(0)})`)) instanceof Module, true);
assertEq(new Module(wasmTextToBinary(`(module (table 10 anyfunc) (elem (i32.const 1) $f0 $f0) (elem (i32.const 2) $f0) ${callee(0)})`)) instanceof Module, true);
wasmEvalText(`(module (table 10 anyfunc) (import "globals" "a" (global i32 immutable)) (elem (i32.const 1) $f0 $f0) (elem (get_global 0) $f0) ${callee(0)})`, {globals:{a:0}});
wasmEvalText(`(module (table 10 anyfunc) (import "globals" "a" (global i32 immutable)) (elem (get_global 0) $f0 $f0) (elem (i32.const 2) $f0) ${callee(0)})`, {globals:{a:1}});
assertEq(new Module(wasmTextToBinary(`(module (table (resizable 10)) (elem (i32.const 1) $f0 $f0) (elem (i32.const 0) $f0) ${callee(0)})`)) instanceof Module, true);
assertEq(new Module(wasmTextToBinary(`(module (table (resizable 10)) (elem (i32.const 1) $f0 $f0) (elem (i32.const 2) $f0) ${callee(0)})`)) instanceof Module, true);
wasmEvalText(`(module (table (resizable 10)) (import "globals" "a" (global i32 immutable)) (elem (i32.const 1) $f0 $f0) (elem (get_global 0) $f0) ${callee(0)})`, {globals:{a:0}});
wasmEvalText(`(module (table (resizable 10)) (import "globals" "a" (global i32 immutable)) (elem (get_global 0) $f0 $f0) (elem (i32.const 2) $f0) ${callee(0)})`, {globals:{a:1}});
var m = new Module(wasmTextToBinary(`
(module
(import "globals" "table" (table 10 anyfunc))
(import "globals" "table" (table 10))
(import "globals" "a" (global i32 immutable))
(elem (get_global 0) $f0 $f0)
${callee(0)})
@ -38,21 +38,21 @@ assertErrorMessage(() => new Instance(m, {globals:{a:50, table:tbl}}), RangeErro
var caller = `(type $v2i (func (result i32))) (func $call (param $i i32) (result i32) (call_indirect $v2i (get_local $i))) (export "call" $call)`
var callee = i => `(func $f${i} (type $v2i) (result i32) (i32.const ${i}))`;
var call = wasmEvalText(`(module (table 10 anyfunc) ${callee(0)} ${caller})`).exports.call;
var call = wasmEvalText(`(module (table (resizable 10)) ${callee(0)} ${caller})`).exports.call;
assertErrorMessage(() => call(0), Error, /indirect call to null/);
assertErrorMessage(() => call(10), Error, /out-of-range/);
var call = wasmEvalText(`(module (table 10 anyfunc) (elem (i32.const 0)) ${callee(0)} ${caller})`).exports.call;
var call = wasmEvalText(`(module (table (resizable 10)) (elem (i32.const 0)) ${callee(0)} ${caller})`).exports.call;
assertErrorMessage(() => call(0), Error, /indirect call to null/);
assertErrorMessage(() => call(10), Error, /out-of-range/);
var call = wasmEvalText(`(module (table 10 anyfunc) (elem (i32.const 0) $f0) ${callee(0)} ${caller})`).exports.call;
var call = wasmEvalText(`(module (table (resizable 10)) (elem (i32.const 0) $f0) ${callee(0)} ${caller})`).exports.call;
assertEq(call(0), 0);
assertErrorMessage(() => call(1), Error, /indirect call to null/);
assertErrorMessage(() => call(2), Error, /indirect call to null/);
assertErrorMessage(() => call(10), Error, /out-of-range/);
var call = wasmEvalText(`(module (table 10 anyfunc) (elem (i32.const 1) $f0 $f1) (elem (i32.const 4) $f0 $f2) ${callee(0)} ${callee(1)} ${callee(2)} ${caller})`).exports.call;
var call = wasmEvalText(`(module (table (resizable 10)) (elem (i32.const 1) $f0 $f1) (elem (i32.const 4) $f0 $f2) ${callee(0)} ${callee(1)} ${callee(2)} ${caller})`).exports.call;
assertErrorMessage(() => call(0), Error, /indirect call to null/);
assertEq(call(1), 0);
assertEq(call(2), 1);
@ -63,7 +63,7 @@ assertErrorMessage(() => call(6), Error, /indirect call to null/);
assertErrorMessage(() => call(10), Error, /out-of-range/);
var tbl = new Table({initial:3, element:"anyfunc"});
var call = wasmEvalText(`(module (import "a" "b" (table 3 anyfunc)) (export "tbl" table) (elem (i32.const 0) $f0 $f1) ${callee(0)} ${callee(1)} ${caller})`, {a:{b:tbl}}).exports.call;
var call = wasmEvalText(`(module (import "a" "b" (table 3)) (export "tbl" table) (elem (i32.const 0) $f0 $f1) ${callee(0)} ${callee(1)} ${caller})`, {a:{b:tbl}}).exports.call;
assertEq(call(0), 0);
assertEq(call(1), 1);
assertEq(tbl.get(0)(), 0);
@ -71,7 +71,7 @@ assertEq(tbl.get(1)(), 1);
assertErrorMessage(() => call(2), Error, /indirect call to null/);
assertEq(tbl.get(2), null);
var exp = wasmEvalText(`(module (import "a" "b" (table 3 anyfunc)) (export "tbl" table) (elem (i32.const 2) $f2) ${callee(2)} ${caller})`, {a:{b:tbl}}).exports;
var exp = wasmEvalText(`(module (import "a" "b" (table 3)) (export "tbl" table) (elem (i32.const 2) $f2) ${callee(2)} ${caller})`, {a:{b:tbl}}).exports;
assertEq(exp.tbl, tbl);
assertEq(exp.call(0), 0);
assertEq(exp.call(1), 1);
@ -83,14 +83,14 @@ assertEq(tbl.get(0)(), 0);
assertEq(tbl.get(1)(), 1);
assertEq(tbl.get(2)(), 2);
var exp1 = wasmEvalText(`(module (table 10 anyfunc) (export "tbl" table) (elem (i32.const 0) $f0 $f0) ${callee(0)} (export "f0" $f0) ${caller})`).exports
var exp1 = wasmEvalText(`(module (table (resizable 10)) (export "tbl" table) (elem (i32.const 0) $f0 $f0) ${callee(0)} (export "f0" $f0) ${caller})`).exports
assertEq(exp1.tbl.get(0), exp1.f0);
assertEq(exp1.tbl.get(1), exp1.f0);
assertEq(exp1.tbl.get(2), null);
assertEq(exp1.call(0), 0);
assertEq(exp1.call(1), 0);
assertErrorMessage(() => exp1.call(2), Error, /indirect call to null/);
var exp2 = wasmEvalText(`(module (import "a" "b" (table 10 anyfunc)) (export "tbl" table) (elem (i32.const 1) $f1 $f1) ${callee(1)} (export "f1" $f1) ${caller})`, {a:{b:exp1.tbl}}).exports
var exp2 = wasmEvalText(`(module (import "a" "b" (table 10)) (export "tbl" table) (elem (i32.const 1) $f1 $f1) ${callee(1)} (export "f1" $f1) ${caller})`, {a:{b:exp1.tbl}}).exports
assertEq(exp1.tbl, exp2.tbl);
assertEq(exp2.tbl.get(0), exp1.f0);
assertEq(exp2.tbl.get(1), exp2.f1);
@ -109,7 +109,7 @@ var e3 = wasmEvalText(`(module (func $h (result i32) (i32.const 13)) (export "h"
tbl.set(0, e1.f);
tbl.set(1, e2.g);
tbl.set(2, e3.h);
var e4 = wasmEvalText(`(module (import "a" "b" (table 3 anyfunc)) ${caller})`, {a:{b:tbl}}).exports;
var e4 = wasmEvalText(`(module (import "a" "b" (table 3)) ${caller})`, {a:{b:tbl}}).exports;
assertEq(e4.call(0), 42);
assertErrorMessage(() => e4.call(1), Error, /indirect call signature mismatch/);
assertEq(e4.call(2), 13);
@ -117,7 +117,7 @@ assertEq(e4.call(2), 13);
var m = new Module(wasmTextToBinary(`(module
(type $i2i (func (param i32) (result i32)))
(import "a" "mem" (memory 1))
(import "a" "tbl" (table 10 anyfunc))
(import "a" "tbl" (table 10))
(import $imp "a" "imp" (result i32))
(func $call (param $i i32) (result i32)
(i32.add
@ -154,7 +154,7 @@ var call = wasmEvalText(`(module
(type $v2i1 (func (result i32)))
(type $v2i2 (func (result i32)))
(type $i2v (func (param i32)))
(table anyfunc (elem $a $b $c))
(table $a $b $c)
(func $a (type $v2i1) (result i32) (i32.const 0))
(func $b (type $v2i2) (result i32) (i32.const 1))
(func $c (type $i2v) (param i32))
@ -173,7 +173,7 @@ var call = wasmEvalText(`(module
(type $E (func (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (result i32)))
(type $F (func (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (result i32)))
(type $G (func (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (param i32) (result i32)))
(table anyfunc (elem $a $b $c $d $e $f $g))
(table $a $b $c $d $e $f $g)
(func $a (type $A) (get_local 7))
(func $b (type $B) (get_local 8))
(func $c (type $C) (get_local 9))

Просмотреть файл

@ -35,31 +35,5 @@ wasmEvalText('(module (func (local i32 i32 f32 f64 i32)))');
assertErrorMessage(() => wasmEvalText('(module (func (local $a)))'), SyntaxError, parsingError);
assertErrorMessage(() => wasmEvalText('(module (func (local $a i32 i32)))'), SyntaxError, parsingError);
// Table
assertErrorMessage(() => wasmEvalText('(module (table (local $a)))'), SyntaxError, parsingError);
assertErrorMessage(() => wasmEvalText('(module (table $t))'), SyntaxError, parsingError);
assertErrorMessage(() => wasmEvalText('(module (table $t 1))'), SyntaxError, parsingError);
assertErrorMessage(() => wasmEvalText('(module (table $t 1 10))'), SyntaxError, parsingError);
wasmEvalText('(module (table $t 1 10 anyfunc))');
wasmEvalText('(module (table $t 1 anyfunc))');
wasmEvalText('(module (table 0 anyfunc))');
assertErrorMessage(() => wasmEvalText('(module (table $t anyfunc))'), SyntaxError, parsingError);
wasmEvalText('(module (table $t anyfunc (elem)))');
wasmEvalText('(module (func) (table $t anyfunc (elem 0 0 0)))');
const { Table } = WebAssembly;
const table = new Table({initial:1, element:"anyfunc"});
assertErrorMessage(() => wasmEvalText('(module (table $t (import) 1 anyfunc))'), SyntaxError, parsingError);
assertErrorMessage(() => wasmEvalText('(module (table $t (import "mod") 1 anyfunc))'), SyntaxError, parsingError);
assertErrorMessage(() => wasmEvalText('(module (table $t (import "mod" "field") 1 anyfunc (elem 1 2 3)))'), SyntaxError, parsingError);
wasmEvalText('(module (table $t (import "mod" "field") 1 anyfunc))', {mod: {field: table}});
assertErrorMessage(() => wasmEvalText('(module (table $t (export "mod") 1))'), SyntaxError, parsingError);
assertErrorMessage(() => wasmEvalText('(module (table $t (export "mod") anyfunc))'), SyntaxError, parsingError);
assertErrorMessage(() => wasmEvalText('(module (table $t (export "mod") anyfunc 1 2 3))'), SyntaxError, parsingError);
assertEq(wasmEvalText('(module (table $t (export "tbl") anyfunc (elem)))').exports.tbl instanceof Table, true);
assertEq(wasmEvalText('(module (func) (table $t (export "tbl") anyfunc (elem 0 0 0)))').exports.tbl instanceof Table, true);
// Note: the s-expression text format is temporary, this file is mostly just to
// hold basic error smoke tests.

Просмотреть файл

@ -70,7 +70,7 @@ runTest(`
(module
(type $type1 (func (param i32) (result i32)))
(import $import1 "mod" "test" (param f32) (result f32))
(table anyfunc (elem $func1 $func2))
(table $func1 $func2)
(func $func1 (param i32) (param f32) (nop))
(func $func2 (param i32) (result i32) (get_local 0))
(func $test

Просмотреть файл

@ -156,7 +156,7 @@ runTest(`
(module
(type $type1 (func (param i32) (result i32)))
(import $import1 "mod" "test" (param f32) (result f32))
(table anyfunc (elem $func1 $func2))
(table $func1 $func2)
(func $func1 (param i32) (param f32) (nop))
(func $func2 (param i32) (result i32) (get_local 0))
(func $test