-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fuzzer: Use a WebAssembly.Tag from JS (#7277)
We now create a Tag in JS and import it in the wasm. We can then use that tag from JS when we throw (only some of the time, controlled by a new parameter to the throwing import).
- Loading branch information
Showing
6 changed files
with
143 additions
and
56 deletions.
There are no files selected for viewing
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
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
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
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,35 @@ | ||
;; Test throwing from JS by calling the throw import. | ||
|
||
(module | ||
(import "fuzzing-support" "throw" (func $throw (param i32))) | ||
|
||
(func $throwing-js (export "throwing-js") | ||
;; Telling JS to throw with arg 0 leads to a JS exception thrown. | ||
(call $throw | ||
(i32.const 0) | ||
) | ||
) | ||
|
||
(func $throwing-tag (export "throwing-tag") | ||
;; A non-0 arg leads to a wasm Tag being thrown. | ||
(call $throw | ||
(i32.const 42) | ||
) | ||
) | ||
) | ||
|
||
;; Build to a binary wasm. | ||
;; | ||
;; RUN: wasm-opt %s -o %t.wasm -q | ||
|
||
;; Run in node. | ||
;; | ||
;; RUN: v8 %S/../../../scripts/fuzz_shell.js -- %t.wasm | filecheck %s | ||
;; | ||
;; CHECK: [fuzz-exec] calling throwing-js | ||
;; CHECK: exception thrown: some JS error | ||
;; CHECK: [fuzz-exec] calling throwing-tag | ||
;; CHECK: exception thrown: [object WebAssembly.Exception] | ||
|
||
|
||
|
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
72 changes: 31 additions & 41 deletions
72
test/passes/translate-to-fuzz_all-features_metrics_noprint.txt
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 |
---|---|---|
@@ -1,52 +1,42 @@ | ||
Metrics | ||
total | ||
[exports] : 10 | ||
[funcs] : 9 | ||
[exports] : 15 | ||
[funcs] : 17 | ||
[globals] : 4 | ||
[imports] : 8 | ||
[imports] : 11 | ||
[memories] : 1 | ||
[memory-data] : 112 | ||
[table-data] : 0 | ||
[table-data] : 4 | ||
[tables] : 1 | ||
[tags] : 1 | ||
[total] : 553 | ||
[vars] : 38 | ||
ArrayCopy : 2 | ||
ArrayLen : 4 | ||
[tags] : 0 | ||
[total] : 688 | ||
[vars] : 15 | ||
ArrayNew : 1 | ||
ArrayNewFixed : 7 | ||
Binary : 69 | ||
Block : 55 | ||
BrOn : 1 | ||
Break : 1 | ||
Call : 23 | ||
Const : 107 | ||
Drop : 7 | ||
GlobalGet : 19 | ||
GlobalSet : 18 | ||
If : 17 | ||
Load : 17 | ||
LocalGet : 66 | ||
LocalSet : 39 | ||
Loop : 1 | ||
ArrayNewFixed : 5 | ||
Binary : 70 | ||
Block : 77 | ||
Call : 43 | ||
Const : 166 | ||
Drop : 8 | ||
GlobalGet : 43 | ||
GlobalSet : 38 | ||
If : 19 | ||
Load : 16 | ||
LocalGet : 45 | ||
LocalSet : 21 | ||
Loop : 3 | ||
Nop : 3 | ||
RefAs : 13 | ||
RefFunc : 9 | ||
RefI31 : 2 | ||
RefIsNull : 2 | ||
RefNull : 7 | ||
RefTest : 1 | ||
RefAs : 2 | ||
RefFunc : 28 | ||
RefNull : 8 | ||
Return : 5 | ||
SIMDReplace : 1 | ||
Select : 3 | ||
Select : 1 | ||
Store : 1 | ||
StringConst : 3 | ||
StringEncode : 1 | ||
StringMeasure : 1 | ||
StructGet : 1 | ||
StructNew : 15 | ||
StructSet : 2 | ||
TupleExtract : 1 | ||
StringConst : 2 | ||
StructNew : 37 | ||
StructSet : 1 | ||
Throw : 1 | ||
TryTable : 3 | ||
TupleMake : 3 | ||
Unary : 16 | ||
Unreachable : 9 | ||
Unary : 19 | ||
Unreachable : 19 |