зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1612534 - Switch (export memory). r=lth
This commit uses a regex to automatically switch the export syntax for memory. Differential Revision: https://phabricator.services.mozilla.com/D67251 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
906dd95923
Коммит
fa3be1fcf3
|
@ -132,11 +132,11 @@ try {
|
|||
assertEq(String(e).indexOf("out of memory") !== -1, true);
|
||||
}
|
||||
|
||||
var buf = wasmEvalText('(module (memory 1) (export "memory" memory))').exports.memory.buffer;
|
||||
var buf = wasmEvalText('(module (memory 1) (export "memory" (memory 0)))').exports.memory.buffer;
|
||||
assertEq(buf instanceof ArrayBuffer, true);
|
||||
assertEq(buf.byteLength, 65536);
|
||||
|
||||
var obj = wasmEvalText('(module (memory 1) (func (result i32) (i32.const 42)) (func (nop)) (export "memory" memory) (export "b" (func 0)) (export "c" (func 1)))').exports;
|
||||
var obj = wasmEvalText('(module (memory 1) (func (result i32) (i32.const 42)) (func (nop)) (export "memory" (memory 0)) (export "b" (func 0)) (export "c" (func 1)))').exports;
|
||||
assertEq(obj.memory.buffer instanceof ArrayBuffer, true);
|
||||
assertEq(obj.b instanceof Function, true);
|
||||
assertEq(obj.c instanceof Function, true);
|
||||
|
@ -144,21 +144,21 @@ assertEq(obj.memory.buffer.byteLength, 65536);
|
|||
assertEq(obj.b(), 42);
|
||||
assertEq(obj.c(), undefined);
|
||||
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 0) "") (export "memory" memory))').exports.memory.buffer;
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 0) "") (export "memory" (memory 0)))').exports.memory.buffer;
|
||||
assertEq(new Uint8Array(buf)[0], 0);
|
||||
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 65536) "") (export "memory" memory))').exports.memory.buffer;
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 65536) "") (export "memory" (memory 0)))').exports.memory.buffer;
|
||||
assertEq(new Uint8Array(buf)[0], 0);
|
||||
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 0) "a") (export "memory" memory))').exports.memory.buffer;
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 0) "a") (export "memory" (memory 0)))').exports.memory.buffer;
|
||||
assertEq(new Uint8Array(buf)[0], 'a'.charCodeAt(0));
|
||||
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 0) "a") (data (i32.const 2) "b") (export "memory" memory))').exports.memory.buffer;
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 0) "a") (data (i32.const 2) "b") (export "memory" (memory 0)))').exports.memory.buffer;
|
||||
assertEq(new Uint8Array(buf)[0], 'a'.charCodeAt(0));
|
||||
assertEq(new Uint8Array(buf)[1], 0);
|
||||
assertEq(new Uint8Array(buf)[2], 'b'.charCodeAt(0));
|
||||
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 65535) "c") (export "memory" memory))').exports.memory.buffer;
|
||||
var buf = wasmEvalText('(module (memory 1) (data (i32.const 65535) "c") (export "memory" (memory 0)))').exports.memory.buffer;
|
||||
assertEq(new Uint8Array(buf)[0], 0);
|
||||
assertEq(new Uint8Array(buf)[65535], 'c'.charCodeAt(0));
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ wasmFullPass(`(module
|
|||
i32.const 1
|
||||
i32.load offset=2
|
||||
)
|
||||
(export "mem" memory)
|
||||
(export "mem" (memory 0))
|
||||
)`, 0x050403, {"": {memory}});
|
||||
|
||||
// Tables.
|
||||
|
|
|
@ -190,18 +190,18 @@ assertEq(e.foo(), undefined);
|
|||
assertEq(e.bar(), undefined);
|
||||
assertEq(e.foo, e.bar);
|
||||
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (export "memory" memory))');
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (export "memory" (memory 0)))');
|
||||
var e = new Instance(new Module(code)).exports;
|
||||
assertEq(Object.keys(e).join(), "memory");
|
||||
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (export "foo" memory) (export "bar" memory))');
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (export "foo" (memory 0)) (export "bar" (memory 0)))');
|
||||
var e = new Instance(new Module(code)).exports;
|
||||
assertEq(Object.keys(e).join(), "foo,bar");
|
||||
assertEq(e.foo, e.bar);
|
||||
assertEq(e.foo instanceof Memory, true);
|
||||
assertEq(e.foo.buffer.byteLength, 64*1024);
|
||||
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (func) (export "foo" (func 0)) (export "bar" memory))');
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (func) (export "foo" (func 0)) (export "bar" (memory 0)))');
|
||||
var e = new Instance(new Module(code)).exports;
|
||||
assertEq(Object.keys(e).join(), "foo,bar");
|
||||
assertEq(e.foo(), undefined);
|
||||
|
@ -209,13 +209,13 @@ assertEq(e.bar instanceof Memory, true);
|
|||
assertEq(e.bar instanceof Memory, true);
|
||||
assertEq(e.bar.buffer.byteLength, 64*1024);
|
||||
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (func) (export "bar" memory) (export "foo" (func 0)))');
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (func) (export "bar" (memory 0)) (export "foo" (func 0)))');
|
||||
var e = new Instance(new Module(code)).exports;
|
||||
assertEq(Object.keys(e).join(), "bar,foo");
|
||||
assertEq(e.foo(), undefined);
|
||||
assertEq(e.bar.buffer.byteLength, 64*1024);
|
||||
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (export "" memory))');
|
||||
var code = wasmTextToBinary('(module (memory 1 1) (export "" (memory 0)))');
|
||||
var e = new Instance(new Module(code)).exports;
|
||||
assertEq(Object.keys(e).length, 1);
|
||||
assertEq(String(Object.keys(e)), "");
|
||||
|
@ -235,7 +235,7 @@ assertEq(e.t2 instanceof Table, true);
|
|||
assertEq(e.t1, e.t2);
|
||||
assertEq(e.t1.length, 2);
|
||||
|
||||
var code = wasmTextToBinary('(module (table 2 funcref) (memory 1 1) (func) (export "t" table) (export "m" memory) (export "f" (func 0)))');
|
||||
var code = wasmTextToBinary('(module (table 2 funcref) (memory 1 1) (func) (export "t" table) (export "m" (memory 0)) (export "f" (func 0)))');
|
||||
var e = new Instance(new Module(code)).exports;
|
||||
assertEq(Object.keys(e).join(), "t,m,f");
|
||||
assertEq(e.f(), undefined);
|
||||
|
@ -243,7 +243,7 @@ assertEq(e.t instanceof Table, true);
|
|||
assertEq(e.m instanceof Memory, true);
|
||||
assertEq(e.t.length, 2);
|
||||
|
||||
var code = wasmTextToBinary('(module (table 1 funcref) (memory 1 1) (func) (export "m" memory) (export "f" (func 0)) (export "t" table))');
|
||||
var code = wasmTextToBinary('(module (table 1 funcref) (memory 1 1) (func) (export "m" (memory 0)) (export "f" (func 0)) (export "t" table))');
|
||||
var e = new Instance(new Module(code)).exports;
|
||||
assertEq(Object.keys(e).join(), "m,f,t");
|
||||
assertEq(e.f(), undefined);
|
||||
|
@ -335,7 +335,7 @@ assertEq(args.length, 0);
|
|||
|
||||
// Re-exports and Identity:
|
||||
|
||||
var code = wasmTextToBinary('(module (import "a" "b" (memory 1 1)) (export "foo" memory) (export "bar" memory))');
|
||||
var code = wasmTextToBinary('(module (import "a" "b" (memory 1 1)) (export "foo" (memory 0)) (export "bar" (memory 0)))');
|
||||
var mem = new Memory({initial:1, maximum:1});
|
||||
var e = new Instance(new Module(code), {a:{b:mem}}).exports;
|
||||
assertEq(mem, e.foo);
|
||||
|
@ -422,7 +422,7 @@ assertEq(e2.f(), 52);
|
|||
|
||||
wasmFailValidateText('(module (export "a" (func 0)))', /exported function index out of bounds/);
|
||||
wasmFailValidateText('(module (export "a" global 0))', /exported global index out of bounds/);
|
||||
wasmFailValidateText('(module (export "a" memory))', /exported memory index out of bounds/);
|
||||
wasmFailValidateText('(module (export "a" (memory 0)))', /exported memory index out of bounds/);
|
||||
wasmFailValidateText('(module (export "a" table))', /exported table index out of bounds/);
|
||||
|
||||
// Default memory/table rules
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var exp = wasmEvalText(`(module
|
||||
(memory 1)
|
||||
(export "mem" memory)
|
||||
(export "mem" (memory 0))
|
||||
(func $f (result i32) (i32.load (i32.const 0)))
|
||||
(export "f" (func $f))
|
||||
)`).exports;
|
||||
|
|
Загрузка…
Ссылка в новой задаче