diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-05-31 20:02:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-31 20:02:37 -0700 |
commit | fe99e3458f11d1a01fa3ad5b68883dbcba3903af (patch) | |
tree | 6f5eda61c7c7cba9c3b16be5e361cdc148d8b315 /test | |
parent | 7306f60a4474ca1fa948bddee5c068e7c2f635f6 (diff) | |
download | binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.tar.gz binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.tar.bz2 binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.zip |
Add event section (#2151)
This adds support for the event and the event section, as specified in
https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model.
Wasm events are features that suspend the current execution and transfer
the control flow to a corresponding handler. Currently the only
supported event kind is exceptions.
For events, this includes support for
- Binary file reading/writing
- Wast file reading/writing
- Binaryen.js API
- Fuzzer
- Validation
- Metadce
- Passes: metrics, minify-imports-and-exports,
remove-unused-module-elements
Diffstat (limited to 'test')
35 files changed, 1186 insertions, 704 deletions
diff --git a/test/binaryen.js/event.js b/test/binaryen.js/event.js new file mode 100644 index 000000000..ec7a0f3b1 --- /dev/null +++ b/test/binaryen.js/event.js @@ -0,0 +1,32 @@ +function cleanInfo(info) { + var ret = {}; + for (var x in info) { + ret[x] = info[x]; + } + return ret; +} + +var module = new Binaryen.Module(); +module.setFeatures(Binaryen.Features.ExceptionHandling); + +var vi = module.addFunctionType("vi", Binaryen.none, [Binaryen.i32]); +var vif = module.addFunctionType("vif", Binaryen.none, [Binaryen.i32, Binaryen.f32]); + +var event_ = module.addEvent("a-event", 0, vi); + +console.log("GetEvent is equal: " + (event_ === module.getEvent("a-event"))); + +var eventInfo = Binaryen.getEventInfo(event_); +console.log("getEventInfo=" + JSON.stringify(cleanInfo(eventInfo))); + +module.addEventExport("a-event", "a-event-exp"); +module.addEventImport("a-event-imp", "module", "base", 0, vif); + +module.validate(); +console.log(module.emitText()); + +module.removeExport("a-event-exp"); +module.removeEvent("a-event"); + +module.validate(); +console.log(module.emitText()); diff --git a/test/binaryen.js/event.js.txt b/test/binaryen.js/event.js.txt new file mode 100644 index 000000000..233f4b037 --- /dev/null +++ b/test/binaryen.js/event.js.txt @@ -0,0 +1,16 @@ +GetEvent is equal: true +getEventInfo={"name":"a-event","module":"","base":"","attribute":0,"type":"vi"} +(module + (type $vi (func (param i32))) + (type $vif (func (param i32 f32))) + (import "module" "base" (event $a-event-imp (attr 0) (param i32 f32))) + (event $a-event (attr 0) (param i32)) + (export "a-event-exp" (event $a-event)) +) + +(module + (type $vi (func (param i32))) + (type $vif (func (param i32 f32))) + (import "module" "base" (event $a-event-imp (attr 0) (param i32 f32))) +) + diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 649abfa4b..e745c0303 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -423,16 +423,22 @@ function test_core() { var initExpr = module.i32.const(1); var global = module.addGlobal("a-global", Binaryen.i32, false, initExpr) + // Create an event + var vi = module.addFunctionType("vi", Binaryen.none, [Binaryen.i32]); + var event_ = module.addEvent("a-event", 0, vi); + // Imports var fiF = module.addFunctionType("fiF", Binaryen.f32, [ Binaryen.i32, Binaryen.f64 ]); module.addFunctionImport("an-imported", "module", "base", fiF); module.addGlobalImport("a-global-imp", "module", "base", Binaryen.i32); + module.addEventImport("a-event-imp", "module", "base", 0, vi); // Exports module.addFunctionExport("kitchen()sinker", "kitchen_sinker"); module.addGlobalExport("a-global", "a-global-exp"); + module.addEventExport("a-event", "a-event-exp"); // Function table. One per module @@ -683,13 +689,16 @@ function test_binaries() { { // create a module and write it to binary module = new Binaryen.Module(); + module.setFeatures(Binaryen.Features.All); var iii = module.addFunctionType("iii", Binaryen.i32, [ Binaryen.i32, Binaryen.i32 ]); + var vii = module.addFunctionType("vii", Binaryen.none, [ Binaryen.i32, Binaryen.i32 ]); var x = module.local.get(0, Binaryen.i32), y = module.local.get(1, Binaryen.i32); var add = module.i32.add(x, y); var adder = module.addFunction("adder", iii, [], add); var initExpr = module.i32.const(3); var global = module.addGlobal("a-global", Binaryen.i32, false, initExpr) + var event_ = module.addEvent("a-event", 0, vii); Binaryen.setDebugInfo(true); // include names section buffer = module.emitBinary(); Binaryen.setDebugInfo(false); @@ -702,6 +711,7 @@ function test_binaries() { // read the module from the binary module = Binaryen.readBinary(buffer); + module.setFeatures(Binaryen.Features.All); // validate, print, and free assert(module.validate()); @@ -755,16 +765,17 @@ function test_parsing() { // create a module and write it to text module = new Binaryen.Module(); - module.setFeatures(Binaryen.Features.All); var iii = module.addFunctionType("iii", Binaryen.i32, [ Binaryen.i32, Binaryen.i32 ]); + var vi = module.addFunctionType("vi", Binaryen.none, [ Binaryen.i32 ]); var x = module.local.get(0, Binaryen.i32), y = module.local.get(1, Binaryen.i32); var add = module.i32.add(x, y); var adder = module.addFunction("adder", iii, [], add); var initExpr = module.i32.const(3); var global = module.addGlobal("a-global", Binaryen.i32, false, initExpr) + var event_ = module.addEvent("a-event", 0, vi); text = module.emitText(); module.dispose(); module = null; @@ -773,6 +784,7 @@ function test_parsing() { text = text.replace('adder', 'ADD_ER'); var module2 = Binaryen.parseText(text); + module2.setFeatures(Binaryen.Features.All); assert(module2.validate()); console.log("module loaded from text form:"); console.log(module2.emitText()); diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 857950e6b..85085fa82 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -63,19 +63,23 @@ getExpressionInfo(f32.const)={"id":14,"type":3,"value":8.5} getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} (module (type $iiIfF (func (param i32 i64 f32 f64) (result i32))) + (type $vi (func (param i32))) (type $fiF (func (param i32 f64) (result f32))) (type $v (func)) - (type $3 (func)) + (type $4 (func)) (import "module" "base" (global $a-global-imp i32)) (import "module" "base" (func $an-imported (param i32 f64) (result f32))) + (import "module" "base" (event $a-event-imp (attr 0) (param i32))) (memory $0 1 256) (data (i32.const 10) "hello, world") (data passive "I am passive") (table $0 1 funcref) (elem (i32.const 0) "$kitchen()sinker") (global $a-global i32 (i32.const 1)) + (event $a-event (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "a-global-exp" (global $a-global)) + (export "a-event-exp" (event $a-event)) (export "mem" (memory $0)) (start $starter) (func "$kitchen()sinker" (; 1 ;) (type $iiIfF) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) @@ -1898,7 +1902,9 @@ optimized: module loaded from binary form: (module (type $0 (func (param i32 i32) (result i32))) + (type $1 (func (param i32 i32))) (global $global$0 i32 (i32.const 3)) + (event $event$0 (attr 0) (param i32 i32)) (func $adder (; 0 ;) (type $0) (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) @@ -1944,6 +1950,7 @@ int main() { std::map<size_t, BinaryenExpressionRef> expressions; std::map<size_t, BinaryenFunctionRef> functions; std::map<size_t, BinaryenGlobalRef> globals; + std::map<size_t, BinaryenEventRef> events; std::map<size_t, BinaryenExportRef> exports; std::map<size_t, RelooperBlockRef> relooperBlocks; BinaryenModuleRef the_module = NULL; @@ -3343,13 +3350,20 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} expressions[656] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); globals[0] = BinaryenAddGlobal(the_module, "a-global", 1, 0, expressions[656]); { + BinaryenType paramTypes[] = { 1 }; + functionTypes[1] = BinaryenAddFunctionType(the_module, "vi", 0, paramTypes, 1); + } + BinaryenAddEvent(the_module, "a-event", 0, functionTypes[1]); + { BinaryenType paramTypes[] = { 1, 4 }; - functionTypes[1] = BinaryenAddFunctionType(the_module, "fiF", 3, paramTypes, 2); + functionTypes[2] = BinaryenAddFunctionType(the_module, "fiF", 3, paramTypes, 2); } - BinaryenAddFunctionImport(the_module, "an-imported", "module", "base", functionTypes[1]); + BinaryenAddFunctionImport(the_module, "an-imported", "module", "base", functionTypes[2]); BinaryenAddGlobalImport(the_module, "a-global-imp", "module", "base", 1); + BinaryenAddEventImport(the_module, "a-event-imp", "module", "base", 0, functionTypes[1]); exports[0] = BinaryenAddFunctionExport(the_module, "kitchen()sinker", "kitchen_sinker"); exports[1] = BinaryenAddGlobalExport(the_module, "a-global", "a-global-exp"); + exports[2] = BinaryenAddEventExport(the_module, "a-event", "a-event-exp"); BinaryenFunctionGetName(functions[0]); BinaryenFunctionImportGetModule(functions[0]); BinaryenFunctionImportGetBase(functions[0]); @@ -3379,17 +3393,17 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} } { BinaryenType paramTypes[] = { 0 }; - functionTypes[2] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); + functionTypes[3] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); } expressions[658] = BinaryenNop(the_module); { BinaryenType varTypes[] = { 0 }; - functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[2], varTypes, 0, expressions[658]); + functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[658]); } BinaryenSetStart(the_module, functions[1]); { BinaryenType paramTypes[] = { 0 }; - functionTypes[3] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); + functionTypes[4] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); } BinaryenModuleAutoDrop(the_module); BinaryenModuleSetFeatures(the_module, 127); @@ -3398,19 +3412,23 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} BinaryenModulePrint(the_module); (module (type $iiIfF (func (param i32 i64 f32 f64) (result i32))) + (type $vi (func (param i32))) (type $fiF (func (param i32 f64) (result f32))) (type $v (func)) - (type $3 (func)) + (type $4 (func)) (import "module" "base" (global $a-global-imp i32)) (import "module" "base" (func $an-imported (param i32 f64) (result f32))) + (import "module" "base" (event $a-event-imp (attr 0) (param i32))) (memory $0 1 256) (data (i32.const 10) "hello, world") (data passive "I am passive") (table $0 1 funcref) (elem (i32.const 0) "$kitchen()sinker") (global $a-global i32 (i32.const 1)) + (event $a-event (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "a-global-exp" (global $a-global)) + (export "a-event-exp" (event $a-event)) (export "mem" (memory $0)) (start $starter) (func "$kitchen()sinker" (; 1 ;) (type $iiIfF) (param $0 i32) (param $1 i64) (param $2 f32) (param $3 f64) (result i32) @@ -4765,6 +4783,7 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} expressions.clear(); functions.clear(); globals.clear(); + events.clear(); exports.clear(); relooperBlocks.clear(); the_module = BinaryenModuleCreate(); @@ -5706,6 +5725,7 @@ optimized: expressions.clear(); functions.clear(); globals.clear(); + events.clear(); exports.clear(); relooperBlocks.clear(); return 0; @@ -5713,7 +5733,9 @@ optimized: test_parsing text: (module (type $iii (func (param i32 i32) (result i32))) + (type $vi (func (param i32))) (global $a-global i32 (i32.const 3)) + (event $a-event (attr 0) (param i32)) (func $adder (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) @@ -5725,7 +5747,9 @@ test_parsing text: module loaded from text form: (module (type $iii (func (param i32 i32) (result i32))) + (type $vi (func (param i32))) (global $a-global i32 (i32.const 3)) + (event $a-event (attr 0) (param i32)) (func $ADD_ER (; 0 ;) (type $iii) (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) diff --git a/test/events.wast b/test/events.wast new file mode 100644 index 000000000..a2c88b977 --- /dev/null +++ b/test/events.wast @@ -0,0 +1,15 @@ +;; Test events + +(module + (event (attr 0) (param i32)) + (event $e (attr 0) (param i32 f32)) + + (event $e-params0 (attr 0) (param i32 f32)) + (event $e-params1 (attr 0) (param i32) (param f32)) + + (event $e-export (export "ex0") (attr 0) (param i32)) + (event $e-import (import "env" "im0") (attr 0) (param i32)) + + (import "env" "im1" (event (attr 0) (param i32 f32))) + (export "ex1" (event $e)) +) diff --git a/test/events.wast.from-wast b/test/events.wast.from-wast new file mode 100644 index 000000000..bcb78f6df --- /dev/null +++ b/test/events.wast.from-wast @@ -0,0 +1,12 @@ +(module + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$vif (func (param i32 f32))) + (import "env" "im0" (event $e-import (attr 0) (param i32))) + (import "env" "im1" (event $import$event1 (attr 0) (param i32 f32))) + (event $2 (attr 0) (param i32)) + (event $e (attr 0) (param i32 f32)) + (event $e-params0 (attr 0) (param i32 f32)) + (event $e-params1 (attr 0) (param i32 f32)) + (event $e-export (attr 0) (param i32)) + (export "ex1" (event $e)) +) diff --git a/test/events.wast.fromBinary b/test/events.wast.fromBinary new file mode 100644 index 000000000..ce19c63bd --- /dev/null +++ b/test/events.wast.fromBinary @@ -0,0 +1,13 @@ +(module + (type $0 (func (param i32))) + (type $1 (func (param i32 f32))) + (import "env" "im0" (event $eimport$0 (attr 0) (param i32))) + (import "env" "im1" (event $eimport$1 (attr 0) (param i32 f32))) + (event $event$0 (attr 0) (param i32)) + (event $event$1 (attr 0) (param i32 f32)) + (event $event$2 (attr 0) (param i32 f32)) + (event $event$3 (attr 0) (param i32 f32)) + (event $event$4 (attr 0) (param i32)) + (export "ex1" (event $event$1)) +) + diff --git a/test/events.wast.fromBinary.noDebugInfo b/test/events.wast.fromBinary.noDebugInfo new file mode 100644 index 000000000..ce19c63bd --- /dev/null +++ b/test/events.wast.fromBinary.noDebugInfo @@ -0,0 +1,13 @@ +(module + (type $0 (func (param i32))) + (type $1 (func (param i32 f32))) + (import "env" "im0" (event $eimport$0 (attr 0) (param i32))) + (import "env" "im1" (event $eimport$1 (attr 0) (param i32 f32))) + (event $event$0 (attr 0) (param i32)) + (event $event$1 (attr 0) (param i32 f32)) + (event $event$2 (attr 0) (param i32 f32)) + (event $event$3 (attr 0) (param i32 f32)) + (event $event$4 (attr 0) (param i32)) + (export "ex1" (event $event$1)) +) + diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index e0b4a5ec4..76a8aa675 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -488,6 +488,11 @@ void test_core() { BinaryenAddGlobal(module, "a-global", BinaryenTypeInt32(), 0, makeInt32(module, 7)); BinaryenAddGlobal(module, "a-mutable-global", BinaryenTypeFloat32(), 1, makeFloat32(module, 7.5)); + // Events + BinaryenType eparams[1] = { BinaryenTypeInt32() }; + BinaryenFunctionTypeRef vi = BinaryenAddFunctionType(module, "vi", BinaryenTypeNone(), eparams, 1); + BinaryenAddEvent(module, "a-event", 0, vi); + // Imports BinaryenType iparams[2] = { BinaryenTypeInt32(), BinaryenTypeFloat64() }; diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index c9bcc4b68..e5e16c6fe 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -21,9 +21,10 @@ BinaryenFeatureAll: 127 ) (module (type $iiIfF (func (param i32 i64 f32 f64) (result i32))) + (type $vi (func (param i32))) (type $fiF (func (param i32 f64) (result f32))) (type $v (func)) - (type $3 (func)) + (type $4 (func)) (import "module" "base" (func $an-imported (param i32 f64) (result f32))) (memory $0 1 256) (data (i32.const 10) "hello, world") @@ -32,6 +33,7 @@ BinaryenFeatureAll: 127 (elem (i32.const 0) "$kitchen()sinker") (global $a-global i32 (i32.const 7)) (global $a-mutable-global (mut f32) (f32.const 7.5)) + (event $a-event (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "mem" (memory $0)) (start $starter) @@ -1930,6 +1932,7 @@ int main() { std::map<size_t, BinaryenExpressionRef> expressions; std::map<size_t, BinaryenFunctionRef> functions; std::map<size_t, BinaryenGlobalRef> globals; + std::map<size_t, BinaryenEventRef> events; std::map<size_t, BinaryenExportRef> exports; std::map<size_t, RelooperBlockRef> relooperBlocks; BinaryenModuleRef the_module = NULL; @@ -3308,10 +3311,15 @@ int main() { expressions[654] = BinaryenConst(the_module, BinaryenLiteralFloat32(7.5)); globals[1] = BinaryenAddGlobal(the_module, "a-mutable-global", 3, 1, expressions[654]); { + BinaryenType paramTypes[] = { 1 }; + functionTypes[1] = BinaryenAddFunctionType(the_module, "vi", 0, paramTypes, 1); + } + BinaryenAddEvent(the_module, "a-event", 0, functionTypes[1]); + { BinaryenType paramTypes[] = { 1, 4 }; - functionTypes[1] = BinaryenAddFunctionType(the_module, "fiF", 3, paramTypes, 2); + functionTypes[2] = BinaryenAddFunctionType(the_module, "fiF", 3, paramTypes, 2); } - BinaryenAddFunctionImport(the_module, "an-imported", "module", "base", functionTypes[1]); + BinaryenAddFunctionImport(the_module, "an-imported", "module", "base", functionTypes[2]); exports[0] = BinaryenAddFunctionExport(the_module, "kitchen()sinker", "kitchen_sinker"); BinaryenFunctionGetName(functions[0]); { @@ -3330,17 +3338,17 @@ int main() { } { BinaryenType paramTypes[] = { 0 }; - functionTypes[2] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); + functionTypes[3] = BinaryenAddFunctionType(the_module, "v", 0, paramTypes, 0); } expressions[656] = BinaryenNop(the_module); { BinaryenType varTypes[] = { 0 }; - functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[2], varTypes, 0, expressions[656]); + functions[1] = BinaryenAddFunction(the_module, "starter", functionTypes[3], varTypes, 0, expressions[656]); } BinaryenSetStart(the_module, functions[1]); { BinaryenType paramTypes[] = { 0 }; - functionTypes[3] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); + functionTypes[4] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); } BinaryenModuleAutoDrop(the_module); BinaryenModuleSetFeatures(the_module, 127); @@ -3349,9 +3357,10 @@ int main() { BinaryenModulePrint(the_module); (module (type $iiIfF (func (param i32 i64 f32 f64) (result i32))) + (type $vi (func (param i32))) (type $fiF (func (param i32 f64) (result f32))) (type $v (func)) - (type $3 (func)) + (type $4 (func)) (import "module" "base" (func $an-imported (param i32 f64) (result f32))) (memory $0 1 256) (data (i32.const 10) "hello, world") @@ -3360,6 +3369,7 @@ int main() { (elem (i32.const 0) "$kitchen()sinker") (global $a-global i32 (i32.const 7)) (global $a-mutable-global (mut f32) (f32.const 7.5)) + (event $a-event (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "mem" (memory $0)) (start $starter) @@ -4723,6 +4733,7 @@ int main() { expressions.clear(); functions.clear(); globals.clear(); + events.clear(); exports.clear(); relooperBlocks.clear(); the_module = BinaryenModuleCreate(); @@ -5657,6 +5668,7 @@ optimized: expressions.clear(); functions.clear(); globals.clear(); + events.clear(); exports.clear(); relooperBlocks.clear(); return 0; diff --git a/test/example/c-api-kitchen-sink.txt.txt b/test/example/c-api-kitchen-sink.txt.txt index 05edca1a2..679ae534c 100644 --- a/test/example/c-api-kitchen-sink.txt.txt +++ b/test/example/c-api-kitchen-sink.txt.txt @@ -3,9 +3,10 @@ ) (module (type $iiIfF (func (param i32 i64 f32 f64) (result i32))) + (type $vi (func (param i32))) (type $fiF (func (param i32 f64) (result f32))) (type $v (func)) - (type $3 (func)) + (type $4 (func)) (import "module" "base" (func $an-imported (param i32 f64) (result f32))) (memory $0 1 256) (data (i32.const 10) "hello, world") @@ -14,6 +15,7 @@ (elem (i32.const 0) "$kitchen()sinker") (global $a-global i32 (i32.const 7)) (global $a-mutable-global (mut f32) (f32.const 7.5)) + (event $a-event (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) (export "mem" (memory $0)) (start $starter) diff --git a/test/metadce/rooted-export.wast b/test/metadce/rooted-export.wast index c2c88ec40..4b93969b4 100644 --- a/test/metadce/rooted-export.wast +++ b/test/metadce/rooted-export.wast @@ -8,5 +8,11 @@ (func $b_wasm_func (unreachable) ) + + (export "wasm_event_a" (event $a_wasm_event)) + (export "wasm_event_b" (event $b_wasm_event)) + + (event $a_wasm_event (attr 0) (param i32)) + (event $b_wasm_event (attr 0) (param i32)) ) diff --git a/test/metadce/rooted-export.wast.dced b/test/metadce/rooted-export.wast.dced index 636be324b..7eef01f40 100644 --- a/test/metadce/rooted-export.wast.dced +++ b/test/metadce/rooted-export.wast.dced @@ -1,6 +1,9 @@ (module (type $FUNCSIG$v (func)) + (type $FUNCSIG$vi (func (param i32))) + (event $b_wasm_event (attr 0) (param i32)) (export "wasm_func_b" (func $b_wasm_func)) + (export "wasm_event_b" (event $b_wasm_event)) (func $b_wasm_func (; 0 ;) (type $FUNCSIG$v) (unreachable) ) diff --git a/test/metadce/rooted-export.wast.dced.stdout b/test/metadce/rooted-export.wast.dced.stdout index 0a0cce75a..5b6a25c02 100644 --- a/test/metadce/rooted-export.wast.dced.stdout +++ b/test/metadce/rooted-export.wast.dced.stdout @@ -1,2 +1,4 @@ -unused: export$wasm_func_a$2 +unused: event$a_wasm_event$2 +unused: export$wasm_event_a$5 +unused: export$wasm_func_a$4 unused: func$a_wasm_func$0 diff --git a/test/metadce/rooted-export.wast.graph.txt b/test/metadce/rooted-export.wast.graph.txt index 274fb0d18..8ecd66dc0 100644 --- a/test/metadce/rooted-export.wast.graph.txt +++ b/test/metadce/rooted-export.wast.graph.txt @@ -1,8 +1,13 @@ [ { - "name": "rooted-export", + "name": "rooted-export-func", "root": true, "export": "wasm_func_b" + }, + { + "name": "rooted-export-event", + "root": true, + "export": "wasm_event_b" } ] diff --git a/test/passes/O3_low-memory-unused_metrics.txt b/test/passes/O3_low-memory-unused_metrics.txt index 91ddf6d87..bf5cd01a8 100644 --- a/test/passes/O3_low-memory-unused_metrics.txt +++ b/test/passes/O3_low-memory-unused_metrics.txt @@ -1,4 +1,5 @@ total + [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 diff --git a/test/passes/converge_O3_metrics.bin.txt b/test/passes/converge_O3_metrics.bin.txt index dd8470d0d..1c7a3275e 100644 --- a/test/passes/converge_O3_metrics.bin.txt +++ b/test/passes/converge_O3_metrics.bin.txt @@ -1,4 +1,5 @@ total + [events] : 0 [exports] : 2 [funcs] : 8 [globals] : 1 @@ -242,6 +243,7 @@ total ) ) total + [events] : 0 [exports] : 2 [funcs] : 8 [globals] : 1 @@ -486,6 +488,7 @@ total ) ) total + [events] : 0 [exports] : 2 [funcs] : 8 [globals] : 1 diff --git a/test/passes/func-metrics.txt b/test/passes/func-metrics.txt index 83aabc2fe..a6e9b0c92 100644 --- a/test/passes/func-metrics.txt +++ b/test/passes/func-metrics.txt @@ -1,4 +1,5 @@ global + [events] : 0 [exports] : 0 [funcs] : 3 [globals] : 1 @@ -89,6 +90,7 @@ func: ifs ) ) global + [events] : 0 [exports] : 0 [funcs] : 0 [globals] : 0 @@ -97,6 +99,7 @@ global (module ) global + [events] : 0 [exports] : 2 [funcs] : 3 [globals] : 0 @@ -171,6 +174,7 @@ export: b (func_b) ) ) global + [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 @@ -202,6 +206,7 @@ start: func_a ) ) global + [events] : 0 [exports] : 0 [funcs] : 1 [globals] : 0 @@ -229,6 +234,7 @@ start: func_a ) ) global + [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 1 diff --git a/test/passes/metrics.txt b/test/passes/metrics_all-features.txt index 95ca2c601..ba772597d 100644 --- a/test/passes/metrics.txt +++ b/test/passes/metrics_all-features.txt @@ -1,4 +1,5 @@ total + [events] : 2 [exports] : 0 [funcs] : 1 [globals] : 1 @@ -14,11 +15,14 @@ total if : 4 (module (type $0 (func (param i32))) + (type $FUNCSIG$vii (func (param i32 i32))) (memory $0 256 256) (data (i32.const 0) "\ff\ef\0f\1f 0@P\99") (table $0 256 256 funcref) (elem (i32.const 0) $ifs $ifs $ifs) (global $glob i32 (i32.const 1337)) + (event $e0 (attr 0) (param i32)) + (event $e1 (attr 0) (param i32 i32)) (func $ifs (; 0 ;) (type $0) (param $x i32) (local $y f32) (block $block0 @@ -60,6 +64,7 @@ total ) ) total + [events] : 0 [exports] : 0 [funcs] : 0 [globals] : 0 diff --git a/test/passes/metrics.wast b/test/passes/metrics_all-features.wast index 5ae98b7c7..018262f22 100644 --- a/test/passes/metrics.wast +++ b/test/passes/metrics_all-features.wast @@ -5,6 +5,8 @@ (data (i32.const 0) "\ff\ef\0f\1f\20\30\40\50\99") (type $0 (func (param i32))) (global $glob i32 (i32.const 1337)) + (event $e0 (attr 0) (param i32)) + (event $e1 (attr 0) (param i32 i32)) (func $ifs (type $0) (param $x i32) (local $y f32) (block $block0 diff --git a/test/passes/metrics_strip-debug_metrics.bin.txt b/test/passes/metrics_strip-debug_metrics.bin.txt index 3e7294453..51dfd1e79 100644 --- a/test/passes/metrics_strip-debug_metrics.bin.txt +++ b/test/passes/metrics_strip-debug_metrics.bin.txt @@ -1,4 +1,5 @@ total + [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 @@ -7,6 +8,7 @@ total [vars] : 0 nop : 1 total + [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 diff --git a/test/passes/metrics_strip-producers_metrics.bin.txt b/test/passes/metrics_strip-producers_metrics.bin.txt index e977d4ed5..290ed2599 100644 --- a/test/passes/metrics_strip-producers_metrics.bin.txt +++ b/test/passes/metrics_strip-producers_metrics.bin.txt @@ -1,4 +1,5 @@ total + [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 @@ -7,6 +8,7 @@ total [vars] : 0 nop : 1 total + [events] : 0 [exports] : 1 [funcs] : 1 [globals] : 0 diff --git a/test/passes/minify-imports-and-exports.txt b/test/passes/minify-imports-and-exports_all-features.txt index b6a2cf8bf..78852dfa8 100644 --- a/test/passes/minify-imports-and-exports.txt +++ b/test/passes/minify-imports-and-exports_all-features.txt @@ -942,7 +942,7 @@ longname3488 => J9 longname1490 => JA longname4946 => JAa longname1544 => JB -exp1 => JBa +eventname1 => JBa longname1598 => JC longname1652 => JD longname1706 => JE @@ -1035,7 +1035,7 @@ longname3489 => K9 longname1491 => KA longname4947 => KAa longname1545 => KB -exp2 => KBa +exp1 => KBa longname1599 => KC longname1653 => KD longname1707 => KE @@ -1128,6 +1128,7 @@ longname3490 => L9 longname1492 => LA longname4948 => LAa longname1546 => LB +exp2 => LBa longname1600 => LC longname1654 => LD longname1708 => LE @@ -1220,6 +1221,7 @@ longname3491 => M9 longname1493 => MA longname4949 => MAa longname1547 => MB +event1 => MBa longname1601 => MC longname1655 => MD longname1709 => ME @@ -5002,6 +5004,8 @@ longname1426 => zz longname4882 => zza (module (type $FUNCSIG$v (func)) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$vii (func (param i32 i32))) (import "env" "a" (global $import$global0 i32)) (import "env" "__memory_base" (global $import$global1 i32)) (import "env" "__table_base" (global $import$global2 i32)) @@ -10005,8 +10009,11 @@ longname4882 => zza (import "env" "HBa" (func $internal4998)) (import "env" "IBa" (func $internal4999)) (import "other" "anything" (func $internalInfinity)) - (export "JBa" (func $foo1)) - (export "KBa" (func $foo2)) + (import "env" "JBa" (event $eventname1 (attr 0) (param i32))) + (event $event1 (attr 0) (param i32 i32)) + (export "KBa" (func $foo1)) + (export "LBa" (func $foo2)) + (export "MBa" (event $event1)) (func $foo1 (; 5000 ;) (type $FUNCSIG$v) (nop) ) diff --git a/test/passes/minify-imports-and-exports.wast b/test/passes/minify-imports-and-exports_all-features.wast index ce0c46f95..2db91c2ad 100644 --- a/test/passes/minify-imports-and-exports.wast +++ b/test/passes/minify-imports-and-exports_all-features.wast @@ -5002,9 +5002,11 @@ (import "env" "__memory_base" (global i32)) (import "env" "__table_base" (global i32)) (import "other" "anything" (func $internalInfinity)) + (import "env" "eventname1" (event $eventname1 (attr 0) (param i32))) (export "exp1" (func $foo1)) (export "exp2" (func $foo2)) (func $foo1) (func $foo2) + (export "event1" (event $event1)) + (event $event1 (attr 0) (param i32 i32)) ) - diff --git a/test/passes/minify-imports.txt b/test/passes/minify-imports_all-features.txt index 45e295c67..024018bc2 100644 --- a/test/passes/minify-imports.txt +++ b/test/passes/minify-imports_all-features.txt @@ -942,6 +942,7 @@ longname3488 => J9 longname1490 => JA longname4946 => JAa longname1544 => JB +eventname1 => JBa longname1598 => JC longname1652 => JD longname1706 => JE @@ -5000,6 +5001,8 @@ longname1426 => zz longname4882 => zza (module (type $FUNCSIG$v (func)) + (type $FUNCSIG$vi (func (param i32))) + (type $FUNCSIG$vii (func (param i32 i32))) (import "env" "a" (global $import$global0 i32)) (import "env" "__memory_base" (global $import$global1 i32)) (import "env" "__table_base" (global $import$global2 i32)) @@ -10003,8 +10006,11 @@ longname4882 => zza (import "env" "HBa" (func $internal4998)) (import "env" "IBa" (func $internal4999)) (import "other" "anything" (func $internalInfinity)) + (import "env" "JBa" (event $eventname1 (attr 0) (param i32))) + (event $event1 (attr 0) (param i32 i32)) (export "foo1" (func $foo1)) (export "foo2" (func $foo2)) + (export "event1" (event $event1)) (func $foo1 (; 5000 ;) (type $FUNCSIG$v) (nop) ) diff --git a/test/passes/minify-imports.wast b/test/passes/minify-imports_all-features.wast index b24173163..26c8062ba 100644 --- a/test/passes/minify-imports.wast +++ b/test/passes/minify-imports_all-features.wast @@ -5002,9 +5002,11 @@ (import "env" "__memory_base" (global i32)) (import "env" "__table_base" (global i32)) (import "other" "anything" (func $internalInfinity)) + (import "env" "eventname1" (event $eventname1 (attr 0) (param i32))) (export "foo1" (func $foo1)) (export "foo2" (func $foo2)) + (export "event1" (event $event1)) (func $foo1) (func $foo2) + (event $event1 (attr 0) (param i32 i32)) ) - diff --git a/test/passes/remove-unused-module-elements_enable-threads.txt b/test/passes/remove-unused-module-elements_all-features.txt index 5db1ba5e6..3d80f96e9 100644 --- a/test/passes/remove-unused-module-elements_enable-threads.txt +++ b/test/passes/remove-unused-module-elements_all-features.txt @@ -278,3 +278,8 @@ ) ) ) +(module + (type $FUNCSIG$vj (func (param i64))) + (event $e1 (attr 0) (param i64)) + (export "e1" (event $e1)) +) diff --git a/test/passes/remove-unused-module-elements_enable-threads.wast b/test/passes/remove-unused-module-elements_all-features.wast index 8e07fb9c1..3d0248848 100644 --- a/test/passes/remove-unused-module-elements_enable-threads.wast +++ b/test/passes/remove-unused-module-elements_all-features.wast @@ -261,4 +261,11 @@ ) ) ) - +(module ;; non-exported events can be removed + (type $0 (func (param i32))) + (event $e0 (attr 0) (type $0)) + (event $e1 (attr 0) (param i64)) + (export "e1" (event $e1)) + (import "env" "e" (event $e2 (attr 0) (param i32))) + (func $f (; 0 ;) (type $0)) +) diff --git a/test/passes/remove-unused-nonfunction-module-elements_enable-threads.txt b/test/passes/remove-unused-nonfunction-module-elements_all-features.txt index 140cf61e6..e08bf1eb2 100644 --- a/test/passes/remove-unused-nonfunction-module-elements_enable-threads.txt +++ b/test/passes/remove-unused-nonfunction-module-elements_all-features.txt @@ -329,3 +329,12 @@ ) ) ) +(module + (type $0 (func (param i32))) + (type $FUNCSIG$vj (func (param i64))) + (event $e1 (attr 0) (param i64)) + (export "e1" (event $e1)) + (func $f (; 0 ;) (type $0) (param $0 i32) + (nop) + ) +) diff --git a/test/passes/remove-unused-nonfunction-module-elements_enable-threads.wast b/test/passes/remove-unused-nonfunction-module-elements_all-features.wast index 4c1944c12..36bc79e82 100644 --- a/test/passes/remove-unused-nonfunction-module-elements_enable-threads.wast +++ b/test/passes/remove-unused-nonfunction-module-elements_all-features.wast @@ -261,4 +261,11 @@ ) ) ) - +(module ;; non-exported events can be removed + (type $0 (func (param i32))) + (event $e0 (attr 0) (type $0)) + (event $e1 (attr 0) (param i64)) + (export "e1" (event $e1)) + (import "env" "e" (event $e2 (attr 0) (param i32))) + (func $f (; 0 ;) (type $0)) +) diff --git a/test/passes/translate-to-fuzz_all-features.txt b/test/passes/translate-to-fuzz_all-features.txt index fe24e738e..c3fd77b20 100644 --- a/test/passes/translate-to-fuzz_all-features.txt +++ b/test/passes/translate-to-fuzz_all-features.txt @@ -1,33 +1,26 @@ (module (type $FUNCSIG$i (func (result i32))) + (type $FUNCSIG$vifidi (func (param i32 f32 i32 f64 i32))) (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vj (func (param i64))) (type $FUNCSIG$vf (func (param f32))) (type $FUNCSIG$vd (func (param f64))) - (type $FUNCSIG$vjVdddV (func (param i64 v128 f64 f64 f64 v128))) - (type $FUNCSIG$ddVff (func (param f64 v128 f32 f32) (result f64))) - (type $FUNCSIG$VdVjf (func (param f64 v128 i64 f32) (result v128))) - (type $FUNCSIG$v (func)) - (type $FUNCSIG$jjiV (func (param i64 i32 v128) (result i64))) (import "fuzzing-support" "log-i32" (func $log-i32 (param i32))) (import "fuzzing-support" "log-i64" (func $log-i64 (param i64))) (import "fuzzing-support" "log-f32" (func $log-f32 (param f32))) (import "fuzzing-support" "log-f64" (func $log-f64 (param f64))) - (memory $0 1 1) + (memory $0 (shared 1 1)) (data (i32.const 0) "N\0fN\f5\f9\b1\ff\fa\eb\e5\fe\a7\ec\fb\fc\f4\a6\e4\ea\f0\ae\e3") - (table $0 8 funcref) - (elem (i32.const 0) $func_6 $func_6 $func_6 $func_6 $func_9 $func_9 $func_9 $func_9) - (global $global$0 (mut i32) (i32.const 975664160)) - (global $global$1 (mut i32) (i32.const -536870912)) - (global $global$2 (mut f32) (f32.const 2147483648)) - (global $global$3 (mut f32) (f32.const 1448959360)) + (table $0 3 3 funcref) + (elem (i32.const 0) $func_5 $func_5 $func_5) + (global $global$0 (mut i32) (i32.const 975663930)) + (global $global$1 (mut i32) (i32.const 2066300474)) + (global $global$2 (mut i64) (i64.const 20510)) + (global $global$3 (mut f32) (f32.const -2147483648)) (global $hangLimit (mut i32) (i32.const 10)) + (event $event$0 (attr 0) (param i32 f32 i32 f64 i32)) (export "hashMemory" (func $hashMemory)) (export "func_5" (func $func_5)) - (export "func_6" (func $func_6)) - (export "func_7" (func $func_7)) - (export "func_7_invoker" (func $func_7_invoker)) - (export "func_9" (func $func_9)) (export "hangLimitInitializer" (func $hangLimitInitializer)) (func $hashMemory (; 4 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) @@ -260,171 +253,18 @@ ) (local.get $0) ) - (func $func_5 (; 5 ;) (type $FUNCSIG$vjVdddV) (param $0 i64) (param $1 v128) (param $2 f64) (param $3 f64) (param $4 f64) (param $5 v128) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$0 - (call $log-f64 - (loop $label$1 (result f64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$2 (result f64) - (call $log-i32 - (call $hashMemory) - ) - (local.get $2) - ) - ) - ) - (call $log-i32 - (call $hashMemory) - ) - ) - ) - (func $func_6 (; 6 ;) (type $FUNCSIG$ddVff) (param $0 f64) (param $1 v128) (param $2 f32) (param $3 f32) (result f64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $0) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$0 (result f64) - (call $log-i32 - (i32.const 84215045) - ) - (f64.const 8) - ) - ) - (func $func_7 (; 7 ;) (type $FUNCSIG$VdVjf) (param $0 f64) (param $1 v128) (param $2 i64) (param $3 f32) (result v128) - (local $4 i32) - (local $5 f64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $1) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (local.tee $1 - (local.tee $1 - (v128.const i32x4 0x6d484708 0x13e740fc 0x5849037f 0xe4000000) - ) - ) - ) - (func $func_7_invoker (; 8 ;) (type $FUNCSIG$v) - (drop - (call $func_7 - (f64.const 16986) - (v128.const i32x4 0x00000000 0x00000010 0xffffe000 0xffffffff) - (i64.const -12) - (f32.const 7243) - ) - ) - (drop - (call $func_7 - (f64.const -65536) - (v128.const i32x4 0x00007d1f 0x00000200 0xffff0000 0x7fffffff) - (i64.const 288230376151711744) - (f32.const 128) - ) - ) - (call $log-i32 - (call $hashMemory) - ) - (drop - (call $func_7 - (f64.const -nan:0xfffffffffffb5) - (v128.const i32x4 0x00000000 0x403a0000 0x00000000 0xb8100000) - (i64.const 66) - (f32.const -nan:0x7fffb0) - ) - ) - ) - (func $func_9 (; 9 ;) (type $FUNCSIG$jjiV) (param $0 i64) (param $1 i32) (param $2 v128) (result i64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $0) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (i64.const 8) - ) - (func $func_10 (; 10 ;) (param $0 v128) (param $1 i64) (param $2 i64) (result v128) + (func $func_5 (; 5 ;) (type $FUNCSIG$vj) (param $0 i64) + (local $1 f64) + (local $2 i32) (local $3 i64) (local $4 v128) - (local $5 f64) - (local $6 f32) - (local $7 v128) - (local $8 f64) - (local $9 i64) - (local $10 f32) - (local $11 i32) - (local $12 f32) - (local $13 i32) - (local $14 v128) - (local $15 v128) - (local $16 f64) + (local $5 f32) (block (if (i32.eqz (global.get $hangLimit) ) - (return - (v128.const i32x4 0x80000000 0x80000001 0xffffffa1 0x00000000) - ) + (return) ) (global.set $hangLimit (i32.sub @@ -434,300 +274,193 @@ ) ) (block $label$0 - (local.set $8 - (f64.const 5382) + (br_if $label$0 + (i32.const 1376786182) ) - (if - (i32.eqz - (local.tee $11 - (loop $label$72 (result i32) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $15) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (i32.const -127) - ) - ) - ) - (block $label$19 - (block $label$20 - (loop $label$21 - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (v128.const i32x4 0x4598b000 0x4f000000 0x5f000000 0x4d30d0b0) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (nop) - ) - (local.set $11 - (local.tee $13 - (i32.const 3088) - ) - ) - ) - (return - (local.get $0) - ) - ) - (block $label$43 - (loop $label$44 - (block - (if + (local.set $4 + (v128.const i32x4 0x0e0a0e0d 0x0709060c 0x764b6f6f 0x00040000) + ) + (local.set $4 + (if (result v128) + (i32.eqz + (if (result i32) + (if (result i32) (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $4) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (block - (block $label$45 - (if - (i32.eqz - (i32.const 536870912) - ) - (local.set $11 - (local.get $13) - ) - (block $label$46 - (global.set $global$3 - (f32.const 269239296) - ) - (local.tee $16 - (local.tee $16 - (block $label$47 - (br $label$46) + (if (result i32) + (i32.eqz + (if + (i32.const 1329942351) + (local.tee $2 + (local.tee $2 + (loop $label$38 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (if + (i32.eqz + (local.get $2) + ) + (block $label$39 + (nop) + (br $label$0) + ) + (block $label$40 + (local.set $4 + (v128.const i32x4 0x05050505 0x46190000 0xc6800000 0x4a031a19) + ) + (br $label$0) + ) + ) + ) + ) + ) + (block $label$41 + (nop) + (br $label$0) ) ) ) + (local.get $2) + (local.get $2) + ) + ) + (block $label$47 + (local.set $2 + (local.get $2) ) + (br $label$0) ) - (loop $label$48 - (block - (if - (i32.eqz - (global.get $hangLimit) + (block $label$48 (result i32) + (loop $label$49 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) ) - (return - (local.get $4) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) ) ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) + (block + (local.set $5 + (f32.const 9.625223197211503e-38) ) - ) - ) - (block - (local.set $11 - (local.tee $13 - (i32.const 2097152) - ) - ) - (br_if $label$48 - (i32.eqz - (local.tee $11 - (loop $label$49 (result i32) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $0) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) + (br_if $label$49 + (if (result i32) + (block $label$57 + (local.set $5 + (local.tee $5 + (block $label$58 (result f32) + (local.set $4 + (local.get $4) + ) + (local.get $5) ) ) ) - (block (result i32) - (local.set $10 - (local.tee $12 - (local.tee $6 - (local.tee $12 - (local.get $12) - ) + (br $label$0) + ) + (if (result i32) + (i32.const 1376786182) + (block $label$60 + (if + (block $label$61 (result i32) + (i32.const 925442358) + ) + (block $label$62 + (br_if $label$62 + (i32.const 256) ) ) - ) - (br_if $label$49 - (i32.const 512) - ) - (loop $label$50 (result i32) - (block + (block $label$63 (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (v128.const i32x4 0x0000002a 0xf801141f 0xfe1c005c 0xf1f27f14) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) + (local.get $2) + (local.set $1 + (local.get $1) ) - ) - ) - (block $label$51 (result i32) - (local.set $11 - (if (result i32) - (i32.eqz - (if (result i32) - (if (result i32) - (if (result i32) - (i32.eqz - (i32.const 170) - ) - (i32.const 170) - (i32.const 16) - ) - (local.tee $11 - (local.get $13) - ) - (block $label$52 - (local.set $13 - (local.get $11) - ) - (br $label$44) - ) - ) - (block $label$53 - (loop $label$54 - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $14) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (block - (nop) - (br_if $label$54 - (i32.eqz - (local.get $13) - ) - ) - (local.set $2 - (i64.const 112) - ) - ) - ) - (br $label$49) + (block $label$67 + (if + (i32.eqz + (i32.const 0) + ) + (block $label$68 + (local.set $1 + (local.get $1) ) - (local.tee $11 - (local.tee $13 - (local.get $11) + (block $label$69 + (nop) + (local.set $4 + (local.get $4) ) ) ) - ) - (block $label$55 (result i32) - (br_if $label$48 - (local.tee $11 - (local.tee $13 - (local.get $13) + (if + (i32.eqz + (br_if $label$48 + (i32.const 32768) + (local.get $2) ) ) - ) - (br_if $label$51 - (local.tee $11 - (local.tee $13 - (i32.const -62) - ) + (local.set $4 + (v128.const i32x4 0xffffff81 0xffffffeb 0x80000000 0x74273131) ) - (if (result i32) - (i32.const 86) - (block $label$56 (result i32) - (br_if $label$56 - (local.get $13) - (i32.const -84) - ) - ) - (loop $label$57 (result i32) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $14) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (i32.const 34176355) - ) + (local.set $2 + (local.get $2) ) ) ) - (block $label$58 - (local.set $14 - (v128.const i32x4 0x0f0c0d04 0x0a020d43 0x1402026d 0x47130847) - ) - (br $label$49) + (local.set $0 + (i64.const -2097152) ) ) ) - (loop $label$59 + (local.set $1 + (local.get $1) + ) + ) + ) + (br $label$0) + ) + (block $label$70 (result i32) + (loop $label$71 (result i32) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block (result i32) + (loop $label$72 (block (if (i32.eqz (global.get $hangLimit) ) - (return - (v128.const i32x4 0x00000000 0x43e00000 0x00000000 0xc1f00000) - ) + (return) ) (global.set $hangLimit (i32.sub @@ -736,16 +469,21 @@ ) ) ) - (block $label$60 - (loop $label$61 + (local.set $4 + (local.tee $4 + (local.get $4) + ) + ) + ) + (br_if $label$71 + (i32.eqz + (loop $label$73 (block (if (i32.eqz (global.get $hangLimit) ) - (return - (v128.const i32x4 0x00007272 0x00000000 0x00000001 0x80000000) - ) + (return) ) (global.set $hangLimit (i32.sub @@ -754,97 +492,127 @@ ) ) ) - (block $label$62 - (local.set $3 - (i64.const -2048) - ) - (i64.store16 offset=3 align=1 - (i32.and - (local.tee $13 - (local.tee $13 - (local.tee $13 - (i32.const 64) - ) - ) - ) - (i32.const 15) - ) - (local.tee $9 - (loop $label$63 (result i64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (v128.const i32x4 0x80000000 0x1e1e141e 0x00008000 0x000e010b) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (block (result i64) - (local.set $9 - (local.get $3) - ) - (br_if $label$63 - (i32.const -256) - ) - (block $label$64 (result i64) - (local.set $16 - (f64.const 2147483648) - ) - (local.get $1) - ) - ) - ) - ) + (block $label$74 + (local.set $4 + (v128.const i32x4 0xf8f8ff00 0x000000a5 0x0000000e 0xffff00ff) ) + (br $label$73) ) ) - (return - (local.get $4) - ) ) ) + (i32.const -131072) + ) + ) + ) + ) + (if (result i32) + (local.get $2) + (block $label$75 + (call $log-i32 + (local.tee $2 + (i32.const 5) ) ) + (br $label$49) + ) + (block $label$76 (result i32) + (nop) + (local.tee $2 + (i32.const 1276448839) + ) ) ) ) ) + (local.set $2 + (local.get $2) + ) + ) + ) + (loop $label$90 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) ) - (local.tee $13 - (local.tee $11 - (block $label$65 - (local.set $16 - (f64.const 5.487989131676445e-139) + (block + (local.set $1 + (local.get $1) + ) + (br_if $label$90 + (i32.eqz + (local.tee $2 + (i32.const -93) ) - (br $label$44) ) ) + (nop) ) ) + (local.get $2) ) ) - (local.set $5 - (local.get $5) + (block $label$91 (result i32) + (local.set $5 + (block $label$92 (result f32) + (local.set $1 + (loop $label$19 (result f64) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block (result f64) + (nop) + (br_if $label$19 + (i32.eqz + (i32.const -129) + ) + ) + (local.tee $1 + (f64.const -nan:0xffffffffffff0) + ) + ) + ) + ) + (local.get $5) + ) + ) + (local.get $2) ) - (local.set $11 - (local.get $11) + (block $label$95 (result i32) + (local.get $2) ) ) ) - (unreachable) + (local.get $4) + (block $label$96 (result v128) + (v128.const i32x4 0x80800000 0xdf800000 0xcf000000 0x4f800000) + ) ) ) ) ) - (func $hangLimitInitializer (; 11 ;) + (func $hangLimitInitializer (; 6 ;) (global.set $hangLimit (i32.const 10) ) diff --git a/test/passes/translate-to-fuzz_all-features.wast b/test/passes/translate-to-fuzz_all-features.wast index 5b378f2b2..ae1761899 100644 --- a/test/passes/translate-to-fuzz_all-features.wast +++ b/test/passes/translate-to-fuzz_all-features.wast @@ -1,4 +1,4 @@ -(module # fake module here, for test harness, but it's really not needed +(module # fake module here, for test harness, but it is really not needed .. any 3INPUT diff --git a/test/passes/translate-to-fuzz_no-fuzz-nans_all-features.txt b/test/passes/translate-to-fuzz_no-fuzz-nans_all-features.txt index 294b4f986..57afb02b7 100644 --- a/test/passes/translate-to-fuzz_no-fuzz-nans_all-features.txt +++ b/test/passes/translate-to-fuzz_no-fuzz-nans_all-features.txt @@ -1,35 +1,24 @@ (module (type $FUNCSIG$i (func (result i32))) + (type $FUNCSIG$vifidi (func (param i32 f32 i32 f64 i32))) (type $FUNCSIG$vi (func (param i32))) (type $FUNCSIG$vj (func (param i64))) (type $FUNCSIG$vf (func (param f32))) (type $FUNCSIG$vd (func (param f64))) - (type $FUNCSIG$vjVdddV (func (param i64 v128 f64 f64 f64 v128))) - (type $FUNCSIG$ddVff (func (param f64 v128 f32 f32) (result f64))) - (type $FUNCSIG$VdVjf (func (param f64 v128 i64 f32) (result v128))) - (type $FUNCSIG$v (func)) - (type $FUNCSIG$jjiV (func (param i64 i32 v128) (result i64))) - (type $FUNCSIG$VVjj (func (param v128 i64 i64) (result v128))) (import "fuzzing-support" "log-i32" (func $log-i32 (param i32))) (import "fuzzing-support" "log-i64" (func $log-i64 (param i64))) (import "fuzzing-support" "log-f32" (func $log-f32 (param f32))) (import "fuzzing-support" "log-f64" (func $log-f64 (param f64))) - (memory $0 1 1) + (memory $0 (shared 1 1)) (data (i32.const 0) "N\0fN\f5\f9\b1\ff\fa\eb\e5\fe\a7\ec\fb\fc\f4\a6\e4\ea\f0\ae\e3") - (table $0 8 8 funcref) - (elem (i32.const 0) $func_6 $func_6 $func_6 $func_6 $func_9 $func_9 $func_9 $func_9) - (global $global$0 (mut i32) (i32.const 975664160)) - (global $global$1 (mut i32) (i32.const -536870912)) - (global $global$2 (mut f32) (f32.const 2147483648)) - (global $global$3 (mut f32) (f32.const 1448959360)) + (table $0 0 funcref) + (global $global$0 (mut i32) (i32.const 975663930)) + (global $global$1 (mut i32) (i32.const 2066300474)) + (global $global$2 (mut i64) (i64.const 20510)) + (global $global$3 (mut f32) (f32.const -2147483648)) (global $hangLimit (mut i32) (i32.const 10)) + (event $event$0 (attr 0) (param i32 f32 i32 f64 i32)) (export "hashMemory" (func $hashMemory)) - (export "func_5" (func $func_5)) - (export "func_6" (func $func_6)) - (export "func_7" (func $func_7)) - (export "func_7_invoker" (func $func_7_invoker)) - (export "func_9" (func $func_9)) - (export "func_10" (func $func_10)) (export "hangLimitInitializer" (func $hangLimitInitializer)) (func $hashMemory (; 4 ;) (type $FUNCSIG$i) (result i32) (local $0 i32) @@ -262,7 +251,12 @@ ) (local.get $0) ) - (func $func_5 (; 5 ;) (type $FUNCSIG$vjVdddV) (param $0 i64) (param $1 v128) (param $2 f64) (param $3 f64) (param $4 f64) (param $5 v128) + (func $func_5 (; 5 ;) (param $0 i64) + (local $1 f64) + (local $2 i32) + (local $3 i64) + (local $4 v128) + (local $5 f32) (block (if (i32.eqz @@ -278,173 +272,612 @@ ) ) (block $label$0 - (call $log-f64 - (loop $label$1 (result f64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) + (br_if $label$0 + (i32.eqz + (local.tee $2 + (local.tee $2 + (local.tee $2 + (local.tee $2 + (local.get $2) + ) ) ) ) - (block $label$2 (result f64) - (call $log-i32 - (call $hashMemory) - ) - (local.get $2) - ) - ) - ) - (call $log-i32 - (call $hashMemory) - ) - ) - ) - (func $func_6 (; 6 ;) (type $FUNCSIG$ddVff) (param $0 f64) (param $1 v128) (param $2 f32) (param $3 f32) (result f64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $0) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (block $label$0 (result f64) - (call $log-i32 - (i32.const 84215045) - ) - (f64.const 8) - ) - ) - (func $func_7 (; 7 ;) (type $FUNCSIG$VdVjf) (param $0 f64) (param $1 v128) (param $2 i64) (param $3 f32) (result v128) - (local $4 i32) - (local $5 f64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $1) ) ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (local.tee $1 - (local.tee $1 - (v128.const i32x4 0x6d484708 0x13e740fc 0x5849037f 0xe4000000) - ) - ) - ) - (func $func_7_invoker (; 8 ;) (type $FUNCSIG$v) - (drop - (call $func_7 - (f64.const 16986) - (v128.const i32x4 0x00000000 0x00000010 0xffffe000 0xffffffff) - (i64.const -12) - (f32.const 7243) - ) - ) - (drop - (call $func_7 - (f64.const -65536) - (v128.const i32x4 0x00007d1f 0x00000200 0xffff0000 0x7fffffff) - (i64.const 288230376151711744) - (f32.const 128) - ) - ) - (call $log-i32 - (call $hashMemory) - ) - (drop - (call $func_7 - (f64.const 0) - (v128.const i32x4 0x00000000 0x403a0000 0x00000000 0xb8100000) - (i64.const 66) - (f32.const 0) - ) - ) - ) - (func $func_9 (; 9 ;) (type $FUNCSIG$jjiV) (param $0 i64) (param $1 i32) (param $2 v128) (result i64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $0) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) - ) - ) - ) - (i64.const 8) - ) - (func $func_10 (; 10 ;) (type $FUNCSIG$VVjj) (param $0 v128) (param $1 i64) (param $2 i64) (result v128) - (local $3 i64) - (local $4 v128) - (local $5 f64) - (local $6 f32) - (local $7 v128) - (local $8 f64) - (local $9 i64) - (local $10 f32) - (local $11 i32) - (local $12 f32) - (local $13 i32) - (local $14 v128) - (local $15 v128) - (local $16 f64) - (block - (if - (i32.eqz - (global.get $hangLimit) - ) - (return - (local.get $14) - ) - ) - (global.set $hangLimit - (i32.sub - (global.get $hangLimit) - (i32.const 1) + (local.set $4 + (v128.const i32x4 0x0e0a0e0d 0x0709060c 0x764b6f6f 0x00040000) + ) + (local.set $4 + (if (result v128) + (i32.eqz + (if (result i32) + (if (result i32) + (i32.eqz + (if (result i32) + (i32.eqz + (if + (i32.eqz + (if (result i32) + (i32.eqz + (if (result i32) + (i32.eqz + (if (result i32) + (local.get $2) + (loop $label$1 (result i32) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block (result i32) + (block $label$2 + (local.set $3 + (i64.const 15662) + ) + (local.set $2 + (local.get $2) + ) + ) + (br_if $label$1 + (local.get $2) + ) + (if (result i32) + (i32.eqz + (local.get $2) + ) + (local.get $2) + (local.get $2) + ) + ) + ) + (block $label$3 (result i32) + (local.tee $2 + (i32.const 286267661) + ) + ) + ) + ) + (block $label$4 + (loop $label$5 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block + (block $label$6 + (if + (i32.eqz + (loop $label$7 (result i32) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (i32.const 6506) + ) + ) + (block $label$8 + (local.set $2 + (local.tee $2 + (local.get $2) + ) + ) + (local.set $5 + (local.get $5) + ) + ) + (block $label$9 + (if + (local.tee $2 + (if (result i32) + (local.get $2) + (local.get $2) + (loop $label$10 (result i32) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block (result i32) + (nop) + (br_if $label$10 + (i32.eqz + (i32.const 64) + ) + ) + (local.tee $2 + (loop $label$11 (result i32) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (i32.const 512) + ) + ) + ) + ) + ) + ) + (local.set $3 + (local.get $3) + ) + (loop $label$12 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (local.set $1 + (local.get $1) + ) + ) + ) + (local.set $2 + (i32.const 170) + ) + ) + ) + (call $log-i32 + (local.get $2) + ) + ) + (br_if $label$5 + (i32.eqz + (i32.const 2376257) + ) + ) + (local.set $4 + (local.tee $4 + (v128.const i32x4 0xfff70000 0x007f700e 0x07420400 0x8000007f) + ) + ) + ) + ) + (block $label$13 + (if + (i32.eqz + (block $label$14 (result i32) + (local.set $4 + (v128.const i32x4 0x80000000 0x00000080 0xfffffffc 0x00007fff) + ) + (i32.const -123) + ) + ) + (local.set $1 + (local.get $1) + ) + (local.set $5 + (local.get $5) + ) + ) + (br $label$0) + ) + ) + (block $label$17 (result i32) + (i64.atomic.store offset=3 + (i32.const 640629291) + (local.tee $0 + (i64.const -16) + ) + ) + (if (result i32) + (block $label$18 + (local.set $1 + (loop $label$19 (result f64) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block (result f64) + (nop) + (br_if $label$19 + (i32.eqz + (local.get $2) + ) + ) + (local.tee $1 + (f64.const 0) + ) + ) + ) + ) + (return) + ) + (local.tee $2 + (local.get $2) + ) + (block $label$20 + (loop $label$21 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (local.set $1 + (local.get $1) + ) + ) + (return) + ) + ) + ) + ) + ) + (block $label$22 (result i32) + (local.set $5 + (f32.const 10160664) + ) + (if (result i32) + (i32.eqz + (i32.const 0) + ) + (block $label$23 + (local.set $1 + (loop $label$24 (result f64) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block (result f64) + (local.set $3 + (local.get $0) + ) + (br_if $label$24 + (i32.const -9) + ) + (f64.const -18446744073709551615) + ) + ) + ) + (br $label$0) + ) + (block $label$25 (result i32) + (loop $label$26 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block + (local.set $2 + (local.get $2) + ) + (br_if $label$26 + (i32.eqz + (if (result i32) + (br_if $label$25 + (i32.const -8) + (local.get $2) + ) + (local.get $2) + (block $label$29 (result i32) + (call $log-i32 + (call $hashMemory) + ) + (loop $label$30 (result i32) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (local.get $2) + ) + ) + ) + ) + ) + (local.set $5 + (local.get $5) + ) + ) + ) + (local.get $2) + ) + ) + ) + (block $label$35 + (local.set $1 + (f64.const 1414944843) + ) + (br $label$0) + ) + ) + ) + (local.tee $2 + (local.tee $2 + (loop $label$38 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (if + (i32.eqz + (local.get $2) + ) + (block $label$39 + (nop) + (br $label$0) + ) + (block $label$40 + (local.set $1 + (local.get $1) + ) + (br $label$0) + ) + ) + ) + ) + ) + (block $label$41 + (memory.copy + (loop $label$42 (result i32) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (if (result i32) + (loop $label$43 (result i32) + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block $label$44 (result i32) + (local.set $3 + (i64.const 2097574720517510216) + ) + (if (result i32) + (i32.eqz + (local.get $2) + ) + (i32.const 1296450369) + (local.tee $2 + (i32.const -14) + ) + ) + ) + ) + (block $label$45 + (local.set $2 + (i32.const 235407412) + ) + (br $label$0) + ) + (block $label$46 (result i32) + (local.set $2 + (local.tee $2 + (local.tee $2 + (local.tee $2 + (i32.const 1179009606) + ) + ) + ) + ) + (i32.const 1073741824) + ) + ) + ) + (local.get $2) + (i32.const 1073741824) + ) + (return) + ) + ) + ) + (local.get $2) + (local.get $2) + ) + ) + (block $label$47 + (local.set $2 + (local.get $2) + ) + (br $label$0) + ) + (block $label$48 (result i32) + (loop $label$49 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (local.set $5 + (local.get $5) + ) + ) + (loop $label$90 + (block + (if + (i32.eqz + (global.get $hangLimit) + ) + (return) + ) + (global.set $hangLimit + (i32.sub + (global.get $hangLimit) + (i32.const 1) + ) + ) + ) + (block + (local.set $1 + (local.get $1) + ) + (local.set $2 + (local.get $2) + ) + (nop) + ) + ) + (local.get $2) + ) + ) + (block $label$91 (result i32) + (local.set $5 + (block $label$92 (result f32) + (f32.const 6) + ) + ) + (local.get $2) + ) + (local.get $2) + ) + ) + (v128.const i32x4 0xffffffc0 0x00001f16 0x00008000 0x505c1a13) + (v128.const i32x4 0xc7007b11 0x721d0901 0x01810043 0x441f1201) ) ) ) - (return - (local.get $14) - ) ) - (func $hangLimitInitializer (; 11 ;) + (func $hangLimitInitializer (; 6 ;) (global.set $hangLimit (i32.const 10) ) ) - (func $deNan32 (; 12 ;) (param $0 f32) (result f32) + (func $deNan32 (; 7 ;) (param $0 f32) (result f32) (if (result f32) (f32.eq (local.get $0) @@ -454,7 +887,7 @@ (f32.const 0) ) ) - (func $deNan64 (; 13 ;) (param $0 f64) (result f64) + (func $deNan64 (; 8 ;) (param $0 f64) (result f64) (if (result f64) (f64.eq (local.get $0) diff --git a/test/passes/translate-to-fuzz_no-fuzz-nans_all-features.wast b/test/passes/translate-to-fuzz_no-fuzz-nans_all-features.wast index cbf25fde1..3dab8874e 100644 --- a/test/passes/translate-to-fuzz_no-fuzz-nans_all-features.wast +++ b/test/passes/translate-to-fuzz_no-fuzz-nans_all-features.wast @@ -1,4 +1,4 @@ -(module # fake module here, for test harness, but it's really not needed +(module # fake module here, for test harness, but it is really not needed .. any 3INPUT diff --git a/test/spec/events.wast b/test/spec/events.wast new file mode 100644 index 000000000..80a6b11fe --- /dev/null +++ b/test/spec/events.wast @@ -0,0 +1,43 @@ +;; Test events + +(module + (event (attr 0) (param i32)) + (event $e (attr 0) (param i32 f32)) + + (event $e-params0 (attr 0) (param i32 f32)) + (event $e-params1 (attr 0) (param i32) (param f32)) + + (event $e-export (export "ex0") (attr 0) (param i32)) + (event $e-import (import "env" "im0") (attr 0) (param i32)) + + (import "env" "im1" (event (attr 0) (param i32 f32))) + (export "ex1" (event $e)) +) + +(assert_invalid + (module (event $e (attr 0) (param i32) (result i32))) + "Event type's result type should be none" +) + +(assert_invalid + (module (event $e (attr 0))) + "There should be 1 or more values in an event type" +) + +(assert_invalid + (module (event $e (attr 1) (param i32))) + "Currently only attribute 0 is supported" +) + +(assert_invalid + (module (event $e (attr 0) (param except_ref))) + "Values in an event should have integer or float type" +) + +(assert_invalid + (module + (type $t (param i32)) + (event $e (attr 0) (type $t) (param i32 f32)) + "type and param don't match" + ) +) |