├── binaryen ├── test │ ├── revision │ ├── unit │ │ ├── __init__.py │ │ └── input │ │ │ ├── empty.wasm │ │ │ ├── random_data.txt │ │ │ ├── dwarf │ │ │ ├── zlib.wasm │ │ │ └── cubescript.wasm │ │ │ ├── bulkmem_data.wasm │ │ │ ├── gc_target_feature.wasm │ │ │ ├── simd_target_feature.wasm │ │ │ ├── atomics_target_feature.wasm │ │ │ ├── bulkmem_bad_datacount.wasm │ │ │ ├── bulkmem_target_feature.wasm │ │ │ ├── signext_target_feature.wasm │ │ │ ├── truncsat_target_feature.wasm │ │ │ ├── exception_handling_target_feature.wasm │ │ │ ├── tail_call_target_feature.wasm │ │ │ ├── mutable_globals_target_feature.wasm │ │ │ ├── reference_types_target_feature.wasm │ │ │ ├── asyncify-pure.txt │ │ │ ├── hello_world.wat │ │ │ ├── empty_lld.wat │ │ │ ├── stack_ir.wat │ │ │ ├── em_asm_mangled_string.wat │ │ │ └── asyncify-stackOverflow.wat │ ├── fannkuch.args │ ├── fasta.args │ ├── example │ │ ├── hash.txt │ │ ├── cpp-unit.txt │ │ ├── small_vector.txt │ │ ├── space.txt │ │ ├── c-api-relooper-unreachable-if.txt │ │ ├── cpp-threads.txt │ │ ├── c-api-hello-world.txt │ │ ├── stack-utils.txt │ │ └── match.txt │ ├── binaryen.js │ │ ├── copy-expression.js.txt │ │ ├── pass-arguments.js.txt │ │ ├── tail_calls.js.txt │ │ ├── fast-math.js.txt │ │ ├── simd.js.txt │ │ ├── custom-section.js.txt │ │ ├── fast-math.js │ │ ├── inlining-options.js.txt │ │ ├── expressionrunner.js.txt │ │ ├── custom-section.js │ │ ├── simd.js │ │ ├── validation_errors.js.txt │ │ ├── sourcemap.js.txt │ │ ├── emit_asmjs.js │ │ ├── reloc.js.txt │ │ ├── sideffects.js.txt │ │ ├── pass-arguments.js │ │ ├── functions.js.txt │ │ ├── global.js.txt │ │ └── event.js.txt │ ├── linker │ │ ├── quux.c │ │ ├── baz.c │ │ ├── foo.c │ │ ├── bar.c │ │ └── main.c │ ├── calls.emcc │ ├── hello_libcxx.txt │ ├── hello_world.txt │ ├── int_ops.emcc │ ├── mem.emcc │ ├── metadce │ │ ├── all-outside.wast │ │ ├── spanning_cycle.wast.dced.stdout │ │ ├── threaded_cycle.wast.dced.stdout │ │ ├── all-outside.wast.dced │ │ ├── no-outside.wast.dced │ │ ├── threaded_unrooted.wast.dced │ │ ├── no-outside.wast.graph.txt │ │ ├── spanning_cycle_unrooted.wast.dced │ │ ├── threaded_unrooted_cycle.wast.dced │ │ ├── threaded.wast.dced.stdout │ │ ├── corners.wast.dced.stdout │ │ ├── all-outside.wast.dced.stdout │ │ ├── spanning_cycle_unrooted.wast.dced.stdout │ │ ├── rooted-export.wast.dced.stdout │ │ ├── no-outside.wast.dced.stdout │ │ ├── spanning_cycle_unrooted.wast │ │ ├── outside.wast.graph.txt │ │ ├── outside.wast.dced.stdout │ │ ├── spanning_cycle_unrooted.wast.graph.txt │ │ ├── rooted-export.wast.graph.txt │ │ ├── rooted-export.wast.dced │ │ ├── corners.wast.graph.txt │ │ ├── no-outside.wast │ │ ├── spanning_cycle.wast.graph.txt │ │ ├── spanning_cycle.wast.dced │ │ ├── threaded_unrooted.wast.dced.stdout │ │ ├── threaded_unrooted_cycle.wast.dced.stdout │ │ ├── spanning_cycle.wast │ │ └── rooted-export.wast │ ├── control_flow.emcc │ ├── ctor-eval │ │ ├── imported3.wast.ctors │ │ ├── no_partial.wast.ctors │ │ ├── unsafe_call.wast.ctors │ │ ├── unsafe_store.wast.ctors │ │ ├── unsafe_store2.wast.ctors │ │ ├── unsafe_store3.wast.ctors │ │ ├── bad-indirect-call.wast.ctors │ │ ├── bad-indirect-call2.wast.ctors │ │ ├── basics.wast.ctors │ │ ├── imported-min.wast.out │ │ ├── imported.wast.out │ │ ├── indirect-call3.wast.ctors │ │ ├── unsafe_store.wast.out │ │ ├── imported.wast.ctors │ │ ├── imported2.wast.ctors │ │ ├── just_some.wast.ctors │ │ ├── stack-direction.wast.out │ │ ├── unsafe_store2.wast.out │ │ ├── unsafe_store3.wast.out │ │ ├── bad-indirect-call3.wast.ctors │ │ ├── basics-flatten.wast.ctors │ │ ├── imported-min.wast.ctors │ │ ├── stack-direction.wast.ctors │ │ ├── unsafe_store.wast │ │ ├── unsafe_store2.wast │ │ ├── unsafe_store3.wast │ │ ├── basics.wast.out │ │ ├── imported3.wast.out │ │ ├── basics-flatten.wast.out │ │ ├── no_partial.wast.out │ │ ├── just_some.wast.out │ │ ├── indirect-call3.wast.out │ │ ├── no_partial.wast │ │ ├── imported3.wast │ │ ├── unsafe_call.wast │ │ ├── bad-indirect-call.wast │ │ ├── imported2.wast.out │ │ ├── unsafe_call.wast.out │ │ ├── bad-indirect-call2.wast │ │ ├── bad-indirect-call3.wast │ │ ├── bad-indirect-call.wast.out │ │ └── indirect-call3.wast │ ├── float_ops.emcc │ ├── lld │ │ ├── hello_world.wat.mem.mem │ │ ├── em_asm.wat.mem.mem │ │ ├── hello_world.c │ │ ├── shared_add_to_table.wasm │ │ ├── em_asm.cpp │ │ ├── em_asm64.cpp │ │ ├── em_asm_shared.cpp │ │ ├── init.c │ │ ├── em_asm_O0.c │ │ ├── shared.cpp │ │ ├── shared_longjmp.c │ │ ├── longjmp.c │ │ ├── main_module_table.wat │ │ ├── main_module_table_2.wat │ │ ├── recursive.c │ │ ├── main_module_table_3.wat │ │ ├── standalone-wasm3.wat │ │ ├── main_module_table_4.wat │ │ ├── standalone-wasm-with-start.wat │ │ ├── main_module_table_5.wat │ │ ├── em_asm_table.wat │ │ └── standalone-wasm2.wat │ ├── passes │ │ ├── multi_unit_abbrev_noprint.bin.txt │ │ ├── dwarf_unit_with_no_abbrevs_noprint.bin.txt │ │ ├── dealign64.passes │ │ ├── safe-heap_start-function.passes │ │ ├── class_with_dwarf_noprint.passes │ │ ├── dwarf_unit_with_no_abbrevs_noprint.passes │ │ ├── fib2_dwarf.passes │ │ ├── fuzz_metrics_noprint.passes │ │ ├── inlined_to_start_dwarf.passes │ │ ├── reverse_dwarf_abbrevs.passes │ │ ├── fannkuch0_dwarf.passes │ │ ├── fannkuch3_dwarf.passes │ │ ├── remove-memory.txt │ │ ├── alignment-lowering64.passes │ │ ├── avoid-reinterprets64.passes │ │ ├── fib2_emptylocspan_dwarf.passes │ │ ├── instrument-memory64.passes │ │ ├── fannkuch3_manyopts_dwarf.passes │ │ ├── multi_unit_abbrev_noprint.passes │ │ ├── strip-target-features.wasm │ │ ├── ignore_missing_func_dwarf.passes │ │ ├── dwarf-local-order.passes │ │ ├── multi_line_table_dwarf.passes │ │ ├── too_much_for_liveness.passes │ │ ├── O.wasm │ │ ├── fib_nonzero-low-pc_dwarf.passes │ │ ├── strip-target-features.bin.txt │ │ ├── print.wasm │ │ ├── safe-heap_enable-threads_enable-simd64.passes │ │ ├── dwarfdump.wasm │ │ ├── flatten.wasm │ │ ├── print_g.wasm │ │ ├── fib2_dwarf.wasm │ │ ├── strip-debug.wasm │ │ ├── strip-dwarf.wasm │ │ ├── fannkuch0_dwarf.wasm │ │ ├── fannkuch3_dwarf.wasm │ │ ├── print-function-map.wast │ │ ├── print_g_metrics.wasm │ │ ├── remove-memory.wast │ │ ├── strip-producers.wasm │ │ ├── converge_O3_metrics.wasm │ │ ├── dwarf-local-order.wasm │ │ ├── print_g_strip-dwarf.wasm │ │ ├── fuzz_metrics_noprint.wasm │ │ ├── reverse_dwarf_abbrevs.wasm │ │ ├── too_much_for_liveness.wasm │ │ ├── class_with_dwarf_noprint.wasm │ │ ├── fannkuch3_manyopts_dwarf.wasm │ │ ├── fib2_emptylocspan_dwarf.wasm │ │ ├── fib_nonzero-low-pc_dwarf.wasm │ │ ├── inlined_to_start_dwarf.wasm │ │ ├── multi_line_table_dwarf.wasm │ │ ├── ignore_missing_func_dwarf.wasm │ │ ├── multi_unit_abbrev_noprint.wasm │ │ ├── dwarfdump_roundtrip_dwarfdump.wasm │ │ ├── memory-packing_all-features_zero-filled-memory.txt │ │ ├── metrics_strip-debug_metrics.wasm │ │ ├── roundtrip_signed.passes │ │ ├── dce_vacuum_remove-unused-names.wasm │ │ ├── metrics_strip-producers_metrics.wasm │ │ ├── dwarf_unit_with_no_abbrevs_noprint.wasm │ │ ├── interesting-pass-mix.passes │ │ ├── roundtrip_signed.wasm │ │ ├── legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast │ │ ├── roundtrip.txt │ │ ├── extract-function_pass-arg=extract@foo.wast │ │ ├── precompute_coalesce-locals_vacuum.txt │ │ ├── print-function-map.txt │ │ ├── generate-i64-dyncalls.wast │ │ ├── extract-function_pass-arg=extract@foo.txt │ │ ├── O1.txt │ │ ├── memory-packing_all-features_zero-filled-memory.wast │ │ ├── O_all-features_ignore-implicit-traps.txt │ │ ├── reorder-functions.txt │ │ ├── merge-blocks_remove-unused-brs.wast │ │ ├── vacuum_remove-unused-names_merge-blocks.txt │ │ ├── roundtrip.wast │ │ ├── generate-dyncalls.wast │ │ ├── reorder-functions.wast │ │ ├── merge-blocks_remove-unused-brs.txt │ │ ├── O_all-features.txt │ │ ├── safe-heap_start-function.wast │ │ ├── minify-imports-and-exports-and-modules.wast │ │ ├── untee.wast │ │ ├── vacuum_ignore-implicit-traps.txt │ │ ├── duplicate-import-elimination.wast │ │ ├── remove-unused-brs_precompute_vacuum_remove-unused-brs.txt │ │ ├── asyncify_pass-arg=asyncify-blacklist@foo,bar.wast │ │ ├── asyncify_pass-arg=asyncify-verbose.wast │ │ ├── dealign.wast │ │ ├── asyncify_pass-arg=asyncify-addlist@foo.wast │ │ ├── dealign64.wast │ │ ├── safe-heap_disable-simd.wast │ │ ├── souperify.wast │ │ ├── strip-debug.bin.txt │ │ ├── simplify-locals.txt │ │ ├── duplicate-import-elimination.txt │ │ ├── strip-target-features_roundtrip_print-features_all-features.wast │ │ ├── fpcast-emu_pass-arg=max-func-params@5.wast │ │ ├── minify-imports-and-exports-and-modules.txt │ │ ├── emit-spec-wrapper=a.wat.wast.wat │ │ ├── O_all-features.wast │ │ ├── asyncify_pass-arg=asyncify-onlylist@foo,bar.wast │ │ ├── souperify.txt │ │ ├── O3_inlining.txt │ │ ├── remove-unused-brs_generate-stack-ir_print-stack-ir.wast │ │ ├── precompute_coalesce-locals_vacuum.wast │ │ ├── legalize-js-interface-minimally.wast │ │ ├── remove-imports.txt │ │ ├── duplicate-function-elimination_all-features.txt │ │ ├── O1_print-stack-ir.wast │ │ ├── O2_print-stack-ir.wast │ │ ├── O3_print-stack-ir.wast │ │ ├── remove-unused-names_precompute.txt │ │ ├── pick-load-signs_all-features.wast │ │ ├── O1.wast │ │ ├── Os_print-stack-ir_all-features.wast │ │ ├── generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast │ │ ├── simplify-globals_all-features_fuzz-exec.wast │ │ ├── pick-load-signs_all-features.txt │ │ ├── roundtrip_signed.bin.txt │ │ ├── stack-check_enable-mutable-globals.wast │ │ ├── O_all-features_ignore-implicit-traps.wast │ │ ├── remove-unused-names_precompute.wast │ │ ├── dealign.txt │ │ └── remove-unused-brs_precompute_vacuum_remove-unused-brs.wast │ ├── br_to_exit.wasm │ ├── elided-br.wasm │ ├── grow_memory.emcc │ ├── spec │ │ ├── expected-output │ │ │ ├── func_ptrs.wast.log │ │ │ ├── names.wast.log │ │ │ ├── old_start.wast.log │ │ │ └── old_imports.wast.log │ │ ├── inline-module.wast │ │ ├── func-local-after-body.fail.wast │ │ ├── func-param-after-body.fail.wast │ │ ├── func-result-after-body.fail.wast │ │ ├── import-after-func.fail.wast │ │ ├── func-local-before-param.fail.wast │ │ ├── of_string-overflow-s32.fail.wast │ │ ├── of_string-overflow-u32.fail.wast │ │ ├── import-after-memory.fail.wast │ │ ├── import-after-table.fail.wast │ │ ├── of_string-overflow-hex-u32.fail.wast │ │ ├── import-after-global.fail.wast │ │ ├── of_string-overflow-hex-u64.fail.wast │ │ ├── of_string-overflow-s64.fail.wast │ │ ├── of_string-overflow-u64.fail.wast │ │ ├── func-local-before-result.fail.wast │ │ ├── func-result-before-param.fail.wast │ │ ├── f32.load32.fail.wast │ │ ├── f32.load64.fail.wast │ │ ├── f64.load32.fail.wast │ │ ├── f64.load64.fail.wast │ │ ├── i32.load32_s.fail.wast │ │ ├── i32.load32_u.fail.wast │ │ ├── i32.load64_s.fail.wast │ │ ├── i32.load64_u.fail.wast │ │ ├── i64.load64_s.fail.wast │ │ ├── i64.load64_u.fail.wast │ │ ├── f32.store32.fail.wast │ │ ├── f32.store64.fail.wast │ │ ├── f64.store32.fail.wast │ │ ├── f64.store64.fail.wast │ │ ├── i32.store32.fail.wast │ │ ├── i32.store64.fail.wast │ │ ├── i64.store64.fail.wast │ │ ├── address-offset-range.fail.wast │ │ ├── atomics.wast │ │ ├── token.wast │ │ ├── break-drop.wast │ │ ├── ref_null.wast │ │ ├── Contributing.md │ │ ├── ref_is_null.wast │ │ └── call_indirect_sig_mismatch.wast │ ├── unreachable-pops.wasm │ ├── break-within-catch.wasm │ ├── consume-stacky.wasm │ ├── fn_prolog_epilog.debugInfo.wasm │ ├── memory-shared.wast │ ├── print │ │ ├── memory-shared.minified.txt │ │ ├── memory-shared.txt │ │ ├── memory-shared.wast │ │ ├── memory-import-shared.minified.txt │ │ ├── memory-import-shared.txt │ │ └── memory-import-shared.wast │ ├── lit │ │ ├── CMakeLists.txt │ │ ├── parse-error.wast │ │ ├── wasm-split │ │ │ ├── export-name-already-exists.wast │ │ │ ├── instrument-memory-too-small.wast │ │ │ ├── verbose.wast │ │ │ ├── initial-table.wast │ │ │ └── name-collision.wast │ │ ├── lit.site.cfg.py.in │ │ └── validation │ │ │ └── shared-memory.wast │ ├── memory-shared.wast.from-wast │ ├── mutable-global.wasm │ ├── validator │ │ ├── invalid_import.wast │ │ ├── invalid_return.wast │ │ ├── invalid_export.wast │ │ └── invalid_number.wast │ ├── empty_table.wast │ ├── duplicated_names.wasm │ ├── memory-shared.wast.fromBinary │ ├── dylib.wasm │ ├── empty_table.wast.from-wast │ ├── stacky.wasm │ ├── empty_table.wast.fromBinary │ ├── fib-dbg.wasm │ ├── memory-shared.wast.fromBinary.noDebugInfo │ ├── wasm2js │ │ ├── base64.wast │ │ ├── empty_export.wast │ │ ├── dot_import.wast │ │ ├── atomic_fence.wast │ │ ├── minified-memory.wast │ │ ├── start_func.wast │ │ ├── emscripten-grow-no.wast │ │ ├── emscripten-grow-yes.wast │ │ ├── sign_ext.wast │ │ ├── i64-ctz.wast │ │ ├── global_i64.wast │ │ ├── add_div.wast │ │ ├── br_table_to_loop.wast │ │ ├── deterministic.wast │ │ ├── unreachable-insts.wast │ │ ├── excess_fallthrough.wast │ │ ├── minus_minus.wast │ │ ├── nested-selects.wast │ │ ├── reinterpret_scratch.wast │ │ ├── if_unreachable.wast │ │ └── func-ptr-offset.wast │ ├── duplicated_names_collision.wasm │ ├── metadatas.wasm │ ├── complexBinaryNames.wasm │ ├── crash │ │ ├── outside.wasm │ │ ├── use_var_outside_func.wasm │ │ └── expression-past-end-of-input.wasm │ ├── empty_table.wast.fromBinary.noDebugInfo │ ├── break-to-return.wasm │ ├── empty_imported_table.wast │ ├── fib-dbg.wasm.map │ ├── hello_world.c │ ├── bigswitch.txt │ ├── complexTextNames.wast │ ├── fn_prolog_epilog.debugInfo.wasm.map │ ├── empty_imported_table.wast.from-wast │ ├── fasta.txt │ ├── empty_imported_table.wast.fromBinary │ ├── hello_libcxx.cpp │ ├── imported_memory.wast │ ├── imported_memory_growth.wast │ ├── empty_imported_table.wast.fromBinary.noDebugInfo │ ├── imported_memory_growth.wast.from-wast │ ├── br_to_exit.wasm.fromBinary │ ├── elided-br.wasm.fromBinary │ ├── imported_memory.wast.from-wast │ ├── extended-names.wast.fromBinary.noDebugInfo │ ├── imported_memory.wast.fromBinary │ ├── imported_memory_growth.wast.fromBinary │ ├── segment-overlap.wast.from-wast │ ├── unreachable-instr-type.wast.fromBinary │ ├── extended-names.wast │ ├── segment-overlap.wast.fromBinary │ ├── extended-names.wast.from-wast │ ├── printf.txt │ ├── reduce │ │ ├── imports.wast.txt │ │ ├── simple.wast.txt │ │ ├── destructive.wast.txt │ │ ├── simple.wast │ │ ├── destructive.wast │ │ ├── imports.wast │ │ └── memory_table.wast.txt │ ├── unreachable-instr-type.wast.fromBinary.noDebugInfo │ ├── extended-names.wast.fromBinary │ ├── segment-overlap.wast.fromBinary.noDebugInfo │ ├── imported_memory.wast.fromBinary.noDebugInfo │ ├── imported_memory_growth.wast.fromBinary.noDebugInfo │ ├── segment-overlap.wast │ ├── atomics-unshared.wast │ ├── unreachable-pops.wasm.fromBinary │ ├── table-import.wast │ ├── complexTextNames.wast.fromBinary.noDebugInfo │ ├── export-import.wast │ ├── complexTextNames.wast.from-wast │ ├── table-import.wast.from-wast │ ├── complexTextNames.wast.fromBinary │ ├── memory-import.wast │ ├── memory-import.wast.from-wast │ ├── table-import.wast.fromBinary │ ├── complexBinaryNames.wasm.fromBinary │ ├── export-import.wast.from-wast │ ├── fn_prolog_epilog.debugInfo.wast.fromBinary │ ├── memory-import64.wast.from-wast │ ├── export-import.wast.fromBinary │ ├── memory-import.wast.fromBinary │ ├── memory-import64.wast │ ├── table-import.wast.fromBinary.noDebugInfo │ ├── tail-call.wast │ ├── memory-import64.wast.fromBinary │ ├── memory-import64.wast.wasm.fromBinary │ ├── metadatas.wasm.fromBinary │ ├── reg_switch.wast.from-wast │ ├── fn_prolog_epilog.debugInfo.wast.fromBinary.noDebugInfo │ ├── memory-import.wast.fromBinary.noDebugInfo │ ├── atomics-unshared.wast.from-wast │ ├── memory-import64.wast.fromBinary.noDebugInfo │ ├── reg_switch.wast │ ├── reg_switch.wast.fromBinary │ ├── atomics-unshared.wast.fromBinary │ ├── duplicate_types.wast.from-wast │ ├── export-import.wast.fromBinary.noDebugInfo │ ├── atomics-unshared.wast.fromBinary.noDebugInfo │ ├── calls.txt │ ├── reg_switch.wast.fromBinary.noDebugInfo │ ├── duplicate_types.wast.fromBinary │ ├── duplicated_names.wasm.fromBinary │ ├── duplicate_types.wast.fromBinary.noDebugInfo │ ├── duplicated_names_collision.wasm.fromBinary │ ├── hello_world.wat │ ├── mutable-global.wast.from-wast │ ├── tail-call.wast.from-wast │ ├── mutable-global.wasm.fromBinary │ ├── newsyntax.wast │ ├── tail-call.wast.fromBinary │ ├── mutable-global.wast │ ├── mutable-global.wast.fromBinary │ ├── tail-call.wast.fromBinary.noDebugInfo │ ├── untaken-br_if.wast │ ├── mutable-global.wast.fromBinary.noDebugInfo │ ├── break-within-catch.wasm.fromBinary │ ├── hello_world.wast.from-wast │ ├── fn_prolog_epilog.debugInfo.wast │ ├── consume-stacky.wasm.fromBinary │ ├── hello_world.wast.fromBinary │ ├── hello_world.wast.fromBinary.noDebugInfo │ ├── fn_prolog_epilog.debugInfo.wast.from-wast │ ├── untaken-br_if.wast.fromBinary.noDebugInfo │ ├── fn_prolog_epilog.debugInfo.wasm.fromBinary │ ├── untaken-br_if.wast.fromBinary │ ├── untaken-br_if.wast.from-wast │ ├── fannkuch.txt │ ├── signext.wast │ ├── break-to-return.wasm.fromBinary │ ├── grow_memory.txt │ ├── duplicate_types.wast │ ├── grow_memory.wast.from-wast │ ├── grow_memory.wast.fromBinary │ ├── grow_memory.wast │ ├── grow_memory.wast.fromBinary.noDebugInfo │ ├── grow_memory.cpp │ ├── stacky.wasm.fromBinary │ ├── newsyntax.wast.from-wast │ ├── newsyntax.wast.fromBinary │ ├── newsyntax.wast.fromBinary.noDebugInfo │ ├── events.wast │ ├── calls.cpp │ ├── calls.post.js │ ├── signext.wast.from-wast │ ├── extra-unreachable.wast.fromBinary.noDebugInfo │ ├── extra-unreachable.wast.fromBinary │ ├── nonspec-bulk-memory.wast │ ├── printf.c │ ├── signext.wast.fromBinary │ ├── unreachable-instr-type.wast.from-wast │ ├── signext.wast.fromBinary.noDebugInfo │ ├── unreachable-instr-type.wast │ ├── nonspec-bulk-memory.wast.fromBinary.noDebugInfo │ ├── control_flow.post.js │ ├── externref.wast.from-wast │ ├── events.wast.from-wast │ ├── nonspec-bulk-memory.wast.from-wast │ └── nonspec-bulk-memory.wast.fromBinary ├── third_party │ ├── .clang-tidy │ ├── v8 │ │ └── .gitignore │ ├── mozjs │ │ └── .gitignore │ ├── llvm-project │ │ └── include │ │ │ └── llvm │ │ │ ├── Support │ │ │ ├── Threading.h │ │ │ ├── CommandLine.h │ │ │ ├── ManagedStatic.h │ │ │ ├── Locale.h │ │ │ ├── LICENSE.TXT │ │ │ └── ReverseIteration.h │ │ │ ├── Config │ │ │ ├── abi-breaking.h │ │ │ ├── config.h │ │ │ └── llvm-config.h │ │ │ └── BinaryFormat │ │ │ └── ELFRelocs │ │ │ └── BPF.def │ ├── wabt │ │ ├── .gitignore │ │ └── wasm2c │ │ │ └── README.md │ ├── CMakeLists.txt │ └── .clang-format ├── src │ ├── config.h │ ├── js │ │ ├── binaryen.js-extern-pre.js │ │ └── binaryen.js-extern-post.js │ ├── templates │ │ ├── normal.js │ │ └── wasm.js │ ├── cfg │ │ └── CMakeLists.txt │ ├── asmjs │ │ └── CMakeLists.txt │ ├── ir │ │ └── CMakeLists.txt │ ├── emscripten-optimizer │ │ └── CMakeLists.txt │ ├── support │ │ └── CMakeLists.txt │ └── wasm │ │ ├── CMakeLists.txt │ │ └── wasm-interpreter.cpp ├── config.h.in ├── .gitattributes ├── media │ └── example.png ├── scripts │ ├── test │ │ ├── mod.ule.js │ │ ├── env.js │ │ └── spectest.js │ ├── strip_local_names.py │ └── emcc-tests.sh ├── .flake8 ├── requirements-dev.txt ├── ubsan.blacklist └── .clang-format ├── .gitignore ├── cabal.project ├── test └── test.hs ├── stack.yaml ├── src └── Binaryen │ └── Module.hs-boot ├── CHANGELOG.md └── nix ├── binaryenOverlay.nix ├── nixpkgs.nix └── binaryen-3481-fix.patch /binaryen/test/revision: -------------------------------------------------------------------------------- 1 | 13645 2 | -------------------------------------------------------------------------------- /binaryen/test/unit/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /binaryen/test/fannkuch.args: -------------------------------------------------------------------------------- 1 | ["5"] 2 | -------------------------------------------------------------------------------- /binaryen/test/fasta.args: -------------------------------------------------------------------------------- 1 | ["10"] 2 | -------------------------------------------------------------------------------- /binaryen/test/example/hash.txt: -------------------------------------------------------------------------------- 1 | success. 2 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/empty.wasm: -------------------------------------------------------------------------------- 1 | asm -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/copy-expression.js.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/pass-arguments.js.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /binaryen/test/example/cpp-unit.txt: -------------------------------------------------------------------------------- 1 | Success 2 | -------------------------------------------------------------------------------- /binaryen/test/example/small_vector.txt: -------------------------------------------------------------------------------- 1 | ok. 2 | -------------------------------------------------------------------------------- /binaryen/test/example/space.txt: -------------------------------------------------------------------------------- 1 | success. 2 | -------------------------------------------------------------------------------- /binaryen/test/linker/quux.c: -------------------------------------------------------------------------------- 1 | void quux() {} 2 | -------------------------------------------------------------------------------- /binaryen/third_party/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: '' 2 | -------------------------------------------------------------------------------- /binaryen/test/calls.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /binaryen/test/hello_libcxx.txt: -------------------------------------------------------------------------------- 1 | hello, world! 2 | 3 | -------------------------------------------------------------------------------- /binaryen/test/hello_world.txt: -------------------------------------------------------------------------------- 1 | hello, world! 2 | 3 | -------------------------------------------------------------------------------- /binaryen/test/int_ops.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /binaryen/test/linker/baz.c: -------------------------------------------------------------------------------- 1 | void baz() { 2 | } 3 | -------------------------------------------------------------------------------- /binaryen/test/mem.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /binaryen/test/metadce/all-outside.wast: -------------------------------------------------------------------------------- 1 | (module) 2 | -------------------------------------------------------------------------------- /binaryen/test/metadce/spanning_cycle.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /binaryen/test/metadce/threaded_cycle.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /binaryen/test/control_flow.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/imported3.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/no_partial.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_call.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_store.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_store2.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_store3.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /binaryen/test/example/c-api-relooper-unreachable-if.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /binaryen/test/float_ops.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /binaryen/test/lld/hello_world.wat.mem.mem: -------------------------------------------------------------------------------- 1 | Hello, world -------------------------------------------------------------------------------- /binaryen/test/passes/multi_unit_abbrev_noprint.bin.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /binaryen/third_party/v8/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/tail_calls.js.txt: -------------------------------------------------------------------------------- 1 | true 2 | true 3 | -------------------------------------------------------------------------------- /binaryen/test/br_to_exit.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/bad-indirect-call.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/bad-indirect-call2.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/basics.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/imported-min.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/imported.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/indirect-call3.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_store.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/metadce/all-outside.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/metadce/no-outside.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/passes/dwarf_unit_with_no_abbrevs_noprint.bin.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /binaryen/third_party/mozjs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work 2 | dist-newstyle 3 | stack.yaml.lock 4 | -------------------------------------------------------------------------------- /binaryen/src/config.h: -------------------------------------------------------------------------------- 1 | #define PROJECT_VERSION "98 (version_99)" 2 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/fast-math.js.txt: -------------------------------------------------------------------------------- 1 | // fastMath=false 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/imported.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/imported2.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/just_some.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/stack-direction.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_store2.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_store3.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/elided-br.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  @@  -------------------------------------------------------------------------------- /binaryen/test/grow_memory.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ALLOW_MEMORY_GROWTH=1"] 2 | -------------------------------------------------------------------------------- /binaryen/test/linker/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { 2 | return 43; 3 | } 4 | -------------------------------------------------------------------------------- /binaryen/test/metadce/threaded_unrooted.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/passes/dealign64.passes: -------------------------------------------------------------------------------- 1 | dealign_enable-memory64 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/safe-heap_start-function.passes: -------------------------------------------------------------------------------- 1 | safe-heap 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/expected-output/func_ptrs.wast.log: -------------------------------------------------------------------------------- 1 | 83 : i32 2 | -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/Support/Threading.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/bad-indirect-call3.wast.ctors: -------------------------------------------------------------------------------- 1 | sig_mismatch 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/basics-flatten.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/imported-min.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3 2 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/stack-direction.wast.ctors: -------------------------------------------------------------------------------- 1 | __post_instantiate 2 | -------------------------------------------------------------------------------- /binaryen/test/linker/bar.c: -------------------------------------------------------------------------------- 1 | void quux(); 2 | void bar() { quux(); } 3 | -------------------------------------------------------------------------------- /binaryen/test/metadce/no-outside.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | ] 3 | 4 | 5 | -------------------------------------------------------------------------------- /binaryen/test/metadce/spanning_cycle_unrooted.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/metadce/threaded_unrooted_cycle.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /binaryen/test/unreachable-pops.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 | j -------------------------------------------------------------------------------- /cabal.project: -------------------------------------------------------------------------------- 1 | packages: . 2 | 3 | index-state: 2021-01-11T00:00:00Z 4 | -------------------------------------------------------------------------------- /binaryen/config.h.in: -------------------------------------------------------------------------------- 1 | #cmakedefine PROJECT_VERSION "${PROJECT_VERSION}" 2 | -------------------------------------------------------------------------------- /binaryen/src/js/binaryen.js-extern-pre.js: -------------------------------------------------------------------------------- 1 | var binaryen = {}; 2 | (function() { -------------------------------------------------------------------------------- /binaryen/test/break-within-catch.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  3 | @ -------------------------------------------------------------------------------- /binaryen/test/consume-stacky.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  AAA6 -------------------------------------------------------------------------------- /binaryen/test/passes/class_with_dwarf_noprint.passes: -------------------------------------------------------------------------------- 1 | roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/dwarf_unit_with_no_abbrevs_noprint.passes: -------------------------------------------------------------------------------- 1 | roundtrip_g 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/fib2_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/fuzz_metrics_noprint.passes: -------------------------------------------------------------------------------- 1 | translate-to-fuzz_metrics 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/inlined_to_start_dwarf.passes: -------------------------------------------------------------------------------- 1 | g_roundtrip_dwarfdump 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/reverse_dwarf_abbrevs.passes: -------------------------------------------------------------------------------- 1 | roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/expected-output/names.wast.log: -------------------------------------------------------------------------------- 1 | 42 : i32 2 | 123 : i32 3 | -------------------------------------------------------------------------------- /binaryen/test/spec/expected-output/old_start.wast.log: -------------------------------------------------------------------------------- 1 | 1 : i32 2 | 2 : i32 3 | -------------------------------------------------------------------------------- /binaryen/test/fn_prolog_epilog.debugInfo.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  @@  -------------------------------------------------------------------------------- /binaryen/test/memory-shared.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 (shared 23 256)) 3 | ) 4 | -------------------------------------------------------------------------------- /binaryen/test/metadce/threaded.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: outside_js_function1 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/fannkuch0_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/fannkuch3_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/remove-memory.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 1024 1024) 3 | ) 4 | -------------------------------------------------------------------------------- /binaryen/test/spec/inline-module.wast: -------------------------------------------------------------------------------- 1 | (func) (memory 0) (func (export "f")) 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/alignment-lowering64.passes: -------------------------------------------------------------------------------- 1 | alignment-lowering_enable-memory64 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/avoid-reinterprets64.passes: -------------------------------------------------------------------------------- 1 | avoid-reinterprets_enable-memory64 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/fib2_emptylocspan_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/instrument-memory64.passes: -------------------------------------------------------------------------------- 1 | instrument-memory_enable-memory64 2 | -------------------------------------------------------------------------------- /binaryen/test/print/memory-shared.minified.txt: -------------------------------------------------------------------------------- 1 | (module(memory $0 (shared 23 256)) 2 | ) -------------------------------------------------------------------------------- /binaryen/test/print/memory-shared.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 (shared 23 256)) 3 | ) 4 | -------------------------------------------------------------------------------- /binaryen/test/spec/func-local-after-body.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (nop) (local i32))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/func-param-after-body.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (nop) (param i32))) 2 | -------------------------------------------------------------------------------- /binaryen/third_party/wabt/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !wasm2c 4 | !wasm2c/* 5 | -------------------------------------------------------------------------------- /binaryen/src/templates/normal.js: -------------------------------------------------------------------------------- 1 | 2 | var Module = {}; // *.asm.js expects this 3 | 4 | 5 | -------------------------------------------------------------------------------- /binaryen/test/lit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file(lit.site.cfg.py.in lit.site.cfg.py @ONLY) 2 | -------------------------------------------------------------------------------- /binaryen/test/memory-shared.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 (shared 23 256)) 3 | ) 4 | -------------------------------------------------------------------------------- /binaryen/test/mutable-global.wasm: -------------------------------------------------------------------------------- 1 | asm`env 2 | global-mut 3 |  #Aj$ -------------------------------------------------------------------------------- /binaryen/test/passes/fannkuch3_manyopts_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_O4_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/multi_unit_abbrev_noprint.passes: -------------------------------------------------------------------------------- 1 | g_roundtrip_roundtrip_roundtrip 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/strip-target-features.wasm: -------------------------------------------------------------------------------- 1 | asm linkingtarget_features+foo -------------------------------------------------------------------------------- /binaryen/test/print/memory-shared.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 (shared 23 256)) 3 | ) 4 | -------------------------------------------------------------------------------- /binaryen/test/spec/func-result-after-body.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (nop) (result i32))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/import-after-func.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func) (import "" "" (memory 0))) 2 | -------------------------------------------------------------------------------- /binaryen/test/validator/invalid_import.wast: -------------------------------------------------------------------------------- 1 | (module (import $bad "test" "bad" (param i64))) -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/Config/abi-breaking.h: -------------------------------------------------------------------------------- 1 | 2 | // waka 3 | 4 | -------------------------------------------------------------------------------- /binaryen/test/empty_table.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (table 0 0 funcref) 3 | (memory $0 0) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/passes/ignore_missing_func_dwarf.passes: -------------------------------------------------------------------------------- 1 | print_dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/func-local-before-param.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (local i32) (param i32))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/of_string-overflow-s32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i32.const -2147483649))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/of_string-overflow-u32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i32.const 4294967296))) 2 | -------------------------------------------------------------------------------- /binaryen/test/validator/invalid_return.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $foo (result i32) (i64.const 1))) -------------------------------------------------------------------------------- /binaryen/test/duplicated_names.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 | A A A namefoofoofoo -------------------------------------------------------------------------------- /binaryen/test/memory-shared.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 (shared 23 256)) 3 | ) 4 | 5 | -------------------------------------------------------------------------------- /binaryen/test/passes/dwarf-local-order.passes: -------------------------------------------------------------------------------- 1 | g_print_roundtrip_print_strip-dwarf_roundtrip_print 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/multi_line_table_dwarf.passes: -------------------------------------------------------------------------------- 1 | g_dwarfdump_roundtrip_dwarfdump_all-features 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/too_much_for_liveness.passes: -------------------------------------------------------------------------------- 1 | metrics_coalesce-locals_metrics_reorder-locals 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/import-after-memory.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 0) (import "" "" (global i32))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/import-after-table.fail.wast: -------------------------------------------------------------------------------- 1 | (module (table 0 funcref) (import "" "" (func))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/of_string-overflow-hex-u32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i32.const 0x100000000))) 2 | -------------------------------------------------------------------------------- /binaryen/.gitattributes: -------------------------------------------------------------------------------- 1 | *.py text eol=lf 2 | *.sh text eol=lf 3 | test/binaryen.js/*.txt text eol=lf 4 | -------------------------------------------------------------------------------- /binaryen/test/dylib.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/dylib.wasm -------------------------------------------------------------------------------- /binaryen/test/empty_table.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 0) 3 | (table $0 0 0 funcref) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/metadce/corners.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: global$UNUSEDTOP$2 2 | unused: ignorable import 3 | -------------------------------------------------------------------------------- /binaryen/test/spec/import-after-global.fail.wast: -------------------------------------------------------------------------------- 1 | (module (global i64) (import "" "" (table 0 funcref))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/of_string-overflow-hex-u64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i64.const 0x10000000000000000))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/of_string-overflow-s64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i64.const -9223372036854775809))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/of_string-overflow-u64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i64.const 18446744073709551616))) 2 | -------------------------------------------------------------------------------- /binaryen/test/stacky.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/stacky.wasm -------------------------------------------------------------------------------- /binaryen/media/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/media/example.png -------------------------------------------------------------------------------- /binaryen/scripts/test/mod.ule.js: -------------------------------------------------------------------------------- 1 | 2 | export function ba_se() { 3 | console.log('"mod.ule"."ba.se"'); 4 | } 5 | -------------------------------------------------------------------------------- /binaryen/test/empty_table.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 0) 3 | (table $0 0 0 funcref) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/fib-dbg.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/fib-dbg.wasm -------------------------------------------------------------------------------- /binaryen/test/memory-shared.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 (shared 23 256)) 3 | ) 4 | 5 | -------------------------------------------------------------------------------- /binaryen/test/passes/O.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/O.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/fib_nonzero-low-pc_dwarf.passes: -------------------------------------------------------------------------------- 1 | enable-mutable-globals_dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /binaryen/test/passes/strip-target-features.bin.txt: -------------------------------------------------------------------------------- 1 | (module 2 | ;; custom section "linking", size 1 3 | ) 4 | -------------------------------------------------------------------------------- /binaryen/test/print/memory-import-shared.minified.txt: -------------------------------------------------------------------------------- 1 | (module(import "env" "memory" (memory $0 (shared 256 256)))) -------------------------------------------------------------------------------- /binaryen/test/spec/func-local-before-result.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (local i32) (result i32) (local.get 0))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/func-result-before-param.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (result i32) (param i32) (local.get 0))) 2 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/random_data.txt: -------------------------------------------------------------------------------- 1 | 6sgkjdfghk34589n-947-vn98f2yr-nb8f7t08b7gv*~&!%&^@}{PASD kjgsdf768 2 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/base64.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $memory 1 1) 3 | (data (i32.const 2) "\00\fe\ff") 4 | ) -------------------------------------------------------------------------------- /binaryen/test/wasm2js/empty_export.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "" (func $foo)) 3 | (func $foo) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /binaryen/third_party/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(BUILD_LLVM_DWARF) 2 | add_subdirectory(llvm-project) 3 | endif() 4 | -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/Config/config.h: -------------------------------------------------------------------------------- 1 | 2 | // waka waka 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /test/test.hs: -------------------------------------------------------------------------------- 1 | import qualified Binaryen 2 | 3 | main :: IO () 4 | main = print =<< Binaryen.getOptimizeLevel 5 | -------------------------------------------------------------------------------- /binaryen/test/duplicated_names_collision.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 | A A A namefoofoofoo.1 -------------------------------------------------------------------------------- /binaryen/test/metadatas.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/metadatas.wasm -------------------------------------------------------------------------------- /binaryen/test/validator/invalid_export.wast: -------------------------------------------------------------------------------- 1 | (module (func $export64 (result i64) (i64.const 1)) (export "a" $export64)) -------------------------------------------------------------------------------- /binaryen/third_party/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | DisableFormat: true 4 | SortIncludes: false 5 | --- 6 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/simd.js.txt: -------------------------------------------------------------------------------- 1 | v128.const i8x16 0x1 0x0 0x0 0x0 0x2 0x0 0x0 0x0 0x3 0x0 0x0 0x0 0x4 0x0 0x0 0x0 2 | -------------------------------------------------------------------------------- /binaryen/test/complexBinaryNames.wasm: -------------------------------------------------------------------------------- 1 | asm` $zoo (.bar) 2 | 3 |   name 4 | foo (.bar)1 -------------------------------------------------------------------------------- /binaryen/test/crash/outside.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/crash/outside.wasm -------------------------------------------------------------------------------- /binaryen/test/empty_table.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 0) 3 | (table $0 0 0 funcref) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/passes/print.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/print.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/safe-heap_enable-threads_enable-simd64.passes: -------------------------------------------------------------------------------- 1 | safe-heap_enable-threads_enable-simd_enable-memory64 2 | -------------------------------------------------------------------------------- /binaryen/test/print/memory-import-shared.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 (shared 256 256))) 3 | ) 4 | -------------------------------------------------------------------------------- /binaryen/test/print/memory-import-shared.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 (shared 256 256))) 3 | ) 4 | -------------------------------------------------------------------------------- /binaryen/test/spec/f32.load32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result f32) (f32.load32 (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/f32.load64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result f32) (f32.load64 (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/f64.load32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result f64) (f64.load32 (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/f64.load64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result f64) (f64.load64 (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/custom-section.js.txt: -------------------------------------------------------------------------------- 1 | (module 2 | ;; custom section "hello", size 5, contents: "world" 3 | ) 4 | 5 | -------------------------------------------------------------------------------- /binaryen/test/break-to-return.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/break-to-return.wasm -------------------------------------------------------------------------------- /binaryen/test/empty_imported_table.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "table" (table 0 0 funcref)) 3 | (memory $0 0) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/fib-dbg.wasm.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["fib.c"],"names":[],"mappings":"moBAEA,4BAKA,QAJA,OADA,OAAA,uCAKA"} 2 | -------------------------------------------------------------------------------- /binaryen/test/lld/em_asm.wat.mem.mem: -------------------------------------------------------------------------------- 1 | { Module.print("Hello world"); }{ return $0 + $1; }ii{ Module.print("Got " + $0); }i -------------------------------------------------------------------------------- /binaryen/test/passes/dwarfdump.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/dwarfdump.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/flatten.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/flatten.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/print_g.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/print_g.wasm -------------------------------------------------------------------------------- /binaryen/test/spec/i32.load32_s.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i32) (i32.load32_s (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/i32.load32_u.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i32) (i32.load32_u (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/i32.load64_s.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i32) (i32.load64_s (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/i32.load64_u.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i32) (i32.load64_u (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/i64.load64_s.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i64) (i64.load64_s (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/i64.load64_u.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i64) (i64.load64_u (local.get 0)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/hello_world.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("hello, world!\n"); 5 | return 0; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /binaryen/test/passes/fib2_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/fib2_dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/strip-debug.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/strip-debug.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/strip-dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/strip-dwarf.wasm -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/Support/CommandLine.h: -------------------------------------------------------------------------------- 1 | // XXX BINARYEN - we don't need this, but stuff imports it 2 | -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/Support/ManagedStatic.h: -------------------------------------------------------------------------------- 1 | // XXX BINARYEN - we don't need this, but stuff imports it 2 | -------------------------------------------------------------------------------- /stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-16.28 2 | 3 | nix: 4 | path: 5 | - nixpkgs=./nix/nixpkgs.nix 6 | packages: 7 | - binaryen 8 | -------------------------------------------------------------------------------- /binaryen/test/bigswitch.txt: -------------------------------------------------------------------------------- 1 | 34962: GL_ARRAY_BUFFER (0x8892) 2 | 26214: what? 3 | 35040: GL_STREAM_DRAW (0x88E0) 4 | 3060: what? 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/complexTextNames.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $foo\20\28.bar\29) 3 | (func "$zoo (.bar)" (call $foo\20\28.bar\29)) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/fn_prolog_epilog.debugInfo.wasm.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["src.cpp"],"names":[],"mappings":"sBAAC,EACA,EAAC,MACD,CAAC"} -------------------------------------------------------------------------------- /binaryen/test/lld/hello_world.c: -------------------------------------------------------------------------------- 1 | int puts(const char* str); 2 | 3 | int main() { 4 | puts("Hello, world"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /binaryen/test/spec/f32.store32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param f32) (f32.store32 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/f32.store64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param f64) (f32.store64 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/f64.store32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param f32) (f64.store32 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/f64.store64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param f64) (f64.store64 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/i32.store32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param i32) (i32.store32 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/i32.store64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param i64) (i32.store64 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/spec/i64.store64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param i64) (i64.store64 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/dwarf/zlib.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/dwarf/zlib.wasm -------------------------------------------------------------------------------- /binaryen/test/example/cpp-threads.txt: -------------------------------------------------------------------------------- 1 | create threads... 2 | threads running in parallel... 3 | waiting for threads to join... 4 | all done. 5 | -------------------------------------------------------------------------------- /binaryen/test/lld/shared_add_to_table.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/lld/shared_add_to_table.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/fannkuch0_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/fannkuch0_dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/fannkuch3_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/fannkuch3_dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/print-function-map.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "foo" (func $Foo)) 3 | (func $bar) 4 | (func $baz) 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /binaryen/test/passes/print_g_metrics.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/print_g_metrics.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/remove-memory.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1024 1024 3 | (segment 10 "123") 4 | (segment 20 "149") 5 | ) 6 | ) 7 | -------------------------------------------------------------------------------- /binaryen/test/passes/strip-producers.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/strip-producers.wasm -------------------------------------------------------------------------------- /binaryen/test/unit/input/bulkmem_data.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/bulkmem_data.wasm -------------------------------------------------------------------------------- /src/Binaryen/Module.hs-boot: -------------------------------------------------------------------------------- 1 | module Binaryen.Module where 2 | 3 | import Foreign.Ptr (Ptr) 4 | 5 | newtype Module = Module (Ptr Module) 6 | -------------------------------------------------------------------------------- /binaryen/test/crash/use_var_outside_func.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/crash/use_var_outside_func.wasm -------------------------------------------------------------------------------- /binaryen/test/empty_imported_table.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "table" (table $timport$0 0 0 funcref)) 3 | (memory $0 0) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/fasta.txt: -------------------------------------------------------------------------------- 1 | GGCCGGGCGCGGTGGCTCAC 2 | cttBtatcatatgctaKggNcataaaSatg 3 | 4 | taaatcttgtgcttcgttagaagtctcgactacgtgtagcctagtgtttg 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/metadce/all-outside.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: island 2 | unused: lonely 3 | unused: loop1 4 | unused: loop2 5 | unused: reverse 6 | -------------------------------------------------------------------------------- /binaryen/test/passes/converge_O3_metrics.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/converge_O3_metrics.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/dwarf-local-order.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/dwarf-local-order.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/print_g_strip-dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/print_g_strip-dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/validator/invalid_number.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $invalid_number 3 | (i64.const 70847791997969805621592064) 4 | ) 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/dot_import.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "mod.ule" "ba.se" (func $base)) 3 | (func "exported" 4 | (call $base) 5 | ) 6 | ) 7 | -------------------------------------------------------------------------------- /binaryen/test/empty_imported_table.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "table" (table $timport$0 0 0 funcref)) 3 | (memory $0 0) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/linker/main.c: -------------------------------------------------------------------------------- 1 | int foo() { 2 | return 42; 3 | } 4 | 5 | void bar(); 6 | 7 | int main() { 8 | foo(); 9 | bar(); 10 | } 11 | -------------------------------------------------------------------------------- /binaryen/test/metadce/spanning_cycle_unrooted.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: func$a_wasm_func$0 2 | unused: outside_js_function 3 | unused: wasm_export 4 | -------------------------------------------------------------------------------- /binaryen/test/passes/fuzz_metrics_noprint.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/fuzz_metrics_noprint.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/reverse_dwarf_abbrevs.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/reverse_dwarf_abbrevs.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/too_much_for_liveness.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/too_much_for_liveness.wasm -------------------------------------------------------------------------------- /binaryen/test/spec/address-offset-range.fail.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1) 3 | (func $bad (drop (i32.load offset=4294967296 (i32.const 0)))) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/dwarf/cubescript.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/dwarf/cubescript.wasm -------------------------------------------------------------------------------- /binaryen/test/unit/input/gc_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/gc_target_feature.wasm -------------------------------------------------------------------------------- /binaryen/test/hello_libcxx.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "hello, world!" << std::endl; 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /binaryen/test/imported_memory.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 256 256)) 3 | (import "env" "table" (table 256 256 funcref)) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/imported_memory_growth.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 256)) 3 | (import "env" "table" (table 256 funcref)) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/passes/class_with_dwarf_noprint.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/class_with_dwarf_noprint.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/fannkuch3_manyopts_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/fannkuch3_manyopts_dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/fib2_emptylocspan_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/fib2_emptylocspan_dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/fib_nonzero-low-pc_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/fib_nonzero-low-pc_dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/inlined_to_start_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/inlined_to_start_dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/multi_line_table_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/multi_line_table_dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/unit/input/simd_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/simd_target_feature.wasm -------------------------------------------------------------------------------- /binaryen/test/wasm2js/atomic_fence.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 (shared 23 256)) 3 | (func (export "atomic-fence") 4 | (atomic.fence) 5 | ) 6 | ) 7 | -------------------------------------------------------------------------------- /binaryen/test/empty_imported_table.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "table" (table $timport$0 0 0 funcref)) 3 | (memory $0 0) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/passes/ignore_missing_func_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/ignore_missing_func_dwarf.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/multi_unit_abbrev_noprint.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/multi_unit_abbrev_noprint.wasm -------------------------------------------------------------------------------- /binaryen/test/unit/input/atomics_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/atomics_target_feature.wasm -------------------------------------------------------------------------------- /binaryen/test/unit/input/bulkmem_bad_datacount.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/bulkmem_bad_datacount.wasm -------------------------------------------------------------------------------- /binaryen/test/unit/input/bulkmem_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/bulkmem_target_feature.wasm -------------------------------------------------------------------------------- /binaryen/test/unit/input/signext_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/signext_target_feature.wasm -------------------------------------------------------------------------------- /binaryen/src/templates/wasm.js: -------------------------------------------------------------------------------- 1 | 2 | var Module = { 3 | asmjsCodeFile: 'a.asm.js' // tell polyfill (which replaces a.asm.js) where the asm.js code is 4 | }; 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/crash/expression-past-end-of-input.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/crash/expression-past-end-of-input.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/dwarfdump_roundtrip_dwarfdump.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/dwarfdump_roundtrip_dwarfdump.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/memory-packing_all-features_zero-filled-memory.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 1 1)) 3 | (data (i32.const 1024) "x") 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/passes/metrics_strip-debug_metrics.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/metrics_strip-debug_metrics.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/roundtrip_signed.passes: -------------------------------------------------------------------------------- 1 | remove-unused-module-elements_roundtrip_vacuum_remove-unused-brs_merge-blocks_vacuum_duplicate-function-elimination 2 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/truncsat_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/unit/input/truncsat_target_feature.wasm -------------------------------------------------------------------------------- /binaryen/test/wasm2js/minified-memory.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "a" (memory $0 1)) 3 | (func "foo" (result i32) 4 | (i32.load (i32.const 0)) 5 | ) 6 | ) 7 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/start_func.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1) 3 | (start $foo) 4 | (func $foo 5 | (i32.store (i32.const 1) (i32.const 2)) 6 | ) 7 | ) 8 | -------------------------------------------------------------------------------- /binaryen/src/cfg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB cfg_HEADERS *.h) 2 | set(cfg_SOURCES 3 | Relooper.cpp 4 | ${cfg_HEADERS} 5 | ) 6 | add_library(cfg OBJECT ${cfg_SOURCES}) 7 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/fast-math.js: -------------------------------------------------------------------------------- 1 | console.log("// fastMath=" + binaryen.getFastMath()); 2 | binaryen.setFastMath(true); 3 | assert(binaryen.getFastMath() == true); 4 | -------------------------------------------------------------------------------- /binaryen/test/imported_memory_growth.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 256)) 3 | (import "env" "table" (table $timport$0 256 funcref)) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/passes/dce_vacuum_remove-unused-names.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/dce_vacuum_remove-unused-names.wasm -------------------------------------------------------------------------------- /binaryen/test/passes/metrics_strip-producers_metrics.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/metrics_strip-producers_metrics.wasm -------------------------------------------------------------------------------- /binaryen/test/unit/input/exception_handling_target_feature.wasm: -------------------------------------------------------------------------------- 1 | asm``  2 | A name06target_features+exception-handling+reference-types -------------------------------------------------------------------------------- /binaryen/test/br_to_exit.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (func $0 4 | (block $label$0 5 | (br $label$0) 6 | ) 7 | ) 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /binaryen/test/elided-br.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (func $0 4 | (block $label$1 5 | (unreachable) 6 | ) 7 | ) 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /binaryen/test/imported_memory.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 256 256)) 3 | (import "env" "table" (table $timport$0 256 256 funcref)) 4 | ) 5 | -------------------------------------------------------------------------------- /binaryen/test/passes/dwarf_unit_with_no_abbrevs_noprint.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweag/haskell-binaryen/HEAD/binaryen/test/passes/dwarf_unit_with_no_abbrevs_noprint.wasm -------------------------------------------------------------------------------- /binaryen/test/unit/input/tail_call_target_feature.wasm: -------------------------------------------------------------------------------- 1 | asm` envbarmemoryfoo 2 |  name barfoo0target_features+ tail-call -------------------------------------------------------------------------------- /binaryen/test/extended-names.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 1 1) 3 | (data (i32.const 0) "a") 4 | (data passive "b") 5 | (table $0 1 funcref) 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /binaryen/test/imported_memory.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 256 256)) 3 | (import "env" "table" (table $timport$0 256 256 funcref)) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/imported_memory_growth.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 256)) 3 | (import "env" "table" (table $timport$0 256 funcref)) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/metadce/rooted-export.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: event$a_wasm_event$2 2 | unused: export$wasm_event_a$5 3 | unused: export$wasm_func_a$4 4 | unused: func$a_wasm_func$0 5 | -------------------------------------------------------------------------------- /binaryen/test/segment-overlap.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 10) 3 | (data (i32.const 100) "\ff\ff\ff\ff\ff\ff\ff\ff") 4 | (data (i32.const 104) "\00\00\00\00") 5 | ) 6 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/mutable_globals_target_feature.wasm: -------------------------------------------------------------------------------- 1 | asm`env 2 | global-mut 3 |  #Aj$ name0  gimport$0"target_features+mutable-globals -------------------------------------------------------------------------------- /binaryen/test/unreachable-instr-type.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 (shared 1 1)) 4 | (func $test 5 | (unreachable) 6 | ) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/inlining-options.js.txt: -------------------------------------------------------------------------------- 1 | // alwaysInlineMaxSize=2 2 | // flexibleInlineMaxSize=20 3 | // oneCallerInlineMaxSize=15 4 | // allowInliningFunctionsWithLoops=false 5 | -------------------------------------------------------------------------------- /binaryen/test/extended-names.wast: -------------------------------------------------------------------------------- 1 | (module $foo 2 | (table $t1 1 funcref) 3 | (memory $m1 1 1) 4 | (data $mydata (i32.const 0) "a") 5 | (data $passive_data passive "b") 6 | ) 7 | -------------------------------------------------------------------------------- /binaryen/test/metadce/no-outside.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: export$wasm_func$4 2 | unused: export$wasm_func_unused$5 3 | unused: func$a_wasm_func$0 4 | unused: func$an_unused_wasm_func$1 5 | -------------------------------------------------------------------------------- /binaryen/test/segment-overlap.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 10) 3 | (data (i32.const 100) "\ff\ff\ff\ff\ff\ff\ff\ff") 4 | (data (i32.const 104) "\00\00\00\00") 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/expressionrunner.js.txt: -------------------------------------------------------------------------------- 1 | // ExpressionRunner.Flags.Default = 0 2 | // ExpressionRunner.Flags.PreserveSideeffects = 1 3 | // ExpressionRunner.Flags.TraverseCalls = 2 4 | -------------------------------------------------------------------------------- /binaryen/test/extended-names.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module $foo 2 | (memory $m1 1 1) 3 | (data $mydata (i32.const 0) "a") 4 | (data $passive_data passive "b") 5 | (table $t1 1 funcref) 6 | ) 7 | -------------------------------------------------------------------------------- /binaryen/test/printf.txt: -------------------------------------------------------------------------------- 1 | int a = 12345 2 | unsigned b = 123456 3 | long c = 1234567 4 | unsigned long d = 12345678 5 | long long e = 1234567891011 6 | unsigned long long f = 123456789101112 7 | -------------------------------------------------------------------------------- /binaryen/test/reduce/imports.wast.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (export "x" (func $0)) 4 | (func $0 (result i32) 5 | (i32.const 5678) 6 | ) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /binaryen/test/reduce/simple.wast.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (export "x" (func $0)) 4 | (func $0 (result i32) 5 | (i32.const 5678) 6 | ) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /binaryen/test/unreachable-instr-type.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 (shared 1 1)) 4 | (func $0 5 | (unreachable) 6 | ) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /binaryen/test/extended-names.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module $foo 2 | (memory $m1 1 1) 3 | (data $mydata (i32.const 0) "a") 4 | (data $passive_data passive "b") 5 | (table $t1 1 funcref) 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /binaryen/test/passes/interesting-pass-mix.passes: -------------------------------------------------------------------------------- 1 | flatten_rereloop_dce_remove-unused-brs_remove-unused-names_coalesce-locals_simplify-locals_reorder-locals_remove-unused-brs_merge-blocks_vacuum 2 | -------------------------------------------------------------------------------- /binaryen/test/segment-overlap.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 10) 3 | (data (i32.const 100) "\ff\ff\ff\ff\ff\ff\ff\ff") 4 | (data (i32.const 104) "\00\00\00\00") 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /binaryen/test/spec/expected-output/old_imports.wast.log: -------------------------------------------------------------------------------- 1 | 13 : i32 2 | 14 : i32 3 | 42 : f32 4 | 13 : i32 5 | 13 : i32 6 | 24 : i64 7 | 25 : i64 8 | 53 : f64 9 | 24 : i64 10 | 24 : i64 11 | -------------------------------------------------------------------------------- /binaryen/test/imported_memory.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $mimport$0 256 256)) 3 | (import "env" "table" (table $timport$0 256 256 funcref)) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/imported_memory_growth.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $mimport$0 256)) 3 | (import "env" "table" (table $timport$0 256 funcref)) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /binaryen/test/passes/roundtrip_signed.wasm: -------------------------------------------------------------------------------- 1 | asm``A 2 | *as-br_table-indexas-local.set-value 3 | C"@#E@ #Ak$ @@A(  A @#E@ #Ak$ A( -------------------------------------------------------------------------------- /binaryen/test/segment-overlap.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 10) 3 | (data (i32.const 100) "\ff\ff\ff\ff\ff\ff\ff\ff") ;; overlaps with the next 4 | (data (i32.const 104) "\00\00\00\00") 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /binaryen/test/spec/atomics.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 (shared 23 256)) 3 | (func (export "atomic-fence") 4 | (atomic.fence) 5 | ) 6 | ) 7 | 8 | (assert_return (invoke "atomic-fence")) 9 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/emscripten-grow-no.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "memory" (memory $0 256 256)) 4 | (data (i32.const 1600) "abc") 5 | (export "memory" (memory $0)) 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/emscripten-grow-yes.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "memory" (memory $0 256 1024)) 4 | (data (i32.const 1600) "abc") 5 | (export "memory" (memory $0)) 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /binaryen/test/atomics-unshared.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 1 1) 3 | (func $foo 4 | (drop (i32.atomic.rmw.cmpxchg 5 | (i32.const 0) 6 | (i32.const 0) 7 | (i32.const 0) 8 | )) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "func" (func $func)) 3 | (func $func (result i64) 4 | (unreachable) 5 | ) 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /binaryen/test/reduce/destructive.wast.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_i32 (func (param i32) (result i32))) 3 | (export "x" (func $0)) 4 | (func $0 (param $0 i32) (result i32) 5 | (i32.const 100) 6 | ) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /binaryen/test/unreachable-pops.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (func $0 (result i32) 4 | (block $label$1 (result i32) 5 | (unreachable) 6 | ) 7 | ) 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/custom-section.js: -------------------------------------------------------------------------------- 1 | var module = new binaryen.Module(); 2 | 3 | module.addCustomSection("hello", [119, 111, 114, 108, 100]); 4 | 5 | assert(module.validate()); 6 | console.log(module.emitText()); 7 | -------------------------------------------------------------------------------- /binaryen/src/asmjs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB asmjs_HEADERS *.h) 2 | set(asmjs_SOURCES 3 | asm_v_wasm.cpp 4 | asmangle.cpp 5 | shared-constants.cpp 6 | ${asmjs_HEADERS} 7 | ) 8 | add_library(asmjs OBJECT ${asmjs_SOURCES}) 9 | -------------------------------------------------------------------------------- /binaryen/test/passes/roundtrip.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (export "foo" (func $0)) 4 | (func $0 5 | (unreachable) 6 | ) 7 | ) 8 | (module 9 | (memory $0 1 1) 10 | (table $0 0 funcref) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/table-import.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "table" (table 1 1 funcref)) 4 | (elem (i32.const 0) $foo) 5 | (memory $0 0) 6 | (func $foo (type $0) 7 | (nop) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/test/complexTextNames.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (export "$zoo (.bar)" (func $1)) 4 | (func $0 5 | (nop) 6 | ) 7 | (func $1 8 | (call $0) 9 | ) 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /binaryen/test/export-import.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $v (func)) 3 | (import "env" "test1" (func $test1)) 4 | (import "env" "test2" (global $test2 i32)) 5 | (export "test1" (func $test1)) 6 | (export "test2" (global $test2)) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/reference_types_target_feature.wasm: -------------------------------------------------------------------------------- 1 | asm`ooenvtest1envtest2otest1test2 2 |   8nametest1 anyref_test00  gimport$1"target_features+reference-types -------------------------------------------------------------------------------- /binaryen/test/complexTextNames.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (export "$zoo (.bar)" (func $1)) 4 | (func $foo\20\28.bar\29 5 | (nop) 6 | ) 7 | (func $1 8 | (call $foo\20\28.bar\29) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/metadce/spanning_cycle_unrooted.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "js_func" (func $a_js_func)) 3 | 4 | (export "wasm_func_a" (func $a_wasm_func)) 5 | 6 | (func $a_wasm_func 7 | (call $a_js_func) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/passes/extract-function_pass-arg=extract@foo.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $foo 3 | (call $bar) 4 | ) 5 | (func $bar 6 | (call $foo) 7 | ) 8 | (func $other 9 | (drop (i32.const 1)) 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /binaryen/test/passes/precompute_coalesce-locals_vacuum.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_i32 (func (param i32) (result i32))) 3 | (func $nested-br_if-value (param $0 i32) (result i32) 4 | (loop $label$0 5 | (br $label$0) 6 | ) 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /binaryen/test/passes/print-function-map.txt: -------------------------------------------------------------------------------- 1 | 0:Foo 2 | 1:bar 3 | 2:baz 4 | (module 5 | (type $none_=>_none (func)) 6 | (import "env" "foo" (func $Foo)) 7 | (func $bar 8 | (nop) 9 | ) 10 | (func $baz 11 | (nop) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /binaryen/test/table-import.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "table" (table $timport$0 1 1 funcref)) 4 | (elem (i32.const 0) $foo) 5 | (memory $0 0) 6 | (func $foo 7 | (nop) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/sign_ext.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func "test8" (param $x i32) (result i32) 3 | (i32.extend8_s (local.get $x)) 4 | ) 5 | (func "test16" (param $x i32) (result i32) 6 | (i32.extend16_s (local.get $x)) 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /binaryen/test/complexTextNames.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (export "$zoo (.bar)" (func $1)) 4 | (func $foo\20\28.bar\29 5 | (nop) 6 | ) 7 | (func $1 8 | (call $foo\20\28.bar\29) 9 | ) 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /binaryen/test/memory-import.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (import "env" "memory" (memory $0 1 1)) 4 | (func $foo (type $0) (result i32) 5 | (i32.load offset=13 6 | (i32.const 37) 7 | ) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/test/memory-import.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (import "env" "memory" (memory $0 1 1)) 4 | (func $foo (result i32) 5 | (i32.load offset=13 6 | (i32.const 37) 7 | ) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/test/table-import.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "table" (table $timport$0 1 1 funcref)) 4 | (elem (i32.const 0) $foo) 5 | (memory $0 0) 6 | (func $foo 7 | (nop) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/complexBinaryNames.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (export "$zoo (.bar)" (func $1)) 4 | (func $foo\20\28.bar\29 5 | (nop) 6 | ) 7 | (func $1 8 | (call $foo\20\28.bar\29) 9 | ) 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /binaryen/test/export-import.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "test2" (global $test2 i32)) 4 | (import "env" "test1" (func $test1)) 5 | (export "test1" (func $test1)) 6 | (export "test2" (global $test2)) 7 | ) 8 | -------------------------------------------------------------------------------- /binaryen/test/fn_prolog_epilog.debugInfo.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (func $0 4 | (nop) 5 | (block $label$1 6 | (block $label$2 7 | (br $label$2) 8 | ) 9 | ) 10 | (return) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/lit/parse-error.wast: -------------------------------------------------------------------------------- 1 | ;; Test that parse errors have helpful messages 2 | 3 | ;; RUN: not wasm-opt %s 2>&1 | filecheck %s 4 | ;; CHECK: [parse exception: abc (at 8:4)] 5 | 6 | (module 7 | (func $foo 8 | (abc) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/memory-import64.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (import "env" "memory" (memory $0 i64 1 1)) 4 | (func $foo (result i32) 5 | (i32.load offset=13 6 | (i64.const 37) 7 | ) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = 3 | E501, # line too long 4 | E241, # space after comma (ignored for list in gen-s-parser.py) 5 | W504 # line break after binary operator 6 | exclude = ./test/emscripten,./test/spec,./test/wasm-install,./test/lit 7 | -------------------------------------------------------------------------------- /binaryen/test/export-import.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "test2" (global $test2 i32)) 4 | (import "env" "test1" (func $test1)) 5 | (export "test1" (func $test1)) 6 | (export "test2" (global $test2)) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /binaryen/test/lld/em_asm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | EM_ASM({ Module.print("Hello world"); }); 5 | int x = EM_ASM_INT({ return $0 + $1; }, 13, 27); 6 | EM_ASM_({ Module.print("Got " + $0); }, x); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /binaryen/test/lld/em_asm64.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | EM_ASM({ Module.print("Hello world"); }); 5 | int x = EM_ASM_INT({ return $0 + $1; }, 13, 27); 6 | EM_ASM_({ Module.print("Got " + $0); }, x); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /binaryen/test/memory-import.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (import "env" "memory" (memory $0 1 1)) 4 | (func $foo (result i32) 5 | (i32.load offset=13 6 | (i32.const 37) 7 | ) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/memory-import64.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (import "env" "memory" (memory $0 i64 1 1)) 4 | (func $foo (type $0) (result i32) 5 | (i32.load offset=13 6 | (i64.const 37) 7 | ) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/test/passes/generate-i64-dyncalls.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $f1 (result i32) 3 | (i32.const 1024) 4 | ) 5 | (func $f2 (param i32) (result i64) 6 | (i64.const 42) 7 | ) 8 | (table 2 2 funcref) 9 | (elem (i32.const 0) $f1 $f2) 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/table-import.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "table" (table $timport$0 1 1 funcref)) 4 | (elem (i32.const 0) $0) 5 | (memory $0 0) 6 | (func $0 7 | (nop) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/tail-call.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $void (func)) 3 | (table 1 1 funcref) 4 | (elem (i32.const 0) $foo) 5 | (func $foo 6 | (return_call $bar) 7 | ) 8 | (func $bar 9 | (return_call_indirect (type $void) (i32.const 0)) 10 | ) 11 | ) -------------------------------------------------------------------------------- /binaryen/test/lld/em_asm_shared.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | EM_ASM({ Module.print("Hello world"); }); 5 | int x = EM_ASM_INT({ return $0 + $1; }, 13, 27); 6 | EM_ASM_({ Module.print("Got " + $0); }, x); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /binaryen/test/memory-import64.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (import "env" "memory" (memory $0 i64 1 1)) 4 | (func $foo (result i32) 5 | (i32.load offset=13 6 | (i64.const 37) 7 | ) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/memory-import64.wast.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (import "env" "memory" (memory $0 1 1 i64)) 4 | (func $0 (result i32) 5 | (i32.load offset=13 6 | (i64.const 37) 7 | ) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/metadatas.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (export "a" (func $0)) 4 | (func $0 5 | (nop) 6 | ) 7 | ;; custom section "emscripten_metadata", size 7 8 | ;; custom section "producers", size 187 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/reg_switch.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 0) 4 | (func $0 5 | (if 6 | (i32.const 0) 7 | (block $A 8 | (br_table $A 9 | (i32.const 0) 10 | ) 11 | ) 12 | ) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/spec/token.wast: -------------------------------------------------------------------------------- 1 | ;; Test tokenization 2 | 3 | (assert_malformed 4 | (module quote "(func (drop (i32.const0)))") 5 | "unknown operator" 6 | ) 7 | (assert_malformed 8 | (module quote "(func br 0drop)") 9 | "unknown operator" 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_store.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 256 256) 3 | (data (i32.const 10) "waka waka waka waka waka") 4 | (export "test1" $test1) 5 | (func $test1 6 | (i32.store8 (i32.const 9) (i32.const 109)) ;; before first segment 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_store2.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 256 256) 3 | (data (i32.const 10) "waka waka waka waka waka") 4 | (export "test1" $test1) 5 | (func $test1 6 | (i32.store8 (i32.const 34) (i32.const 109)) ;; after last segment 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /binaryen/test/example/c-api-hello-world.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 3 | (func $adder (param $0 i32) (param $1 i32) (result i32) 4 | (i32.add 5 | (local.get $0) 6 | (local.get $1) 7 | ) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/test/fn_prolog_epilog.debugInfo.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (func $0 4 | (nop) 5 | (block $label$1 6 | (block $label$2 7 | (br $label$2) 8 | ) 9 | ) 10 | (return) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/lit/wasm-split/export-name-already-exists.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-split %s --instrument --profile-export=foo 2>&1 \ 2 | ;; RUN: | filecheck %s 3 | 4 | ;; CHECK: error: Export foo already exists. 5 | 6 | (module 7 | (export "foo" (memory 0 0)) 8 | ) 9 | -------------------------------------------------------------------------------- /binaryen/test/metadce/outside.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "outside-entity", 4 | "reaches": ["inside-wasm-func"], 5 | "root": true 6 | }, 7 | { 8 | "name": "inside-wasm-func", 9 | "export": "wasm_func" 10 | } 11 | ] 12 | 13 | -------------------------------------------------------------------------------- /binaryen/test/lld/init.c: -------------------------------------------------------------------------------- 1 | volatile int x, y; 2 | 3 | __attribute__((constructor)) 4 | void init_x() { 5 | x = 14; 6 | } 7 | 8 | __attribute__((constructor)) 9 | void init_y() { 10 | y = 144; 11 | } 12 | 13 | int main() { 14 | return x + y; 15 | } 16 | -------------------------------------------------------------------------------- /binaryen/test/memory-import.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (import "env" "memory" (memory $mimport$0 1 1)) 4 | (func $0 (result i32) 5 | (i32.load offset=13 6 | (i32.const 37) 7 | ) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/metadce/outside.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: export$wasm_func_unused$10 2 | unused: func$an_unused_wasm_func$1 3 | unused: global$__THREW__unused$4 4 | unused: global$from_segment$5 5 | unused: global$from_segment_2$6 6 | unused: global$from_segment_never_used$7 7 | -------------------------------------------------------------------------------- /binaryen/test/passes/extract-function_pass-arg=extract@foo.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "bar" (func $bar)) 4 | (import "env" "other" (func $other)) 5 | (export "foo" (func $foo)) 6 | (func $foo 7 | (call $bar) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/requirements-dev.txt: -------------------------------------------------------------------------------- 1 | # These requirements are only needed for developers who want to run the test 2 | # suite or flake8, not for end users. 3 | 4 | # Install with `pip3 install -r requirements-dev.txt` 5 | 6 | flake8==3.7.8 7 | filecheck==0.0.17 8 | lit==0.11.0.post1 9 | -------------------------------------------------------------------------------- /binaryen/test/atomics-unshared.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 1 1) 4 | (func $foo 5 | (drop 6 | (i32.atomic.rmw.cmpxchg 7 | (i32.const 0) 8 | (i32.const 0) 9 | (i32.const 0) 10 | ) 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /binaryen/test/lit/lit.site.cfg.py.in: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | config.binaryen_src_root = r'@CMAKE_SOURCE_DIR@' 4 | config.binaryen_build_root = r'@CMAKE_BINARY_DIR@' 5 | 6 | lit_config.load_config( 7 | config, os.path.join(config.binaryen_src_root, 'test', 'lit', 'lit.cfg.py')) 8 | -------------------------------------------------------------------------------- /binaryen/test/lld/em_asm_O0.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) { 4 | EM_ASM({ Module.print("Hello world"); }); 5 | int ret = EM_ASM_INT({ return $0 + $1; }, 20, 30); 6 | EM_ASM({ Module.print("Got " + $0); }, 42); 7 | return ret; 8 | } 9 | -------------------------------------------------------------------------------- /binaryen/test/memory-import64.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (import "env" "memory" (memory $mimport$0 i64 1 1)) 4 | (func $0 (result i32) 5 | (i32.load offset=13 6 | (i64.const 37) 7 | ) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/passes/O1.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (memory $0 1 1) 4 | (export "foo" (func $0)) 5 | (func $0 (result i32) 6 | (drop 7 | (i32.const 0) 8 | ) 9 | (i32.load align=1 10 | (i32.const 4) 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /binaryen/test/passes/memory-packing_all-features_zero-filled-memory.wast: -------------------------------------------------------------------------------- 1 | (module 2 | ;; we can optimize on an imported memory with zeroFilledMemory being set. 3 | (import "env" "memory" (memory $0 1 1)) 4 | (data (i32.const 1024) "x") 5 | (data (i32.const 1023) "\00") 6 | ) 7 | -------------------------------------------------------------------------------- /binaryen/test/reg_switch.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (memory $0 0) 4 | (func $0 (type $0) 5 | (if 6 | (i32.const 0) 7 | (block $A 8 | (br_table $A 9 | (i32.const 0) 10 | ) 11 | ) 12 | ) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/reg_switch.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 0) 4 | (func $0 5 | (if 6 | (i32.const 0) 7 | (block $label$2 8 | (br_table $label$2 9 | (i32.const 0) 10 | ) 11 | ) 12 | ) 13 | ) 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/BinaryFormat/ELFRelocs/BPF.def: -------------------------------------------------------------------------------- 1 | #ifndef ELF_RELOC 2 | #error "ELF_RELOC must be defined" 3 | #endif 4 | 5 | // No relocation 6 | ELF_RELOC(R_BPF_NONE, 0) 7 | ELF_RELOC(R_BPF_64_64, 1) 8 | ELF_RELOC(R_BPF_64_32, 10) 9 | -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/Config/llvm-config.h: -------------------------------------------------------------------------------- 1 | 2 | // This is all terrible 3 | 4 | #ifndef _WIN32 5 | #define LLVM_ON_UNIX 6 | #endif 7 | 8 | // Use simple std:: based atomics, no windows specifics 9 | #define LLVM_THREADING_USE_STD_CALL_ONCE 1 10 | -------------------------------------------------------------------------------- /binaryen/test/atomics-unshared.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 1 1) 4 | (func $foo 5 | (drop 6 | (i32.atomic.rmw.cmpxchg 7 | (i32.const 0) 8 | (i32.const 0) 9 | (i32.const 0) 10 | ) 11 | ) 12 | ) 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/i64-ctz.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "a" (func $popcnt64)) 3 | (export "b" (func $ctz64)) 4 | (func $popcnt64 (param $0 i64) (result i64) 5 | (i64.popcnt (local.get $0))) 6 | (func $ctz64 (param $0 i64) (result i64) 7 | (i64.ctz (local.get $0))) 8 | ) 9 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_store3.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 256 256) 3 | (data (i32.const 10) "waka waka waka waka waka") 4 | (export "test1" $test1) 5 | (func $test1 6 | (i32.store16 (i32.const 33) (i32.const 109)) ;; after last segment due to size of type 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /binaryen/test/duplicate_types.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_none (func (param i32))) 3 | (type $i32_=>_i32 (func (param i32) (result i32))) 4 | (func $f0 (param $0 i32) 5 | (nop) 6 | ) 7 | (func $f1 (param $0 i32) (result i32) 8 | (i32.const 0) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/export-import.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "test2" (global $gimport$0 i32)) 4 | (import "env" "test1" (func $fimport$0)) 5 | (export "test1" (func $fimport$0)) 6 | (export "test2" (global $gimport$0)) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /binaryen/test/atomics-unshared.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 1 1) 4 | (func $0 5 | (drop 6 | (i32.atomic.rmw.cmpxchg 7 | (i32.const 0) 8 | (i32.const 0) 9 | (i32.const 0) 10 | ) 11 | ) 12 | ) 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /binaryen/test/calls.txt: -------------------------------------------------------------------------------- 1 | simple 2 | 1 ==> 3 3 | 2 ==> 6 4 | 3 ==> 11 5 | 4 ==> 18 6 | 7 ==> 51 7 | fibo 8 | 1 ==> 1 9 | 2 ==> 2 10 | 3 ==> 3 11 | 4 ==> 5 12 | 7 ==> 21 13 | run_script 14 | hello from called script 15 | 9 16 | too many/few arguments 17 | 2 18 | 102 19 | -------------------------------------------------------------------------------- /binaryen/test/lld/shared.cpp: -------------------------------------------------------------------------------- 1 | extern "C" int puts(const char* str); 2 | extern "C" int external_var; 3 | 4 | int print_message() { 5 | puts("Hello, world"); 6 | return external_var; 7 | } 8 | 9 | void* ptr_puts = (void*)&puts; 10 | void* ptr_local_func = (void*)&print_message; 11 | -------------------------------------------------------------------------------- /binaryen/test/metadce/spanning_cycle_unrooted.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "wasm_export", 4 | "export": "wasm_func_a" 5 | }, 6 | { 7 | "name": "outside_js_function", 8 | "reaches": ["wasm_export"], 9 | "import": ["env", "js_func"] 10 | } 11 | ] 12 | 13 | -------------------------------------------------------------------------------- /binaryen/test/passes/O_all-features_ignore-implicit-traps.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type ${i32} (struct (field i32))) 3 | (type $ref?|{i32}|_=>_none (func (param (ref null ${i32})))) 4 | (export "foo" (func $0)) 5 | (func $0 (; has Stack IR ;) (param $0 (ref null ${i32})) 6 | (nop) 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /binaryen/test/passes/reorder-functions.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 256 256) 4 | (func $c 5 | (call $c) 6 | (call $c) 7 | (call $c) 8 | ) 9 | (func $b 10 | (call $b) 11 | (call $b) 12 | ) 13 | (func $a 14 | (call $a) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/reg_switch.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 0) 4 | (func $0 5 | (if 6 | (i32.const 0) 7 | (block $label$2 8 | (br_table $label$2 9 | (i32.const 0) 10 | ) 11 | ) 12 | ) 13 | ) 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/asyncify-pure.txt: -------------------------------------------------------------------------------- 1 | 100 : i32 2 | 10 : i32 3 | 1 : i32 4 | 20 : i32 5 | 1000 : i32 6 | 2000 : i32 7 | 4000 : i32 8 | 200 : i32 9 | 300 : i32 10 | 400 : i32 11 | 1000 : i32 12 | 3000 : i32 13 | 4000 : i32 14 | 30 : i32 15 | 2 : i32 16 | 40 : i32 17 | 500 : i32 18 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/simd.js: -------------------------------------------------------------------------------- 1 | var module = new binaryen.Module(); 2 | 3 | var expr = module.v128.const([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]); 4 | var info = binaryen.getExpressionInfo(expr); 5 | console.log("v128.const i8x16 0x" + info.value.map(b => b.toString(16)).join(" 0x")); 6 | -------------------------------------------------------------------------------- /binaryen/test/duplicate_types.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_none (func (param i32))) 3 | (type $i32_=>_i32 (func (param i32) (result i32))) 4 | (func $f0 (param $0 i32) 5 | (nop) 6 | ) 7 | (func $f1 (param $0 i32) (result i32) 8 | (i32.const 0) 9 | ) 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /binaryen/test/duplicated_names.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (func $foo (result i32) 4 | (i32.const 0) 5 | ) 6 | (func $foo.1 (result i32) 7 | (i32.const 1) 8 | ) 9 | (func $foo.2 (result i32) 10 | (i32.const 2) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/metadce/rooted-export.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "rooted-export-func", 4 | "root": true, 5 | "export": "wasm_func_b" 6 | }, 7 | { 8 | "name": "rooted-export-event", 9 | "root": true, 10 | "export": "wasm_event_b" 11 | } 12 | ] 13 | 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG for `binaryen` 2 | 3 | ## 0.0.1.1 4 | 5 | - Fix a runtime error when linking against `version_92` or above due to a 6 | breaking [change](https://github.com/WebAssembly/binaryen/pull/2745) in 7 | upstream C API. 8 | 9 | ## 0.0.1.0 10 | 11 | - Initial release. 12 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/validation_errors.js.txt: -------------------------------------------------------------------------------- 1 | [wasm-validator error in function test] unexpected false: global.get name must be valid, on 2 | (global.get $missing) 3 | 0 4 | [wasm-validator error in function test] unexpected false: local.get index must be small enough, on 5 | (local.get $0) 6 | 0 7 | -------------------------------------------------------------------------------- /binaryen/test/passes/merge-blocks_remove-unused-brs.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $func (param $x i32) 3 | (block $out 4 | (loop $loop 5 | (br_if $out 6 | (local.get $x) 7 | ) 8 | (nop) 9 | (br $loop) 10 | ) 11 | ) 12 | ) 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /binaryen/test/passes/vacuum_remove-unused-names_merge-blocks.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_i32 (func (param i32) (result i32))) 3 | (func $return-block (param $x i32) (result i32) 4 | (local.set $x 5 | (local.get $x) 6 | ) 7 | (return 8 | (local.get $x) 9 | ) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/global_i64.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (global $f (mut i64) (i64.const 0x12345678ABCDEFAF)) 3 | (global $g (mut i64) (global.get $f)) 4 | (func $call (param i64)) 5 | (func "exp" 6 | (call $call (global.get $f)) 7 | (global.set $f (i64.const 0x1122334455667788)) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/src/ir/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB ir_HEADERS *.h) 2 | set(ir_SOURCES 3 | ExpressionAnalyzer.cpp 4 | ExpressionManipulator.cpp 5 | LocalGraph.cpp 6 | ReFinalize.cpp 7 | stack-utils.cpp 8 | module-splitting.cpp 9 | ${ir_HEADERS} 10 | ) 11 | add_library(ir OBJECT ${ir_SOURCES}) 12 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/basics.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 256 256) 4 | (data (i32.const 10) "nas\00\00\00aka yzkx waka wakm\00\00\00\00\00\00C") 5 | (func $call-indirect 6 | (i32.store8 7 | (i32.const 40) 8 | (i32.const 67) 9 | ) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/duplicate_types.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_none (func (param i32))) 3 | (type $i32_=>_i32 (func (param i32) (result i32))) 4 | (func $0 (param $0 i32) 5 | (nop) 6 | ) 7 | (func $1 (param $0 i32) (result i32) 8 | (i32.const 0) 9 | ) 10 | ) 11 | 12 | -------------------------------------------------------------------------------- /binaryen/test/duplicated_names_collision.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (func $foo (result i32) 4 | (i32.const 0) 5 | ) 6 | (func $foo.1 (result i32) 7 | (i32.const 1) 8 | ) 9 | (func $foo.1.1 (result i32) 10 | (i32.const 2) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/hello_world.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 3 | (memory $0 256 256) 4 | (export "add" (func $add)) 5 | (func $add (param $x i32) (param $y i32) (result i32) 6 | (i32.add 7 | (local.get $x) 8 | (local.get $y) 9 | ) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/mutable-global.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "global-mut" (global $global-mut (mut i32))) 4 | (func $foo 5 | (global.set $global-mut 6 | (i32.add 7 | (global.get $global-mut) 8 | (i32.const 1) 9 | ) 10 | ) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /binaryen/test/tail-call.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (table $0 1 1 funcref) 4 | (elem (i32.const 0) $foo) 5 | (func $foo 6 | (return_call $bar) 7 | ) 8 | (func $bar 9 | (return_call_indirect (type $none_=>_none) 10 | (i32.const 0) 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/imported3.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 256 256) 4 | (data (i32.const 10) "waka waka waka waka waka") 5 | (export "test1" (func $test1)) 6 | (func $test1 7 | (i32.store8 8 | (i32.const 13) 9 | (i32.const 115) 10 | ) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /binaryen/test/mutable-global.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "global-mut" (global $gimport$0 (mut i32))) 4 | (func $0 5 | (global.set $gimport$0 6 | (i32.add 7 | (global.get $gimport$0) 8 | (i32.const 1) 9 | ) 10 | ) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/newsyntax.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "table" (table 9 9 funcref)) 3 | (func "call_indirect" 4 | (drop 5 | (call_indirect (param i32) (param f64) (result i32) (i32.const 10) (f64.const 20) (i32.const 30)) 6 | ) 7 | (call_indirect (i32.const 1)) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/test/tail-call.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (table $0 1 1 funcref) 4 | (elem (i32.const 0) $foo) 5 | (func $foo 6 | (return_call $bar) 7 | ) 8 | (func $bar 9 | (return_call_indirect (type $none_=>_none) 10 | (i32.const 0) 11 | ) 12 | ) 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /binaryen/ubsan.blacklist: -------------------------------------------------------------------------------- 1 | # Work around libstdc++ bug: https://llvm.org/bugs/show_bug.cgi?id=18156 2 | # Also see: http://lists.llvm.org/pipermail/cfe-dev/2015-January/040945.html 3 | src:*/ios_base.h 4 | # Work around another libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60734 5 | src:*/stl_tree.h 6 | -------------------------------------------------------------------------------- /nix/binaryenOverlay.nix: -------------------------------------------------------------------------------- 1 | let 2 | sources = import ./sources.nix { }; 3 | in 4 | self: super: 5 | { 6 | binaryen = super.binaryen.overrideAttrs (oldAttrs: { 7 | version = "99"; 8 | src = sources.binaryen; 9 | patches = [ 10 | ./binaryen-3481-fix.patch 11 | ]; 12 | }); 13 | } 14 | -------------------------------------------------------------------------------- /binaryen/src/emscripten-optimizer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB emscripten-optimizer_HEADERS *.h) 2 | set(emscripten-optimizer_SOURCES 3 | optimizer-shared.cpp 4 | parser.cpp 5 | simple_ast.cpp 6 | ${emscripten-optimizer_HEADERS} 7 | ) 8 | add_library(emscripten-optimizer OBJECT ${emscripten-optimizer_SOURCES}) 9 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/basics-flatten.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 256 256) 4 | (data (i32.const 10) "nas\00\00\00aka\00yzkx waka wakm\00\00\00\00\00\00C") 5 | (func $call-indirect 6 | (i32.store8 7 | (i32.const 40) 8 | (i32.const 67) 9 | ) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/mutable-global.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "global-mut" (global $global-mut (mut i32))) 4 | (func $foo (type $0) 5 | (global.set $global-mut 6 | (i32.add 7 | (global.get $global-mut) 8 | (i32.const 1) 9 | ) 10 | ) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /binaryen/test/mutable-global.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "global-mut" (global $global-mut (mut i32))) 4 | (func $foo 5 | (global.set $global-mut 6 | (i32.add 7 | (global.get $global-mut) 8 | (i32.const 1) 9 | ) 10 | ) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/tail-call.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (table $0 1 1 funcref) 4 | (elem (i32.const 0) $0) 5 | (func $0 6 | (return_call $1) 7 | ) 8 | (func $1 9 | (return_call_indirect (type $none_=>_none) 10 | (i32.const 0) 11 | ) 12 | ) 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /binaryen/test/untaken-br_if.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $binaryify-untaken-br_if (result f32) 3 | (if (result f32) 4 | (i32.const 1) 5 | (unreachable) 6 | (block $label$1 (result f32) 7 | (br_if $label$1 8 | (f32.const 1) 9 | (unreachable) 10 | ) 11 | ) 12 | ) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/mutable-global.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "global-mut" (global $gimport$0 (mut i32))) 4 | (func $0 5 | (global.set $gimport$0 6 | (i32.add 7 | (global.get $gimport$0) 8 | (i32.const 1) 9 | ) 10 | ) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/passes/roundtrip.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func "foo" 3 | ;; binaryen skips unreachable code while reading the binary format 4 | (unreachable) 5 | (nop) 6 | (nop) 7 | (nop) 8 | (nop) 9 | (nop) 10 | ) 11 | ) 12 | 13 | (module 14 | (memory 1 1) 15 | (table 0 funcref) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/reduce/simple.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "x" (func $x)) 3 | (func $x (result i32) 4 | (nop) 5 | (nop) 6 | (nop) 7 | (drop (i32.const 1234)) 8 | (i32.const 5678) ;; easily reducible 9 | ) 10 | (func $not-exported 11 | (nop) 12 | (unreachable) 13 | ) 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/hello_world.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 3 | (memory $0 256 256) 4 | (export "add" (func $add)) 5 | (func $add (param $x i32) (param $y i32) (result i32) 6 | (i32.add 7 | (local.get $x) 8 | (local.get $y) 9 | ) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/break-within-catch.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (func $0 4 | (block $label$2 5 | (try 6 | (do 7 | (nop) 8 | ) 9 | (catch 10 | (drop 11 | (pop exnref) 12 | ) 13 | (br $label$2) 14 | ) 15 | ) 16 | ) 17 | ) 18 | ) 19 | 20 | -------------------------------------------------------------------------------- /binaryen/test/hello_world.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 3 | (memory $0 256 256) 4 | (export "add" (func $add)) 5 | (func $add (; 0 ;) (param $x i32) (param $y i32) (result i32) 6 | (i32.add 7 | (local.get $x) 8 | (local.get $y) 9 | ) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/passes/generate-dyncalls.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "invoke_vii" (func $invoke_vii (param i32 i32 i32))) 3 | (func $f1 (result i32) 4 | (i32.const 1024) 5 | ) 6 | (func $f2 (param i32) (result i64) 7 | (i64.const 42) 8 | ) 9 | (table 2 2 funcref) 10 | (elem (i32.const 0) $f1 $f2) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/passes/reorder-functions.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 256 256) 3 | (type $0 (func)) 4 | (func $a (type $0) 5 | (call $a) 6 | ) 7 | (func $b (type $0) 8 | (call $b) 9 | (call $b) 10 | ) 11 | (func $c (type $0) 12 | (call $c) 13 | (call $c) 14 | (call $c) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/empty_lld.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (global $global$0 (mut i32) (i32.const 66192)) 3 | (global $global$1 i32 (i32.const 652)) 4 | (export "__data_end" (global $global$1)) 5 | (export "main" (func $main)) 6 | (func $main (param $0 i32) (param $1 i32) (result i32) 7 | (i32.const 0) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/test/fn_prolog_epilog.debugInfo.wast: -------------------------------------------------------------------------------- 1 | (module 2 | ;;@ src.cpp:1:1 3 | (func 4 | (nop) 5 | ;;@ src.cpp:2:1 6 | (block $l0 7 | ;;@ src.cpp:2:2 8 | (block $l1 9 | (br $l1) 10 | ) 11 | ) 12 | ;;@ src.cpp:3:1 13 | (return) 14 | ;;@ src.cpp:3:2 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/reduce/destructive.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "x" (func $x)) 3 | (func $x (param $x i32) (result i32) 4 | (if (i32.eq (local.get $x) (i32.const 98658746)) 5 | (unreachable) ;; this can be removed destructively, since we do not sent this param 6 | ) 7 | (i32.const 100) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /binaryen/src/js/binaryen.js-extern-post.js: -------------------------------------------------------------------------------- 1 | 2 | })(); 3 | if (typeof exports === 'object' && typeof module === 'object') 4 | module.exports = binaryen; 5 | else if (typeof define === 'function' && define['amd']) 6 | define([], function() { return binaryen; }); 7 | else if (typeof exports === 'object') 8 | exports["binaryen"] = binaryen; -------------------------------------------------------------------------------- /binaryen/test/consume-stacky.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (memory $0 1 1) 4 | (func $0 (result i32) 5 | (local $0 i32) 6 | (local.set $0 7 | (i32.const 1) 8 | ) 9 | (i32.store 10 | (i32.const 2) 11 | (i32.const 3) 12 | ) 13 | (local.get $0) 14 | ) 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/no_partial.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 256 256) 4 | (data (i32.const 10) "waka waka waka waka waka") 5 | (export "test1" (func $test1)) 6 | (func $test1 7 | (i32.store8 8 | (i32.const 12) 9 | (i32.const 115) 10 | ) 11 | (unreachable) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /binaryen/test/hello_world.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 3 | (memory $0 256 256) 4 | (export "add" (func $add)) 5 | (func $add (; 0 ;) (param $0 i32) (param $1 i32) (result i32) 6 | (i32.add 7 | (local.get $0) 8 | (local.get $1) 9 | ) 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/add_div.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "foo" (func $foo (param i32) (result i32))) 3 | (func $foo (param $0 i32) (result i32) 4 | (i32.add 5 | (i32.div_u 6 | (local.get $0) 7 | (i32.const 100) 8 | ) 9 | (i32.div_s 10 | (local.get $0) 11 | (i32.const -100) 12 | ) 13 | ) 14 | ) 15 | ) -------------------------------------------------------------------------------- /binaryen/test/hello_world.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 3 | (memory $0 256 256) 4 | (export "add" (func $0)) 5 | (func $0 (; 0 ;) (param $0 i32) (param $1 i32) (result i32) 6 | (i32.add 7 | (local.get $0) 8 | (local.get $1) 9 | ) 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /binaryen/test/passes/merge-blocks_remove-unused-brs.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_none (func (param i32))) 3 | (func $func (param $x i32) 4 | (loop $loop 5 | (block $out 6 | (block 7 | (br_if $out 8 | (local.get $x) 9 | ) 10 | (nop) 11 | (br $loop) 12 | ) 13 | ) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/br_table_to_loop.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func "exp1" 3 | (block $block 4 | (loop $loop 5 | (br_table $block $loop $block (i32.const 1)) 6 | ) 7 | ) 8 | ) 9 | (func "exp2" 10 | (block $block 11 | (loop $loop 12 | (br_table $loop $block $loop (i32.const 1)) 13 | ) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/fn_prolog_epilog.debugInfo.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | ;;@ src.cpp:1:1 4 | (func $0 5 | (nop) 6 | ;;@ src.cpp:2:1 7 | (block $l0 8 | ;;@ src.cpp:2:2 9 | (block $l1 10 | (br $l1) 11 | ) 12 | ) 13 | ;;@ src.cpp:3:1 14 | (return) 15 | ;;@ src.cpp:3:2 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /binaryen/test/lld/shared_longjmp.c: -------------------------------------------------------------------------------- 1 | typedef struct jmp_buf_buf { 2 | int thing; 3 | } jmp_buf; 4 | 5 | void longjmp(jmp_buf env, int val); 6 | int setjmp(jmp_buf env); 7 | 8 | int __THREW__; 9 | int __threwValue; 10 | 11 | void _start() { 12 | jmp_buf jmp; 13 | if (setjmp(jmp) == 0) { 14 | longjmp(jmp, 1); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /binaryen/test/metadce/rooted-export.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (type $i32_=>_none (func (param i32))) 4 | (event $b_wasm_event (attr 0) (param i32)) 5 | (export "wasm_func_b" (func $b_wasm_func)) 6 | (export "wasm_event_b" (event $b_wasm_event)) 7 | (func $b_wasm_func 8 | (unreachable) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/spec/break-drop.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func (export "br") (block (br 0))) 3 | (func (export "br_if") (block (br_if 0 (i32.const 1)))) 4 | (func (export "br_table") (block (br_table 0 (i32.const 0)))) 5 | ) 6 | 7 | (assert_return (invoke "br")) 8 | (assert_return (invoke "br_if")) 9 | (assert_return (invoke "br_table")) 10 | -------------------------------------------------------------------------------- /binaryen/test/lld/longjmp.c: -------------------------------------------------------------------------------- 1 | typedef struct jmp_buf_buf { 2 | int thing; 3 | } jmp_buf; 4 | 5 | void longjmp(jmp_buf env, int val); 6 | int setjmp(jmp_buf env); 7 | 8 | int __THREW__; 9 | int __threwValue; 10 | 11 | int main() { 12 | jmp_buf jmp; 13 | if (setjmp(jmp) == 0) { 14 | longjmp(jmp, 1); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /binaryen/test/passes/O_all-features.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type ${i32} (struct (field i32))) 3 | (type $ref?|{i32}|_=>_none (func (param (ref null ${i32})))) 4 | (export "foo" (func $0)) 5 | (func $0 (; has Stack IR ;) (param $0 (ref null ${i32})) 6 | (drop 7 | (struct.get ${i32} 0 8 | (local.get $0) 9 | ) 10 | ) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/deterministic.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (global $global$0 (mut i32) (i32.const -44)) 3 | (import "env" "memory" (memory $0 1 1)) 4 | (func "foo" (result i32) 5 | (if 6 | (i32.div_u 7 | (global.get $global$0) 8 | (i32.load (i32.const 0)) 9 | ) 10 | (unreachable) 11 | ) 12 | (i32.const 1) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/sourcemap.js.txt: -------------------------------------------------------------------------------- 1 | module.c 2 | 3 | 000: 00 a s m 01 00 00 00 01 05 01 ` 00 01 7f 03 4 | 010: 02 01 00 0a 06 01 04 00 A 01 0b 00 ! 10 s o 5 | 020: u r c e M a p p i n g U R L 0f m 6 | 030: o d u l e . w a s m . m a p 7 | 8 | {"version":3,"sources":["module.c"],"names":[],"mappings":"wBAAE"} 9 | -------------------------------------------------------------------------------- /binaryen/test/lit/wasm-split/instrument-memory-too-small.wast: -------------------------------------------------------------------------------- 1 | ;; Test that the instrumentation increases the memory bounds if necessary 2 | 3 | ;; RUN: wasm-split %s --instrument -S -o - | filecheck %s 4 | 5 | ;; CHECK: (memory $0 1 1) 6 | ;; CHECK: (export "__write_profile" (func $__write_profile)) 7 | 8 | (module 9 | (memory $0 0 0) 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/passes/safe-heap_start-function.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1 1) 3 | (func $foo 4 | ;; should not be modified because its the start function 5 | (i32.store (i32.load (i32.const 1234)) (i32.const 5678)) 6 | ) 7 | (func $bar 8 | (i32.store (i32.load (i32.const 1234)) (i32.const 5678)) 9 | ) 10 | (start $foo) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/stack_ir.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "bar" (func $bar (param i32) (result i32))) 3 | (func "foo1" (result i32) 4 | (local $x i32) 5 | (local.set $x (call $bar (i32.const 0))) 6 | (drop 7 | (call $bar (i32.const 1)) 8 | ) 9 | (local.get $x) ;; local2stack can help here 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /binaryen/test/untaken-br_if.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_f32 (func (result f32))) 3 | (func $0 (result f32) 4 | (if (result f32) 5 | (i32.const 1) 6 | (unreachable) 7 | (block $label$3 (result f32) 8 | (drop 9 | (f32.const 1) 10 | ) 11 | (unreachable) 12 | ) 13 | ) 14 | ) 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/unreachable-insts.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param f64 f64 f32))) 3 | (memory $0 1 1) 4 | (func $0 (; 0 ;) (type $0) (param $0 f64) (param $1 f64) (param $2 f32) 5 | (f64.store offset=22 align=1 6 | (block $label$1 (result i32) 7 | (unreachable) 8 | ) 9 | (f64.const 1) 10 | ) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/third_party/wabt/wasm2c/README.md: -------------------------------------------------------------------------------- 1 | These files are part of WABT, but are currently not present in releases, so the 2 | directory is included as a fallback in Binaryen in a way that the files will be 3 | overwritten in case WABT contains them in the future. 4 | 5 | Original README: https://github.com/WebAssembly/wabt/blob/master/wasm2c/README.md 6 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/emit_asmjs.js: -------------------------------------------------------------------------------- 1 | var module = new binaryen.Module(); 2 | 3 | module.addFunction("main", binaryen.i32, binaryen.i32, [], module.local.get(0, binaryen.i32)); 4 | 5 | module.addFunctionExport("main", "main"); 6 | 7 | assert(module.validate()); // should validate before calling emitAsmjs 8 | 9 | console.log(module.emitAsmjs()); 10 | -------------------------------------------------------------------------------- /binaryen/test/metadce/corners.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "ignorable import", 4 | "import": ["non", "existent"] 5 | }, 6 | { 7 | "name": "imported_twice", 8 | "import": ["env", "imported_twice"] 9 | }, 10 | { 11 | "name": "stackAllocGood", 12 | "export": "stackAlloc", 13 | "root": true 14 | } 15 | ] 16 | 17 | -------------------------------------------------------------------------------- /binaryen/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: LLVM 4 | PointerAlignment: Left 5 | IndentCaseLabels: true 6 | ContinuationIndentWidth: 2 7 | ConstructorInitializerIndentWidth: 2 8 | SpaceAfterTemplateKeyword: false 9 | BinPackArguments: false 10 | BinPackParameters: false 11 | --- 12 | Language: JavaScript 13 | DisableFormat: true 14 | --- 15 | -------------------------------------------------------------------------------- /binaryen/src/support/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB support_HEADERS *.h) 2 | set(support_SOURCES 3 | archive.cpp 4 | bits.cpp 5 | colors.cpp 6 | command-line.cpp 7 | debug.cpp 8 | file.cpp 9 | path.cpp 10 | safe_integer.cpp 11 | threads.cpp 12 | utilities.cpp 13 | ${support_HEADERS} 14 | ) 15 | add_library(support OBJECT ${support_SOURCES}) 16 | -------------------------------------------------------------------------------- /binaryen/test/fn_prolog_epilog.debugInfo.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | ;;@ src.cpp:1:1 4 | (func $0 5 | (nop) 6 | ;;@ src.cpp:2:1 7 | (block $label$1 8 | ;;@ src.cpp:2:2 9 | (block $label$2 10 | (br $label$2) 11 | ) 12 | ) 13 | ;;@ src.cpp:3:1 14 | (return) 15 | ;;@ src.cpp:3:2 16 | ) 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /binaryen/test/lld/main_module_table.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "__stack_pointer" (global $sp (mut i32))) 3 | (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) 4 | (global $global i32 (i32.const 42)) 5 | (export "__stdio_write" (func $__stdio_write)) 6 | (export "__data_end" (global $global)) 7 | (func $__stdio_write 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /binaryen/test/untaken-br_if.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_f32 (func (result f32))) 3 | (func $binaryify-untaken-br_if (result f32) 4 | (if (result f32) 5 | (i32.const 1) 6 | (unreachable) 7 | (block $label$3 (result f32) 8 | (drop 9 | (f32.const 1) 10 | ) 11 | (unreachable) 12 | ) 13 | ) 14 | ) 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/Support/Locale.h: -------------------------------------------------------------------------------- 1 | #ifndef LLVM_SUPPORT_LOCALE_H 2 | #define LLVM_SUPPORT_LOCALE_H 3 | 4 | namespace llvm { 5 | class StringRef; 6 | 7 | namespace sys { 8 | namespace locale { 9 | 10 | int columnWidth(StringRef s); 11 | bool isPrint(int c); 12 | 13 | } 14 | } 15 | } 16 | 17 | #endif // LLVM_SUPPORT_LOCALE_H 18 | -------------------------------------------------------------------------------- /binaryen/scripts/test/env.js: -------------------------------------------------------------------------------- 1 | // This is the name by which the tests import the wasm table. 2 | export const table = []; 3 | 4 | var tempRet0 = 0; 5 | 6 | export function setTempRet0(x) { 7 | tempRet0 = x; 8 | } 9 | 10 | export function getTempRet0() { 11 | return tempRet0; 12 | } 13 | 14 | export const memoryBase = 0; 15 | export const tableBase = 0; 16 | -------------------------------------------------------------------------------- /binaryen/test/untaken-br_if.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_f32 (func (result f32))) 3 | (func $binaryify-untaken-br_if (result f32) 4 | (if (result f32) 5 | (i32.const 1) 6 | (unreachable) 7 | (block $label$1 (result f32) 8 | (br_if $label$1 9 | (f32.const 1) 10 | (unreachable) 11 | ) 12 | ) 13 | ) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/Support/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | LLVM System Interface Library 2 | ------------------------------------------------------------------------------- 3 | The LLVM System Interface Library is licensed under the Illinois Open Source 4 | License and has the following additional copyright: 5 | 6 | Copyright (C) 2004 eXtensible Systems, Inc. 7 | -------------------------------------------------------------------------------- /binaryen/test/fannkuch.txt: -------------------------------------------------------------------------------- 1 | 12345 2 | 21345 3 | 23145 4 | 32145 5 | 31245 6 | 13245 7 | 23415 8 | 32415 9 | 34215 10 | 43215 11 | 42315 12 | 24315 13 | 34125 14 | 43125 15 | 41325 16 | 14325 17 | 13425 18 | 31425 19 | 41235 20 | 14235 21 | 12435 22 | 21435 23 | 24135 24 | 42135 25 | 23451 26 | 32451 27 | 34251 28 | 43251 29 | 42351 30 | 24351 31 | Pfannkuchen(5) = 7. 32 | -------------------------------------------------------------------------------- /binaryen/test/signext.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (func $signext (type $0) 4 | (local $0 i32) 5 | (local $1 i64) 6 | (drop (i32.extend8_s (local.get $0))) 7 | (drop (i32.extend16_s (local.get $0))) 8 | (drop (i64.extend8_s (local.get $1))) 9 | (drop (i64.extend16_s (local.get $1))) 10 | (drop (i64.extend32_s (local.get $1))) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /nix/nixpkgs.nix: -------------------------------------------------------------------------------- 1 | { sources ? import ./sources.nix { } 2 | , binaryenOverlay ? import ./binaryenOverlay.nix 3 | , haskellNix ? import sources.haskell-nix { } 4 | , nixpkgsSrc ? haskellNix.sources.nixpkgs-2009 5 | , nixpkgsArgs ? haskellNix.nixpkgsArgs // { overlays = haskellNix.nixpkgsArgs.overlays ++ [ binaryenOverlay ]; } 6 | , pkgs ? import nixpkgsSrc nixpkgsArgs 7 | }: pkgs 8 | -------------------------------------------------------------------------------- /binaryen/test/metadce/no-outside.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "js_func" (func $a_js_func)) 3 | (import "env" "js_func_unused" (func $an_unused_js_func)) 4 | (export "wasm_func" (func $a_wasm_func)) 5 | (export "wasm_func_unused" (func $an_unused_wasm_func)) 6 | (func $a_wasm_func 7 | (call $a_js_func) 8 | ) 9 | (func $an_unused_wasm_func 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /binaryen/test/passes/minify-imports-and-exports-and-modules.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 256 256)) 3 | (import "env" "table" (table $0 4 funcref)) 4 | (import "env" "longname1" (func $internal1)) 5 | (import "env" "longname2" (func $internal2)) 6 | (import "env" "longname3" (func $internal3)) 7 | (import "other" "longname4" (func $internal4)) 8 | ) 9 | -------------------------------------------------------------------------------- /binaryen/test/metadce/spanning_cycle.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "root", 4 | "root": true, 5 | "reaches": ["wasm_export"], 6 | }, 7 | { 8 | "name": "wasm_export", 9 | "export": "wasm_func_a" 10 | }, 11 | { 12 | "name": "outside_js_function", 13 | "reaches": ["wasm_export"], 14 | "import": ["env", "js_func"] 15 | } 16 | ] 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/passes/untee.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $tee 3 | (local $x i32) 4 | (local $y f64) 5 | (drop (local.tee $x (i32.const 1))) 6 | (drop (local.tee $y (f64.const 2))) 7 | (local.set $x (local.tee $x (i32.const 3))) 8 | (local.set $x (local.tee $x (local.tee $x (i32.const 3)))) 9 | (drop (local.tee $x (unreachable))) 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /binaryen/test/passes/vacuum_ignore-implicit-traps.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (type $none_=>_i32 (func (result i32))) 4 | (memory $0 1) 5 | (func $load-would-normally-have-side-effects (result i32) 6 | (i64.ge_s 7 | (i64.const 2912825531628789796) 8 | (i64.const 0) 9 | ) 10 | ) 11 | (func $unary-binary-may-trap 12 | (nop) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/reduce/imports.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "func" (func $import)) 3 | (export "x" (func $x)) 4 | (func $x (result i32) 5 | (nop) 6 | (nop) 7 | (nop) 8 | (call $import) 9 | (drop (i32.const 1234)) 10 | (i32.const 5678) ;; easily reducible 11 | ) 12 | (func $not-exported 13 | (nop) 14 | (unreachable) 15 | ) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/just_some.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 256 256) 4 | (data (i32.const 10) "wasa waka waka waka waka") 5 | (export "test2" (func $test2)) 6 | (export "test3" (func $test3)) 7 | (func $test2 8 | (unreachable) 9 | ) 10 | (func $test3 11 | (i32.store8 12 | (i32.const 13) 13 | (i32.const 113) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/example/stack-utils.txt: -------------------------------------------------------------------------------- 1 | ;; Test removeNops 2 | (block (result i32 i64) 3 | (nop) 4 | (i32.const 0) 5 | (nop) 6 | (i64.const 0) 7 | (nop) 8 | (nop) 9 | ) 10 | (block (result i32 i64) 11 | (i32.const 0) 12 | (i64.const 0) 13 | ) 14 | ;; Test stack signatures 15 | ;; Test stack signature composition 16 | ;; Test stack signature satisfaction 17 | ;; Test stack flow 18 | -------------------------------------------------------------------------------- /binaryen/test/spec/ref_null.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func (export "externref") (result externref) (ref.null extern)) 3 | (func (export "funcref") (result funcref) (ref.null func)) 4 | 5 | (global externref (ref.null extern)) 6 | (global funcref (ref.null func)) 7 | ) 8 | 9 | (assert_return (invoke "externref") (ref.null extern)) 10 | (assert_return (invoke "funcref") (ref.null func)) 11 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/reloc.js.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "memory_base" (global $memory_base i32)) 4 | (import "env" "table_base" (global $table_base i32)) 5 | (memory $0 1) 6 | (data (global.get $memory_base) "data data") 7 | (table $0 1 funcref) 8 | (elem (global.get $table_base) $func $func) 9 | (func $func 10 | (nop) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/indirect-call3.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "tableBase" (global $tableBase i32)) 4 | (import "env" "_abort" (func $_abort)) 5 | (memory $0 256 256) 6 | (data (i32.const 10) "waka waka xaka waka waka\00\00\00\00\00\00C") 7 | (func $call-indirect 8 | (i32.store8 9 | (i32.const 40) 10 | (i32.const 67) 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /binaryen/test/passes/duplicate-import-elimination.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "waka" (func $foo)) 3 | (import "env" "waka" (func $bar)) 4 | (import "env" "waka" (func $wrong (param i32))) 5 | (table 2 2 funcref) 6 | (elem (i32.const 0) $foo $bar) 7 | (start $bar) 8 | (func "baz" 9 | (call $foo) 10 | (call $bar) 11 | (call $wrong (i32.const 1)) 12 | ) 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /binaryen/test/passes/remove-unused-brs_precompute_vacuum_remove-unused-brs.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_f64 (func (param i32) (result f64))) 3 | (global $global$3 (mut f64) (f64.const 0)) 4 | (func $1 (param $x i32) (result f64) 5 | (local $var$0 f64) 6 | (block $label$0 (result f64) 7 | (local.set $var$0 8 | (f64.const 0) 9 | ) 10 | (f64.const -3.4) 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /binaryen/test/spec/Contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to WebAssembly 2 | 3 | Interested in participating? Please follow 4 | [the same contributing guidelines as the design repository][]. 5 | 6 | [the same contributing guidelines as the design repository]: https://github.com/WebAssembly/design/blob/master/Contributing.md 7 | 8 | Also, please be sure to read [the README.md](README.md) for this repository. 9 | -------------------------------------------------------------------------------- /binaryen/test/break-to-return.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 3 | (memory $0 256 256) 4 | (export "add" (func $0)) 5 | (func $0 (param $0 i32) (param $1 i32) (result i32) 6 | (block $label$0 (result i32) 7 | (br $label$0 8 | (i32.add 9 | (local.get $0) 10 | (local.get $1) 11 | ) 12 | ) 13 | ) 14 | ) 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /binaryen/test/grow_memory.txt: -------------------------------------------------------------------------------- 1 | alloc 1MB: 0 2 | alloc 1MB: 1 3 | alloc 1MB: 2 4 | alloc 1MB: 3 5 | alloc 1MB: 4 6 | alloc 1MB: 5 7 | alloc 1MB: 6 8 | alloc 1MB: 7 9 | alloc 1MB: 8 10 | alloc 1MB: 9 11 | alloc 1MB: 10 12 | alloc 1MB: 11 13 | alloc 1MB: 12 14 | alloc 1MB: 13 15 | alloc 1MB: 14 16 | alloc 1MB: 15 17 | alloc 1MB: 16 18 | alloc 1MB: 17 19 | alloc 1MB: 18 20 | alloc 1MB: 19 21 | ok. 22 | 23 | -------------------------------------------------------------------------------- /binaryen/test/passes/asyncify_pass-arg=asyncify-blacklist@foo,bar.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1 2) 3 | (import "env" "import" (func $import)) 4 | (func $foo 5 | (call $import) 6 | ) 7 | (func $bar 8 | (call $import) 9 | ) 10 | (func $baz 11 | (call $import) 12 | ) 13 | (func $other1 14 | (call $foo) 15 | ) 16 | (func $other2 17 | (call $baz) 18 | ) 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /binaryen/test/passes/asyncify_pass-arg=asyncify-verbose.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1 2) 3 | (import "env" "import" (func $import)) 4 | (func $calls-import 5 | (call $import) 6 | ) 7 | (func $calls-calls-import 8 | (call $calls-import) 9 | ) 10 | (func $calls-calls-calls-import 11 | (call $calls-calls-import) 12 | ) 13 | (func $nothing 14 | (nop) 15 | ) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/passes/dealign.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 1 1) 3 | (func $test 4 | (drop (i32.load (i32.const 4))) 5 | (drop (i32.load align=1 (i32.const 8))) 6 | (drop (i32.load align=2 (i32.const 12))) 7 | (i32.store (i32.const 16) (i32.const 28)) 8 | (i32.store align=1 (i32.const 20) (i32.const 32)) 9 | (i32.store align=2 (i32.const 24) (i32.const 36)) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/passes/asyncify_pass-arg=asyncify-addlist@foo.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1 2) 3 | (import "env" "import" (func $import)) 4 | (func $foo ;; doesn't look like it needs instrumentation, but in add list 5 | (call $nothing) 6 | ) 7 | (func $bar ;; doesn't look like it needs instrumentation, and not in add list 8 | (call $nothing) 9 | ) 10 | (func $nothing 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/passes/dealign64.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 i64 1 1) 3 | (func $test 4 | (drop (i32.load (i64.const 4))) 5 | (drop (i32.load align=1 (i64.const 8))) 6 | (drop (i32.load align=2 (i64.const 12))) 7 | (i32.store (i64.const 16) (i32.const 28)) 8 | (i32.store align=1 (i64.const 20) (i32.const 32)) 9 | (i32.store align=2 (i64.const 24) (i32.const 36)) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/metadce/spanning_cycle.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "js_func" (func $a_js_func)) 4 | (memory $0 1 1) 5 | (data passive "Hello, datacount section!") 6 | (export "wasm_func_a" (func $a_wasm_func)) 7 | (func $a_wasm_func 8 | (memory.init 0 9 | (i32.const 0) 10 | (i32.const 0) 11 | (i32.const 25) 12 | ) 13 | (call $a_js_func) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /binaryen/test/metadce/threaded_unrooted.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: func$wasm_func_1$0 2 | unused: func$wasm_func_2$1 3 | unused: func$wasm_func_3$2 4 | unused: func$wasm_func_4$3 5 | unused: outside_js_function1 6 | unused: outside_js_function2 7 | unused: outside_js_function3 8 | unused: outside_js_function4 9 | unused: wasm_export1 10 | unused: wasm_export2 11 | unused: wasm_export3 12 | unused: wasm_export4 13 | -------------------------------------------------------------------------------- /binaryen/test/passes/safe-heap_disable-simd.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1 1) 3 | ) 4 | (module 5 | (memory 1 1) 6 | (import "env" "emscripten_get_sbrk_ptr" (func $foo (result i32))) 7 | ) 8 | (module 9 | (memory 1 1) 10 | (export "emscripten_get_sbrk_ptr" (func $foo)) 11 | (func $foo (result i32) 12 | (drop (i32.load (i32.const 0))) ;; should not be modified! 13 | (i32.const 1234) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /binaryen/test/lld/main_module_table_2.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "__stack_pointer" (global $sp (mut i32))) 3 | (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) 4 | (import "env" "table" (table $timport$9 1 funcref)) 5 | (global $global i32 (i32.const 42)) 6 | (export "__stdio_write" (func $__stdio_write)) 7 | (export "__data_end" (global $global)) 8 | (func $__stdio_write 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/metadce/threaded_unrooted_cycle.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: func$wasm_func_1$0 2 | unused: func$wasm_func_2$1 3 | unused: func$wasm_func_3$2 4 | unused: func$wasm_func_4$3 5 | unused: outside_js_function1 6 | unused: outside_js_function2 7 | unused: outside_js_function3 8 | unused: outside_js_function4 9 | unused: wasm_export1 10 | unused: wasm_export2 11 | unused: wasm_export3 12 | unused: wasm_export4 13 | -------------------------------------------------------------------------------- /binaryen/scripts/strip_local_names.py: -------------------------------------------------------------------------------- 1 | 2 | """Removes local names. When you don't care about local names but do want 3 | to diff for structural changes, this can help. 4 | """ 5 | 6 | import sys 7 | 8 | for line in open(sys.argv[1]).readlines(): 9 | if '(local.tee ' in line or '(local.set ' in line or '(local.get ' in line: 10 | print(line[:line.find('$')]) 11 | else: 12 | print(line.rstrip()) 13 | -------------------------------------------------------------------------------- /binaryen/src/wasm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB wasm_HEADERS ../*.h) 2 | set(wasm_SOURCES 3 | literal.cpp 4 | wasm.cpp 5 | wasm-binary.cpp 6 | wasm-debug.cpp 7 | wasm-emscripten.cpp 8 | wasm-debug.cpp 9 | wasm-interpreter.cpp 10 | wasm-io.cpp 11 | wasm-s-parser.cpp 12 | wasm-stack.cpp 13 | wasm-type.cpp 14 | wasm-validator.cpp 15 | ${wasm_HEADERS} 16 | ) 17 | add_library(wasm OBJECT ${wasm_SOURCES}) 18 | -------------------------------------------------------------------------------- /binaryen/test/lit/validation/shared-memory.wast: -------------------------------------------------------------------------------- 1 | ;; Test that shared memory requires atomics 2 | 3 | ;; RUN: not wasm-opt %s 2>&1 | filecheck %s --check-prefix NO-ATOMICS 4 | ;; RUN: wasm-opt %s --enable-threads -o - -S | filecheck %s --check-prefix ATOMICS 5 | 6 | ;; NO-ATOMICS: memory is shared, but atomics are disabled 7 | ;; ATOMICS: (memory $0 (shared 10 20)) 8 | 9 | (module 10 | (memory (shared 10 20)) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/lld/recursive.c: -------------------------------------------------------------------------------- 1 | // This test emits a stack pointer, which tests global importing in object files 2 | // (which are mutable and not normally allowed). 3 | 4 | int printf(const char* fmt, ...); 5 | 6 | __attribute__((noinline)) 7 | int foo(int a, int b) { 8 | printf("%d:%d\n", a, b); 9 | return a + b; 10 | } 11 | 12 | int main() { 13 | printf("Result: %d\n", foo(1, 2)); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /binaryen/test/passes/souperify.wast: -------------------------------------------------------------------------------- 1 | (module 2 | ;; This tests if we can create dataflow graph correctly in the presence of 3 | ;; loops. 4 | (func $if-loop-test (local $0 i32) 5 | (if 6 | (i32.const 0) 7 | (loop $label$0 8 | (local.set $0 9 | (i32.sub 10 | (i32.const 0) 11 | (i32.const 0) 12 | ) 13 | ) 14 | ) 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /binaryen/test/spec/ref_is_null.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $f1 (export "externref") (param $x externref) (result i32) 3 | (ref.is_null (local.get $x)) 4 | ) 5 | (func $f2 (export "funcref") (param $x funcref) (result i32) 6 | (ref.is_null (local.get $x)) 7 | ) 8 | ) 9 | 10 | (assert_return (invoke "externref" (ref.null extern)) (i32.const 1)) 11 | (assert_return (invoke "funcref" (ref.null func)) (i32.const 1)) 12 | -------------------------------------------------------------------------------- /binaryen/test/passes/strip-debug.bin.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (import "env" "__linear_memory" (memory $mimport$0 0)) 4 | (import "env" "__indirect_function_table" (table $timport$0 0 funcref)) 5 | (func $0 (result i32) 6 | (local $0 i32) 7 | (local.set $0 8 | (i32.const 1) 9 | ) 10 | (return 11 | (local.get $0) 12 | ) 13 | ) 14 | ;; custom section "zinking", size 28 15 | ) 16 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/excess_fallthrough.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "foo" (func $foo)) 3 | (func $bar) 4 | (func $foo (param $0 i32) 5 | (loop $label$4 6 | (block $label$5 7 | (call $bar) 8 | (block 9 | (block $label$7 10 | (br_table $label$7 $label$5 11 | (i32.const 123) 12 | ) 13 | ) 14 | (call $bar) 15 | ) 16 | (return) 17 | ) 18 | (unreachable) 19 | ) 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /binaryen/test/duplicate_types.wast: -------------------------------------------------------------------------------- 1 | (module ;; tests duplicate types are named properly 2 | (type (func)) 3 | (type (func)) 4 | (type (func)) 5 | (type (func (param i32))) 6 | (type $0 (func (param i32))) 7 | (type (func (param i32))) 8 | (type $b (func (param i32) (result f32))) 9 | (type (func (param i32) (result f32))) 10 | 11 | (func $f0 (param i32)) 12 | (func $f1 (param i32) (result i32) 13 | (i32.const 0) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /binaryen/test/grow_memory.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (type $i32_=>_i32 (func (param i32) (result i32))) 4 | (memory $0 1) 5 | (export "memory" (memory $0)) 6 | (export "grow" (func $0)) 7 | (export "current" (func $1)) 8 | (func $0 (param $var$0 i32) (result i32) 9 | (memory.grow 10 | (local.get $var$0) 11 | ) 12 | ) 13 | (func $1 (result i32) 14 | (memory.size) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/lld/main_module_table_3.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "__stack_pointer" (global $sp (mut i32))) 3 | (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) 4 | (import "env" "table" (table $timport$9 1 funcref)) 5 | (elem (i32.const 0)) 6 | (global $global i32 (i32.const 42)) 7 | (export "__stdio_write" (func $__stdio_write)) 8 | (export "__data_end" (global $global)) 9 | (func $__stdio_write 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/lld/standalone-wasm3.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 2) 3 | (global $global$0 (mut i32) (i32.const 66112)) 4 | (global $global$1 i32 (i32.const 66112)) 5 | (global $global$2 i32 (i32.const 576)) 6 | (export "memory" (memory $0)) 7 | (export "__heap_base" (global $global$1)) 8 | (export "__data_end" (global $global$2)) 9 | (func $__original_main (param $0 i32) (param $1 i32) (result i32) 10 | (nop) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/metadce/spanning_cycle.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1 1) 3 | (data passive "Hello, datacount section!") 4 | 5 | (import "env" "js_func" (func $a_js_func)) 6 | 7 | (export "wasm_func_a" (func $a_wasm_func)) 8 | 9 | (func $a_wasm_func 10 | ;; refer to the data segment to keep it around 11 | (memory.init 0 12 | (i32.const 0) 13 | (i32.const 0) 14 | (i32.const 25) 15 | ) 16 | (call $a_js_func) 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /binaryen/test/example/match.txt: -------------------------------------------------------------------------------- 1 | Testing Internal::Any 2 | Testing Internal::Exact 3 | Testing Internal::{I32,I64,Int,F32,F64,Float}Lit 4 | Testing Internal::ConstantMatcher 5 | Testing Internal::UnaryMatcher 6 | Testing Internal::UnaryOpMatcher 7 | Testing Internal::AbstractUnaryOpMatcher 8 | Testing Internal::BinaryMatcher 9 | Testing Internal::BinaryOpMatcher 10 | Testing Internal::AbstractBinaryOpMatcher 11 | Testing Internal::SelectMatcher 12 | -------------------------------------------------------------------------------- /binaryen/test/grow_memory.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (type $i32_=>_i32 (func (param i32) (result i32))) 4 | (memory $0 1) 5 | (export "memory" (memory $0)) 6 | (export "grow" (func $0)) 7 | (export "current" (func $1)) 8 | (func $0 (param $var$0 i32) (result i32) 9 | (memory.grow 10 | (local.get $var$0) 11 | ) 12 | ) 13 | (func $1 (result i32) 14 | (memory.size) 15 | ) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/sideffects.js.txt: -------------------------------------------------------------------------------- 1 | SideEffects.None=0 2 | SideEffects.Branches=1 3 | SideEffects.Calls=2 4 | SideEffects.ReadsLocal=4 5 | SideEffects.WritesLocal=8 6 | SideEffects.ReadsGlobal=16 7 | SideEffects.WritesGlobal=32 8 | SideEffects.ReadsMemory=64 9 | SideEffects.WritesMemory=128 10 | SideEffects.ImplicitTrap=256 11 | SideEffects.IsAtomic=512 12 | SideEffects.Throws=1024 13 | SideEffects.DanglingPop=2048 14 | SideEffects.Any=4095 15 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/no_partial.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 256 256) 3 | (data (i32.const 10) "waka waka waka waka waka") 4 | (export "test1" $test1) 5 | (func $test1 6 | (i32.store8 (i32.const 12) (i32.const 115)) ;; a safe store, should alter memory 7 | (unreachable) 8 | (i32.store8 (i32.const 13) (i32.const 114)) ;; a safe store, should alter memory, but we trapped already, and so must roll back the first one too 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /binaryen/test/grow_memory.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32) (result i32))) 3 | (type $1 (func (result i32))) 4 | (memory $0 1) 5 | (export "memory" (memory $0)) 6 | (export "grow" (func $0)) 7 | (export "current" (func $1)) 8 | (func $0 (; 0 ;) (type $0) (param $var$0 i32) (result i32) 9 | (memory.grow 10 | (local.get $var$0) 11 | ) 12 | ) 13 | (func $1 (; 1 ;) (type $1) (result i32) 14 | (memory.size) 15 | ) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/grow_memory.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (type $i32_=>_i32 (func (param i32) (result i32))) 4 | (memory $0 1) 5 | (export "memory" (memory $0)) 6 | (export "grow" (func $0)) 7 | (export "current" (func $1)) 8 | (func $0 (param $0 i32) (result i32) 9 | (memory.grow 10 | (local.get $0) 11 | ) 12 | ) 13 | (func $1 (result i32) 14 | (memory.size) 15 | ) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/lit/wasm-split/verbose.wast: -------------------------------------------------------------------------------- 1 | ;; Test that --verbose mode correctly prints the kept and split funcs 2 | 3 | ;; RUN: wasm-split %s --keep-funcs=foo,bar --split-funcs=baz --verbose \ 4 | ;; RUN: -o1 %t1.wasm -o2 %t2.wasm | filecheck %s 5 | 6 | ;; CHECK: Keeping functions: bar, foo{{$}} 7 | ;; CHECK: Splitting out functions: baz, quux{{$}} 8 | 9 | (module 10 | (func $foo) 11 | (func $bar) 12 | (func $baz) 13 | (func $quux) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/passes/simplify-locals.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (func $sink-from-inside (result i32) 4 | (local $0 i32) 5 | (local $1 i32) 6 | (local $2 i32) 7 | (nop) 8 | (i32.and 9 | (select 10 | (i32.const 0) 11 | (i32.const 1) 12 | (i32.const 1) 13 | ) 14 | (block $block (result i32) 15 | (nop) 16 | (nop) 17 | (nop) 18 | (i32.const 1) 19 | ) 20 | ) 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/minus_minus.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (type $1 (func)) 4 | (export "func_44_invoker" (func $1)) 5 | (func $0 (; 0 ;) (type $0) (result i32) 6 | (i32.trunc_f64_s 7 | (f64.neg 8 | (f64.const -7094) ;; negation of a negative must not be emitted as "--" in js, that will not parse 9 | ) 10 | ) 11 | ) 12 | (func $1 (; 1 ;) (type $1) 13 | (drop 14 | (call $0) 15 | ) 16 | ) 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /binaryen/test/passes/duplicate-import-elimination.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (type $i32_=>_none (func (param i32))) 4 | (import "env" "waka" (func $foo)) 5 | (import "env" "waka" (func $wrong (param i32))) 6 | (table $0 2 2 funcref) 7 | (elem (i32.const 0) $foo $foo) 8 | (export "baz" (func $0)) 9 | (start $foo) 10 | (func $0 11 | (call $foo) 12 | (call $foo) 13 | (call $wrong 14 | (i32.const 1) 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /binaryen/test/passes/strip-target-features_roundtrip_print-features_all-features.wast: -------------------------------------------------------------------------------- 1 | ;; Test that features enabled on the IR Module survive a round trip 2 | ;; even if the target features section is stripped first 3 | 4 | (module 5 | (func $foo (result v128 externref ) 6 | (tuple.make 7 | (v128.const i32x4 0 0 0 0) 8 | (ref.null extern) 9 | ) 10 | ) 11 | (func $bar (result v128 externref) 12 | (return_call $foo) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/lit/wasm-split/initial-table.wast: -------------------------------------------------------------------------------- 1 | ;; Test that the --initial-table flag works as expected 2 | 3 | ;; RUN: wasm-split %s --instrument --initial-table=1234 -S | filecheck %s 4 | 5 | ;; RUN: wasm-split %s -g -o1 %t.1.wasm -o2 %t.2.wasm --initial-table=1234 6 | ;; RUN: wasm-dis %t.1.wasm | filecheck %s 7 | ;; RUN: wasm-dis %t.2.wasm | filecheck %s 8 | 9 | ;; CHECK: (table $table 1234 funcref) 10 | 11 | (module 12 | (table $table 3 funcref) 13 | ) 14 | -------------------------------------------------------------------------------- /binaryen/test/passes/fpcast-emu_pass-arg=max-func-params@5.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $vijfd (func (param i32) (param i64) (param f32) (param f64))) 3 | (table 10 10 funcref) 4 | (elem (i32.const 0) $a) 5 | (func $a (param $x i32) (param $y i64) (param $z f32) (param $w f64) 6 | (call_indirect (type $vijfd) 7 | (i32.const 1) 8 | (i64.const 2) 9 | (f32.const 3) 10 | (f64.const 4) 11 | (i32.const 1337) 12 | ) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/passes/minify-imports-and-exports-and-modules.txt: -------------------------------------------------------------------------------- 1 | memory => a 2 | table => b 3 | longname1 => c 4 | longname2 => d 5 | longname3 => e 6 | longname4 => f 7 | (module 8 | (type $none_=>_none (func)) 9 | (import "a" "a" (memory $0 256 256)) 10 | (import "a" "b" (table $0 4 funcref)) 11 | (import "a" "c" (func $internal1)) 12 | (import "a" "d" (func $internal2)) 13 | (import "a" "e" (func $internal3)) 14 | (import "a" "f" (func $internal4)) 15 | ) 16 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/nested-selects.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $dummy) 3 | 4 | (func (export "sign") (param $0 i32) (result i32) 5 | (select 6 | (i32.const -1) 7 | (select 8 | (i32.const 1) 9 | (i32.const 0) 10 | (i32.gt_s 11 | (local.get $0) 12 | (i32.const 0) 13 | ) 14 | ) 15 | (i32.lt_s 16 | (local.get $0) 17 | (i32.const 0) 18 | ) 19 | ) 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/imported3.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 256 256) 3 | (data (i32.const 10) "waka waka waka waka waka") 4 | ;; imports must not be used 5 | (import "env" "tempDoublePtr" (global $tempDoublePtr i32)) 6 | (export "test1" $test1) 7 | (global $mine (mut i32) (global.get $tempDoublePtr)) ;; BAD, if used 8 | (func $test1 9 | (drop (global.get $mine)) 10 | (i32.store8 (i32.const 13) (i32.const 115)) ;; we never get here. 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /binaryen/test/grow_memory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | volatile int writeOnly; 6 | 7 | int main() { 8 | EM_ASM({ 9 | assert(HEAPU8.length === 16*1024*1024); 10 | }); 11 | for (int i = 0; i < 20; i++) { 12 | printf("alloc 1MB: %d\n", i); 13 | writeOnly = (int)malloc(1024*1024); 14 | } 15 | EM_ASM({ 16 | assert(HEAPU8.length > 16*1024*1024); 17 | }); 18 | printf("ok.\n"); 19 | } 20 | 21 | -------------------------------------------------------------------------------- /binaryen/test/metadce/rooted-export.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "wasm_func_a" (func $a_wasm_func)) 3 | (export "wasm_func_b" (func $b_wasm_func)) 4 | 5 | (func $a_wasm_func 6 | (unreachable) 7 | ) 8 | (func $b_wasm_func 9 | (unreachable) 10 | ) 11 | 12 | (export "wasm_event_a" (event $a_wasm_event)) 13 | (export "wasm_event_b" (event $b_wasm_event)) 14 | 15 | (event $a_wasm_event (attr 0) (param i32)) 16 | (event $b_wasm_event (attr 0) (param i32)) 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /binaryen/test/passes/emit-spec-wrapper=a.wat.wast.wat: -------------------------------------------------------------------------------- 1 | (invoke "hangLimitInitializer") (invoke "add" (i32.const 0) (i32.const 0) ) (invoke "hangLimitInitializer") (invoke "no_return" (i32.const 0) ) (invoke "hangLimitInitializer") (invoke "types" (i32.const 0) (i64.const 0) (f32.const 0) (f64.const 0) ) (invoke "hangLimitInitializer") (invoke "types2" (i32.const 0) (f32.const 0) (f64.const 0) ) (invoke "hangLimitInitializer") (invoke "types3" (i32.const 0) (f32.const 0) (f64.const 0) ) -------------------------------------------------------------------------------- /binaryen/test/passes/O_all-features.wast: -------------------------------------------------------------------------------- 1 | ;; Test that we can run GC types through the optimizer 2 | (module 3 | (type $struct.A (struct i32)) 4 | 5 | (func "foo" (param $x (ref null $struct.A)) 6 | ;; get a struct reference 7 | (drop 8 | (local.get $x) 9 | ) 10 | ;; get a struct field value 11 | ;; (note that since this is a nullable reference, it may trap) 12 | (drop 13 | (struct.get $struct.A 0 (local.get $x)) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/passes/asyncify_pass-arg=asyncify-onlylist@foo,bar.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1 2) 3 | (import "env" "import" (func $import)) 4 | (func $foo 5 | (call $import) 6 | ) 7 | (func $bar 8 | (call $import) 9 | ) 10 | (func $baz 11 | (call $import) 12 | ) 13 | (func $other1 14 | (call $foo) ;; even though we call foo, we are not in the only list, so do not instrument us 15 | ) 16 | (func $other2 17 | (call $baz) 18 | ) 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/reinterpret_scratch.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 1 1) 3 | (func "foo" (result i32) 4 | (local $0 f32) 5 | (i64.store align=4 6 | (i32.reinterpret_f32 ;; i32 0 7 | (local.get $0) ;; f32 0 8 | ) 9 | (i64.reinterpret_f64 ;; these two reinterprets must not interfere with 10 | (f64.const 0x12345678) ;; each other, even though both use scratch memory 11 | ) 12 | ) 13 | (i32.load 14 | (i32.const 0) 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /binaryen/test/passes/souperify.txt: -------------------------------------------------------------------------------- 1 | 2 | ; function: if-loop-test 3 | 4 | ; start LHS (in if-loop-test) 5 | %0 = sub 0:i32, 0:i32 6 | %1 = ne 0:i32, 0:i32 7 | pc %1 1:i1 8 | infer %0 9 | 10 | (module 11 | (type $none_=>_none (func)) 12 | (func $if-loop-test 13 | (local $0 i32) 14 | (if 15 | (i32.const 0) 16 | (loop $label$0 17 | (local.set $0 18 | (i32.sub 19 | (i32.const 0) 20 | (i32.const 0) 21 | ) 22 | ) 23 | ) 24 | ) 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /binaryen/test/spec/call_indirect_sig_mismatch.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $funcref_=>_none (func (param funcref))) 3 | (table funcref (elem $callee)) 4 | (export "sig_mismatch" (func $sig_mismatch)) 5 | (func $callee (param $0 exnref)) 6 | (func $sig_mismatch 7 | (call_indirect (type $funcref_=>_none) 8 | (ref.null func) 9 | (i32.const 0) 10 | ) 11 | ) 12 | ) 13 | 14 | (assert_trap (invoke "sig_mismatch") "callIndirect: function signatures don't match") 15 | -------------------------------------------------------------------------------- /binaryen/test/stacky.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 3 | (memory $0 256 256) 4 | (export "add" (func $0)) 5 | (func $0 (param $0 i32) (param $1 i32) (result i32) 6 | (local $2 i32) 7 | (i32.add 8 | (block (result i32) 9 | (local.set $2 10 | (local.get $0) 11 | ) 12 | (local.set $0 13 | (i32.const 100) 14 | ) 15 | (local.get $2) 16 | ) 17 | (local.get $1) 18 | ) 19 | ) 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /binaryen/test/newsyntax.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) 4 | (import "env" "table" (table $timport$0 9 9 funcref)) 5 | (export "call_indirect" (func $0)) 6 | (func $0 7 | (drop 8 | (call_indirect (type $i32_f64_=>_i32) 9 | (i32.const 10) 10 | (f64.const 20) 11 | (i32.const 30) 12 | ) 13 | ) 14 | (call_indirect (type $none_=>_none) 15 | (i32.const 1) 16 | ) 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_call.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 256 256) 3 | (data (i32.const 10) "waka waka waka waka waka") 4 | (export "test1" $test1) 5 | (func $test1 6 | (call $unsafe-to-call) ;; unsafe to call 7 | (i32.store (i32.const 12) (i32.const 115)) ;; a safe store, should alter memory 8 | (i32.store16 (i32.const 20) (i32.const 31353)) 9 | (i32.store8 (i32.const 23) (i32.const 120)) 10 | ) 11 | (func $unsafe-to-call 12 | (unreachable) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/lld/main_module_table_4.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "__stack_pointer" (global $sp (mut i32))) 3 | (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) 4 | (import "env" "__table_base" (global $tb i32)) 5 | (import "env" "table" (table $timport$9 1 funcref)) 6 | (elem (global.get $tb)) 7 | (global $global i32 (i32.const 42)) 8 | (export "__stdio_write" (func $__stdio_write)) 9 | (export "__data_end" (global $global)) 10 | (func $__stdio_write 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /binaryen/test/newsyntax.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) 4 | (import "env" "table" (table $timport$0 9 9 funcref)) 5 | (export "call_indirect" (func $0)) 6 | (func $0 7 | (drop 8 | (call_indirect (type $i32_f64_=>_i32) 9 | (i32.const 10) 10 | (f64.const 20) 11 | (i32.const 30) 12 | ) 13 | ) 14 | (call_indirect (type $none_=>_none) 15 | (i32.const 1) 16 | ) 17 | ) 18 | ) 19 | 20 | -------------------------------------------------------------------------------- /binaryen/test/passes/O3_inlining.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_none (func (param i32))) 3 | (memory $0 1 1) 4 | (global $global$1 (mut i32) (i32.const 100)) 5 | (export "func_217" (func $1)) 6 | (func $1 (param $0 i32) 7 | (if 8 | (global.get $global$1) 9 | (unreachable) 10 | ) 11 | (global.set $global$1 12 | (i32.const 0) 13 | ) 14 | (if 15 | (i32.eqz 16 | (i32.load16_u 17 | (i32.const 3) 18 | ) 19 | ) 20 | (unreachable) 21 | ) 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /binaryen/test/passes/remove-unused-brs_generate-stack-ir_print-stack-ir.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i64))) 3 | (func $0 (; 0 ;) (type $0) (param $var$0 i64) 4 | (block $label$1 5 | (br_if $label$1 6 | (block $label$2 (result i32) 7 | (loop $label$3 8 | (local.set $var$0 9 | (block $label$4 (result i64) 10 | (unreachable) 11 | ) 12 | ) 13 | ) 14 | (unreachable) 15 | ) 16 | ) 17 | (nop) 18 | ) 19 | ) 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /binaryen/test/passes/precompute_coalesce-locals_vacuum.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $nested-br_if-value (param $var$0 i32) (result i32) 3 | (local $1 i32) 4 | (local $2 i32) 5 | (loop $label$0 (result i32) 6 | (drop 7 | (i32.const 2) 8 | ) 9 | (block (result i32) 10 | (local.set $2 11 | (i32.const 4) 12 | ) 13 | (br_if $label$0 ;; precomputing this into a br must change the type 14 | (i32.const 1) 15 | ) 16 | (local.get $2) 17 | ) 18 | ) 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/bad-indirect-call.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $v (func)) 3 | (memory 256 256) 4 | (data (i32.const 10) "waka waka waka waka waka") 5 | (table 1 1 funcref) 6 | (elem (i32.const 0) $call-indirect) 7 | (export "test1" $test1) 8 | (func $test1 9 | (call_indirect (type $v) (i32.const 1)) ;; unsafe to call, out of range 10 | (i32.store8 (i32.const 20) (i32.const 120)) 11 | ) 12 | (func $call-indirect 13 | (i32.store8 (i32.const 40) (i32.const 67)) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /binaryen/test/newsyntax.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (type $i32_f64_=>_i32 (func (param i32 f64) (result i32))) 4 | (import "env" "table" (table $timport$0 9 9 funcref)) 5 | (export "call_indirect" (func $0)) 6 | (func $0 7 | (drop 8 | (call_indirect (type $i32_f64_=>_i32) 9 | (i32.const 10) 10 | (f64.const 20) 11 | (i32.const 30) 12 | ) 13 | ) 14 | (call_indirect (type $none_=>_none) 15 | (i32.const 1) 16 | ) 17 | ) 18 | ) 19 | 20 | -------------------------------------------------------------------------------- /binaryen/test/events.wast: -------------------------------------------------------------------------------- 1 | ;; Test events 2 | 3 | (module 4 | (event (attr 0) (param i32)) 5 | (event $e (attr 0) (param i32 f32)) 6 | (event $empty (attr 0)) 7 | 8 | (event $e-params0 (attr 0) (param i32 f32)) 9 | (event $e-params1 (attr 0) (param i32) (param f32)) 10 | 11 | (event $e-export (export "ex0") (attr 0) (param i32)) 12 | (event $e-import (import "env" "im0") (attr 0) (param i32)) 13 | 14 | (import "env" "im1" (event (attr 0) (param i32 f32))) 15 | (export "ex1" (event $e)) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/third_party/llvm-project/include/llvm/Support/ReverseIteration.h: -------------------------------------------------------------------------------- 1 | #ifndef LLVM_SUPPORT_REVERSEITERATION_H 2 | #define LLVM_SUPPORT_REVERSEITERATION_H 3 | 4 | #include "llvm/Config/abi-breaking.h" 5 | #include "llvm/Support/PointerLikeTypeTraits.h" 6 | 7 | namespace llvm { 8 | 9 | template 10 | bool shouldReverseIterate() { 11 | #if LLVM_ENABLE_REVERSE_ITERATION 12 | return detail::IsPointerLike::value; 13 | #else 14 | return false; 15 | #endif 16 | } 17 | 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /binaryen/test/passes/legalize-js-interface-minimally.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "imported" (func $imported (result i64))) 3 | (import "env" "invoke_vj" (func $invoke_vj (param i64))) 4 | (export "func" (func $func)) 5 | (export "dynCall_foo" (func $dyn)) 6 | (func $func (result i64) 7 | (drop (call $imported)) 8 | (call $invoke_vj (i64.const 0)) 9 | (unreachable) 10 | ) 11 | (func $dyn (result i64) 12 | (drop (call $imported)) 13 | (unreachable) 14 | ) 15 | ) 16 | (module) 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/passes/remove-imports.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (import "env" "table" (table $table 1 1 funcref)) 4 | (elem (i32.const 0) $waka-sneaky) 5 | (import "env" "memBase" (global $gimport$0 i32)) 6 | (import "somewhere" "waka-sneaky" (func $waka-sneaky)) 7 | (memory $0 1024 1024) 8 | (func $nada 9 | (nop) 10 | (drop 11 | (i32.const 0) 12 | ) 13 | (drop 14 | (f64.const 0) 15 | ) 16 | (call_indirect (type $none_=>_none) 17 | (i32.const 0) 18 | ) 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /binaryen/test/passes/duplicate-function-elimination_all-features.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (type $none_=>_funcref (func (result funcref))) 4 | (func $0 (result i32) 5 | (i32.const 0) 6 | ) 7 | (func $test (result funcref) 8 | (ref.func $0) 9 | ) 10 | ) 11 | (module 12 | (type $none_=>_none (func)) 13 | (memory $foo 16 16) 14 | (global $bar i32 (i32.const 0)) 15 | (export "memory" (memory $foo)) 16 | (export "global" (global $bar)) 17 | (func $bar 18 | (nop) 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /binaryen/test/passes/O1_print-stack-ir.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "stacky-help" (func $stacky-help)) 3 | (func $stacky-help (param $x i32) (result i32) 4 | (local $temp i32) 5 | (i32.add 6 | (call $stacky-help (i32.const 0)) 7 | (i32.eqz 8 | (block (result i32) ;; after we use the stack instead of the local, we can remove this block 9 | (local.set $temp (call $stacky-help (i32.const 1))) 10 | (drop (call $stacky-help (i32.const 2))) 11 | (local.get $temp) 12 | ) 13 | ) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/passes/O2_print-stack-ir.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "stacky-help" (func $stacky-help)) 3 | (func $stacky-help (param $x i32) (result i32) 4 | (local $temp i32) 5 | (i32.add 6 | (call $stacky-help (i32.const 0)) 7 | (i32.eqz 8 | (block (result i32) ;; after we use the stack instead of the local, we can remove this block 9 | (local.set $temp (call $stacky-help (i32.const 1))) 10 | (drop (call $stacky-help (i32.const 2))) 11 | (local.get $temp) 12 | ) 13 | ) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/passes/O3_print-stack-ir.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "stacky-help" (func $stacky-help)) 3 | (func $stacky-help (param $x i32) (result i32) 4 | (local $temp i32) 5 | (i32.add 6 | (call $stacky-help (i32.const 0)) 7 | (i32.eqz 8 | (block (result i32) ;; after we use the stack instead of the local, we can remove this block 9 | (local.set $temp (call $stacky-help (i32.const 1))) 10 | (drop (call $stacky-help (i32.const 2))) 11 | (local.get $temp) 12 | ) 13 | ) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/passes/remove-unused-names_precompute.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_=>_none (func (param i32))) 3 | (memory $0 256 256) 4 | (func $__ZN10WasmAssertC2Ev__async_cb (param $$0 i32) 5 | (block $switch-default 6 | (nop) 7 | (block 8 | (i32.store 9 | (i32.const 12) 10 | (i32.const 26) 11 | ) 12 | (return) 13 | ) 14 | ) 15 | (block 16 | (local.set $$0 17 | (i32.const 4) 18 | ) 19 | (i32.store 20 | (local.get $$0) 21 | (i32.const 1) 22 | ) 23 | ) 24 | ) 25 | ) 26 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/em_asm_mangled_string.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "emscripten_asm_const_int" (func $emscripten_asm_const_int (param i32 i32 i32) (result i32))) 3 | (global $global$0 (mut i32) (i32.const 66192)) 4 | (global $global$1 i32 (i32.const 652)) 5 | (export "__data_end" (global $global$1)) 6 | (export "main" (func $main)) 7 | (func $main (param $0 i32) (param $1 i32) (result i32) 8 | (drop (call $emscripten_asm_const_int (local.get $0) (i32.const 0) (i32.const 0))) 9 | (i32.const 0) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /binaryen/test/calls.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | 5 | int inner(int x) { 6 | return x*x + 2; 7 | } 8 | 9 | int EMSCRIPTEN_KEEPALIVE simple(int x) { 10 | return inner(x); 11 | } 12 | 13 | int EMSCRIPTEN_KEEPALIVE fibo(int x) { 14 | if (x == 0 || x == 1) return 1; 15 | return fibo(x-1) + fibo(x-2); 16 | } 17 | 18 | int EMSCRIPTEN_KEEPALIVE run_script() { 19 | emscripten_run_script("Module.print('hello from called script')"); 20 | return emscripten_run_script_int("1+2+3+4-1"); 21 | } 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/imported2.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 256 256) 4 | (data (i32.const 10) "wasa waka waka waka waka") 5 | (global $mine (mut i32) (i32.const 1)) 6 | (export "test2" (func $test2)) 7 | (export "test3" (func $test3)) 8 | (func $test2 9 | (global.set $mine 10 | (i32.const 2) 11 | ) 12 | (i32.store8 13 | (i32.const 13) 14 | (i32.const 115) 15 | ) 16 | ) 17 | (func $test3 18 | (i32.store8 19 | (i32.const 14) 20 | (i32.const 115) 21 | ) 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/unsafe_call.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 256 256) 4 | (data (i32.const 10) "waka waka waka waka waka") 5 | (export "test1" (func $test1)) 6 | (func $test1 7 | (call $unsafe-to-call) 8 | (i32.store 9 | (i32.const 12) 10 | (i32.const 115) 11 | ) 12 | (i32.store16 13 | (i32.const 20) 14 | (i32.const 31353) 15 | ) 16 | (i32.store8 17 | (i32.const 23) 18 | (i32.const 120) 19 | ) 20 | ) 21 | (func $unsafe-to-call 22 | (unreachable) 23 | ) 24 | ) 25 | -------------------------------------------------------------------------------- /binaryen/test/lld/standalone-wasm-with-start.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 2) 3 | (table $0 1 1 funcref) 4 | (elem (i32.const 0) $foo) 5 | (global $global$0 (mut i32) (i32.const 66112)) 6 | (global $global$1 i32 (i32.const 66112)) 7 | (global $global$2 i32 (i32.const 576)) 8 | (export "memory" (memory $0)) 9 | (export "_start" (func $_start)) 10 | (export "__heap_base" (global $global$1)) 11 | (export "__data_end" (global $global$2)) 12 | (func $_start (result i32) 13 | (nop) 14 | ) 15 | (func $foo (result i32)) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/passes/pick-load-signs_all-features.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 (shared 16 16)) 3 | (func $atomics-are-always-unsigned (result i32) 4 | (local $0 i32) 5 | (drop 6 | (block (result i32) 7 | (local.set $0 8 | (i32.atomic.load16_u ;; an atomic load cannot become signed 9 | (i32.const 27) 10 | ) 11 | ) 12 | (i32.shr_s 13 | (i32.shl 14 | (local.get $0) 15 | (i32.const 16) 16 | ) 17 | (i32.const 16) 18 | ) 19 | ) 20 | ) 21 | (i32.const -65) 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/pass-arguments.js: -------------------------------------------------------------------------------- 1 | assert(binaryen.getPassArgument("theKey") === null); 2 | 3 | binaryen.setPassArgument("theKey", "theValue"); 4 | assert(binaryen.getPassArgument("theKey") === "theValue"); 5 | 6 | binaryen.setPassArgument("theKey", null); 7 | assert(binaryen.getPassArgument("theKey") === null); 8 | 9 | binaryen.setPassArgument("theKey", "theValue2"); 10 | assert(binaryen.getPassArgument("theKey") === "theValue2"); 11 | 12 | binaryen.clearPassArguments(); 13 | assert(binaryen.getPassArgument("theKey") === null); 14 | -------------------------------------------------------------------------------- /binaryen/test/calls.post.js: -------------------------------------------------------------------------------- 1 | 2 | function test(name) { 3 | Module.print(name); 4 | function doTest(x) { 5 | Module.print(' ' + [x] + ' ==> ' + Module['_' + name](x)); 6 | } 7 | doTest(1); 8 | doTest(2); 9 | doTest(3); 10 | doTest(4); 11 | doTest(7); 12 | } 13 | 14 | test('simple'); 15 | test('fibo'); 16 | 17 | Module.print('run_script'); 18 | Module.print(Module['_run_script']()); 19 | 20 | Module.print('too many/few arguments'); 21 | Module.print(Module['_simple']()); 22 | Module.print(Module['_simple'](10, 20)); 23 | 24 | -------------------------------------------------------------------------------- /binaryen/test/passes/O1.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 1 1) 3 | (global $global$0 (mut i32) (i32.const 10)) 4 | (func "foo" (result i32) 5 | (i32.load offset=4 align=1 6 | (i32.and 7 | (block $label$1 (result i32) 8 | (global.set $global$0 9 | (i32.const 0) 10 | ) 11 | (i32.const -64) 12 | ) 13 | (i32.const 15) 14 | ) 15 | ) 16 | ) 17 | (func $signed-overflow (param $0 f32) (result i32) 18 | (i32.sub 19 | (i32.const 268435456) 20 | (i32.const -2147483648) 21 | ) 22 | ) 23 | ) 24 | 25 | 26 | -------------------------------------------------------------------------------- /binaryen/test/passes/Os_print-stack-ir_all-features.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "stacky-help" (func $stacky-help)) 3 | (func $stacky-help (param $x i32) (result i32) 4 | (local $temp i32) 5 | (i32.add 6 | (call $stacky-help (i32.const 0)) 7 | (i32.eqz 8 | (block (result i32) ;; after we use the stack instead of the local, we can remove this block 9 | (local.set $temp (call $stacky-help (i32.const 1))) 10 | (drop (call $stacky-help (i32.const 2))) 11 | (local.get $temp) 12 | ) 13 | ) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_all-features.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (event $e0 (attr 0) (param i32)) 3 | 4 | (func $eh (local $exn exnref) 5 | (try 6 | (do 7 | (throw $e0 (i32.const 0)) 8 | ) 9 | (catch 10 | (local.set $exn (pop exnref)) 11 | (drop 12 | (block $l0 (result i32) 13 | (rethrow 14 | (br_on_exn $l0 $e0 (local.get $exn)) 15 | ) 16 | ) 17 | ) 18 | ) 19 | ) 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /binaryen/test/signext.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (func $signext 4 | (local $0 i32) 5 | (local $1 i64) 6 | (drop 7 | (i32.extend8_s 8 | (local.get $0) 9 | ) 10 | ) 11 | (drop 12 | (i32.extend16_s 13 | (local.get $0) 14 | ) 15 | ) 16 | (drop 17 | (i64.extend8_s 18 | (local.get $1) 19 | ) 20 | ) 21 | (drop 22 | (i64.extend16_s 23 | (local.get $1) 24 | ) 25 | ) 26 | (drop 27 | (i64.extend32_s 28 | (local.get $1) 29 | ) 30 | ) 31 | ) 32 | ) 33 | -------------------------------------------------------------------------------- /binaryen/test/extra-unreachable.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (type $i32_=>_none (func (param i32))) 4 | (type $i32_=>_i32 (func (param i32) (result i32))) 5 | (memory $0 (shared 1 1)) 6 | (table $0 0 funcref) 7 | (global $global$0 (mut f32) (f32.const 0)) 8 | (event $event$0 (attr 0) (param i32)) 9 | (func $0 (param $0 i32) (result i32) 10 | (i32.const 0) 11 | ) 12 | (func $1 13 | (unreachable) 14 | ) 15 | (func $2 16 | (block $label$1 17 | (unreachable) 18 | ) 19 | ) 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /binaryen/test/passes/simplify-globals_all-features_fuzz-exec.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (global $global$0 (mut funcref) (ref.null func)) 3 | (func $0 (param $0 f32) (param $1 i31ref) (param $2 i64) (param $3 f64) (param $4 funcref) 4 | (nop) 5 | ) 6 | (func "export" (result funcref) 7 | ;; this set's value will be applied to the get right after it. we should carry 8 | ;; over the specific typed function reference type properly while doing so. 9 | (global.set $global$0 10 | (ref.func $0) 11 | ) 12 | (global.get $global$0) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/reduce/memory_table.wast.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (type $none_=>_none (func)) 4 | (memory $0 256 256) 5 | (export "f1" (func $0)) 6 | (export "f2" (func $1)) 7 | (export "f4" (func $2)) 8 | (func $0 9 | (nop) 10 | ) 11 | (func $1 (result i32) 12 | (i32.store 13 | (i32.const 0) 14 | (i32.const 65530) 15 | ) 16 | (i32.load 17 | (i32.const 0) 18 | ) 19 | ) 20 | (func $2 (result i32) 21 | (i32.add 22 | (call $1) 23 | (i32.const 1234) 24 | ) 25 | ) 26 | ) 27 | 28 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/if_unreachable.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32 i32 i32 i32 i32 i32))) 3 | (import "env" "table" (table $timport$0 6 funcref)) 4 | (func $0 (; 0 ;) (type $0) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) (param $5 i32) 5 | (if 6 | (i32.ne 7 | (i32.const 0) 8 | (i32.const 48) 9 | ) 10 | (block $label$2 11 | (br_if $label$2 12 | (i32.const 0) 13 | ) 14 | (unreachable) 15 | ) 16 | (unreachable) 17 | ) 18 | (unreachable) 19 | ) 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /binaryen/test/extra-unreachable.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (type $i32_=>_none (func (param i32))) 4 | (type $i32_=>_i32 (func (param i32) (result i32))) 5 | (memory $0 (shared 1 1)) 6 | (table $0 0 funcref) 7 | (global $g (mut f32) (f32.const 0)) 8 | (event $event$0 (attr 0) (param i32)) 9 | (func $foo (param $0 i32) (result i32) 10 | (i32.const 0) 11 | ) 12 | (func $test_function_block 13 | (unreachable) 14 | ) 15 | (func $test 16 | (block $label$1 17 | (unreachable) 18 | ) 19 | ) 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /binaryen/test/nonspec-bulk-memory.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1024 1024 3 | (segment 0 "hello, world") 4 | ) 5 | (func $memory.init 6 | (memory.init 0 7 | (i32.const 512) 8 | (i32.const 0) 9 | (i32.const 12) 10 | ) 11 | ) 12 | (func $data.drop 13 | (data.drop 0) 14 | ) 15 | (func $memory.copy 16 | (memory.copy 17 | (i32.const 512) 18 | (i32.const 0) 19 | (i32.const 12) 20 | ) 21 | ) 22 | (func $memory.fill 23 | (memory.fill 24 | (i32.const 0) 25 | (i32.const 42) 26 | (i32.const 1024) 27 | ) 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /binaryen/test/passes/pick-load-signs_all-features.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (memory $0 (shared 16 16)) 4 | (func $atomics-are-always-unsigned (result i32) 5 | (local $0 i32) 6 | (drop 7 | (block $block (result i32) 8 | (local.set $0 9 | (i32.atomic.load16_u 10 | (i32.const 27) 11 | ) 12 | ) 13 | (i32.shr_s 14 | (i32.shl 15 | (local.get $0) 16 | (i32.const 16) 17 | ) 18 | (i32.const 16) 19 | ) 20 | ) 21 | ) 22 | (i32.const -65) 23 | ) 24 | ) 25 | -------------------------------------------------------------------------------- /binaryen/test/printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | int a = 12345; 5 | unsigned b = 123456; 6 | long c = 1234567; 7 | unsigned long d = 12345678; 8 | long long e = 1234567891011; 9 | unsigned long long f = 123456789101112; 10 | 11 | printf( 12 | "int a = %d\n" 13 | "unsigned b = %u\n" 14 | "long c = %ld\n" 15 | "unsigned long d = %lu\n" 16 | "long long e = %lld\n" 17 | "unsigned long long f = %llu\n" 18 | , a, b, c, d, e, f); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /binaryen/test/signext.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (func $signext 4 | (local $0 i32) 5 | (local $1 i64) 6 | (drop 7 | (i32.extend8_s 8 | (local.get $0) 9 | ) 10 | ) 11 | (drop 12 | (i32.extend16_s 13 | (local.get $0) 14 | ) 15 | ) 16 | (drop 17 | (i64.extend8_s 18 | (local.get $1) 19 | ) 20 | ) 21 | (drop 22 | (i64.extend16_s 23 | (local.get $1) 24 | ) 25 | ) 26 | (drop 27 | (i64.extend32_s 28 | (local.get $1) 29 | ) 30 | ) 31 | ) 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /binaryen/test/unreachable-instr-type.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 (shared 1 1)) 4 | (func $test 5 | (i32.load 6 | (unreachable) 7 | ) 8 | (f32.store 9 | (unreachable) 10 | (f32.const 0) 11 | ) 12 | (i32.atomic.rmw.add 13 | (unreachable) 14 | (i64.const 0) 15 | ) 16 | (i32.atomic.rmw.cmpxchg 17 | (unreachable) 18 | (i64.const 0) 19 | (i64.const 1) 20 | ) 21 | (memory.atomic.wait64 22 | (unreachable) 23 | (i64.const 0) 24 | (i64.const 0) 25 | ) 26 | ) 27 | ) 28 | -------------------------------------------------------------------------------- /binaryen/scripts/emcc-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | mkdir -p emcc-build 6 | echo "emcc-tests: build:wasm" 7 | emcmake cmake -B emcc-build -DCMAKE_BUILD_TYPE=Release -G Ninja 8 | ninja -C emcc-build binaryen_wasm 9 | echo "emcc-tests: test:wasm" 10 | ./check.py --binaryen-bin=emcc-build/bin binaryenjs_wasm 11 | echo "emcc-tests: done:wasm" 12 | 13 | echo "emcc-tests: build:js" 14 | ninja -C emcc-build binaryen_js 15 | echo "emcc-tests: test:js" 16 | ./check.py --binaryen-bin=emcc-build/bin binaryenjs 17 | echo "emcc-tests: done:js" 18 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/functions.js.txt: -------------------------------------------------------------------------------- 1 | GetFunction is equal: true 2 | getFunctionInfo={"module":"","base":"","params":0,"results":2,"vars":[]} 3 | getExpressionInfo(body)={"id":14,"value":3} 4 | (i32.const 3) 5 | 6 | (module 7 | ) 8 | 9 | (module 10 | (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) 11 | (func $b-function (param $a i32) (param $b i32) (result i32) 12 | (local $res i32) 13 | (local $unused f64) 14 | (local.tee $res 15 | (i32.add 16 | (local.get $a) 17 | (local.get $b) 18 | ) 19 | ) 20 | ) 21 | ) 22 | 23 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/bad-indirect-call2.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $v (func)) 3 | (memory 256 256) 4 | (data (i32.const 10) "waka waka waka waka waka") 5 | (import "env" "_abort" (func $_abort)) 6 | (table 2 2 funcref) 7 | (elem (i32.const 0) $_abort $call-indirect) 8 | (export "test1" $test1) 9 | (func $test1 10 | (call_indirect (type $v) (i32.const 0)) ;; unsafe to call, imported 11 | (i32.store8 (i32.const 20) (i32.const 120)) 12 | ) 13 | (func $call-indirect 14 | (i32.store8 (i32.const 40) (i32.const 67)) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/bad-indirect-call3.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $funcref_=>_none (func (param funcref))) 3 | (memory 256 256) 4 | (data (i32.const 10) "waka waka waka waka waka") 5 | (table funcref (elem $callee)) 6 | (export "sig_mismatch" (func $sig_mismatch)) 7 | (func $callee (param $0 exnref) 8 | (i32.store8 (i32.const 40) (i32.const 67)) 9 | ) 10 | (func $sig_mismatch 11 | (call_indirect (type $funcref_=>_none) ;; unsafe to call, signature mismatch 12 | (ref.null func) 13 | (i32.const 0) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/passes/roundtrip_signed.bin.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 16 17) 4 | (global $global$0 (mut i32) (i32.const 10)) 5 | (export "as-br_table-index" (func $0)) 6 | (export "as-local.set-value" (func $0)) 7 | (func $0 8 | (if 9 | (i32.eqz 10 | (global.get $global$0) 11 | ) 12 | (return) 13 | ) 14 | (global.set $global$0 15 | (i32.sub 16 | (global.get $global$0) 17 | (i32.const 1) 18 | ) 19 | ) 20 | (drop 21 | (i32.load 22 | (i32.const 0) 23 | ) 24 | ) 25 | ) 26 | ) 27 | -------------------------------------------------------------------------------- /binaryen/test/signext.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (func $0 4 | (local $0 i32) 5 | (local $1 i64) 6 | (drop 7 | (i32.extend8_s 8 | (local.get $0) 9 | ) 10 | ) 11 | (drop 12 | (i32.extend16_s 13 | (local.get $0) 14 | ) 15 | ) 16 | (drop 17 | (i64.extend8_s 18 | (local.get $1) 19 | ) 20 | ) 21 | (drop 22 | (i64.extend16_s 23 | (local.get $1) 24 | ) 25 | ) 26 | (drop 27 | (i64.extend32_s 28 | (local.get $1) 29 | ) 30 | ) 31 | ) 32 | ) 33 | 34 | -------------------------------------------------------------------------------- /binaryen/scripts/test/spectest.js: -------------------------------------------------------------------------------- 1 | export function print() { 2 | console.log(); 3 | } 4 | export function print_i32(arg) { 5 | console.log(arg, ': i32'); 6 | } 7 | export function print_f32(arg) { 8 | console.log(arg, ': f32'); 9 | } 10 | export function print_f64(arg) { 11 | console.log(arg, ': f64'); 12 | } 13 | export function print_i32_f32(arg0, arg1) { 14 | console.log(arg0, ': i32'); 15 | console.log(arg1, ': f32'); 16 | } 17 | export function print_f64_f64(arg0, arg1) { 18 | console.log(arg0, ': f64'); 19 | console.log(arg1, ': f64'); 20 | } 21 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/bad-indirect-call.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 256 256) 4 | (data (i32.const 10) "waka waka waka waka waka") 5 | (table $0 1 1 funcref) 6 | (elem (i32.const 0) $call-indirect) 7 | (export "test1" (func $test1)) 8 | (func $test1 9 | (call_indirect (type $none_=>_none) 10 | (i32.const 1) 11 | ) 12 | (i32.store8 13 | (i32.const 20) 14 | (i32.const 120) 15 | ) 16 | ) 17 | (func $call-indirect 18 | (i32.store8 19 | (i32.const 40) 20 | (i32.const 67) 21 | ) 22 | ) 23 | ) 24 | -------------------------------------------------------------------------------- /binaryen/test/lld/main_module_table_5.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "__stack_pointer" (global $sp (mut i32))) 3 | (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) 4 | (import "env" "__table_base" (global $tb i32)) 5 | (import "env" "table" (table $timport$9 1 funcref)) 6 | (elem (global.get $tb) $other $stuff) 7 | (global $global i32 (i32.const 42)) 8 | (export "__stdio_write" (func $__stdio_write)) 9 | (export "__data_end" (global $global)) 10 | (func $__stdio_write 11 | ) 12 | (func $other 13 | ) 14 | (func $stuff 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/unreachable-instr-type.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory (shared 1 1)) 3 | (func $test 4 | (f32.load (unreachable)) 5 | 6 | (f32.store 7 | (unreachable) 8 | (f32.const 0) 9 | ) 10 | 11 | (i64.atomic.rmw.add 12 | (unreachable) 13 | (i64.const 0) 14 | ) 15 | 16 | (i64.atomic.rmw.cmpxchg 17 | (unreachable) 18 | (i64.const 0) 19 | (i64.const 1) 20 | ) 21 | 22 | (memory.atomic.wait64 23 | (unreachable) 24 | (i64.const 0) 25 | (i64.const 0) 26 | ) 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /binaryen/test/passes/stack-check_enable-mutable-globals.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "__stack_pointer" (global $sp (mut i32))) 3 | (func "use_stack" (result i32) 4 | (global.set $sp (i32.const 42)) 5 | (global.get $sp) 6 | ) 7 | ) 8 | ;; if the global names are taken we should not crash 9 | (module 10 | (import "env" "__stack_pointer" (global $sp (mut i32))) 11 | (global $__stack_base (mut i32) (i32.const 0)) 12 | (global $__stack_limit (mut i32) (i32.const 0)) 13 | (export "use_stack" (func $0)) 14 | (func $0 (result i32) 15 | (unreachable) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /binaryen/test/unit/input/asyncify-stackOverflow.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1 2) 3 | (import "env" "sleep" (func $sleep)) 4 | (export "memory" (memory 0)) 5 | (func "many_locals" (param $x i32) (result i32) 6 | (local $y i32) 7 | (local $z i32) 8 | (local.set $y 9 | (i32.add (local.get $x) (i32.const 10)) 10 | ) 11 | (local.set $z 12 | (i32.add (local.get $y) (i32.const 20)) 13 | ) 14 | (call $sleep) 15 | (select 16 | (local.get $y) 17 | (local.get $z) 18 | (local.get $x) 19 | ) 20 | ) 21 | ) 22 | 23 | -------------------------------------------------------------------------------- /binaryen/test/passes/O_all-features_ignore-implicit-traps.wast: -------------------------------------------------------------------------------- 1 | ;; Test that we can run GC types through the optimizer 2 | (module 3 | (type $struct.A (struct i32)) 4 | 5 | (func "foo" (param $x (ref null $struct.A)) 6 | ;; get a struct reference 7 | (drop 8 | (local.get $x) 9 | ) 10 | ;; get a struct field value 11 | ;; (note that since this is a nullable reference, it may trap, but we 12 | ;; are ignoring implicit traps, so it has no side effects) 13 | (drop 14 | (struct.get $struct.A 0 (local.get $x)) 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/global.js.txt: -------------------------------------------------------------------------------- 1 | GetGlobal is equal: true 2 | getGlobalInfo={"module":"","base":"","mutable":false} 3 | getExpressionInfo(init)={"id":14,"value":1} 4 | (i32.const 1) 5 | 6 | (module 7 | (import "module" "base" (global $a-global-imp i32)) 8 | (import "module" "base" (global $a-mut-global-imp (mut i32))) 9 | (global $a-global i32 (i32.const 1)) 10 | (export "a-global-exp" (global $a-global)) 11 | ) 12 | 13 | (module 14 | (import "module" "base" (global $a-global-imp i32)) 15 | (import "module" "base" (global $a-mut-global-imp (mut i32))) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/lld/em_asm_table.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32 i32))) 3 | (type $1 (func (param i32 i32 i32) (result i32))) 4 | (import "env" "memory" (memory $2 8192)) 5 | (import "env" "emscripten_log" (func $fimport$0 (param i32 i32))) 6 | (import "env" "emscripten_asm_const_int" (func $fimport$1 (param i32 i32 i32) (result i32))) 7 | (table $0 159609 funcref) 8 | (elem (i32.const 1) $fimport$0 $fimport$1) 9 | (global $global$0 (mut i32) (i32.const 1024)) 10 | (global $global$1 i32 (i32.const 1048)) 11 | (export "__data_end" (global $global$1)) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /binaryen/test/nonspec-bulk-memory.wast.fromBinary.noDebugInfo: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 1024 1024) 4 | (data (i32.const 0) "hello, world") 5 | (func $0 6 | (memory.init 0 7 | (i32.const 512) 8 | (i32.const 0) 9 | (i32.const 12) 10 | ) 11 | ) 12 | (func $1 13 | (data.drop 0) 14 | ) 15 | (func $2 16 | (memory.copy 17 | (i32.const 512) 18 | (i32.const 0) 19 | (i32.const 12) 20 | ) 21 | ) 22 | (func $3 23 | (memory.fill 24 | (i32.const 0) 25 | (i32.const 42) 26 | (i32.const 1024) 27 | ) 28 | ) 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /binaryen/test/binaryen.js/event.js.txt: -------------------------------------------------------------------------------- 1 | GetEvent is equal: true 2 | getEventInfo={"name":"a-event","module":"","base":"","attribute":0,"params":2,"results":0} 3 | (module 4 | (type $i32_=>_none (func (param i32))) 5 | (type $i32_f32_=>_none (func (param i32 f32))) 6 | (import "module" "base" (event $a-event-imp (attr 0) (param i32 f32))) 7 | (event $a-event (attr 0) (param i32)) 8 | (export "a-event-exp" (event $a-event)) 9 | ) 10 | 11 | (module 12 | (type $i32_f32_=>_none (func (param i32 f32))) 13 | (import "module" "base" (event $a-event-imp (attr 0) (param i32 f32))) 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /binaryen/test/control_flow.post.js: -------------------------------------------------------------------------------- 1 | 2 | function test(name) { 3 | Module.print(name); 4 | function doTest(x) { 5 | Module.print(' ' + [x] + ' ==> ' + Module['_check_' + name](x)); 6 | } 7 | doTest(1); 8 | doTest(2); 9 | doTest(3); 10 | doTest(4); 11 | doTest(11); 12 | doTest(90); 13 | } 14 | 15 | test('if'); 16 | test('loop'); 17 | test('loop_break'); 18 | test('loop_continue'); 19 | test('do_loop'); 20 | test('do_once'); 21 | test('while_forever'); 22 | test('switch'); 23 | test('switch_nodefault'); 24 | test('switch_rdefault'); 25 | test('switch_fallthrough'); 26 | 27 | -------------------------------------------------------------------------------- /binaryen/test/passes/remove-unused-names_precompute.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 256 256) 3 | (func $__ZN10WasmAssertC2Ev__async_cb (param $$0 i32) 4 | (block $switch-default 5 | (block $switch-case 6 | (br_table $switch-case $switch-default 7 | (i32.const 0) 8 | ) 9 | ) 10 | (block 11 | (i32.store 12 | (i32.const 12) 13 | (i32.const 26) 14 | ) 15 | (return) 16 | ) 17 | ) 18 | (block 19 | (local.set $$0 20 | (i32.const 4) 21 | ) 22 | (i32.store 23 | (local.get $$0) 24 | (i32.const 1) 25 | ) 26 | ) 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /nix/binaryen-3481-fix.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index 9a2744b08..775fade24 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -315,7 +315,7 @@ install(TARGETS binaryen 6 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 7 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 8 | 9 | -install(FILES src/binaryen-c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 10 | +install(FILES src/binaryen-c.h src/wasm-delegations.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 11 | 12 | function(binaryen_add_executable name sources) 13 | add_executable(${name} ${sources}) 14 | -------------------------------------------------------------------------------- /binaryen/test/externref.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $externref_=>_externref (func (param externref) (result externref))) 3 | (import "env" "test2" (global $test2 externref)) 4 | (import "env" "test1" (func $test1 (param externref) (result externref))) 5 | (memory $0 1 1) 6 | (export "test1" (func $test1)) 7 | (export "test2" (global $test2)) 8 | (func $externref_test (; 1 ;) (param $0 externref) (result externref) 9 | (local $1 externref) 10 | (local.set $1 11 | (call $test1 12 | (local.get $0) 13 | ) 14 | ) 15 | (return 16 | (local.get $1) 17 | ) 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /binaryen/test/wasm2js/func-ptr-offset.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $T (func (result i32))) 3 | (table 4 funcref) 4 | (elem (i32.const 1) $t1 $t2 $t3) 5 | 6 | (func $t1 (type $T) (i32.const 1)) 7 | (func $t2 (type $T) (i32.const 2)) 8 | (func $t3 (type $T) (i32.const 3)) 9 | 10 | (func (export "call") (param i32) (result i32) 11 | (call_indirect (type $T) (local.get $0)) 12 | ) 13 | ) 14 | 15 | (assert_return (invoke "call" (i32.const 1)) (i32.const 1)) 16 | (assert_return (invoke "call" (i32.const 2)) (i32.const 2)) 17 | (assert_return (invoke "call" (i32.const 3)) (i32.const 3)) 18 | -------------------------------------------------------------------------------- /binaryen/src/wasm/wasm-interpreter.cpp: -------------------------------------------------------------------------------- 1 | #include "wasm-interpreter.h" 2 | 3 | namespace wasm { 4 | 5 | #ifdef WASM_INTERPRETER_DEBUG 6 | int Indenter::indentLevel = 0; 7 | 8 | Indenter::Indenter(const char* entry) : entryName(entry) { ++indentLevel; } 9 | Indenter::~Indenter() { 10 | print(); 11 | std::cout << "exit " << entryName << '\n'; 12 | --indentLevel; 13 | } 14 | void Indenter::print() { 15 | std::cout << indentLevel << ':'; 16 | for (int i = 0; i <= indentLevel; ++i) { 17 | std::cout << ' '; 18 | } 19 | } 20 | #endif // WASM_INTERPRETER_DEBUG 21 | 22 | } // namespace wasm 23 | -------------------------------------------------------------------------------- /binaryen/test/events.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $i32_f32_=>_none (func (param i32 f32))) 3 | (type $i32_=>_none (func (param i32))) 4 | (type $none_=>_none (func)) 5 | (import "env" "im0" (event $e-import (attr 0) (param i32))) 6 | (import "env" "im1" (event $eimport$1 (attr 0) (param i32 f32))) 7 | (event $2 (attr 0) (param i32)) 8 | (event $e (attr 0) (param i32 f32)) 9 | (event $empty (attr 0) (param)) 10 | (event $e-params0 (attr 0) (param i32 f32)) 11 | (event $e-params1 (attr 0) (param i32 f32)) 12 | (event $e-export (attr 0) (param i32)) 13 | (export "ex1" (event $e)) 14 | ) 15 | -------------------------------------------------------------------------------- /binaryen/test/lit/wasm-split/name-collision.wast: -------------------------------------------------------------------------------- 1 | ;; Regression test for a bug in which colliding internal names between 2 | ;; non-function exports would result in the wrong import names being used in the 3 | ;; secondary module. 4 | 5 | ;; RUN: wasm-split %s -o1 %t.1.wasm -o2 %t.2.wasm 6 | ;; RUN: wasm-dis %t.2.wasm | filecheck %s 7 | 8 | ;; CHECK-NOT: (import "primary" "memory" (table 9 | ;; CHECK: (import "primary" "table" (table 10 | 11 | (module 12 | (table $collide 1 funcref) 13 | (memory $collide 1 1) 14 | (export "table" (table $collide)) 15 | (export "memory" (memory $collide)) 16 | ) 17 | -------------------------------------------------------------------------------- /binaryen/test/lld/standalone-wasm2.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 2) 3 | (global $global$0 (mut i32) (i32.const 66112)) 4 | (global $global$1 i32 (i32.const 66112)) 5 | (global $global$2 i32 (i32.const 576)) 6 | (export "memory" (memory $0)) 7 | (export "main" (func $main)) 8 | (export "__heap_base" (global $global$1)) 9 | (export "__data_end" (global $global$2)) 10 | (func $__original_main (param $0 i32) (param $1 i32) (result i32) 11 | (nop) 12 | ) 13 | (func $main (param $0 i32) (param $1 i32) (result i32) 14 | (call $__original_main (local.get $0) (local.get $1)) 15 | ) 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /binaryen/test/nonspec-bulk-memory.wast.from-wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 1024 1024) 4 | (data (i32.const 0) "hello, world") 5 | (func $memory.init 6 | (memory.init 0 7 | (i32.const 512) 8 | (i32.const 0) 9 | (i32.const 12) 10 | ) 11 | ) 12 | (func $data.drop 13 | (data.drop 0) 14 | ) 15 | (func $memory.copy 16 | (memory.copy 17 | (i32.const 512) 18 | (i32.const 0) 19 | (i32.const 12) 20 | ) 21 | ) 22 | (func $memory.fill 23 | (memory.fill 24 | (i32.const 0) 25 | (i32.const 42) 26 | (i32.const 1024) 27 | ) 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /binaryen/test/passes/dealign.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 1 1) 4 | (func $test 5 | (drop 6 | (i32.load align=1 7 | (i32.const 4) 8 | ) 9 | ) 10 | (drop 11 | (i32.load align=1 12 | (i32.const 8) 13 | ) 14 | ) 15 | (drop 16 | (i32.load align=1 17 | (i32.const 12) 18 | ) 19 | ) 20 | (i32.store align=1 21 | (i32.const 16) 22 | (i32.const 28) 23 | ) 24 | (i32.store align=1 25 | (i32.const 20) 26 | (i32.const 32) 27 | ) 28 | (i32.store align=1 29 | (i32.const 24) 30 | (i32.const 36) 31 | ) 32 | ) 33 | ) 34 | -------------------------------------------------------------------------------- /binaryen/test/passes/remove-unused-brs_precompute_vacuum_remove-unused-brs.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (global $global$3 (mut f64) (f64.const 0)) 3 | (func $1 (param $x i32) (result f64) 4 | (local $var$0 f64) 5 | (block $label$0 6 | (local.set $var$0 7 | (f64.const 0) 8 | ) 9 | (if 10 | (i32.gt_s 11 | (i32.const 9) 12 | (i32.const 0) 13 | ) 14 | (return 15 | (f64.const -3.4) 16 | ) 17 | ) 18 | (if 19 | (local.get $x) 20 | (return 21 | (f64.const 5.6) 22 | ) 23 | ) 24 | (return 25 | (f64.const 1.2) 26 | ) 27 | ) 28 | ) 29 | ) 30 | -------------------------------------------------------------------------------- /binaryen/test/ctor-eval/indirect-call3.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (type $v (func)) 3 | (memory 256 256) 4 | (data (i32.const 10) "waka waka waka waka waka") 5 | (import "env" "tableBase" (global $tableBase i32)) 6 | (import "env" "_abort" (func $_abort)) 7 | (table 2 2 funcref) 8 | (elem (global.get $tableBase) $_abort $call-indirect) 9 | (export "test1" $test1) 10 | (func $test1 11 | (call_indirect (type $v) (i32.const 1)) ;; safe to call 12 | (i32.store8 (i32.const 20) (i32.const 120)) 13 | ) 14 | (func $call-indirect 15 | (i32.store8 (i32.const 40) (i32.const 67)) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /binaryen/test/nonspec-bulk-memory.wast.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_none (func)) 3 | (memory $0 1024 1024) 4 | (data (i32.const 0) "hello, world") 5 | (func $memory.init 6 | (memory.init 0 7 | (i32.const 512) 8 | (i32.const 0) 9 | (i32.const 12) 10 | ) 11 | ) 12 | (func $data.drop 13 | (data.drop 0) 14 | ) 15 | (func $memory.copy 16 | (memory.copy 17 | (i32.const 512) 18 | (i32.const 0) 19 | (i32.const 12) 20 | ) 21 | ) 22 | (func $memory.fill 23 | (memory.fill 24 | (i32.const 0) 25 | (i32.const 42) 26 | (i32.const 1024) 27 | ) 28 | ) 29 | ) 30 | 31 | --------------------------------------------------------------------------------