зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1612534 - Switch to (result) type parameter for block. r=lth
This commit uses a regex to automatically replace uses of block valtype with block (result valtype) Differential Revision: https://phabricator.services.mozilla.com/D67247 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b60da2612e
Коммит
090d0ade91
|
@ -197,7 +197,7 @@ wasmFullPass('(module (func (result i32) (local i32) (tee_local 0 (i32.const 42)
|
|||
wasmFullPass('(module (func (result i32) (local i32) (tee_local 0 (local.get 0))) (export "run" 0))', 0);
|
||||
|
||||
wasmFullPass('(module (func (param $a i32) (result i32) (local.get $a)) (export "run" 0))', 0);
|
||||
wasmFullPass('(module (func (param $a i32) (local $b i32) (result i32) (block i32 (local.set $b (local.get $a)) (local.get $b))) (export "run" 0))', 42, {}, 42);
|
||||
wasmFullPass('(module (func (param $a i32) (local $b i32) (result i32) (block (result i32) (local.set $b (local.get $a)) (local.get $b))) (export "run" 0))', 42, {}, 42);
|
||||
|
||||
wasmValidateText('(module (func (local i32) (local $a f32) (local.set 0 (i32.const 1)) (local.set $a (f32.const nan))))');
|
||||
|
||||
|
@ -211,12 +211,12 @@ wasmFailValidateText('(module (func (result i32) (block (block ))))', emptyStack
|
|||
wasmFailValidateText('(module (func (local i32) (local.set 0 (block ))))', emptyStackError);
|
||||
|
||||
wasmFullPass('(module (func (block (block ))) (export "run" 0))', undefined);
|
||||
wasmFullPass('(module (func (result i32) (block i32 (i32.const 42))) (export "run" 0))', 42);
|
||||
wasmFullPass('(module (func (result i32) (block i32 (block i32 (i32.const 42)))) (export "run" 0))', 42);
|
||||
wasmFailValidateText('(module (func (result f32) (block i32 (i32.const 0))))', mismatchError("i32", "f32"));
|
||||
wasmFullPass('(module (func (result i32) (block (result i32) (i32.const 42))) (export "run" 0))', 42);
|
||||
wasmFullPass('(module (func (result i32) (block (result i32) (block (result i32) (i32.const 42)))) (export "run" 0))', 42);
|
||||
wasmFailValidateText('(module (func (result f32) (block (result i32) (i32.const 0))))', mismatchError("i32", "f32"));
|
||||
|
||||
wasmFullPass('(module (func (result i32) (block i32 (drop (i32.const 13)) (block i32 (i32.const 42)))) (export "run" 0))', 42);
|
||||
wasmFailValidateText('(module (func (result f32) (param f32) (block i32 (drop (local.get 0)) (i32.const 0))))', mismatchError("i32", "f32"));
|
||||
wasmFullPass('(module (func (result i32) (block (result i32) (drop (i32.const 13)) (block (result i32) (i32.const 42)))) (export "run" 0))', 42);
|
||||
wasmFailValidateText('(module (func (result f32) (param f32) (block (result i32) (drop (local.get 0)) (i32.const 0))))', mismatchError("i32", "f32"));
|
||||
|
||||
wasmFullPass('(module (func (result i32) (local i32) (local.set 0 (i32.const 42)) (local.get 0)) (export "run" 0))', 42);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ wasmFullPass(`(module
|
|||
(result i32)
|
||||
(if i32
|
||||
(i32.const 42)
|
||||
(block i32
|
||||
(block (result i32)
|
||||
(
|
||||
if i32
|
||||
(block (result i32)
|
||||
|
@ -313,44 +313,44 @@ assertEq(isNonZero(-1), 1);
|
|||
wasmFailValidateText('(module (func (result i32) (br 0)))', emptyStackError);
|
||||
wasmFailValidateText('(module (func (result i32) (br 0 (f32.const 42))))', mismatchError("f32", "i32"));
|
||||
wasmFailValidateText('(module (func (result i32) (block (br 0))))', emptyStackError);
|
||||
wasmFailValidateText('(module (func (result i32) (block f32 (br 0 (f32.const 42)))))', mismatchError("f32", "i32"));
|
||||
wasmFailValidateText('(module (func (result i32) (block (result f32) (br 0 (f32.const 42)))))', mismatchError("f32", "i32"));
|
||||
|
||||
wasmFailValidateText(`(module (func (result i32) (param i32) (block (if i32 (local.get 0) (br 0 (i32.const 42))))) (export "" 0))`, /if without else with a result value/);
|
||||
wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (drop (i32.const 42))) (br 0 (f32.const 42)))) (export "" 0))`, mismatchError("f32", "i32"));
|
||||
wasmFailValidateText(`(module (func (result i32) (param i32) (block (result i32) (if (local.get 0) (drop (i32.const 42))) (br 0 (f32.const 42)))) (export "" 0))`, mismatchError("f32", "i32"));
|
||||
|
||||
wasmFullPass('(module (func (result i32) (br 0 (i32.const 42)) (i32.const 13)) (export "run" 0))', 42);
|
||||
wasmFullPass('(module (func (result i32) (block i32 (br 0 (i32.const 42)) (i32.const 13))) (export "run" 0))', 42);
|
||||
wasmFullPass('(module (func (result i32) (block (result i32) (br 0 (i32.const 42)) (i32.const 13))) (export "run" 0))', 42);
|
||||
|
||||
wasmFailValidateText('(module (func) (func (block i32 (br 0 (call 0)) (i32.const 13))) (export "" 0))', emptyStackError);
|
||||
wasmFailValidateText('(module (func) (func (block i32 (br_if 0 (call 0) (i32.const 1)) (i32.const 13))) (export "" 0))', emptyStackError);
|
||||
wasmFailValidateText('(module (func) (func (block (result i32) (br 0 (call 0)) (i32.const 13))) (export "" 0))', emptyStackError);
|
||||
wasmFailValidateText('(module (func) (func (block (result i32) (br_if 0 (call 0) (i32.const 1)) (i32.const 13))) (export "" 0))', emptyStackError);
|
||||
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (drop (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block (result i32) (if (local.get 0) (drop (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 43);
|
||||
assertEq(f(1), 43);
|
||||
|
||||
wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if i32 (local.get 0) (br 0 (i32.const 42))) (i32.const 43))) (export "" 0))`, /if without else with a result value/);
|
||||
wasmFailValidateText(`(module (func (result i32) (param i32) (block (result i32) (if i32 (local.get 0) (br 0 (i32.const 42))) (i32.const 43))) (export "" 0))`, /if without else with a result value/);
|
||||
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (br 1 (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block (result i32) (if (local.get 0) (br 1 (i32.const 42))) (i32.const 43))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 43);
|
||||
assertEq(f(1), 42);
|
||||
|
||||
wasmFailValidateText(`(module (func (result i32) (param i32) (block (br_if 0 (i32.const 42) (local.get 0)) (i32.const 43))) (export "" 0))`, /unused values not explicitly dropped by end of block/);
|
||||
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (drop (br_if 0 (i32.const 42) (local.get 0))) (i32.const 43))) (export "" 0))`).exports[""];
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block (result i32) (drop (br_if 0 (i32.const 42) (local.get 0))) (i32.const 43))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 43);
|
||||
assertEq(f(1), 42);
|
||||
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (drop (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block (result i32) (if (local.get 0) (drop (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 43);
|
||||
assertEq(f(1), 43);
|
||||
|
||||
wasmFailValidateText(`(module (func (result i32) (param i32) (block i32 (if i32 (local.get 0) (br 0 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`, /if without else with a result value/);
|
||||
wasmFailValidateText(`(module (func (result i32) (param i32) (block (result i32) (if i32 (local.get 0) (br 0 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`, /if without else with a result value/);
|
||||
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (if (local.get 0) (br 1 (i32.const 42))) (br 0 (i32.const 43))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 43);
|
||||
assertEq(f(1), 42);
|
||||
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (if (local.get 0) (br 1 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block (result i32) (if (local.get 0) (br 1 (i32.const 42))) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 43);
|
||||
assertEq(f(1), 42);
|
||||
|
||||
|
@ -358,31 +358,31 @@ var f = wasmEvalText(`(module (func (result i32) (param i32) (br_if 0 (i32.const
|
|||
assertEq(f(0), 43);
|
||||
assertEq(f(1), 42);
|
||||
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block i32 (br_if 0 (i32.const 42) (local.get 0)) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
|
||||
var f = wasmEvalText(`(module (func (result i32) (param i32) (block (result i32) (br_if 0 (i32.const 42) (local.get 0)) (br 0 (i32.const 43)))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 43);
|
||||
assertEq(f(1), 42);
|
||||
|
||||
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if (local.get 0) (drop (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
|
||||
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block (result i32) (if (local.get 0) (drop (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 0);
|
||||
assertEq(f(1), 0);
|
||||
|
||||
wasmFailValidateText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if i32 (local.get 0) (br 0 (i32.const 99))) (i32.const -1)))) (export "" 0))`, /if without else with a result value/);
|
||||
wasmFailValidateText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block (result i32) (if i32 (local.get 0) (br 0 (i32.const 99))) (i32.const -1)))) (export "" 0))`, /if without else with a result value/);
|
||||
|
||||
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (if (local.get 0) (br 1 (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
|
||||
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block (result i32) (if (local.get 0) (br 1 (i32.const 99))) (i32.const -1)))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 0);
|
||||
assertEq(f(1), 100);
|
||||
|
||||
wasmFailValidateText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block (br_if 0 (i32.const 99) (local.get 0)) (i32.const -1)))) (export "" 0))`, /unused values not explicitly dropped by end of block/);
|
||||
|
||||
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block i32 (drop (br_if 0 (i32.const 99) (local.get 0))) (i32.const -1)))) (export "" 0))`).exports[""];
|
||||
var f = wasmEvalText(`(module (func (param i32) (result i32) (i32.add (i32.const 1) (block (result i32) (drop (br_if 0 (i32.const 99) (local.get 0))) (i32.const -1)))) (export "" 0))`).exports[""];
|
||||
assertEq(f(0), 0);
|
||||
assertEq(f(1), 100);
|
||||
|
||||
wasmFullPass(`(module (func (result i32) (block i32 (br 0 (return (i32.const 42))) (i32.const 0))) (export "run" 0))`, 42);
|
||||
wasmFullPass(`(module (func (result i32) (block i32 (return (br 0 (i32.const 42))))) (export "run" 0))`, 42);
|
||||
wasmFullPass(`(module (func (result i32) (block i32 (return (br 0 (i32.const 42))) (i32.const 0))) (export "run" 0))`, 42);
|
||||
wasmFullPass(`(module (func (result i32) (block (result i32) (br 0 (return (i32.const 42))) (i32.const 0))) (export "run" 0))`, 42);
|
||||
wasmFullPass(`(module (func (result i32) (block (result i32) (return (br 0 (i32.const 42))))) (export "run" 0))`, 42);
|
||||
wasmFullPass(`(module (func (result i32) (block (result i32) (return (br 0 (i32.const 42))) (i32.const 0))) (export "run" 0))`, 42);
|
||||
|
||||
wasmFullPass(`(module (func (result f32) (drop (block i32 (br 0 (i32.const 0)))) (block f32 (br 0 (f32.const 42)))) (export "run" 0))`, 42);
|
||||
wasmFullPass(`(module (func (result f32) (drop (block (result i32) (br 0 (i32.const 0)))) (block (result f32) (br 0 (f32.const 42)))) (export "run" 0))`, 42);
|
||||
|
||||
var called = 0;
|
||||
var imports = {
|
||||
|
@ -692,8 +692,8 @@ assertEq(f(2), 2);
|
|||
assertEq(f(3), -1);
|
||||
|
||||
// br_table with values
|
||||
wasmFailValidateText('(module (func (result i32) (block i32 (br_table 0 (i32.const 0)))))', emptyStackError);
|
||||
wasmFailValidateText('(module (func (result i32) (block i32 (br_table 0 (f32.const 0) (i32.const 0)))))', mismatchError("f32", "i32"));
|
||||
wasmFailValidateText('(module (func (result i32) (block (result i32) (br_table 0 (i32.const 0)))))', emptyStackError);
|
||||
wasmFailValidateText('(module (func (result i32) (block (result i32) (br_table 0 (f32.const 0) (i32.const 0)))))', mismatchError("f32", "i32"));
|
||||
|
||||
wasmFailValidateText(`(module
|
||||
(func
|
||||
|
|
|
@ -177,4 +177,4 @@ function testCompileError(opcode, text) {
|
|||
|
||||
testCompileError(CallCode, '(module (func $f (param i32)) (func $g call $f))');
|
||||
testCompileError(I32AddCode, '(module (func (i32.add (i32.const 1) (f32.const 1))))');
|
||||
testCompileError(EndCode, '(module (func (block i32)))');
|
||||
testCompileError(EndCode, '(module (func (block (result i32))))');
|
||||
|
|
|
@ -41,7 +41,7 @@ let simpleTests = [
|
|||
"(module (func $test (local anyref)))",
|
||||
"(module (func $test (param anyref)))",
|
||||
"(module (func $test (result anyref) (ref.null)))",
|
||||
"(module (func $test (block anyref (unreachable)) unreachable))",
|
||||
"(module (func $test (block (result anyref) (unreachable)) unreachable))",
|
||||
"(module (func $test (local anyref) (result i32) (ref.is_null (local.get 0))))",
|
||||
`(module (import "a" "b" (param anyref)))`,
|
||||
`(module (import "a" "b" (result anyref)))`,
|
||||
|
@ -173,7 +173,7 @@ function assertJoin(body) {
|
|||
assertEq(val.i, -1);
|
||||
}
|
||||
|
||||
assertJoin("(block anyref local.get $ref)");
|
||||
assertJoin("(block (result anyref) local.get $ref)");
|
||||
assertJoin("(block $out anyref local.get $ref br $out)");
|
||||
assertJoin("(loop anyref local.get $ref)");
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ let simpleTests = [
|
|||
"(module (func $test (local anyref)))",
|
||||
"(module (func $test (param anyref)))",
|
||||
"(module (func $test (result anyref) (ref.null)))",
|
||||
"(module (func $test (block anyref (unreachable)) unreachable))",
|
||||
"(module (func $test (block (result anyref) (unreachable)) unreachable))",
|
||||
"(module (func $test (local anyref) (result i32) (ref.is_null (local.get 0))))",
|
||||
`(module (import "a" "b" (param anyref)))`,
|
||||
`(module (import "a" "b" (result anyref)))`,
|
||||
|
|
|
@ -18,9 +18,9 @@ wasmFailValidateText(`(module (global (mut funcref) (ref.null)) (func (param any
|
|||
wasmEvalText(`(module (func (param funcref)) (func (param funcref) (call 0 (local.get 0))))`);
|
||||
wasmEvalText(`(module (func (param anyref)) (func (param funcref) (call 0 (local.get 0))))`);
|
||||
wasmFailValidateText(`(module (func (param funcref)) (func (param anyref) (call 0 (local.get 0))))`, typeErr);
|
||||
wasmEvalText(`(module (func (param funcref) (result funcref) (block funcref (local.get 0) (br 0))))`);
|
||||
wasmEvalText(`(module (func (param funcref) (result anyref) (block anyref (local.get 0) (br 0))))`);
|
||||
wasmFailValidateText(`(module (func (param anyref) (result anyref) (block funcref (local.get 0) (br 0))))`, typeErr);
|
||||
wasmEvalText(`(module (func (param funcref) (result funcref) (block (result funcref) (local.get 0) (br 0))))`);
|
||||
wasmEvalText(`(module (func (param funcref) (result anyref) (block (result anyref) (local.get 0) (br 0))))`);
|
||||
wasmFailValidateText(`(module (func (param anyref) (result anyref) (block (result funcref) (local.get 0) (br 0))))`, typeErr);
|
||||
wasmEvalText(`(module (func (param funcref funcref) (result funcref) (select (result funcref) (local.get 0) (local.get 1) (i32.const 0))))`);
|
||||
wasmEvalText(`(module (func (param anyref funcref) (result anyref) (select (result anyref) (local.get 0) (local.get 1) (i32.const 0))))`);
|
||||
wasmEvalText(`(module (func (param funcref anyref) (result anyref) (select (result anyref)(local.get 0) (local.get 1) (i32.const 0))))`);
|
||||
|
@ -46,7 +46,7 @@ var run = wasmEvalText(`(module
|
|||
(func (export "run") (param $a funcref) (param $b funcref) (param $c funcref) (param $test1 i32) (param $test2 i32) (result funcref)
|
||||
local.get $a
|
||||
global.set 0
|
||||
block funcref
|
||||
block (result funcref)
|
||||
local.get $b
|
||||
local.get $test1
|
||||
br_if 0
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
wasmEvalText(
|
||||
`(module
|
||||
(func $run (param i64) (param i64) (result i64)
|
||||
block i64
|
||||
block (result i64)
|
||||
i64.const 1
|
||||
(i64.lt_s (local.get 0) (local.get 1))
|
||||
br_if 0
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
wasmEvalText(`
|
||||
(module
|
||||
(func $run
|
||||
(drop (block f64
|
||||
(drop (block (result f64)
|
||||
(drop (br_if 0 (f64.const 1) (f64.eq (f64.const 1) (f64.const 0))))
|
||||
(drop (br 0 (f64.const 2))))))
|
||||
(export "run" $run))`);
|
||||
|
|
|
@ -12,11 +12,11 @@ let mt = `
|
|||
(func (export "f") (result i32)
|
||||
(local i32)
|
||||
(local i32)
|
||||
(block i32
|
||||
(block (result i32)
|
||||
(local.set 0 (global.get 0))
|
||||
(block i32
|
||||
(block (result i32)
|
||||
(global.set 1 (i32.const 37))
|
||||
(block i32
|
||||
(block (result i32)
|
||||
(local.set 1 (global.get 0))
|
||||
(i32.add (local.get 0) (local.get 1)))))))
|
||||
`;
|
||||
|
|
|
@ -34,8 +34,8 @@ wasmEvalText(`(module (func
|
|||
|
||||
wasmEvalText(`(module (func (result i32)
|
||||
(select
|
||||
(block i32
|
||||
(drop (block i32
|
||||
(block (result i32)
|
||||
(drop (block (result i32)
|
||||
(br_table
|
||||
1
|
||||
0
|
||||
|
@ -93,7 +93,7 @@ wasmEvalText(`
|
|||
(block $b i32
|
||||
(if (i32.const 1)
|
||||
(call 0
|
||||
(block i32
|
||||
(block (result i32)
|
||||
(call 0 (i32.const 42))
|
||||
(br $b (i32.const 10)))))
|
||||
(i32.const 44))))
|
||||
|
|
|
@ -6,7 +6,7 @@ wasmEvalText(
|
|||
(local.set $var0 (i64.extend_u/i32 (local.get $arg0)))
|
||||
(i32.wrap/i64
|
||||
(i64.add
|
||||
(block i64
|
||||
(block (result i64)
|
||||
(loop $label1 $label0
|
||||
(drop (block $label2 i64
|
||||
(br_table $label2 (i64.const 0) (local.get $arg0))))
|
||||
|
|
|
@ -139,7 +139,7 @@ var exports = wasmEvalText(`(module
|
|||
(func $test (result i32)
|
||||
(i32.add
|
||||
(call_indirect $v2i (i32.const 0))
|
||||
(block i32
|
||||
(block (result i32)
|
||||
(call $grow)
|
||||
(call_indirect $v2i (i32.const 1)))))
|
||||
(func $one (result i32) (i32.const 1))
|
||||
|
@ -170,7 +170,7 @@ var exports2 = wasmEvalText(`(module
|
|||
(func $test (result i32)
|
||||
(i32.add
|
||||
(call_indirect $v2i (i32.const 1))
|
||||
(block i32
|
||||
(block (result i32)
|
||||
(call_indirect $v2v (i32.const 0))
|
||||
(call_indirect $v2i (i32.const 2)))))
|
||||
(func $ten (result i32) (i32.const 10))
|
||||
|
|
|
@ -22,8 +22,8 @@ wasmFullPass(` (module
|
|||
i32.const 17
|
||||
i32.store
|
||||
end
|
||||
block i32
|
||||
block i32
|
||||
block (result i32)
|
||||
block (result i32)
|
||||
i32.const 2
|
||||
if i32
|
||||
i32.const 500
|
||||
|
|
Загрузка…
Ссылка в новой задаче