This repository was archived by the owner on Mar 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: YiYing He <yiying@secondstate.io>
- Loading branch information
Showing
45 changed files
with
872 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{"source_filename": "return_call.wast", | ||
"commands": [ | ||
{"type": "module", "line": 3, "filename": "return_call.0.wasm"}, | ||
{"type": "assert_return", "line": 80, "action": {"type": "invoke", "field": "type-i32", "args": []}, "expected": [{"type": "i32", "value": "306"}]}, | ||
{"type": "assert_return", "line": 81, "action": {"type": "invoke", "field": "type-i64", "args": []}, "expected": [{"type": "i64", "value": "356"}]}, | ||
{"type": "assert_return", "line": 82, "action": {"type": "invoke", "field": "type-f32", "args": []}, "expected": [{"type": "f32", "value": "1165172736"}]}, | ||
{"type": "assert_return", "line": 83, "action": {"type": "invoke", "field": "type-f64", "args": []}, "expected": [{"type": "f64", "value": "4660882566700597248"}]}, | ||
{"type": "assert_return", "line": 85, "action": {"type": "invoke", "field": "type-first-i32", "args": []}, "expected": [{"type": "i32", "value": "32"}]}, | ||
{"type": "assert_return", "line": 86, "action": {"type": "invoke", "field": "type-first-i64", "args": []}, "expected": [{"type": "i64", "value": "64"}]}, | ||
{"type": "assert_return", "line": 87, "action": {"type": "invoke", "field": "type-first-f32", "args": []}, "expected": [{"type": "f32", "value": "1068037571"}]}, | ||
{"type": "assert_return", "line": 88, "action": {"type": "invoke", "field": "type-first-f64", "args": []}, "expected": [{"type": "f64", "value": "4610064722561534525"}]}, | ||
{"type": "assert_return", "line": 90, "action": {"type": "invoke", "field": "type-second-i32", "args": []}, "expected": [{"type": "i32", "value": "32"}]}, | ||
{"type": "assert_return", "line": 91, "action": {"type": "invoke", "field": "type-second-i64", "args": []}, "expected": [{"type": "i64", "value": "64"}]}, | ||
{"type": "assert_return", "line": 92, "action": {"type": "invoke", "field": "type-second-f32", "args": []}, "expected": [{"type": "f32", "value": "1107296256"}]}, | ||
{"type": "assert_return", "line": 93, "action": {"type": "invoke", "field": "type-second-f64", "args": []}, "expected": [{"type": "f64", "value": "4634211053438658150"}]}, | ||
{"type": "assert_return", "line": 95, "action": {"type": "invoke", "field": "fac-acc", "args": [{"type": "i64", "value": "0"}, {"type": "i64", "value": "1"}]}, "expected": [{"type": "i64", "value": "1"}]}, | ||
{"type": "assert_return", "line": 96, "action": {"type": "invoke", "field": "fac-acc", "args": [{"type": "i64", "value": "1"}, {"type": "i64", "value": "1"}]}, "expected": [{"type": "i64", "value": "1"}]}, | ||
{"type": "assert_return", "line": 97, "action": {"type": "invoke", "field": "fac-acc", "args": [{"type": "i64", "value": "5"}, {"type": "i64", "value": "1"}]}, "expected": [{"type": "i64", "value": "120"}]}, | ||
{"type": "assert_return", "line": 99, "action": {"type": "invoke", "field": "fac-acc", "args": [{"type": "i64", "value": "25"}, {"type": "i64", "value": "1"}]}, "expected": [{"type": "i64", "value": "7034535277573963776"}]}, | ||
{"type": "assert_return", "line": 103, "action": {"type": "invoke", "field": "count", "args": [{"type": "i64", "value": "0"}]}, "expected": [{"type": "i64", "value": "0"}]}, | ||
{"type": "assert_return", "line": 104, "action": {"type": "invoke", "field": "count", "args": [{"type": "i64", "value": "1000"}]}, "expected": [{"type": "i64", "value": "0"}]}, | ||
{"type": "assert_return", "line": 105, "action": {"type": "invoke", "field": "count", "args": [{"type": "i64", "value": "1000000"}]}, "expected": [{"type": "i64", "value": "0"}]}, | ||
{"type": "assert_return", "line": 107, "action": {"type": "invoke", "field": "even", "args": [{"type": "i64", "value": "0"}]}, "expected": [{"type": "i32", "value": "44"}]}, | ||
{"type": "assert_return", "line": 108, "action": {"type": "invoke", "field": "even", "args": [{"type": "i64", "value": "1"}]}, "expected": [{"type": "i32", "value": "99"}]}, | ||
{"type": "assert_return", "line": 109, "action": {"type": "invoke", "field": "even", "args": [{"type": "i64", "value": "100"}]}, "expected": [{"type": "i32", "value": "44"}]}, | ||
{"type": "assert_return", "line": 110, "action": {"type": "invoke", "field": "even", "args": [{"type": "i64", "value": "77"}]}, "expected": [{"type": "i32", "value": "99"}]}, | ||
{"type": "assert_return", "line": 111, "action": {"type": "invoke", "field": "even", "args": [{"type": "i64", "value": "1000000"}]}, "expected": [{"type": "i32", "value": "44"}]}, | ||
{"type": "assert_return", "line": 112, "action": {"type": "invoke", "field": "even", "args": [{"type": "i64", "value": "1000001"}]}, "expected": [{"type": "i32", "value": "99"}]}, | ||
{"type": "assert_return", "line": 113, "action": {"type": "invoke", "field": "odd", "args": [{"type": "i64", "value": "0"}]}, "expected": [{"type": "i32", "value": "99"}]}, | ||
{"type": "assert_return", "line": 114, "action": {"type": "invoke", "field": "odd", "args": [{"type": "i64", "value": "1"}]}, "expected": [{"type": "i32", "value": "44"}]}, | ||
{"type": "assert_return", "line": 115, "action": {"type": "invoke", "field": "odd", "args": [{"type": "i64", "value": "200"}]}, "expected": [{"type": "i32", "value": "99"}]}, | ||
{"type": "assert_return", "line": 116, "action": {"type": "invoke", "field": "odd", "args": [{"type": "i64", "value": "77"}]}, "expected": [{"type": "i32", "value": "44"}]}, | ||
{"type": "assert_return", "line": 117, "action": {"type": "invoke", "field": "odd", "args": [{"type": "i64", "value": "1000000"}]}, "expected": [{"type": "i32", "value": "99"}]}, | ||
{"type": "assert_return", "line": 118, "action": {"type": "invoke", "field": "odd", "args": [{"type": "i64", "value": "999999"}]}, "expected": [{"type": "i32", "value": "44"}]}, | ||
{"type": "assert_invalid", "line": 124, "filename": "return_call.1.wasm", "text": "type mismatch", "module_type": "binary"}, | ||
{"type": "assert_invalid", "line": 131, "filename": "return_call.2.wasm", "text": "type mismatch", "module_type": "binary"}, | ||
{"type": "assert_invalid", "line": 139, "filename": "return_call.3.wasm", "text": "type mismatch", "module_type": "binary"}, | ||
{"type": "assert_invalid", "line": 146, "filename": "return_call.4.wasm", "text": "type mismatch", "module_type": "binary"}, | ||
{"type": "module", "line": 153, "filename": "return_call.5.wasm"}, | ||
{"type": "module", "line": 158, "filename": "return_call.6.wasm"}, | ||
{"type": "assert_invalid", "line": 164, "filename": "return_call.7.wasm", "text": "type mismatch", "module_type": "binary"}, | ||
{"type": "assert_invalid", "line": 171, "filename": "return_call.8.wasm", "text": "type mismatch", "module_type": "binary"}, | ||
{"type": "assert_invalid", "line": 178, "filename": "return_call.9.wasm", "text": "type mismatch", "module_type": "binary"}, | ||
{"type": "assert_invalid", "line": 185, "filename": "return_call.10.wasm", "text": "type mismatch", "module_type": "binary"}, | ||
{"type": "assert_invalid", "line": 196, "filename": "return_call.11.wasm", "text": "unknown function", "module_type": "binary"}, | ||
{"type": "assert_invalid", "line": 200, "filename": "return_call.12.wasm", "text": "unknown function", "module_type": "binary"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
;; Test `return_call` operator | ||
|
||
(module | ||
;; Auxiliary definitions | ||
(func $const-i32 (result i32) (i32.const 0x132)) | ||
(func $const-i64 (result i64) (i64.const 0x164)) | ||
(func $const-f32 (result f32) (f32.const 0xf32)) | ||
(func $const-f64 (result f64) (f64.const 0xf64)) | ||
|
||
(func $id-i32 (param i32) (result i32) (local.get 0)) | ||
(func $id-i64 (param i64) (result i64) (local.get 0)) | ||
(func $id-f32 (param f32) (result f32) (local.get 0)) | ||
(func $id-f64 (param f64) (result f64) (local.get 0)) | ||
|
||
(func $f32-i32 (param f32 i32) (result i32) (local.get 1)) | ||
(func $i32-i64 (param i32 i64) (result i64) (local.get 1)) | ||
(func $f64-f32 (param f64 f32) (result f32) (local.get 1)) | ||
(func $i64-f64 (param i64 f64) (result f64) (local.get 1)) | ||
|
||
;; Typing | ||
|
||
(func (export "type-i32") (result i32) (return_call $const-i32)) | ||
(func (export "type-i64") (result i64) (return_call $const-i64)) | ||
(func (export "type-f32") (result f32) (return_call $const-f32)) | ||
(func (export "type-f64") (result f64) (return_call $const-f64)) | ||
|
||
(func (export "type-first-i32") (result i32) (return_call $id-i32 (i32.const 32))) | ||
(func (export "type-first-i64") (result i64) (return_call $id-i64 (i64.const 64))) | ||
(func (export "type-first-f32") (result f32) (return_call $id-f32 (f32.const 1.32))) | ||
(func (export "type-first-f64") (result f64) (return_call $id-f64 (f64.const 1.64))) | ||
|
||
(func (export "type-second-i32") (result i32) | ||
(return_call $f32-i32 (f32.const 32.1) (i32.const 32)) | ||
) | ||
(func (export "type-second-i64") (result i64) | ||
(return_call $i32-i64 (i32.const 32) (i64.const 64)) | ||
) | ||
(func (export "type-second-f32") (result f32) | ||
(return_call $f64-f32 (f64.const 64) (f32.const 32)) | ||
) | ||
(func (export "type-second-f64") (result f64) | ||
(return_call $i64-f64 (i64.const 64) (f64.const 64.1)) | ||
) | ||
|
||
;; Recursion | ||
|
||
(func $fac-acc (export "fac-acc") (param i64 i64) (result i64) | ||
(if (result i64) (i64.eqz (local.get 0)) | ||
(then (local.get 1)) | ||
(else | ||
(return_call $fac-acc | ||
(i64.sub (local.get 0) (i64.const 1)) | ||
(i64.mul (local.get 0) (local.get 1)) | ||
) | ||
) | ||
) | ||
) | ||
|
||
(func $count (export "count") (param i64) (result i64) | ||
(if (result i64) (i64.eqz (local.get 0)) | ||
(then (local.get 0)) | ||
(else (return_call $count (i64.sub (local.get 0) (i64.const 1)))) | ||
) | ||
) | ||
|
||
(func $even (export "even") (param i64) (result i32) | ||
(if (result i32) (i64.eqz (local.get 0)) | ||
(then (i32.const 44)) | ||
(else (return_call $odd (i64.sub (local.get 0) (i64.const 1)))) | ||
) | ||
) | ||
(func $odd (export "odd") (param i64) (result i32) | ||
(if (result i32) (i64.eqz (local.get 0)) | ||
(then (i32.const 99)) | ||
(else (return_call $even (i64.sub (local.get 0) (i64.const 1)))) | ||
) | ||
) | ||
) | ||
|
||
(assert_return (invoke "type-i32") (i32.const 0x132)) | ||
(assert_return (invoke "type-i64") (i64.const 0x164)) | ||
(assert_return (invoke "type-f32") (f32.const 0xf32)) | ||
(assert_return (invoke "type-f64") (f64.const 0xf64)) | ||
|
||
(assert_return (invoke "type-first-i32") (i32.const 32)) | ||
(assert_return (invoke "type-first-i64") (i64.const 64)) | ||
(assert_return (invoke "type-first-f32") (f32.const 1.32)) | ||
(assert_return (invoke "type-first-f64") (f64.const 1.64)) | ||
|
||
(assert_return (invoke "type-second-i32") (i32.const 32)) | ||
(assert_return (invoke "type-second-i64") (i64.const 64)) | ||
(assert_return (invoke "type-second-f32") (f32.const 32)) | ||
(assert_return (invoke "type-second-f64") (f64.const 64.1)) | ||
|
||
(assert_return (invoke "fac-acc" (i64.const 0) (i64.const 1)) (i64.const 1)) | ||
(assert_return (invoke "fac-acc" (i64.const 1) (i64.const 1)) (i64.const 1)) | ||
(assert_return (invoke "fac-acc" (i64.const 5) (i64.const 1)) (i64.const 120)) | ||
(assert_return | ||
(invoke "fac-acc" (i64.const 25) (i64.const 1)) | ||
(i64.const 7034535277573963776) | ||
) | ||
|
||
(assert_return (invoke "count" (i64.const 0)) (i64.const 0)) | ||
(assert_return (invoke "count" (i64.const 1000)) (i64.const 0)) | ||
(assert_return (invoke "count" (i64.const 1_000_000)) (i64.const 0)) | ||
|
||
(assert_return (invoke "even" (i64.const 0)) (i32.const 44)) | ||
(assert_return (invoke "even" (i64.const 1)) (i32.const 99)) | ||
(assert_return (invoke "even" (i64.const 100)) (i32.const 44)) | ||
(assert_return (invoke "even" (i64.const 77)) (i32.const 99)) | ||
(assert_return (invoke "even" (i64.const 1_000_000)) (i32.const 44)) | ||
(assert_return (invoke "even" (i64.const 1_000_001)) (i32.const 99)) | ||
(assert_return (invoke "odd" (i64.const 0)) (i32.const 99)) | ||
(assert_return (invoke "odd" (i64.const 1)) (i32.const 44)) | ||
(assert_return (invoke "odd" (i64.const 200)) (i32.const 99)) | ||
(assert_return (invoke "odd" (i64.const 77)) (i32.const 44)) | ||
(assert_return (invoke "odd" (i64.const 1_000_000)) (i32.const 99)) | ||
(assert_return (invoke "odd" (i64.const 999_999)) (i32.const 44)) | ||
|
||
|
||
;; Invalid typing | ||
|
||
(assert_invalid | ||
(module | ||
(func $type-void-vs-num (result i32) (return_call 1) (i32.const 0)) | ||
(func) | ||
) | ||
"type mismatch" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $type-num-vs-num (result i32) (return_call 1) (i32.const 0)) | ||
(func (result i64) (i64.const 1)) | ||
) | ||
"type mismatch" | ||
) | ||
|
||
(assert_invalid | ||
(module | ||
(func $arity-0-vs-1 (return_call 1)) | ||
(func (param i32)) | ||
) | ||
"type mismatch" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $arity-0-vs-2 (return_call 1)) | ||
(func (param f64 i32)) | ||
) | ||
"type mismatch" | ||
) | ||
|
||
(module | ||
(func $arity-1-vs-0 (i32.const 1) (return_call 1)) | ||
(func) | ||
) | ||
|
||
(module | ||
(func $arity-2-vs-0 (f64.const 2) (i32.const 1) (return_call 1)) | ||
(func) | ||
) | ||
|
||
(assert_invalid | ||
(module | ||
(func $type-first-void-vs-num (return_call 1 (nop) (i32.const 1))) | ||
(func (param i32 i32)) | ||
) | ||
"type mismatch" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $type-second-void-vs-num (return_call 1 (i32.const 1) (nop))) | ||
(func (param i32 i32)) | ||
) | ||
"type mismatch" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $type-first-num-vs-num (return_call 1 (f64.const 1) (i32.const 1))) | ||
(func (param i32 f64)) | ||
) | ||
"type mismatch" | ||
) | ||
(assert_invalid | ||
(module | ||
(func $type-second-num-vs-num (return_call 1 (i32.const 1) (f64.const 1))) | ||
(func (param f64 i32)) | ||
) | ||
"type mismatch" | ||
) | ||
|
||
|
||
;; Unbound function | ||
|
||
(assert_invalid | ||
(module (func $unbound-func (return_call 1))) | ||
"unknown function" | ||
) | ||
(assert_invalid | ||
(module (func $large-func (return_call 1012321300))) | ||
"unknown function" | ||
) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(type $sig (func (param i32) (result i32)))(table 0 funcref)(func (result i32) (return_call_indirect (type $sig) (result i32) (param i32) (i32.const 0) (i32.const 0) )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(type $sig (func (param i32) (result i32)))(table 0 funcref)(func (return_call_indirect (type $sig) (param i32) (i32.const 0) (i32.const 0) )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(type $sig (func (param i32 i32) (result i32)))(table 0 funcref)(func (result i32) (return_call_indirect (type $sig) (param i32) (result i32) (i32.const 0) (i32.const 0) )) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(type $sig (func (param i32) (result i32)))(table 0 funcref)(func (result i32) (return_call_indirect (param i32) (type $sig) (result i32) (i32.const 0) (i32.const 0) )) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(type $sig (func (param i32) (result i32)))(table 0 funcref)(func (result i32) (return_call_indirect (param i32) (result i32) (type $sig) (i32.const 0) (i32.const 0) )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(type $sig (func (param i32) (result i32)))(table 0 funcref)(func (result i32) (return_call_indirect (result i32) (type $sig) (param i32) (i32.const 0) (i32.const 0) )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(type $sig (func (param i32) (result i32)))(table 0 funcref)(func (result i32) (return_call_indirect (result i32) (param i32) (type $sig) (i32.const 0) (i32.const 0) )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(table 0 funcref)(func (result i32) (return_call_indirect (result i32) (param i32) (i32.const 0) (i32.const 0) )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(table 0 funcref)(func (return_call_indirect (param $x i32) (i32.const 0) (i32.const 0))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(type $sig (func))(table 0 funcref)(func (result i32) (return_call_indirect (type $sig) (result i32) (i32.const 0))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(type $sig (func (param i32) (result i32)))(table 0 funcref)(func (result i32) (return_call_indirect (type $sig) (result i32) (i32.const 0))) |
Oops, something went wrong.