├── test ├── revision ├── unit │ ├── __init__.py │ ├── input │ │ ├── empty.wasm │ │ ├── package.json │ │ ├── only-imported-memory.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_target_feature.wasm │ │ ├── signext_target_feature.wasm │ │ ├── exception_handling_target_feature.wasm │ │ ├── truncsat_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 │ ├── test_only_imported_memory.py │ └── test_fuzz_empty_data.py ├── fannkuch.args ├── fasta.args ├── lit │ ├── wasm-split │ │ ├── none.txt │ │ ├── bar.txt │ │ ├── foo.txt │ │ ├── both.txt │ │ ├── multi-split.wast.manifest │ │ ├── export-name-already-exists.wast │ │ ├── multi-split-escape-names.wast.manifest │ │ ├── multi-memory-lowering-export-error.wast │ │ ├── instrument-memory-too-small.wast │ │ ├── initial-table.wast │ │ ├── verbose.wast │ │ └── imported-memory.wast │ ├── binary │ │ ├── component-error.test.wasm │ │ ├── global-local-get.test.wasm │ │ ├── global-local-set.test.wasm │ │ ├── global-local-tee.test.wasm │ │ ├── delegate-block.test.wasm │ │ ├── name-overlap.test.wasm │ │ ├── empty-param-name.test.wasm │ │ ├── debug-bad-binary.test.wasm │ │ ├── duplicated_names_collision.test.wasm │ │ ├── dylink.test.wasm │ │ ├── duplicated_names_collision_underscore.test.wasm │ │ ├── stacky-eh-legacy.test.wasm │ │ ├── bad-datacount.test.wasm │ │ ├── stacky-nn-tuple.test.wasm │ │ ├── dwarf-multivalue.test.wasm │ │ ├── custom-section-build-id.test.wasm │ │ ├── data-names.test.wasm │ │ ├── declarative-element-use-expr.test.wasm │ │ ├── strings-nogc.test │ │ ├── component-error.test │ │ ├── custom-section-build-id.test │ │ ├── bad-datacount.test │ │ ├── global-local-get.test │ │ ├── global-local-set.test │ │ └── global-local-tee.test │ ├── passes │ │ ├── asyncify-foo,bar-nl.txt │ │ ├── signext-lowering-features.wast │ │ ├── memory64-lowering-features.wast │ │ ├── custom-max-data-segments.wast │ │ ├── asyncify_pass-arg=asyncify-export-globals.wast │ │ ├── trace-calls_multi-value-result.wast │ │ └── remove-memory-init.wast │ ├── sourcemap-sourceroot-file.wat.wasm │ ├── CMakeLists.txt │ ├── fuzz-import.wast.dat │ ├── merge │ │ ├── chain.wat.second │ │ ├── chain.wat.third │ │ ├── import_cycle.wat.second │ │ ├── global-ordering.wat.second │ │ ├── export_options_default.wat.second │ │ ├── sourcemap.wat.second │ │ ├── start.flip.wat.second │ │ ├── start3.wat.third │ │ ├── table64.wat.second │ │ ├── func_subtyping.wat.second │ │ ├── export_options.wat.second │ │ ├── global_subtyping.wat.second │ │ ├── start.wat.second │ │ ├── import_cycle.wat │ │ └── memory_data.wat.second │ ├── control-flow-input.wast.wasm │ ├── fuzz-preserve-imports-exports.wast.dat │ ├── node │ │ ├── fuzz_shell_second.wast.second │ │ └── fuzz_shell.wast │ ├── metadce │ │ ├── sourcemap.wat.json │ │ └── remove-unused-module-elements.wat.json │ ├── parse-bad-identifier.wast │ ├── parse-error.wast │ ├── validation │ │ ├── global-cycle.wast │ │ ├── non-ref.wast │ │ ├── nullref-no-gc.wast │ │ ├── imports.wast │ │ ├── bulk.wast │ │ ├── exact-import.wast │ │ ├── nn-locals-ok.wast │ │ ├── open-types-no-gc.wast │ │ ├── function-missing.wast │ │ ├── supertypes-no-gc.wast │ │ ├── array-new-fixed.wast │ │ ├── nn-locals-bad.wast │ │ ├── rec-groups-no-gc.wast │ │ ├── shared-memory.wast │ │ ├── pause.wast │ │ ├── ref-func-simd.wast │ │ ├── nn-tuples.wast │ │ ├── ref-gc-simd.wast │ │ ├── table-type.wast │ │ ├── elem-type.wast │ │ └── fp16.wast │ ├── lit.site.cfg.py.in │ ├── parse-bad-assertion.wast │ ├── sourcemap-sourceroot-file.wat.map │ ├── parse-error-return-nofunc.wast │ ├── parse-bad-tuple-in-sig.wast │ ├── exec │ │ ├── second.wast.second │ │ ├── call_ref-import-cross-module.wast.second │ │ └── second_retcall.wast.second │ ├── parse-bad-supertype.wast │ ├── parse-error-func-param-type.wast │ ├── num_cores.wast │ ├── parse-bad-tuple-extract-index.wast │ ├── parse-bad-gc-rmw-orders.wast │ ├── parse-bad-supertype-8616.wast │ ├── parse-bad-gc-cmpxchg-orders.wast │ ├── stdin-stdout.wast │ ├── parse-bad-gc-br_on-novalue.wast │ ├── d8 │ │ └── fuzz_shell.wast │ ├── structref.wast │ ├── parse-bad-optional-memidx.wast │ ├── parse-bad-nominal-types.wast │ ├── table64.wast │ └── ctor-eval │ │ └── flatten_overflow.wast ├── metadce │ ├── tag.wast.dced.stdout │ ├── ref-func.wast.dced.stdout │ ├── segments.wast.dced.stdout │ ├── 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 │ ├── name_collision.wast.dced.stdout │ ├── threaded.wast.dced.stdout │ ├── corners.wast.dced.stdout │ ├── table.wast.dced.stdout │ ├── all-outside.wast.dced.stdout │ ├── spanning_cycle_unrooted.wast.dced.stdout │ ├── table.wast.graph.txt │ ├── name_collision.wast.dced │ ├── name_collision.wast.graph.txt │ ├── outside.wast.dced.stdout │ ├── rooted-export.wast.dced.stdout │ ├── no-outside.wast.dced.stdout │ ├── spanning_cycle_unrooted.wast │ ├── tag.wast.graph.txt │ ├── outside.wast.graph.txt │ ├── tag.wast │ ├── ref-func.wast │ ├── rooted-export.wast.graph.txt │ ├── spanning_cycle_unrooted.wast.graph.txt │ ├── tag.wast.dced │ ├── rooted-export.wast.dced │ ├── corners.wast.graph.txt │ ├── segments.wast.graph.txt │ ├── no-outside.wast │ ├── spanning_cycle.wast.graph.txt │ ├── threaded_unrooted.wast.dced.stdout │ ├── ref-func.wast.dced │ ├── threaded_unrooted_cycle.wast.dced.stdout │ ├── spanning_cycle.wast.dced │ ├── ref-func.wast.graph.txt │ ├── segments.wast │ ├── rooted-export.wast │ ├── spanning_cycle.wast │ ├── segments.wast.dced │ └── table.wast.dced ├── binaryen.js │ ├── pass-arguments.js.txt │ ├── passes-to-skip.js.txt │ ├── copy-expression.js.txt │ ├── tail_calls.js.txt │ ├── fast-math.js.txt │ ├── closed-world.js.txt │ ├── generate-stack-ir.js.txt │ ├── optimize-stack-ir.js.txt │ ├── traps-never-happen.js.txt │ ├── simd.js.txt │ ├── custom-section.js.txt │ ├── expressionrunner.js.txt │ ├── fast-math.js │ ├── closed-world.js │ ├── inlining-options.js.txt │ ├── generate-stack-ir.js │ ├── optimize-stack-ir.js │ ├── traps-never-happen.js │ ├── custom-section.js │ ├── passes-to-skip.js │ ├── simd.js │ ├── validation_errors.js.txt │ ├── emit_asmjs.js │ ├── sourcemap.js.txt │ ├── reloc.js.txt │ ├── memory-info.js.txt │ ├── tag.js.txt │ ├── pass-arguments.js │ ├── debug-info.js.txt │ ├── functions.js.txt │ └── sideffects.js.txt ├── ctor-eval │ ├── gc.wast.ctors │ ├── gc-2.wast.ctors │ ├── globals.wast.ctors │ ├── params.wast.ctors │ ├── partial.wast.ctors │ ├── gc-array.wast.ctors │ ├── memory-init.wast.ctors │ ├── unsafe_call.wast.ctors │ ├── unsafe_store.wast.ctors │ ├── bad-indirect-call.wast.ctors │ ├── global-get-init.wast.ctors │ ├── imported-global-2.wast.ctors │ ├── imported-global.wast.ctors │ ├── indirect-call3.wast.ctors │ ├── partial-locals.wast.ctors │ ├── partial-return.wast.ctors │ ├── unsafe_store2.wast.ctors │ ├── unsafe_store3.wast.ctors │ ├── bad-indirect-call2.wast.ctors │ ├── basics.wast.ctors │ ├── just_some.wast.ctors │ ├── overlapping-segments.wast.ctors │ ├── partial-locals-tee.wast.ctors │ ├── unsafe_store.wast.out │ ├── unsafe_store2.wast.out │ ├── unsafe_store3.wast.out │ ├── bad-indirect-call3.wast.ctors │ ├── basics-flatten.wast.ctors │ ├── ignore-external-input-gc.wast.ctors │ ├── results.wast.ctors │ ├── ignore-external-input.wast.ctors │ ├── partial-return.wast.out │ ├── params.wast.out │ ├── basics.wast.out │ ├── indirect-call3.wast.out │ ├── basics-flatten.wast.out │ ├── unsafe_store.wast │ ├── unsafe_store2.wast │ ├── global-get-init.wast.out │ ├── params.wast │ ├── unsafe_store3.wast │ ├── imported-global.wast.out │ ├── globals.wast.out │ ├── global-get-init.wast │ ├── bad-indirect-call3.wast.out │ ├── just_some.wast.out │ ├── memory-init.wast.out │ ├── imported-global.wast │ ├── ignore-external-input.wast.out │ ├── partial-locals-tee.wast.out │ ├── unsafe_call.wast │ ├── bad-indirect-call.wast │ ├── overlapping-segments.wast.out │ ├── globals.wast │ └── unsafe_call.wast.out ├── example │ ├── cpp-unit.txt │ ├── domtree.txt │ ├── hash.txt │ ├── small_set.txt │ ├── small_vector.txt │ ├── space.txt │ ├── local-graph.txt │ ├── c-api-relooper-unreachable-if.txt │ ├── sparse_square_matrix.txt │ ├── debug-location-propagation.txt │ ├── cpp-threads.txt │ ├── c-api-hello-world.txt │ ├── stack-utils.txt │ └── match.txt ├── linker │ ├── baz.c │ ├── quux.c │ ├── foo.c │ ├── bar.c │ └── main.c ├── calls.emcc ├── hello_world.txt ├── mem.emcc ├── float_ops.emcc ├── hello_libcxx.txt ├── int_ops.emcc ├── passes │ ├── multi_unit_abbrev_noprint.bin.txt │ ├── dwarf_unit_with_no_abbrevs_noprint.bin.txt │ ├── safe-heap_start-function.passes │ ├── fib2_dwarf.passes │ ├── inlined_to_start_dwarf.passes │ ├── reverse_dwarf_abbrevs.passes │ ├── class_with_dwarf_noprint.passes │ ├── dwarf_unit_with_no_abbrevs_noprint.passes │ ├── fannkuch0_dwarf.passes │ ├── fannkuch3_dwarf.passes │ ├── fuzz_metrics_noprint.passes │ ├── fib2_emptylocspan_dwarf.passes │ ├── dwarf_with_exceptions.passes │ ├── fannkuch3_manyopts_dwarf.passes │ ├── multi_unit_abbrev_noprint.passes │ ├── set-globals.passes │ ├── strip-target-features.wasm │ ├── fuzz_metrics_passes_noprint.passes │ ├── ignore_missing_func_dwarf.passes │ ├── O.wasm │ ├── dwarf-local-order.passes │ ├── multi_line_table_dwarf.passes │ ├── sparse_matrix_liveness.passes │ ├── fib_nonzero-low-pc_dwarf.passes │ ├── print.wasm │ ├── strip-target-features.bin.txt │ ├── dwarfdump.wasm │ ├── flatten.wasm │ ├── print_g.wasm │ ├── fib2_dwarf.wasm │ ├── strip-debug.wasm │ ├── strip-dwarf.wasm │ ├── roundtrip_typenames_features.passes │ ├── safe-heap_enable-threads_enable-simd64.passes │ ├── fannkuch0_dwarf.wasm │ ├── fannkuch3_dwarf.wasm │ ├── print_g_metrics.wasm │ ├── set-globals.txt │ ├── strip-producers.wasm │ ├── converge_O3_metrics.wasm │ ├── dwarf-local-order.wasm │ ├── print_g_strip-dwarf.wasm │ ├── dwarf_with_exceptions.wasm │ ├── fuzz_metrics_noprint.wasm │ ├── print-function-map.wast │ ├── reverse_dwarf_abbrevs.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 │ ├── sparse_matrix_liveness.wasm │ ├── ignore_missing_func_dwarf.wasm │ ├── multi_unit_abbrev_noprint.wasm │ ├── dwarfdump_roundtrip_dwarfdump.wasm │ ├── fuzz_metrics_passes_noprint.wasm │ ├── metrics_strip-debug_metrics.wasm │ ├── dce_vacuum_remove-unused-names.wasm │ ├── metrics_strip-producers_metrics.wasm │ ├── dwarf_unit_with_no_abbrevs_noprint.wasm │ ├── roundtrip_signed.passes │ ├── set-globals.wast │ ├── interesting-pass-mix.passes │ ├── roundtrip_signed.wasm │ ├── print-function-map.txt │ ├── roundtrip.txt │ ├── reorder-functions.txt │ ├── vacuum_remove-unused-names_merge-blocks.txt │ ├── merge-blocks_remove-unused-brs.wast │ ├── emit-spec-wrapper=a.wat.wast.wat │ ├── reorder-functions.wast │ ├── merge-blocks_remove-unused-brs.txt │ ├── roundtrip.wast │ ├── vacuum_ignore-implicit-traps.txt │ ├── minify-imports-and-exports-and-modules.wast │ ├── remove-unused-brs_precompute_vacuum_remove-unused-brs.txt │ ├── roundtrip_typenames_features.txt │ ├── duplicate-import-elimination.wast │ ├── safe-heap_disable-simd.wast │ ├── strip-debug.bin.txt │ ├── roundtrip_typenames_features.wast │ ├── simplify-locals.txt │ ├── duplicate-import-elimination.txt │ ├── minify-imports-and-exports-and-modules.txt │ ├── fpcast-emu_pass-arg=max-func-params@5.wast │ ├── strip-target-features_roundtrip_print-features_all-features.wast │ ├── souperify.wast │ ├── remove-unused-brs_generate-stack-ir_print-stack-ir.wast │ ├── souperify.txt │ ├── remove-imports.txt │ ├── remove-unused-names_precompute.txt │ ├── O1_print-stack-ir.wast │ ├── O2_print-stack-ir.wast │ ├── O3_print-stack-ir.wast │ ├── pick-load-signs_all-features.wast │ ├── pick-load-signs_all-features.txt │ ├── reorder-locals_print_roundtrip.wast │ └── Os_print-stack-ir_all-features_disable-gc.wast ├── br_to_exit.wasm ├── control_flow.emcc ├── elided-br.wasm ├── grow_memory.emcc ├── spec │ ├── expected-output │ │ ├── func_ptrs.wast.log │ │ ├── names.wast.log │ │ ├── old_start.wast.log │ │ └── old_imports.wast.log │ ├── 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-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 │ ├── call_indirect_refnull.wast │ ├── ref_null.wast │ ├── Contributing.md │ ├── ref_is_null.wast │ └── call_indirect_sig_mismatch.wast ├── unreachable-pops.wasm ├── br_to_try.wasm ├── consume-stacky.wasm ├── break-within-catch.wasm ├── fn_prolog_epilog.debugInfo.wasm ├── print │ ├── memory-shared.minified.txt │ ├── memory-shared.txt │ ├── memory-shared.wast │ ├── memory-import-shared.minified.txt │ ├── memory-import-shared.txt │ └── memory-import-shared.wast ├── dylib.wasm ├── mutable-global.wasm ├── stacky.wasm ├── try-delegate.wasm ├── validator │ ├── invalid_return.wast │ ├── invalid_import.wast │ ├── invalid_export.wast │ └── invalid_number.wast ├── fib-dbg.wasm ├── metadatas.wasm ├── crash │ ├── outside.wasm │ ├── use_var_outside_func.wasm │ └── expression-past-end-of-input.wasm ├── wasm2js │ ├── base64.wast │ ├── empty_export.wast │ ├── atomic_fence.wast │ ├── dot_import.wast │ ├── start_func.wast │ ├── minified-memory.wast │ ├── emscripten-grow-no.wast │ ├── export_global.wast │ ├── emscripten-grow-yes.wast │ ├── global_i64.wast │ ├── i64-ctz.wast │ ├── add_div.wast │ ├── unreachable-insts.wast │ ├── target_js.wast │ ├── deterministic.wast │ ├── excess_fallthrough.wast │ ├── minus_minus.wast │ ├── nested-selects.wast │ ├── base64.2asm.js │ ├── base64.2asm.js.opt │ ├── empty_table.2asm.js │ ├── i64-select.2asm.js │ ├── i64-select.2asm.js.opt │ ├── if_unreachable.2asm.js │ ├── unreachable-if.2asm.js │ ├── unreachable-insts.2asm.js │ ├── if_unreachable.2asm.js.opt │ ├── reinterpret_scratch.wast │ ├── unreachable-get-cycle.2asm.js │ ├── unreachable-if.2asm.js.opt │ ├── unreachable-insts.2asm.js.opt │ ├── empty_loop.wast │ ├── unreachable-get-cycle.2asm.js.opt │ ├── unreachable-if.wast │ └── br_table_to_loop.wast ├── break-to-return.wasm ├── complexBinaryNames.wasm ├── lld │ ├── em_asm_pthread.wasm │ ├── shared_add_to_table.wasm │ ├── hello_world.c │ ├── init.c │ ├── em_asm64.cpp │ ├── em_asm_O0.c │ ├── em_asm.cpp │ ├── em_asm_shared.cpp │ ├── shared.cpp │ ├── em_asm_pthread.cpp │ ├── shared_longjmp.c │ ├── longjmp.c │ ├── main_module_table.wat │ ├── main_module_table.wat.out │ ├── recursive.c │ ├── main_module_table_2.wat │ ├── main_module_table_2.wat.out │ ├── main_module_table_3.wat │ ├── standalone-wasm3.wat │ ├── main_module_table_3.wat.out │ ├── main_module_table_4.wat │ ├── standalone-wasm3.wat.out │ └── main_module_table_4.wat.out ├── fib-dbg.wasm.map ├── hello_world.c ├── bigswitch.txt ├── fn_prolog_epilog.debugInfo.wasm.map ├── hello_libcxx.cpp ├── fasta.txt ├── br_to_exit.wasm.fromBinary ├── reduce │ ├── imports.wast.txt │ ├── simple.wast.txt │ ├── destructive.wast.txt │ ├── simple.wast │ ├── atomics-and-bulk-memory.wast.txt │ ├── destructive.wast │ ├── imports.wast │ └── gc.wast.txt ├── printf.txt ├── elided-br.wasm.fromBinary ├── unreachable-pops.wasm.fromBinary ├── complexBinaryNames.wasm.fromBinary ├── metadatas.wasm.fromBinary ├── memory-import64.wast.wasm.fromBinary ├── multi-table.minified.txt ├── calls.txt ├── mutable-global.wasm.fromBinary ├── hello_world.wat ├── consume-stacky.wasm.fromBinary ├── fn_prolog_epilog.debugInfo.wasm.fromBinary ├── br_to_try.wasm.fromBinary ├── fannkuch.txt ├── break-within-catch.wasm.fromBinary ├── break-to-return.wasm.fromBinary ├── grow_memory.txt ├── grow_memory.cpp ├── gtest │ └── json.cpp ├── stacky.wasm.fromBinary └── calls.cpp ├── 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 ├── .clang-format └── FP16 │ ├── include │ └── fp16.h │ └── readme.txt ├── config.h.in ├── src ├── templates │ ├── normal.js │ └── wasm.js ├── cfg │ └── CMakeLists.txt ├── js │ └── binaryen.jsoo-extern-pre.js ├── analysis │ └── CMakeLists.txt ├── tools │ ├── wasm-reduce │ │ └── CMakeLists.txt │ └── wasm-split │ │ └── CMakeLists.txt ├── asmjs │ └── CMakeLists.txt ├── interpreter │ └── CMakeLists.txt ├── passes │ └── WasmIntrinsics.cpp.in ├── emscripten-optimizer │ └── CMakeLists.txt ├── wasm │ ├── wasm-interpreter.cpp │ └── CMakeLists.txt └── parser │ └── CMakeLists.txt ├── media ├── example.png └── just_flow_stuff.pdf ├── .gitattributes ├── scripts ├── test │ ├── mod.ule.js │ └── env.js └── strip_local_names.py ├── .github └── codecov.yml ├── fuzz └── readme.txt ├── requirements-dev.txt ├── .flake8 ├── ubsan.blacklist ├── .clang-format ├── .git-blame-ignore-revs └── .gitmodules /test/revision: -------------------------------------------------------------------------------- 1 | 13645 2 | -------------------------------------------------------------------------------- /test/unit/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fannkuch.args: -------------------------------------------------------------------------------- 1 | ["5"] 2 | -------------------------------------------------------------------------------- /test/fasta.args: -------------------------------------------------------------------------------- 1 | ["10"] 2 | -------------------------------------------------------------------------------- /test/lit/wasm-split/none.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/metadce/tag.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/binaryen.js/pass-arguments.js.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/binaryen.js/passes-to-skip.js.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/ctor-eval/gc.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/example/cpp-unit.txt: -------------------------------------------------------------------------------- 1 | Success 2 | -------------------------------------------------------------------------------- /test/example/domtree.txt: -------------------------------------------------------------------------------- 1 | success. 2 | -------------------------------------------------------------------------------- /test/example/hash.txt: -------------------------------------------------------------------------------- 1 | success. 2 | -------------------------------------------------------------------------------- /test/example/small_set.txt: -------------------------------------------------------------------------------- 1 | ok. 2 | -------------------------------------------------------------------------------- /test/example/small_vector.txt: -------------------------------------------------------------------------------- 1 | ok. 2 | -------------------------------------------------------------------------------- /test/example/space.txt: -------------------------------------------------------------------------------- 1 | success. 2 | -------------------------------------------------------------------------------- /test/linker/baz.c: -------------------------------------------------------------------------------- 1 | void baz() {} 2 | -------------------------------------------------------------------------------- /test/linker/quux.c: -------------------------------------------------------------------------------- 1 | void quux() {} 2 | -------------------------------------------------------------------------------- /test/lit/wasm-split/bar.txt: -------------------------------------------------------------------------------- 1 | bar 2 | -------------------------------------------------------------------------------- /test/lit/wasm-split/foo.txt: -------------------------------------------------------------------------------- 1 | foo 2 | -------------------------------------------------------------------------------- /test/metadce/ref-func.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/metadce/segments.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/unit/input/empty.wasm: -------------------------------------------------------------------------------- 1 | asm -------------------------------------------------------------------------------- /test/unit/input/package.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /third_party/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: '' 2 | -------------------------------------------------------------------------------- /test/binaryen.js/copy-expression.js.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/calls.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /test/ctor-eval/gc-2.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/globals.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/params.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/partial.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/example/local-graph.txt: -------------------------------------------------------------------------------- 1 | Success. 2 | -------------------------------------------------------------------------------- /test/hello_world.txt: -------------------------------------------------------------------------------- 1 | hello, world! 2 | 3 | -------------------------------------------------------------------------------- /test/mem.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /test/metadce/all-outside.wast: -------------------------------------------------------------------------------- 1 | (module) 2 | -------------------------------------------------------------------------------- /test/ctor-eval/gc-array.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/memory-init.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/unsafe_call.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/unsafe_store.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/example/c-api-relooper-unreachable-if.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/example/sparse_square_matrix.txt: -------------------------------------------------------------------------------- 1 | ok. 2 | -------------------------------------------------------------------------------- /test/float_ops.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /test/hello_libcxx.txt: -------------------------------------------------------------------------------- 1 | hello, world! 2 | 3 | -------------------------------------------------------------------------------- /test/int_ops.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /test/linker/foo.c: -------------------------------------------------------------------------------- 1 | int foo() { return 43; } 2 | -------------------------------------------------------------------------------- /test/lit/wasm-split/both.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar 3 | -------------------------------------------------------------------------------- /test/metadce/spanning_cycle.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/metadce/threaded_cycle.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/passes/multi_unit_abbrev_noprint.bin.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /third_party/v8/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /test/binaryen.js/tail_calls.js.txt: -------------------------------------------------------------------------------- 1 | true 2 | true 3 | -------------------------------------------------------------------------------- /test/br_to_exit.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  -------------------------------------------------------------------------------- /test/control_flow.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ASSERTIONS=0"] 2 | -------------------------------------------------------------------------------- /test/ctor-eval/bad-indirect-call.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/global-get-init.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/imported-global-2.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/imported-global.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/indirect-call3.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/partial-locals.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/partial-return.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/unsafe_store2.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/unsafe_store3.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/lit/binary/component-error.test.wasm: -------------------------------------------------------------------------------- 1 | asm  -------------------------------------------------------------------------------- /test/lit/passes/asyncify-foo,bar-nl.txt: -------------------------------------------------------------------------------- 1 | foo 2 | bar -------------------------------------------------------------------------------- /test/lit/sourcemap-sourceroot-file.wat.wasm: -------------------------------------------------------------------------------- 1 | asm -------------------------------------------------------------------------------- /test/metadce/all-outside.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /test/metadce/no-outside.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /third_party/mozjs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /test/binaryen.js/fast-math.js.txt: -------------------------------------------------------------------------------- 1 | // fastMath=false 2 | -------------------------------------------------------------------------------- /test/ctor-eval/bad-indirect-call2.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/basics.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3 2 | -------------------------------------------------------------------------------- /test/ctor-eval/just_some.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3 2 | -------------------------------------------------------------------------------- /test/ctor-eval/overlapping-segments.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/partial-locals-tee.wast.ctors: -------------------------------------------------------------------------------- 1 | test1 2 | -------------------------------------------------------------------------------- /test/ctor-eval/unsafe_store.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /test/ctor-eval/unsafe_store2.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /test/ctor-eval/unsafe_store3.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /test/elided-br.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  @@  -------------------------------------------------------------------------------- /test/example/debug-location-propagation.txt: -------------------------------------------------------------------------------- 1 | success. 2 | -------------------------------------------------------------------------------- /test/grow_memory.emcc: -------------------------------------------------------------------------------- 1 | ["-s", "ALLOW_MEMORY_GROWTH=1"] 2 | -------------------------------------------------------------------------------- /test/lit/binary/global-local-get.test.wasm: -------------------------------------------------------------------------------- 1 | asm -------------------------------------------------------------------------------- /test/metadce/threaded_unrooted.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /test/passes/dwarf_unit_with_no_abbrevs_noprint.bin.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/passes/safe-heap_start-function.passes: -------------------------------------------------------------------------------- 1 | safe-heap 2 | -------------------------------------------------------------------------------- /test/spec/expected-output/func_ptrs.wast.log: -------------------------------------------------------------------------------- 1 | 83 : i32 2 | -------------------------------------------------------------------------------- /third_party/llvm-project/include/llvm/Support/Threading.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/binaryen.js/closed-world.js.txt: -------------------------------------------------------------------------------- 1 | // closedWorld=false 2 | -------------------------------------------------------------------------------- /test/ctor-eval/bad-indirect-call3.wast.ctors: -------------------------------------------------------------------------------- 1 | sig_mismatch 2 | -------------------------------------------------------------------------------- /test/ctor-eval/basics-flatten.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3 2 | -------------------------------------------------------------------------------- /test/linker/bar.c: -------------------------------------------------------------------------------- 1 | void quux(); 2 | void bar() { quux(); } 3 | -------------------------------------------------------------------------------- /test/lit/binary/global-local-set.test.wasm: -------------------------------------------------------------------------------- 1 | asmA! -------------------------------------------------------------------------------- /test/lit/binary/global-local-tee.test.wasm: -------------------------------------------------------------------------------- 1 | asmA" -------------------------------------------------------------------------------- /test/metadce/no-outside.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | ] 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/unreachable-pops.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 | j -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | #cmakedefine PROJECT_VERSION "${PROJECT_VERSION}" 2 | -------------------------------------------------------------------------------- /test/br_to_try.wasm: -------------------------------------------------------------------------------- 1 | asm``  2 |  3 | @  -------------------------------------------------------------------------------- /test/consume-stacky.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  AAA6 -------------------------------------------------------------------------------- /test/ctor-eval/ignore-external-input-gc.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2 2 | -------------------------------------------------------------------------------- /test/ctor-eval/results.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test3,test4,test5 2 | -------------------------------------------------------------------------------- /test/metadce/spanning_cycle_unrooted.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /test/metadce/threaded_unrooted_cycle.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | ) 3 | -------------------------------------------------------------------------------- /test/passes/fib2_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/passes/inlined_to_start_dwarf.passes: -------------------------------------------------------------------------------- 1 | g_roundtrip_dwarfdump 2 | -------------------------------------------------------------------------------- /test/passes/reverse_dwarf_abbrevs.passes: -------------------------------------------------------------------------------- 1 | roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/spec/expected-output/names.wast.log: -------------------------------------------------------------------------------- 1 | 42 : i32 2 | 123 : i32 3 | -------------------------------------------------------------------------------- /test/spec/expected-output/old_start.wast.log: -------------------------------------------------------------------------------- 1 | 1 : i32 2 | 2 : i32 3 | -------------------------------------------------------------------------------- /test/binaryen.js/generate-stack-ir.js.txt: -------------------------------------------------------------------------------- 1 | // generateStackIR=false 2 | -------------------------------------------------------------------------------- /test/binaryen.js/optimize-stack-ir.js.txt: -------------------------------------------------------------------------------- 1 | // optimizeStackIR=false 2 | -------------------------------------------------------------------------------- /test/binaryen.js/traps-never-happen.js.txt: -------------------------------------------------------------------------------- 1 | // trapsNeverHappen=false 2 | -------------------------------------------------------------------------------- /test/metadce/name_collision.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: func$other$0 2 | -------------------------------------------------------------------------------- /test/metadce/threaded.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: outside_js_function1 2 | -------------------------------------------------------------------------------- /test/passes/class_with_dwarf_noprint.passes: -------------------------------------------------------------------------------- 1 | roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/passes/dwarf_unit_with_no_abbrevs_noprint.passes: -------------------------------------------------------------------------------- 1 | roundtrip_g 2 | -------------------------------------------------------------------------------- /test/passes/fannkuch0_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/passes/fannkuch3_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/passes/fuzz_metrics_noprint.passes: -------------------------------------------------------------------------------- 1 | translate-to-fuzz_metrics 2 | -------------------------------------------------------------------------------- /test/break-within-catch.wasm: -------------------------------------------------------------------------------- 1 | asm``  2 |  @ -------------------------------------------------------------------------------- /test/ctor-eval/ignore-external-input.wast.ctors: -------------------------------------------------------------------------------- 1 | test1,test2,test2b,test3 2 | -------------------------------------------------------------------------------- /test/fn_prolog_epilog.debugInfo.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  @@  -------------------------------------------------------------------------------- /test/passes/fib2_emptylocspan_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/print/memory-shared.minified.txt: -------------------------------------------------------------------------------- 1 | (module(memory $0 23 256 shared) 2 | ) -------------------------------------------------------------------------------- /test/print/memory-shared.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 23 256 shared) 3 | ) 4 | -------------------------------------------------------------------------------- /test/print/memory-shared.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 23 256 shared) 3 | ) 4 | -------------------------------------------------------------------------------- /third_party/wabt/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !wasm2c 4 | !wasm2c/* 5 | -------------------------------------------------------------------------------- /test/lit/binary/delegate-block.test.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 |  3 | @@ -------------------------------------------------------------------------------- /test/lit/binary/name-overlap.test.wasm: -------------------------------------------------------------------------------- 1 | asm A A name global$1 -------------------------------------------------------------------------------- /test/passes/dwarf_with_exceptions.passes: -------------------------------------------------------------------------------- 1 | print_dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/passes/fannkuch3_manyopts_dwarf.passes: -------------------------------------------------------------------------------- 1 | dwarfdump_O4_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/passes/multi_unit_abbrev_noprint.passes: -------------------------------------------------------------------------------- 1 | g_roundtrip_roundtrip_roundtrip 2 | -------------------------------------------------------------------------------- /test/passes/set-globals.passes: -------------------------------------------------------------------------------- 1 | set-globals_pass-arg=set-globals@foo=1337,bar=42 2 | -------------------------------------------------------------------------------- /test/passes/strip-target-features.wasm: -------------------------------------------------------------------------------- 1 | asm linkingtarget_features+foo -------------------------------------------------------------------------------- /test/spec/func-local-after-body.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (nop) (local i32))) 2 | -------------------------------------------------------------------------------- /test/spec/func-param-after-body.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (nop) (param i32))) 2 | -------------------------------------------------------------------------------- /test/spec/func-result-after-body.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (nop) (result i32))) 2 | -------------------------------------------------------------------------------- /test/spec/import-after-func.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func) (import "" "" (memory 0))) 2 | -------------------------------------------------------------------------------- /third_party/llvm-project/include/llvm/Config/abi-breaking.h: -------------------------------------------------------------------------------- 1 | 2 | // waka 3 | 4 | -------------------------------------------------------------------------------- /src/templates/normal.js: -------------------------------------------------------------------------------- 1 | 2 | var Module = {}; // *.asm.js expects this 3 | 4 | 5 | -------------------------------------------------------------------------------- /test/dylib.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/dylib.wasm -------------------------------------------------------------------------------- /test/lit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file(lit.site.cfg.py.in lit.site.cfg.py @ONLY) 2 | -------------------------------------------------------------------------------- /test/mutable-global.wasm: -------------------------------------------------------------------------------- 1 | asm`env 2 | global-mut 3 |  #Aj$ -------------------------------------------------------------------------------- /test/passes/fuzz_metrics_passes_noprint.passes: -------------------------------------------------------------------------------- 1 | translate-to-fuzz_fuzz-passes_metrics 2 | -------------------------------------------------------------------------------- /test/passes/ignore_missing_func_dwarf.passes: -------------------------------------------------------------------------------- 1 | print_dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/spec/func-local-before-param.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (local i32) (param i32))) 2 | -------------------------------------------------------------------------------- /test/spec/of_string-overflow-s32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i32.const -2147483649))) 2 | -------------------------------------------------------------------------------- /test/spec/of_string-overflow-u32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i32.const 4294967296))) 2 | -------------------------------------------------------------------------------- /test/stacky.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/stacky.wasm -------------------------------------------------------------------------------- /test/try-delegate.wasm: -------------------------------------------------------------------------------- 1 | asm`  2 | ! @@ @@A@  -------------------------------------------------------------------------------- /test/validator/invalid_return.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $foo (result i32) (i64.const 1))) -------------------------------------------------------------------------------- /media/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/media/example.png -------------------------------------------------------------------------------- /test/fib-dbg.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/fib-dbg.wasm -------------------------------------------------------------------------------- /test/passes/O.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/O.wasm -------------------------------------------------------------------------------- /test/passes/dwarf-local-order.passes: -------------------------------------------------------------------------------- 1 | g_print_roundtrip_print_strip-dwarf_roundtrip_print 2 | -------------------------------------------------------------------------------- /test/passes/multi_line_table_dwarf.passes: -------------------------------------------------------------------------------- 1 | g_dwarfdump_roundtrip_dwarfdump_all-features 2 | -------------------------------------------------------------------------------- /test/passes/sparse_matrix_liveness.passes: -------------------------------------------------------------------------------- 1 | metrics_coalesce-locals_metrics_reorder-locals 2 | -------------------------------------------------------------------------------- /test/spec/import-after-table.fail.wast: -------------------------------------------------------------------------------- 1 | (module (table 0 funcref) (import "" "" (func))) 2 | -------------------------------------------------------------------------------- /test/spec/of_string-overflow-hex-u32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i32.const 0x100000000))) 2 | -------------------------------------------------------------------------------- /test/validator/invalid_import.wast: -------------------------------------------------------------------------------- 1 | (module (import "test" "bad" (func $bad (param i64)))) 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.py text eol=lf 2 | *.sh text eol=lf 3 | test/binaryen.js/*.txt text eol=lf 4 | -------------------------------------------------------------------------------- /test/lit/binary/empty-param-name.test.wasm: -------------------------------------------------------------------------------- 1 | asm`importsfoonamefoo -------------------------------------------------------------------------------- /test/lit/wasm-split/multi-split.wast.manifest: -------------------------------------------------------------------------------- 1 | 1: 2 | A 3 | 4 | 2: 5 | B 6 | 7 | 3: 8 | C 9 | -------------------------------------------------------------------------------- /test/metadatas.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/metadatas.wasm -------------------------------------------------------------------------------- /test/metadce/corners.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: global$UNUSEDTOP 2 | unused: ignorable import 3 | -------------------------------------------------------------------------------- /test/spec/import-after-global.fail.wast: -------------------------------------------------------------------------------- 1 | (module (global i64) (import "" "" (table 0 funcref))) 2 | -------------------------------------------------------------------------------- /test/spec/of_string-overflow-hex-u64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i64.const 0x10000000000000000))) 2 | -------------------------------------------------------------------------------- /test/spec/of_string-overflow-s64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i64.const -9223372036854775809))) 2 | -------------------------------------------------------------------------------- /test/spec/of_string-overflow-u64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (i64.const 18446744073709551616))) 2 | -------------------------------------------------------------------------------- /test/crash/outside.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/crash/outside.wasm -------------------------------------------------------------------------------- /test/lit/binary/debug-bad-binary.test.wasm: -------------------------------------------------------------------------------- 1 | asm`A 2 | 3 | A 4 |   A -------------------------------------------------------------------------------- /test/metadce/table.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: eseg$passive-elem-unused 2 | unused: table$table-unused 3 | -------------------------------------------------------------------------------- /test/passes/fib_nonzero-low-pc_dwarf.passes: -------------------------------------------------------------------------------- 1 | enable-mutable-globals_dwarfdump_roundtrip_dwarfdump_g 2 | -------------------------------------------------------------------------------- /test/passes/print.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/print.wasm -------------------------------------------------------------------------------- /test/passes/strip-target-features.bin.txt: -------------------------------------------------------------------------------- 1 | (module 2 | ;; custom section "linking", size 1 3 | ) 4 | -------------------------------------------------------------------------------- /test/print/memory-import-shared.minified.txt: -------------------------------------------------------------------------------- 1 | (module(import "env" "memory" (memory $0 256 256 shared))) -------------------------------------------------------------------------------- /test/spec/func-local-before-result.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (local i32) (result i32) (local.get 0))) 2 | -------------------------------------------------------------------------------- /test/spec/func-result-before-param.fail.wast: -------------------------------------------------------------------------------- 1 | (module (func (result i32) (param i32) (local.get 0))) 2 | -------------------------------------------------------------------------------- /test/unit/input/only-imported-memory.wasm: -------------------------------------------------------------------------------- 1 | asm`abtest 2 | A 3 | ( -------------------------------------------------------------------------------- /test/unit/input/random_data.txt: -------------------------------------------------------------------------------- 1 | 6sgkjdfghk34589n-947-vn98f2yr-nb8f7t08b7gv*~&!%&^@}{PASD kjgsdf768 2 | -------------------------------------------------------------------------------- /test/wasm2js/base64.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $memory 1 1) 3 | (data (i32.const 2) "\00\fe\ff") 4 | ) -------------------------------------------------------------------------------- /test/wasm2js/empty_export.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "" (func $foo)) 3 | (func $foo) 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /third_party/llvm-project/include/llvm/Config/config.h: -------------------------------------------------------------------------------- 1 | 2 | // waka waka 3 | 4 | #include 5 | -------------------------------------------------------------------------------- /media/just_flow_stuff.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/media/just_flow_stuff.pdf -------------------------------------------------------------------------------- /scripts/test/mod.ule.js: -------------------------------------------------------------------------------- 1 | 2 | export function ba_se() { 3 | console.log('"mod.ule"."ba.se"'); 4 | } 5 | -------------------------------------------------------------------------------- /test/break-to-return.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/break-to-return.wasm -------------------------------------------------------------------------------- /test/passes/dwarfdump.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/dwarfdump.wasm -------------------------------------------------------------------------------- /test/passes/flatten.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/flatten.wasm -------------------------------------------------------------------------------- /test/passes/print_g.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/print_g.wasm -------------------------------------------------------------------------------- /third_party/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | DisableFormat: true 4 | SortIncludes: false 5 | --- 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/complexBinaryNames.wasm: -------------------------------------------------------------------------------- 1 | asm` $zoo (.bar) 2 | 3 |   name 4 | foo (.bar)1 -------------------------------------------------------------------------------- /test/lld/em_asm_pthread.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lld/em_asm_pthread.wasm -------------------------------------------------------------------------------- /test/passes/fib2_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/fib2_dwarf.wasm -------------------------------------------------------------------------------- /test/passes/strip-debug.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/strip-debug.wasm -------------------------------------------------------------------------------- /test/passes/strip-dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/strip-dwarf.wasm -------------------------------------------------------------------------------- /test/print/memory-import-shared.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 256 256 shared)) 3 | ) 4 | -------------------------------------------------------------------------------- /test/print/memory-import-shared.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 256 256 shared)) 3 | ) 4 | -------------------------------------------------------------------------------- /test/spec/f32.load32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result f32) (f32.load32 (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/spec/f32.load64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result f32) (f32.load64 (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/spec/f64.load32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result f64) (f64.load32 (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/spec/f64.load64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result f64) (f64.load64 (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/fib-dbg.wasm.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["fib.c"],"names":[],"mappings":"moBAEA,4BAKA,QAJA,OADA,OAAA,uCAKA"} 2 | -------------------------------------------------------------------------------- /test/hello_world.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("hello, world!\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /test/lit/fuzz-import.wast.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lit/fuzz-import.wast.dat -------------------------------------------------------------------------------- /test/lit/merge/chain.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | (import "first" "f" (func $f)) 3 | (export "g" (func $f)) 4 | ) 5 | -------------------------------------------------------------------------------- /test/passes/roundtrip_typenames_features.passes: -------------------------------------------------------------------------------- 1 | enable-reference-types_enable-gc_emit-target-features_roundtrip 2 | -------------------------------------------------------------------------------- /test/passes/safe-heap_enable-threads_enable-simd64.passes: -------------------------------------------------------------------------------- 1 | safe-heap_enable-threads_enable-simd_enable-memory64 2 | -------------------------------------------------------------------------------- /test/spec/i32.load32_s.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i32) (i32.load32_s (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/spec/i32.load32_u.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i32) (i32.load32_u (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/spec/i32.load64_s.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i32) (i32.load64_s (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/spec/i32.load64_u.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i32) (i32.load64_u (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/spec/i64.load64_s.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i64) (i64.load64_s (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/spec/i64.load64_u.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (result i64) (i64.load64_u (local.get 0)))) 2 | -------------------------------------------------------------------------------- /test/unit/input/dwarf/zlib.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/unit/input/dwarf/zlib.wasm -------------------------------------------------------------------------------- /test/binaryen.js/custom-section.js.txt: -------------------------------------------------------------------------------- 1 | (module 2 | ;; custom section "hello", size 5, contents: "world" 3 | ) 4 | 5 | -------------------------------------------------------------------------------- /test/linker/main.c: -------------------------------------------------------------------------------- 1 | int foo() { return 42; } 2 | 3 | void bar(); 4 | 5 | int main() { 6 | foo(); 7 | bar(); 8 | } 9 | -------------------------------------------------------------------------------- /test/lit/binary/duplicated_names_collision.test.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 | A A A namefoofoofoo.1 -------------------------------------------------------------------------------- /test/lit/binary/dylink.test.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lit/binary/dylink.test.wasm -------------------------------------------------------------------------------- /test/lit/merge/chain.wat.third: -------------------------------------------------------------------------------- 1 | (module 2 | (import "second" "g" (func $g)) 3 | (func (export "h") (call $g)) 4 | ) 5 | -------------------------------------------------------------------------------- /test/lit/merge/import_cycle.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | (import "first" "f" (func $f)) 3 | (export "g" (func $f)) 4 | ) 5 | -------------------------------------------------------------------------------- /test/lld/shared_add_to_table.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lld/shared_add_to_table.wasm -------------------------------------------------------------------------------- /test/passes/fannkuch0_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/fannkuch0_dwarf.wasm -------------------------------------------------------------------------------- /test/passes/fannkuch3_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/fannkuch3_dwarf.wasm -------------------------------------------------------------------------------- /test/passes/print_g_metrics.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/print_g_metrics.wasm -------------------------------------------------------------------------------- /test/passes/set-globals.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (global $foo i32 (i32.const 1337)) 3 | (global $bar i64 (i64.const 42)) 4 | ) 5 | -------------------------------------------------------------------------------- /test/passes/strip-producers.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/strip-producers.wasm -------------------------------------------------------------------------------- /test/unit/input/bulkmem_data.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/unit/input/bulkmem_data.wasm -------------------------------------------------------------------------------- /test/validator/invalid_export.wast: -------------------------------------------------------------------------------- 1 | (module (func $export64 (result i64) (i64.const 1)) (export "a" (func $export64))) 2 | -------------------------------------------------------------------------------- /third_party/llvm-project/include/llvm/Support/CommandLine.h: -------------------------------------------------------------------------------- 1 | // XXX BINARYEN - we don't need this, but stuff imports it 2 | -------------------------------------------------------------------------------- /test/bigswitch.txt: -------------------------------------------------------------------------------- 1 | 34962: GL_ARRAY_BUFFER (0x8892) 2 | 26214: what? 3 | 35040: GL_STREAM_DRAW (0x88E0) 4 | 3060: what? 5 | 6 | -------------------------------------------------------------------------------- /test/crash/use_var_outside_func.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/crash/use_var_outside_func.wasm -------------------------------------------------------------------------------- /test/fn_prolog_epilog.debugInfo.wasm.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["src.cpp"],"names":[],"mappings":"sBAAC,EACA,EAAC,MACD,CAAC"} -------------------------------------------------------------------------------- /test/lld/hello_world.c: -------------------------------------------------------------------------------- 1 | int puts(const char* str); 2 | 3 | int main() { 4 | puts("Hello, world"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /test/passes/converge_O3_metrics.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/converge_O3_metrics.wasm -------------------------------------------------------------------------------- /test/passes/dwarf-local-order.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/dwarf-local-order.wasm -------------------------------------------------------------------------------- /test/passes/print_g_strip-dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/print_g_strip-dwarf.wasm -------------------------------------------------------------------------------- /test/spec/f32.store32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param f32) (f32.store32 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /test/spec/f32.store64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param f64) (f32.store64 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /test/spec/f64.store32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param f32) (f64.store32 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /test/spec/f64.store64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param f64) (f64.store64 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /test/spec/i32.store32.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param i32) (i32.store32 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /test/spec/i32.store64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param i64) (i32.store64 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /test/spec/i64.store64.fail.wast: -------------------------------------------------------------------------------- 1 | (module (memory 1) (func (param i32) (param i64) (i64.store64 (local.get 0) (local.get 1)))) 2 | -------------------------------------------------------------------------------- /third_party/llvm-project/include/llvm/Support/ManagedStatic.h: -------------------------------------------------------------------------------- 1 | // XXX BINARYEN - we don't need this, but stuff imports it 2 | -------------------------------------------------------------------------------- /test/lit/binary/duplicated_names_collision_underscore.test.wasm: -------------------------------------------------------------------------------- 1 | asm` 2 | A A A namefoofoofoo_1 -------------------------------------------------------------------------------- /test/lit/binary/stacky-eh-legacy.test.wasm: -------------------------------------------------------------------------------- 1 | asm``  2 | @A!! %target_features+exception-handling -------------------------------------------------------------------------------- /test/lit/control-flow-input.wast.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lit/control-flow-input.wast.wasm -------------------------------------------------------------------------------- /test/passes/dwarf_with_exceptions.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/dwarf_with_exceptions.wasm -------------------------------------------------------------------------------- /test/passes/fuzz_metrics_noprint.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/fuzz_metrics_noprint.wasm -------------------------------------------------------------------------------- /test/passes/print-function-map.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "foo" (func $Foo)) 3 | (func $bar) 4 | (func $baz) 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /test/passes/reverse_dwarf_abbrevs.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/reverse_dwarf_abbrevs.wasm -------------------------------------------------------------------------------- /test/unit/input/dwarf/cubescript.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/unit/input/dwarf/cubescript.wasm -------------------------------------------------------------------------------- /test/unit/input/gc_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/unit/input/gc_target_feature.wasm -------------------------------------------------------------------------------- /test/binaryen.js/expressionrunner.js.txt: -------------------------------------------------------------------------------- 1 | // ExpressionRunner.Flags.Default = 0 2 | // ExpressionRunner.Flags.PreserveSideeffects = 1 3 | -------------------------------------------------------------------------------- /test/example/cpp-threads.txt: -------------------------------------------------------------------------------- 1 | create threads... 2 | threads running in parallel... 3 | waiting for threads to join... 4 | all done. 5 | -------------------------------------------------------------------------------- /test/hello_libcxx.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | std::cout << "hello, world!" << std::endl; 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /test/lit/binary/bad-datacount.test.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lit/binary/bad-datacount.test.wasm -------------------------------------------------------------------------------- /test/lit/binary/stacky-nn-tuple.test.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lit/binary/stacky-nn-tuple.test.wasm -------------------------------------------------------------------------------- /test/metadce/all-outside.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: island 2 | unused: lonely 3 | unused: loop1 4 | unused: loop2 5 | unused: reverse 6 | -------------------------------------------------------------------------------- /test/metadce/spanning_cycle_unrooted.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: func$a_wasm_func 2 | unused: outside_js_function 3 | unused: wasm_export 4 | -------------------------------------------------------------------------------- /test/passes/class_with_dwarf_noprint.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/class_with_dwarf_noprint.wasm -------------------------------------------------------------------------------- /test/passes/fannkuch3_manyopts_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/fannkuch3_manyopts_dwarf.wasm -------------------------------------------------------------------------------- /test/passes/fib2_emptylocspan_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/fib2_emptylocspan_dwarf.wasm -------------------------------------------------------------------------------- /test/passes/fib_nonzero-low-pc_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/fib_nonzero-low-pc_dwarf.wasm -------------------------------------------------------------------------------- /test/passes/inlined_to_start_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/inlined_to_start_dwarf.wasm -------------------------------------------------------------------------------- /test/passes/multi_line_table_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/multi_line_table_dwarf.wasm -------------------------------------------------------------------------------- /test/passes/sparse_matrix_liveness.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/sparse_matrix_liveness.wasm -------------------------------------------------------------------------------- /test/unit/input/simd_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/unit/input/simd_target_feature.wasm -------------------------------------------------------------------------------- /test/fasta.txt: -------------------------------------------------------------------------------- 1 | GGCCGGGCGCGGTGGCTCAC 2 | cttBtatcatatgctaKggNcataaaSatg 3 | 4 | taaatcttgtgcttcgttagaagtctcgactacgtgtagcctagtgtttg 5 | 6 | -------------------------------------------------------------------------------- /test/lit/binary/dwarf-multivalue.test.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lit/binary/dwarf-multivalue.test.wasm -------------------------------------------------------------------------------- /test/lit/merge/global-ordering.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | (global $second.global (export "second.global.export") i32 (i32.const 42)) 3 | ) 4 | -------------------------------------------------------------------------------- /test/metadce/table.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "func_export", 4 | "root": true, 5 | "export": "test" 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /test/passes/ignore_missing_func_dwarf.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/ignore_missing_func_dwarf.wasm -------------------------------------------------------------------------------- /test/passes/multi_unit_abbrev_noprint.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/multi_unit_abbrev_noprint.wasm -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/unit/input/atomics_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/unit/input/atomics_target_feature.wasm -------------------------------------------------------------------------------- /test/unit/input/bulkmem_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/unit/input/bulkmem_target_feature.wasm -------------------------------------------------------------------------------- /test/unit/input/signext_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/unit/input/signext_target_feature.wasm -------------------------------------------------------------------------------- /test/validator/invalid_number.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $invalid_number 3 | (i64.const 70847791997969805621592064) 4 | ) 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /test/crash/expression-past-end-of-input.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/crash/expression-past-end-of-input.wasm -------------------------------------------------------------------------------- /test/metadce/name_collision.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (export "test" (func $test)) 4 | (func $test (type $0) 5 | ) 6 | ) 7 | -------------------------------------------------------------------------------- /test/metadce/name_collision.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "func$other", 4 | "root": true, 5 | "export": "test" 6 | } 7 | ] 8 | -------------------------------------------------------------------------------- /test/metadce/outside.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: export$wasm_func_unused 2 | unused: func$an_unused_wasm_func 3 | unused: global$__THREW__unused 4 | -------------------------------------------------------------------------------- /test/passes/dwarfdump_roundtrip_dwarfdump.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/dwarfdump_roundtrip_dwarfdump.wasm -------------------------------------------------------------------------------- /test/passes/fuzz_metrics_passes_noprint.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/fuzz_metrics_passes_noprint.wasm -------------------------------------------------------------------------------- /test/passes/metrics_strip-debug_metrics.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/metrics_strip-debug_metrics.wasm -------------------------------------------------------------------------------- /test/unit/input/exception_handling_target_feature.wasm: -------------------------------------------------------------------------------- 1 | asm``  2 | A name0%target_features+exception-handling -------------------------------------------------------------------------------- /test/unit/input/truncsat_target_feature.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/unit/input/truncsat_target_feature.wasm -------------------------------------------------------------------------------- /test/wasm2js/atomic_fence.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 23 256 shared) 3 | (func (export "atomic-fence") 4 | (atomic.fence) 5 | ) 6 | ) 7 | -------------------------------------------------------------------------------- /third_party/FP16/include/fp16.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef FP16_H 3 | #define FP16_H 4 | 5 | #include 6 | 7 | #endif /* FP16_H */ 8 | -------------------------------------------------------------------------------- /test/lit/fuzz-preserve-imports-exports.wast.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lit/fuzz-preserve-imports-exports.wast.dat -------------------------------------------------------------------------------- /test/passes/dce_vacuum_remove-unused-names.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/dce_vacuum_remove-unused-names.wasm -------------------------------------------------------------------------------- /test/passes/metrics_strip-producers_metrics.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/metrics_strip-producers_metrics.wasm -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/br_to_exit.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (func $0 4 | (block $label 5 | (br $label) 6 | ) 7 | ) 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /test/lit/binary/custom-section-build-id.test.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lit/binary/custom-section-build-id.test.wasm -------------------------------------------------------------------------------- /test/lit/merge/export_options_default.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | (func $func1 (export "func") 3 | (drop 4 | (i32.const 1) 5 | ) 6 | ) 7 | ) 8 | -------------------------------------------------------------------------------- /test/passes/dwarf_unit_with_no_abbrevs_noprint.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/passes/dwarf_unit_with_no_abbrevs_noprint.wasm -------------------------------------------------------------------------------- /test/passes/roundtrip_signed.passes: -------------------------------------------------------------------------------- 1 | remove-unused-module-elements_roundtrip_vacuum_remove-unused-brs_merge-blocks_vacuum_duplicate-function-elimination 2 | -------------------------------------------------------------------------------- /test/wasm2js/dot_import.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "mod.ule" "ba.se" (func $base)) 3 | (func $exported (export "exported") 4 | (call $base) 5 | ) 6 | ) 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/binaryen.js/fast-math.js: -------------------------------------------------------------------------------- 1 | console.log("// fastMath=" + binaryen.getFastMath()); 2 | binaryen.setFastMath(true); 3 | assert(binaryen.getFastMath() == true); 4 | -------------------------------------------------------------------------------- /test/lit/binary/data-names.test.wasm: -------------------------------------------------------------------------------- 1 | asm 2 |  -passive1passive2A active1A active26namemem 'active2active1passive2passive1 -------------------------------------------------------------------------------- /test/metadce/rooted-export.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: export$wasm_func_a 2 | unused: export$wasm_tag_a 3 | unused: func$a_wasm_func 4 | unused: tag$a_wasm_tag 5 | -------------------------------------------------------------------------------- /test/ctor-eval/partial-return.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 256 256) 3 | (data $0 (i32.const 10) "__s______________") 4 | (export "memory" (memory $0)) 5 | ) 6 | -------------------------------------------------------------------------------- /test/lit/binary/declarative-element-use-expr.test.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebAssembly/binaryen/HEAD/test/lit/binary/declarative-element-use-expr.test.wasm -------------------------------------------------------------------------------- /test/unit/input/tail_call_target_feature.wasm: -------------------------------------------------------------------------------- 1 | asm` envbarmemoryfoo 2 |  name barfoo0target_features+ tail-call -------------------------------------------------------------------------------- /src/cfg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB cfg_HEADERS *.h) 2 | set(cfg_SOURCES 3 | Relooper.cpp 4 | ${cfg_HEADERS} 5 | ) 6 | target_sources(binaryen PRIVATE ${cfg_SOURCES}) 7 | -------------------------------------------------------------------------------- /src/js/binaryen.jsoo-extern-pre.js: -------------------------------------------------------------------------------- 1 | // js_of_ocaml needs a special syntax for exposing variables to the compiler 2 | 3 | //Provides: Binaryen 4 | var Binaryen = {}; 5 | 6 | -------------------------------------------------------------------------------- /test/lit/merge/sourcemap.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | ;;@ b:7:8 3 | (func (export "g") 4 | ;;@ b:9:10:MyClass::g 5 | (nop) 6 | ;;@ b:11:12 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /test/metadce/no-outside.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: export$wasm_func 2 | unused: export$wasm_func_unused 3 | unused: func$a_wasm_func 4 | unused: func$an_unused_wasm_func 5 | -------------------------------------------------------------------------------- /test/reduce/imports.wast.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (export "x" (func $0)) 4 | (func $0 (result i32) 5 | (i32.const 5678) 6 | ) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /test/reduce/simple.wast.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (export "x" (func $0)) 4 | (func $0 (result i32) 5 | (i32.const 5678) 6 | ) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /test/wasm2js/minified-memory.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "a" (memory $0 1)) 3 | (func $foo (export "foo") (result i32) 4 | (i32.load (i32.const 0)) 5 | ) 6 | ) 7 | -------------------------------------------------------------------------------- /test/binaryen.js/closed-world.js: -------------------------------------------------------------------------------- 1 | console.log("// closedWorld=" + binaryen.getClosedWorld()); 2 | binaryen.setClosedWorld(true); 3 | assert(binaryen.getClosedWorld() == true); 4 | -------------------------------------------------------------------------------- /test/unit/input/mutable_globals_target_feature.wasm: -------------------------------------------------------------------------------- 1 | asm`env 2 | global-mut 3 |  #Aj$ name0  gimport$0"target_features+mutable-globals -------------------------------------------------------------------------------- /test/binaryen.js/inlining-options.js.txt: -------------------------------------------------------------------------------- 1 | // alwaysInlineMaxSize=2 2 | // flexibleInlineMaxSize=20 3 | // oneCallerInlineMaxSize=-1 4 | // allowInliningFunctionsWithLoops=false 5 | -------------------------------------------------------------------------------- /test/ctor-eval/params.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32))) 3 | (export "test1" (func $test1)) 4 | (func $test1 (type $0) (param $x i32) 5 | (nop) 6 | ) 7 | ) 8 | -------------------------------------------------------------------------------- /test/passes/set-globals.wast: -------------------------------------------------------------------------------- 1 | (module 2 | ;; an imported i32 3 | (import "env" "in" (global $foo i32)) 4 | 5 | ;; a defined i64 6 | (global $bar i64 (i64.const 1234)) 7 | ) 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/spec/atomics.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 23 256 shared) 3 | (func (export "atomic-fence") 4 | (atomic.fence) 5 | ) 6 | ) 7 | 8 | (assert_return (invoke "atomic-fence")) 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/ctor-eval/basics.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $m 256 256) 3 | (data $0 (i32.const 10) "nas\00\00\00aka yzkx waka wakm\00\00\00\00\00\00C") 4 | (export "memory" (memory $m)) 5 | ) 6 | -------------------------------------------------------------------------------- /test/ctor-eval/indirect-call3.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $m 256 256) 3 | (data $0 (i32.const 10) "waka waka xaka waka waka\00\00\00\00\00\00C") 4 | (export "memory" (memory $m)) 5 | ) 6 | -------------------------------------------------------------------------------- /test/lit/node/fuzz_shell_second.wast.second: -------------------------------------------------------------------------------- 1 | ;; Second module for the test. 2 | 3 | (module 4 | (func $second (export "second") (result i32) 5 | (i32.const 1337) 6 | ) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /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( -------------------------------------------------------------------------------- /test/binaryen.js/generate-stack-ir.js: -------------------------------------------------------------------------------- 1 | console.log("// generateStackIR=" + binaryen.getGenerateStackIR()); 2 | binaryen.setGenerateStackIR(true); 3 | assert(binaryen.getGenerateStackIR() == true); 4 | -------------------------------------------------------------------------------- /test/binaryen.js/optimize-stack-ir.js: -------------------------------------------------------------------------------- 1 | console.log("// optimizeStackIR=" + binaryen.getOptimizeStackIR()); 2 | binaryen.setOptimizeStackIR(true); 3 | assert(binaryen.getOptimizeStackIR() == true); 4 | -------------------------------------------------------------------------------- /test/ctor-eval/basics-flatten.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $m 256 256) 3 | (data $0 (i32.const 10) "nas\00\00\00aka\00yzkx waka wakm\00\00\00\00\00\00C") 4 | (export "memory" (memory $m)) 5 | ) 6 | -------------------------------------------------------------------------------- /test/elided-br.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (func $0 4 | (block $block 5 | (unreachable) 6 | (block 7 | (br $block) 8 | ) 9 | ) 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /test/passes/print-function-map.txt: -------------------------------------------------------------------------------- 1 | 0:Foo 2 | 1:bar 3 | 2:baz 4 | (module 5 | (type $0 (func)) 6 | (import "env" "foo" (func $Foo)) 7 | (func $bar 8 | ) 9 | (func $baz 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /test/reduce/destructive.wast.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/analysis/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB analysis_HEADERS *.h lattices/*.h) 2 | set(analysis_SOURCES 3 | cfg.cpp 4 | ${analysis_HEADERS} 5 | ) 6 | target_sources(binaryen PRIVATE ${analysis_SOURCES}) 7 | -------------------------------------------------------------------------------- /test/binaryen.js/traps-never-happen.js: -------------------------------------------------------------------------------- 1 | console.log("// trapsNeverHappen=" + binaryen.getTrapsNeverHappen()); 2 | binaryen.setTrapsNeverHappen(true); 3 | assert(binaryen.getTrapsNeverHappen() == true); 4 | -------------------------------------------------------------------------------- /test/lld/init.c: -------------------------------------------------------------------------------- 1 | volatile int x, y; 2 | 3 | __attribute__((constructor)) void init_x() { x = 14; } 4 | 5 | __attribute__((constructor)) void init_y() { y = 144; } 6 | 7 | int main() { return x + y; } 8 | -------------------------------------------------------------------------------- /test/unreachable-pops.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (func $0 (result i32) 4 | (i32.add 5 | (unreachable) 6 | (unreachable) 7 | ) 8 | ) 9 | ) 10 | 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/passes/roundtrip.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (export "foo" (func $foo)) 4 | (func $foo 5 | (unreachable) 6 | ) 7 | ) 8 | (module 9 | (memory $0 1 1) 10 | (table $0 0 funcref) 11 | ) 12 | -------------------------------------------------------------------------------- /test/wasm2js/export_global.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (global $global0 i32 (i32.const 655360)) 3 | (export "HELLO" (global $global0)) 4 | (func (result i32) (i32.const 42)) 5 | (export "helloWorld" (func 0)) 6 | ) -------------------------------------------------------------------------------- /.github/codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | status: 3 | patch: false 4 | project: 5 | default: 6 | informational: true 7 | 8 | github_checks: 9 | annotations: false 10 | 11 | comment: false 12 | -------------------------------------------------------------------------------- /src/tools/wasm-reduce/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB wasm_reduce_HEADERS *h) 2 | set(wasm_reduce_SOURCES 3 | wasm-reduce.cpp 4 | ${wasm_reduce_HEADERS} 5 | ) 6 | binaryen_add_executable(wasm-reduce "${wasm_reduce_SOURCES}") 7 | -------------------------------------------------------------------------------- /test/lit/metadce/sourcemap.wat.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "root", 4 | "reaches": [ 5 | "f" 6 | ], 7 | "root": true 8 | }, 9 | { 10 | "name": "f", 11 | "export": "f" 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /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 | target_sources(binaryen PRIVATE ${asmjs_SOURCES}) 9 | -------------------------------------------------------------------------------- /test/lit/merge/start.flip.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | (func $start (export "start") 3 | ;; Not a start function, but the name overlaps so it will get deduplicated. 4 | (drop 5 | (i32.const 1) 6 | ) 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /test/unit/input/reference_types_target_feature.wasm: -------------------------------------------------------------------------------- 1 | asm`ooenvtest1envtest2otest1test2 2 |   8nametest1 anyref_test00  gimport$1"target_features+reference-types -------------------------------------------------------------------------------- /test/complexBinaryNames.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /test/lit/merge/start3.wat.third: -------------------------------------------------------------------------------- 1 | (module 2 | (start $start) 3 | 4 | (func $start 5 | (local $x f64) 6 | (drop 7 | (local.get $x) 8 | ) 9 | (drop 10 | (i32.const 2) 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/metadce/tag.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "tag_import", 4 | "import": ["env", "imported_tag"] 5 | }, 6 | { 7 | "name": "func_export", 8 | "root": true, 9 | "export": "test" 10 | } 11 | ] 12 | -------------------------------------------------------------------------------- /src/interpreter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB interpreter_HEADERS *.h) 2 | set(interpreter_SOURCES 3 | expression-iterator.cpp 4 | interpreter.cpp 5 | ${interpreter_HEADERS} 6 | ) 7 | target_sources(binaryen PRIVATE ${interpreter_SOURCES}) 8 | -------------------------------------------------------------------------------- /src/passes/WasmIntrinsics.cpp.in: -------------------------------------------------------------------------------- 1 | #include "passes/intrinsics-module.h" 2 | 3 | static const char theModule[] = { 4 | @WASM_INTRINSICS_EMBED@ 5 | }; 6 | 7 | namespace wasm { 8 | const char* IntrinsicsModuleWast = theModule; 9 | } 10 | -------------------------------------------------------------------------------- /test/example/c-api-hello-world.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /test/metadatas.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /test/lit/parse-bad-identifier.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-opt %s -S -o - 2>&1 | filecheck %s 2 | 3 | ;; CHECK: 7:10: error: expected valtype 4 | 5 | (module 6 | ;; String identifiers must still be UTF-8. 7 | (global $"\ff" i32 (i32.const 0)) 8 | ) 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lld/em_asm_O0.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 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 | -------------------------------------------------------------------------------- /test/lit/metadce/remove-unused-module-elements.wat.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "root", 4 | "reaches": [ 5 | "used" 6 | ], 7 | "root": true 8 | }, 9 | { 10 | "name": "used", 11 | "export": "used" 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /test/lld/em_asm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | EM_ASM({ Module.print("Hello \\ world\t\n"); }); 5 | int x = EM_ASM_INT({ return $0 + $1; }, 13, 27); 6 | EM_ASM_({ Module.print("Got " + $0); }, x); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /fuzz/readme.txt: -------------------------------------------------------------------------------- 1 | The wasm contents of this directory (*.wasm, *.wast, *.wat files) are treated as 2 | important contents by the fuzzer, which will test them with high frequency. This 3 | is useful when you have some local files you want the fuzzer to focus on. 4 | -------------------------------------------------------------------------------- /test/binaryen.js/passes-to-skip.js: -------------------------------------------------------------------------------- 1 | assert(!binaryen.hasPassToSkip("thePass")); 2 | 3 | binaryen.addPassToSkip("thePass"); 4 | assert(binaryen.hasPassToSkip("thePass")); 5 | 6 | binaryen.clearPassesToSkip(); 7 | assert(!binaryen.hasPassToSkip("thePass")); 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | (func (export "get_size") (result i32) (memory.size)) 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /test/wasm2js/global_i64.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (global $f (mut i64) (i64.const 0x12345678ABCDEFAF)) 3 | (func $call (param i64)) 4 | (func $exp (export "exp") 5 | (call $call (global.get $f)) 6 | (global.set $f (i64.const 0x1122334455667788)) 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /src/tools/wasm-split/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB wasm_split_HEADERS *h) 2 | set(wasm_split_SOURCES 3 | wasm-split.cpp 4 | split-options.cpp 5 | instrumenter.cpp 6 | ${wasm_split_HEADERS} 7 | ) 8 | binaryen_add_executable(wasm-split "${wasm_split_SOURCES}") 9 | -------------------------------------------------------------------------------- /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" (func $test1)) 5 | (func $test1 6 | (i32.store8 (i32.const 9) (i32.const 109)) ;; before first segment 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /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" (func $test1)) 5 | (func $test1 6 | (i32.store8 (i32.const 34) (i32.const 109)) ;; after last segment 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /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: Fatal: {{.*}}:8:5: error: unrecognized instruction 5 | 6 | (module 7 | (func $foo 8 | (abc) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /test/lit/validation/global-cycle.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-opt %s -all 2>&1 | filecheck %s 2 | 3 | ;; CHECK: global initializer should only refer to previous globals 4 | 5 | (module 6 | (global $a i32 (global.get $b)) 7 | (global $b i32 (global.get $a)) 8 | ) 9 | -------------------------------------------------------------------------------- /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==7.1.1 7 | filecheck==0.0.22 8 | lit==0.11.0.post1 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/ctor-eval/global-get-init.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (import "import" "global" (global $imported i32)) 4 | (export "use-global" (func $use-global)) 5 | (func $use-global (type $0) (result i32) 6 | (global.get $imported) 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /test/ctor-eval/params.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $test1 (export "test1") (param $x i32) 3 | ;; The presence of params stops us from evalling this function, at least 4 | ;; not with --ignore-external-input (see ignore-external-input.wast) 5 | (nop) 6 | ) 7 | ) 8 | -------------------------------------------------------------------------------- /test/lit/binary/strings-nogc.test: -------------------------------------------------------------------------------- 1 | ;; Verify that we support strings in the binary format even without GC. 2 | 3 | ;; RUN: wasm-opt --enable-reference-types --enable-strings --roundtrip %s 4 | 5 | (module 6 | (func $0 7 | (local $0 stringref) 8 | ) 9 | ) 10 | -------------------------------------------------------------------------------- /test/metadce/tag.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "imported_tag" (tag $t0)) 3 | (tag $t1) 4 | (export "test" (func $test)) 5 | 6 | (func $test 7 | (try 8 | (do 9 | (throw $t0) 10 | ) 11 | (catch $t1) 12 | ) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /test/passes/reorder-functions.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/multi-table.minified.txt: -------------------------------------------------------------------------------- 1 | (module(type $none_=>_none (func))(import "a" "b" (table $t1 1 10 funcref))(elem (table $t1) (i32.const 0) func $f)(table $t2 3 3 funcref)(elem (table $t2) (i32.const 0) func $f)(elem (table $t2) (i32.const 1) func $f $g)(func $f(nop))(func $g(nop))) -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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" (func $test1)) 5 | (func $test1 6 | (i32.store16 (i32.const 33) (i32.const 109)) ;; after last segment due to size of type 7 | ) 8 | ) 9 | -------------------------------------------------------------------------------- /test/lit/validation/non-ref.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-opt %s -all 2>&1 | filecheck %s 2 | 3 | ;; CHECK: ref.as value must be reference 4 | 5 | (module 6 | (func $test 7 | (drop 8 | (ref.as_non_null 9 | (i32.const 42) 10 | ) 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/metadce/ref-func.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "f1" (func $f1)) 3 | (import "env" "f2" (func $f2)) 4 | 5 | (export "g" (global $g)) 6 | (export "f" (func $f)) 7 | 8 | (global $g funcref (ref.func $f1)) 9 | 10 | (func $f (result funcref) (ref.func $f2)) 11 | ) 12 | -------------------------------------------------------------------------------- /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-tag", 9 | "root": true, 10 | "export": "wasm_tag_b" 11 | } 12 | ] 13 | 14 | -------------------------------------------------------------------------------- /test/passes/vacuum_remove-unused-names_merge-blocks.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | (memory $m 0 0) 8 | (export "foo" (memory $m)) 9 | ) 10 | -------------------------------------------------------------------------------- /test/lit/wasm-split/multi-split-escape-names.wast.manifest: -------------------------------------------------------------------------------- 1 | 1: 2 | wasm::Type::getFeatures() const 3 | 4 | 2: 5 | wasm::Literal::Literal(std::__2::array const&) 6 | 7 | 3: 8 | std::operator<<(std::__2::basic_ostream>&, wasm::Module&) 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lit/merge/table64.wat.second: -------------------------------------------------------------------------------- 1 | ;; A module with a wasm64 table. We must copy it properly when we merge. 2 | (module 3 | (table $table i64 15 15 funcref) 4 | 5 | (elem $0 (i64.const 0) $second) 6 | 7 | (export "table" (table $table)) 8 | 9 | (func $second) 10 | ) 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/lld/em_asm_pthread.cpp: -------------------------------------------------------------------------------- 1 | // Build with 2 | // 3 | // emcc a.cpp -pthread -s WASM_BIGINT 4 | // 5 | 6 | #include 7 | 8 | EM_JS(void, world, (), { console.log("World."); }); 9 | 10 | int main() { 11 | EM_ASM({ console.log("Hello."); }); 12 | world(); 13 | } 14 | -------------------------------------------------------------------------------- /test/mutable-global.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | target_sources(binaryen PRIVATE ${emscripten-optimizer_SOURCES}) 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lit/merge/func_subtyping.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | (type $second-super (sub (func))) 3 | 4 | (import "primary" "sub" (func $import (type $second-super))) 5 | 6 | (func $caller (export "caller") 7 | (call_ref $second-super 8 | (ref.func $import) 9 | ) 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | ignore = 3 | ; line too long 4 | E501, 5 | ; space after comma (ignored for list in gen-s-parser.py) 6 | E241, 7 | ; line break after binary operator 8 | W504 9 | exclude = third_party,./test/emscripten,./test/spec,./test/wasm-install,./test/lit,./_deps,./build 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lit/binary/component-error.test: -------------------------------------------------------------------------------- 1 | # Verify that we show an error when given a component. 2 | 3 | ;; RUN: not wasm-opt %s.wasm 2>&1 | filecheck %s 4 | 5 | ;; CHECK: this looks like a wasm component, which Binaryen does not support yet (see https://github.com/WebAssembly/binaryen/issues/6728) 6 | 7 | -------------------------------------------------------------------------------- /test/lit/binary/custom-section-build-id.test: -------------------------------------------------------------------------------- 1 | # Verify that the build id is included in the source map. 2 | 3 | ;; RUN: wasm-opt %s.wasm -o %t.wasm -osm %t.map 4 | ;; RUN: cat %t.map | filecheck %s 5 | 6 | ;; CHECK: {"version":3,"debugId":"01ab23cd45ef67ab89","sources":[],"names":[],"mappings":""} 7 | 8 | -------------------------------------------------------------------------------- /test/lit/validation/nullref-no-gc.wast: -------------------------------------------------------------------------------- 1 | ;; Test that nullref without GC is a validation error. 2 | 3 | ;; RUN: not wasm-opt %s -all --disable-gc 2>&1 | filecheck %s 4 | 5 | ;; CHECK: all used types should be allowed 6 | 7 | (module 8 | (func $test 9 | (local nullref) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /test/wasm2js/add_div.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (export "foo" (func $foo)) 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 | ) -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lit/parse-bad-assertion.wast: -------------------------------------------------------------------------------- 1 | ;; Check that we properly error when an action is missing from an assertion that 2 | ;; requires one. Regression test for #6872. 3 | 4 | ;; RUN: not wasm-shell %s 2>&1 | filecheck %s 5 | 6 | (assert_exhaustion "wrong, lol") 7 | 8 | ;; CHECK: 6:19: error: expected action 9 | -------------------------------------------------------------------------------- /test/lit/sourcemap-sourceroot-file.wat.map: -------------------------------------------------------------------------------- 1 | { 2 | "version":3, 3 | "file": "foo.wasm", 4 | "sources":[], 5 | "names":[], 6 | "mappings": "", 7 | "sourceRoot": "/foo/bar", 8 | "sourcesContent": ["#include int main()\n{ printf(\"Gr\u00fc\u00df Gott, Welt!\"); return 0;}"] 9 | } 10 | -------------------------------------------------------------------------------- /test/lit/validation/imports.wast: -------------------------------------------------------------------------------- 1 | ;; Test that we validate imported functions. 2 | 3 | ;; RUN: not wasm-opt %s -all --disable-simd 2>&1 | filecheck %s 4 | 5 | ;; CHECK: all used types should be allowed 6 | 7 | (module 8 | (import "env" "imported-v128" (func $imported-v128 (result v128))) 9 | ) 10 | -------------------------------------------------------------------------------- /test/ctor-eval/imported-global.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (memory $0 256 256) 4 | (data $0 (i32.const 10) "waka waka waka waka waka") 5 | (export "test1" (func $test1)) 6 | (func $test1 (type $0) 7 | (i32.store8 8 | (i32.const 13) 9 | (i32.const 115) 10 | ) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /test/lit/parse-error-return-nofunc.wast: -------------------------------------------------------------------------------- 1 | ;; We should error properly on a return in a non-function scope 2 | 3 | ;; RUN: not wasm-opt %s 2>&1 | filecheck %s 4 | ;; CHECK: Fatal: {{.*}}:8:5: error: return is only valid in a function context 5 | 6 | (module 7 | (elem 8 | (return) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /test/metadce/tag.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "imported_tag" (tag $t0 (type $0))) 4 | (tag $t1 (type $0)) 5 | (export "test" (func $test)) 6 | (func $test (type $0) 7 | (try 8 | (do 9 | (throw $t0) 10 | ) 11 | (catch $t1 12 | ) 13 | ) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/wasm/wasm-interpreter.cpp: -------------------------------------------------------------------------------- 1 | #include "wasm-interpreter.h" 2 | 3 | namespace wasm { 4 | 5 | std::ostream& operator<<(std::ostream& o, const WasmException& exn) { 6 | auto exnData = exn.exn.getExnData(); 7 | return o << exnData->tag->name << " " << exnData->payload; 8 | } 9 | 10 | } // namespace wasm 11 | -------------------------------------------------------------------------------- /test/lit/parse-bad-tuple-in-sig.wast: -------------------------------------------------------------------------------- 1 | ;; Test that tuple types in signatures lead to errors 2 | 3 | ;; RUN: not wasm-opt %s 2>&1 | filecheck %s 4 | 5 | ;; CHECK: Fatal: {{.*}}:9:1: error: tuple types not allowed in signature 6 | 7 | (module 8 | (func $tuple-in-sig (param (tuple i32 i32)) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /test/lit/validation/bulk.wast: -------------------------------------------------------------------------------- 1 | ;; Test for a validation error on bad usage of call.without.effects 2 | 3 | ;; RUN: not wasm-opt -all %s 2>&1 | filecheck %s 4 | 5 | ;; CHECK: data index out of bounds 6 | 7 | (module 8 | (memory $0 16) 9 | (func $1 10 | (data.drop 1) 11 | (unreachable) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /test/metadce/rooted-export.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32))) 3 | (type $1 (func)) 4 | (tag $b_wasm_tag (type $0) (param i32)) 5 | (export "wasm_func_b" (func $b_wasm_func)) 6 | (export "wasm_tag_b" (tag $b_wasm_tag)) 7 | (func $b_wasm_func (type $1) 8 | (unreachable) 9 | ) 10 | ) 11 | -------------------------------------------------------------------------------- /test/passes/emit-spec-wrapper=a.wat.wast.wat: -------------------------------------------------------------------------------- 1 | (invoke "add" (i32.const 0) (i32.const 0) ) (invoke "no_return" (i32.const 0) ) (invoke "types" (i32.const 0) (i64.const 0) (f32.const 0) (f64.const 0) ) (invoke "types2" (i32.const 0) (f32.const 0) (f64.const 0) ) (invoke "types3" (i32.const 0) (f32.const 0) (f64.const 0) ) -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/passes/merge-blocks_remove-unused-brs.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /test/lit/binary/bad-datacount.test: -------------------------------------------------------------------------------- 1 | RUN: not wasm-opt --debug %s.wasm 2>&1 | filecheck %s 2 | 3 | ;; Check that we get the expected error. 4 | 5 | ;; CHECK: data count and data sections disagree on size 6 | 7 | ;; Check that we print out the module rather than hitting an assertion error. 8 | 9 | ;; CHECK: (module 10 | -------------------------------------------------------------------------------- /test/passes/roundtrip.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $foo (export "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 | -------------------------------------------------------------------------------- /test/reduce/atomics-and-bulk-memory.wast.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (memory $0 1 1) 4 | (export "foo" (func $0)) 5 | (func $0 (result i32) 6 | (i32.atomic.store8 7 | (i32.const 0) 8 | (i32.const 99) 9 | ) 10 | (i32.atomic.load8_u 11 | (i32.const 0) 12 | ) 13 | ) 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /test/consume-stacky.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (memory $0 1 1) 4 | (func $0 (result i32) 5 | (local $scratch i32) 6 | (local.set $scratch 7 | (i32.const 1) 8 | ) 9 | (i32.store 10 | (i32.const 2) 11 | (i32.const 3) 12 | ) 13 | (local.get $scratch) 14 | ) 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /test/fn_prolog_epilog.debugInfo.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | ;;@ src.cpp:1:1 4 | (func $0 5 | (nop) 6 | ;;@ src.cpp:2:1 7 | (block 8 | ;;@ src.cpp:2:2 9 | (block $block 10 | (br $block) 11 | ) 12 | ) 13 | ;;@ src.cpp:3:1 14 | (return) 15 | ;;@ src.cpp:3:2 16 | ) 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /test/lit/binary/global-local-get.test: -------------------------------------------------------------------------------- 1 | RUN: not wasm-opt --debug %s.wasm 2>&1 | filecheck %s 2 | 3 | ;; Check that we get the expected error for an input binary that looks like 4 | ;; this: 5 | ;; 6 | ;; (module 7 | ;; (global $g i32 (local.get 0)) 8 | ;; ) 9 | 10 | ;; CHECK: local.get is only valid in a function context 11 | -------------------------------------------------------------------------------- /test/lit/merge/export_options.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | (func $func1 (export "func") 3 | ;; This export will conflict. 4 | (drop 5 | (i32.const 1) 6 | ) 7 | ) 8 | 9 | (func $func2 (export "other") 10 | ;; This export will not conflict. 11 | (drop 12 | (i32.const 2) 13 | ) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /test/lit/wasm-split/multi-memory-lowering-export-error.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-opt %s --multi-memory-lowering -all 2>&1 | filecheck %s 2 | 3 | (module 4 | (memory $memory1 1) 5 | (memory $memory2 1 1) 6 | (export "mem" (memory $memory2)) 7 | ) 8 | 9 | ;; CHECK: MultiMemoryLowering: only the first memory can be exported 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lit/exec/second.wast.second: -------------------------------------------------------------------------------- 1 | (module 2 | (import "primary" "first" (func $first-func (result i32))) 3 | 4 | (func $second (export "second") (result i32) 5 | ;; Test we can call the first module, linked as "primary." 6 | (i32.add 7 | (call $first-func) 8 | (i32.const 1295) 9 | ) 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /test/lit/validation/exact-import.wast: -------------------------------------------------------------------------------- 1 | ;; Test that exact imports require custom descriptors. 2 | 3 | ;; RUN: not wasm-opt %s -all --disable-custom-descriptors 2>&1 | filecheck %s 4 | 5 | ;; CHECK: exact imports require custom descriptors [--enable-custom-descriptors] 6 | 7 | (module 8 | (import "" "" (func $f (exact))) 9 | ) 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/ctor-eval/globals.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (global $g1 (mut i32) (i32.const 50)) 4 | (global $g2 (mut i32) (i32.const 40)) 5 | (export "keepalive" (func $keepalive)) 6 | (func $keepalive (type $0) (result i32) 7 | (i32.add 8 | (global.get $g1) 9 | (global.get $g2) 10 | ) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /test/lit/merge/global_subtyping.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | (type $second-super (sub (func))) 3 | 4 | (import "primary" "sub" (global $import (ref $second-super))) 5 | 6 | (func $second-user (export "second-user") 7 | (drop 8 | (block (result (ref $second-super)) 9 | (global.get $import) 10 | ) 11 | ) 12 | ) 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /test/lit/merge/start.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | (start $start) 3 | 4 | (func $start (export "start") 5 | (drop 6 | (i32.const 1) 7 | ) 8 | ) 9 | 10 | (func $user (export "user") 11 | ;; These calls must go to the function $start here (with body "1"). 12 | (call $start) 13 | (call $start) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /test/lit/parse-bad-supertype.wast: -------------------------------------------------------------------------------- 1 | ;; Test that an invalid supertype results in a useful error message 2 | 3 | ;; RUN: not wasm-opt %s -all 2>&1 | filecheck %s 4 | 5 | ;; CHECK: Fatal: {{.*}}:8:2: error: invalid type: Heap type has an invalid supertype 6 | (module 7 | (type $super (sub (struct i32))) 8 | (type $sub (sub $super (struct i64))) 9 | ) -------------------------------------------------------------------------------- /test/lit/parse-error-func-param-type.wast: -------------------------------------------------------------------------------- 1 | ;; This function's type does not match the param we define for it. 2 | 3 | ;; RUN: not wasm-opt %s 2>&1 | filecheck %s 4 | ;; CHECK: Fatal: {{.*}}:9:10: error: type does not match provided signature 5 | 6 | (module 7 | (type $0 (func)) 8 | 9 | (func $0 (type $0) (param $var$0 i32)) 10 | ) 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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,E"} 9 | -------------------------------------------------------------------------------- /test/ctor-eval/global-get-init.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "import" "global" (global $imported i32)) 3 | (func $use-global (export "use-global") (result i32) 4 | (global.get $imported) 5 | ) 6 | ;; The imported global isn't used in the ctor, 7 | ;; so we're free to remove it completely. 8 | (func $test1 (export "test1")) 9 | ) 10 | -------------------------------------------------------------------------------- /test/lit/binary/global-local-set.test: -------------------------------------------------------------------------------- 1 | RUN: not wasm-opt --debug %s.wasm 2>&1 | filecheck %s 2 | 3 | ;; Check that we get the expected error for an input binary that looks like 4 | ;; this: 5 | ;; 6 | ;; (module 7 | ;; (global $g i32 (local.set 0 (i32.const 1))) 8 | ;; ) 9 | 10 | ;; CHECK: local.set is only valid in a function context 11 | -------------------------------------------------------------------------------- /test/lit/binary/global-local-tee.test: -------------------------------------------------------------------------------- 1 | RUN: not wasm-opt --debug %s.wasm 2>&1 | filecheck %s 2 | 3 | ;; Check that we get the expected error for an input binary that looks like 4 | ;; this: 5 | ;; 6 | ;; (module 7 | ;; (global $g i32 (local.tee 0 (i32.const 1))) 8 | ;; ) 9 | 10 | ;; CHECK: local.tee is only valid in a function context 11 | -------------------------------------------------------------------------------- /test/lit/exec/call_ref-import-cross-module.wast.second: -------------------------------------------------------------------------------- 1 | (module 2 | (import "fuzzing-support" "call-ref" (func $call-ref (param funcref i32))) 3 | (import "primary" "get" (func $primary-get (result funcref))) 4 | 5 | (func $run (export "run") 6 | (call $call-ref 7 | (call $primary-get) 8 | (i32.const 0) 9 | ) 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /test/lit/validation/nn-locals-ok.wast: -------------------------------------------------------------------------------- 1 | ;; Test for validation of non-nullable locals 2 | 3 | ;; RUN: wasm-opt -all %s --print | filecheck %s 4 | 5 | ;; CHECK: (module 6 | 7 | (module 8 | (func $foo (param $nn (ref any)) 9 | ;; It is ok to read a non-nullable param. 10 | (drop 11 | (local.get $nn) 12 | ) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/metadce/segments.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "root", 4 | "reaches": ["f"], 5 | "root": true 6 | }, 7 | { 8 | "name": "f", 9 | "export": "f" 10 | }, 11 | { 12 | "name": "g1", 13 | "import": ["env", "g1"] 14 | }, 15 | { 16 | "name": "g2", 17 | "import": ["env", "g2"] 18 | }, 19 | ] 20 | -------------------------------------------------------------------------------- /test/br_to_try.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32))) 3 | (type $1 (func)) 4 | (tag $tag$0 (type $0) (param i32)) 5 | (func $0 6 | (block $label 7 | (try 8 | (do 9 | (br $label) 10 | ) 11 | (catch $tag$0 12 | (drop 13 | (pop i32) 14 | ) 15 | ) 16 | ) 17 | ) 18 | ) 19 | ) 20 | 21 | -------------------------------------------------------------------------------- /test/lit/merge/import_cycle.wat: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-merge %s first %s.second second 2>&1 | filecheck %s 2 | 3 | ;; Test that wasm-merge terminates with an error when there is an import cycle. 4 | 5 | ;; CHECK: Fatal: wasm-merge: infinite loop of imports on f 6 | 7 | (module 8 | (import "second" "g" (func $f)) 9 | (export "f" (func $f)) 10 | ) 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/passes/vacuum_ignore-implicit-traps.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (type $1 (func)) 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 | -------------------------------------------------------------------------------- /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 | (then 6 | (unreachable) ;; this can be removed destructively, since we do not sent this param 7 | ) 8 | ) 9 | (i32.const 100) 10 | ) 11 | ) 12 | 13 | -------------------------------------------------------------------------------- /test/unit/input/stack_ir.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "bar" (func $bar (param i32) (result i32))) 3 | (func $foo1 (export "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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lit/passes/signext-lowering-features.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: wasm-opt %s --enable-sign-ext --print-features --print --signext-lowering --print-features | filecheck %s 2 | 3 | ;; Check that the --signext-lowering pass disables the signext feature. 4 | 5 | ;; CHECK: --enable-sign-ext 6 | ;; CHECK: (module 7 | ;; CHECK-NOT: --enable-sign-ext 8 | 9 | (module) 10 | -------------------------------------------------------------------------------- /test/lit/validation/open-types-no-gc.wast: -------------------------------------------------------------------------------- 1 | ;; Test that declaring non-final types without GC is a validation error. 2 | 3 | ;; RUN: not wasm-opt %s -all --disable-gc 2>&1 | filecheck %s 4 | 5 | ;; CHECK: all used types should be allowed 6 | 7 | (module 8 | (type $f1 (sub (func))) 9 | 10 | (func $test (type $f1) 11 | (unreachable) 12 | ) 13 | ) -------------------------------------------------------------------------------- /test/spec/call_indirect_refnull.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (table $t 1 1 funcref) 3 | (elem (table $t) (i32.const 0) funcref (ref.null func)) 4 | 5 | (func $call-refnull (export "call-refnull") (result f32) 6 | (call_indirect (result f32) (i32.const 0)) 7 | ) 8 | ) 9 | (assert_trap 10 | (invoke "call-refnull") 11 | "uninitialized table element" 12 | ) -------------------------------------------------------------------------------- /test/wasm2js/target_js.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $func (export "func") (param $x i32) (result i32) 3 | ;; Do not turn xor into something that does not express well in JS 4 | ;; when optimizing. 5 | (i32.xor 6 | (i32.shl 7 | (i32.const 1) 8 | (local.get $x) 9 | ) 10 | (i32.const -1) 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/ctor-eval/bad-indirect-call3.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (type $funcref_=>_none (func (param funcref))) 4 | (table $0 1 1 funcref) 5 | (export "sig_mismatch" (func $sig_mismatch)) 6 | (func $sig_mismatch (type $0) 7 | (call_indirect $0 (type $funcref_=>_none) 8 | (ref.null nofunc) 9 | (i32.const 0) 10 | ) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lit/passes/memory64-lowering-features.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: wasm-opt %s --enable-memory64 --print-features --print --memory64-lowering --print-features | filecheck %s 2 | 3 | ;; Check that the --memory64-lowering pass disables the signext feature. 4 | 5 | ;; CHECK: --enable-memory64 6 | ;; CHECK: (module 7 | ;; CHECK-NOT: --enable-memory64 8 | 9 | (module) 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/break-within-catch.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32))) 3 | (type $1 (func)) 4 | (tag $tag$0 (type $0) (param i32)) 5 | (func $0 6 | (block $label 7 | (try 8 | (do 9 | (nop) 10 | ) 11 | (catch $tag$0 12 | (drop 13 | (pop i32) 14 | ) 15 | (br $label) 16 | ) 17 | ) 18 | ) 19 | ) 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /test/lit/validation/function-missing.wast: -------------------------------------------------------------------------------- 1 | ;; Test that we validate functions declaration and usage for globals. 2 | 3 | ;; RUN: not wasm-opt %s -all 2>&1 | filecheck %s 4 | 5 | (module 6 | ;; CHECK: function not defined 7 | (global (mut i32) (block)) 8 | 9 | ;; CHECK: function not defined 10 | (global (mut i32) (return_call 0)) 11 | 12 | (func $0 13 | ) 14 | ) -------------------------------------------------------------------------------- /test/lld/main_module_table.wat.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "__stack_pointer" (global $sp (mut i32))) 4 | (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/wasm2js/deterministic.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "memory" (memory $0 1 1)) 3 | (global $global$0 (mut i32) (i32.const -44)) 4 | (func $foo (export "foo") (result i32) 5 | (if 6 | (i32.div_u 7 | (global.get $global$0) 8 | (i32.load (i32.const 0)) 9 | ) 10 | (then 11 | (unreachable) 12 | ) 13 | ) 14 | (i32.const 1) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /test/binaryen.js/reloc.js.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 $x0 (global.get $memory_base) "data data") 7 | (table $0 1 funcref) 8 | (elem $0 (global.get $table_base) $func $func) 9 | (func $func 10 | (nop) 11 | ) 12 | ) 13 | 14 | -------------------------------------------------------------------------------- /test/break-to-return.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 (result i32) 7 | (br $label 8 | (i32.add 9 | (local.get $0) 10 | (local.get $1) 11 | ) 12 | ) 13 | ) 14 | ) 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /test/passes/remove-unused-brs_precompute_vacuum_remove-unused-brs.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /test/unit/test_only_imported_memory.py: -------------------------------------------------------------------------------- 1 | from . import utils 2 | 3 | 4 | class OnlyImportedMemoryTest(utils.BinaryenTestCase): 5 | def test_only_imported_memory(self): 6 | # We should not create a memories section for a file with only an 7 | # imported memory: such a module has no declared memories. 8 | self.roundtrip('only-imported-memory.wasm', debug=False) 9 | -------------------------------------------------------------------------------- /test/lit/validation/supertypes-no-gc.wast: -------------------------------------------------------------------------------- 1 | ;; Test that declaring supertypes without GC is a validation error. 2 | 3 | ;; RUN: not wasm-opt %s -all --disable-gc 2>&1 | filecheck %s 4 | 5 | ;; CHECK: all used types should be allowed 6 | 7 | (module 8 | (type $f1 (sub (func))) 9 | (type $f2 (sub $f1 (func))) 10 | 11 | (func $test (type $f2) 12 | (unreachable) 13 | ) 14 | ) -------------------------------------------------------------------------------- /test/passes/roundtrip_typenames_features.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $NamedStruct (struct)) 3 | (type $ref?|$NamedStruct|_=>_none (func (param (ref null $NamedStruct)))) 4 | (export "export" (func $0)) 5 | (func $0 (type $ref?|$NamedStruct|_=>_none) (param $0 (ref null $NamedStruct)) 6 | (nop) 7 | ) 8 | ;; features section: mutable-globals, sign-ext, reference-types, gc 9 | ) 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/ctor-eval/just_some.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (memory $0 256 256) 4 | (data $0 (i32.const 10) "wasa waka waka waka waka") 5 | (export "test2" (func $test2)) 6 | (export "test3" (func $test3)) 7 | (func $test2 (type $0) 8 | (unreachable) 9 | ) 10 | (func $test3 (type $0) 11 | (i32.store8 12 | (i32.const 13) 13 | (i32.const 113) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lit/num_cores.wast: -------------------------------------------------------------------------------- 1 | ;; REQUIRES: linux 2 | ;; Test that getNumCores honors thread affinity on linux 3 | 4 | (module 5 | (func $a) 6 | ) 7 | 8 | ;; RUN: taskset -c 0 wasm-opt -O1 --debug=threads %s 2>&1 | filecheck %s 9 | ;; RUN: taskset -c 0,2 wasm-opt -O1 --debug=threads %s 2>&1 | filecheck %s --check-prefix=TWO 10 | 11 | ;; CHECK: getNumCores: 1 12 | 13 | ;; TWO: getNumCores: 2 14 | -------------------------------------------------------------------------------- /test/lit/parse-bad-tuple-extract-index.wast: -------------------------------------------------------------------------------- 1 | ;; Test that out-of-bounds tuple.extract indices produce parse errors. 2 | 3 | ;; RUN: not wasm-opt %s 2>&1 | filecheck %s 4 | 5 | ;; CHECK: Fatal: {{.*}}:9:3: error: tuple index out of bounds 6 | 7 | (module 8 | (func 9 | (tuple.extract 2 2 10 | (tuple.make 2 11 | (i32.const 0) 12 | (i64.const 1) 13 | ) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /test/lit/validation/array-new-fixed.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-opt -all %s 2>&1 | filecheck %s 2 | 3 | ;; CHECK: expected array type annotation on array.new_fixed 4 | 5 | (module 6 | (type $struct (struct (field anyref))) 7 | 8 | ;; The type here is a struct, not an array, so we error. 9 | (global $struct (ref $struct) (array.new_fixed $struct 1 10 | (i32.const 64) 11 | )) 12 | ) 13 | -------------------------------------------------------------------------------- /test/lit/validation/nn-locals-bad.wast: -------------------------------------------------------------------------------- 1 | ;; Test for validation of non-nullable locals 2 | 3 | ;; RUN: not wasm-opt -all %s 2>&1 | filecheck %s 4 | 5 | ;; CHECK: non-nullable local's sets must dominate gets 6 | 7 | (module 8 | (func $foo 9 | (local $nn (ref any)) 10 | ;; It is not ok to read a non-nullable local. 11 | (drop 12 | (local.get $nn) 13 | ) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /test/metadce/threaded_unrooted.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: func$wasm_func_1 2 | unused: func$wasm_func_2 3 | unused: func$wasm_func_3 4 | unused: func$wasm_func_4 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 | -------------------------------------------------------------------------------- /test/metadce/ref-func.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (type $1 (func (result funcref))) 4 | (import "env" "f2" (func $f2 (type $0))) 5 | (import "env" "f1" (func $f1 (type $0))) 6 | (global $g funcref (ref.func $f1)) 7 | (elem declare func $f2) 8 | (export "g" (global $g)) 9 | (export "f" (func $f)) 10 | (func $f (type $1) (result funcref) 11 | (ref.func $f2) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /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 (export "baz") 9 | (call $foo) 10 | (call $bar) 11 | (call $wrong (i32.const 1)) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /.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 | Language: Json 16 | BasedOnStyle: LLVM 17 | --- 18 | -------------------------------------------------------------------------------- /src/parser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB parser_HEADERS *.h) 2 | set(parser_SOURCES 3 | context-decls.cpp 4 | context-defs.cpp 5 | lexer.cpp 6 | parse-1-decls.cpp 7 | parse-2-typedefs.cpp 8 | parse-3-implicit-types.cpp 9 | parse-4-module-types.cpp 10 | parse-5-defs.cpp 11 | wast-parser.cpp 12 | wat-parser.cpp 13 | ${parser_HEADERS} 14 | ) 15 | target_sources(binaryen PRIVATE ${parser_SOURCES}) 16 | -------------------------------------------------------------------------------- /test/lit/parse-bad-gc-rmw-orders.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-opt %s -all 2>&1 | filecheck %s 2 | 3 | (module 4 | (type $struct (struct (field (mut i32)))) 5 | 6 | ;; CHECK: 8:5: error: struct.atomic.rmw memory orders must be identical 7 | (func $rmw (param (ref null $struct)) 8 | (struct.atomic.rmw.add seqcst acqrel 0 9 | (local.get 0) 10 | (i32.const 1) 11 | ) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /test/lit/parse-bad-supertype-8616.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-opt %s 2>&1 | filecheck %s 2 | 3 | ;; CHECK: Fatal: {{.*}}:9:2: error: invalid type: Heap type has an undeclared supertype 4 | 5 | ;; Regression test for a parser bug that caused an assertion failure in this case. 6 | (module 7 | (rec 8 | (type $A (sub (struct (field i32)))) 9 | (type $B (sub $B (struct (field i32) (field i32)))) 10 | ) 11 | ) -------------------------------------------------------------------------------- /test/lit/validation/rec-groups-no-gc.wast: -------------------------------------------------------------------------------- 1 | ;; Test that using rec groups types without GC is a validation error. 2 | 3 | ;; RUN: not wasm-opt %s -all --disable-gc 2>&1 | filecheck %s 4 | 5 | ;; CHECK: all used types should be allowed 6 | 7 | (module 8 | (rec 9 | (type $f1 (func)) 10 | (type $f2 (func)) 11 | ) 12 | 13 | (func $test (type $f1) 14 | (unreachable) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /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)) int foo(int a, int b) { 7 | printf("%d:%d\n", a, b); 8 | return a + b; 9 | } 10 | 11 | int main() { 12 | printf("Result: %d\n", foo(1, 2)); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /test/metadce/threaded_unrooted_cycle.wast.dced.stdout: -------------------------------------------------------------------------------- 1 | unused: func$wasm_func_1 2 | unused: func$wasm_func_2 3 | unused: func$wasm_func_3 4 | unused: func$wasm_func_4 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 | -------------------------------------------------------------------------------- /test/reduce/gc.wast.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (struct (field (mut i32)))) 3 | (type $1 (func (result i32))) 4 | (global $global$0 (ref null $0) (struct.new_default $0)) 5 | (export "use-global" (func $0)) 6 | (func $0 (result i32) 7 | (struct.set $0 0 8 | (global.get $global$0) 9 | (i32.const 42) 10 | ) 11 | (struct.get $0 0 12 | (global.get $global$0) 13 | ) 14 | ) 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /test/binaryen.js/memory-info.js.txt: -------------------------------------------------------------------------------- 1 | false 2 | true 3 | {"module":"","base":"","initial":1,"shared":false,"is64":false,"max":64} 4 | true 5 | {"module":"","base":"","initial":1,"shared":true,"is64":false,"max":64} 6 | true 7 | {"module":"env","base":"memory","initial":0,"shared":false,"is64":false,"max":65536} 8 | true 9 | {"module":"env","base":"memory","initial":0,"shared":true,"is64":false,"max":65536} 10 | -------------------------------------------------------------------------------- /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 subtyping 17 | ;; Test stack signature lub 18 | ;; Test stack flow 19 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/metadce/spanning_cycle.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "js_func" (func $a_js_func (type $0))) 4 | (memory $0 1 1) 5 | (data $0 "Hello, datacount section!") 6 | (export "wasm_func_a" (func $a_wasm_func)) 7 | (func $a_wasm_func (type $0) 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 | -------------------------------------------------------------------------------- /test/passes/safe-heap_disable-simd.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory 1 1) 3 | ) 4 | (module 5 | (import "env" "emscripten_get_sbrk_ptr" (func $foo (result i32))) 6 | (memory 1 1) 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 8 | ;; CHECK: (table $table 1234 funcref) 9 | 10 | (module 11 | (table $table 3 funcref) 12 | ) 13 | -------------------------------------------------------------------------------- /test/metadce/ref-func.wast.graph.txt: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "root", 4 | "reaches": ["f", "g"], 5 | "root": true 6 | }, 7 | { 8 | "name": "f", 9 | "export": "f" 10 | }, 11 | { 12 | "name": "g", 13 | "export": "g" 14 | }, 15 | { 16 | "name": "f1", 17 | "import": ["env", "f1"] 18 | }, 19 | { 20 | "name": "f2", 21 | "import": ["env", "f2"] 22 | }, 23 | ] 24 | -------------------------------------------------------------------------------- /test/passes/strip-debug.bin.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /test/ctor-eval/memory-init.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (memory $0 1) 4 | (data $0 (i32.const 0) "__________") 5 | (data $1 (i32.const 20) "__________") 6 | (export "test1" (func $test1)) 7 | (func $test1 (type $0) 8 | (i32.store8 9 | (i32.const 4) 10 | (i32.const 100) 11 | ) 12 | (memory.init $1 13 | (i32.const 0) 14 | (i32.const 0) 15 | (i32.const 1) 16 | ) 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /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: shared memory requires threads [--enable-threads] 7 | ;; ATOMICS: (memory $0 10 20 shared) 8 | 9 | (module 10 | (memory 10 20 shared) 11 | ) 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/metadce/segments.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "g1" (global $g1 i32)) 3 | (import "env" "g2" (global $g2 i32)) 4 | 5 | (table $tbl 1 funcref) 6 | (elem (offset (global.get $g1)) funcref (ref.func $f)) 7 | 8 | (memory 3) 9 | (data (offset (global.get $g2)) "xxx") 10 | 11 | (export "f" (func $f)) 12 | (func $f (param i32) 13 | (call_indirect (param i32) (local.get 0) (i32.load8_u (i32.const 0)))) 14 | ) 15 | -------------------------------------------------------------------------------- /test/passes/roundtrip_typenames_features.wast: -------------------------------------------------------------------------------- 1 | ;; This test enables two features, then roundtrips through binary. We should 2 | ;; preserve the features and type names while doing so. 3 | 4 | (module 5 | (type $NamedStruct (struct )) 6 | (type $ref?|$NamedStruct|_=>_none (func (param (ref null $NamedStruct)))) 7 | (export "export" (func $0)) 8 | (func $0 (param $0 (ref null $NamedStruct)) 9 | (nop) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /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 --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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lld/main_module_table_2.wat.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "table" (table $timport$9 1 funcref)) 4 | (import "env" "__stack_pointer" (global $sp (mut i32))) 5 | (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | (i32.const 0) 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /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_tag_a" (tag $a_wasm_tag)) 13 | (export "wasm_tag_b" (tag $b_wasm_tag)) 14 | 15 | (tag $a_wasm_tag (param i32)) 16 | (tag $b_wasm_tag (param i32)) 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /test/metadce/spanning_cycle.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "js_func" (func $a_js_func)) 3 | 4 | (memory 1 1) 5 | 6 | (data "Hello, datacount section!") 7 | 8 | (export "wasm_func_a" (func $a_wasm_func)) 9 | 10 | (func $a_wasm_func 11 | ;; refer to the data segment to keep it around 12 | (memory.init 0 13 | (i32.const 0) 14 | (i32.const 0) 15 | (i32.const 25) 16 | ) 17 | (call $a_js_func) 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /test/passes/simplify-locals.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 (result i32) 15 | (nop) 16 | (nop) 17 | (nop) 18 | (i32.const 1) 19 | ) 20 | ) 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /test/grow_memory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | volatile int writeOnly; 6 | 7 | int main() { 8 | EM_ASM({ assert(HEAPU8.length == = 16 * 1024 * 1024); }); 9 | for (int i = 0; i < 20; i++) { 10 | printf("alloc 1MB: %d\n", i); 11 | writeOnly = (int)malloc(1024 * 1024); 12 | } 13 | EM_ASM({ assert(HEAPU8.length > 16 * 1024 * 1024); }); 14 | printf("ok.\n"); 15 | } 16 | -------------------------------------------------------------------------------- /test/lit/parse-bad-gc-cmpxchg-orders.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-opt %s -all 2>&1 | filecheck %s 2 | 3 | (module 4 | (type $struct (struct (field (mut i32)))) 5 | 6 | ;; CHECK: 8:5: error: struct.atomic.rmw memory orders must be identical 7 | (func $cmpxchg (param (ref null $struct)) 8 | (struct.atomic.rmw.cmpxchg seqcst acqrel 0 9 | (local.get 0) 10 | (i32.const 1) 11 | (i32.const 2) 12 | ) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /test/lit/wasm-split/imported-memory.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: wasm-split --instrument %s -all -S -o - | filecheck %s 2 | 3 | ;; Check that an imported memory is not exported as "profile-memory" 4 | 5 | (module 6 | (import "env" "mem" (memory $mem 1 1)) 7 | ) 8 | 9 | ;; CHECK: (import "env" "mem" (memory $mem 1 1)) 10 | ;; CHECK: (export "__write_profile" (func $__write_profile)) 11 | 12 | ;; CHECK-NOT: (export "profile-memory" (memory $mem)) 13 | -------------------------------------------------------------------------------- /test/passes/duplicate-import-elimination.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (type $1 (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 $0 (i32.const 0) $foo $foo) 8 | (export "baz" (func $baz)) 9 | (start $foo) 10 | (func $baz 11 | (call $foo) 12 | (call $foo) 13 | (call $wrong 14 | (i32.const 1) 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /test/ctor-eval/imported-global.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (import "env" "tempDoublePtr" (global $tempDoublePtr i32)) 3 | (memory 256 256) 4 | (data (i32.const 10) "waka waka waka waka waka") 5 | ;; imports must not be used 6 | (export "test1" (func $test1)) 7 | (global $mine (mut i32) (global.get $tempDoublePtr)) ;; BAD, if used 8 | (func $test1 9 | (i32.store8 (i32.const 13) (i32.const 115)) ;; we never get here. 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /test/example/match.txt: -------------------------------------------------------------------------------- 1 | Testing Internal::Any 2 | Testing Internal::Exact 3 | Testing Internal::{Bool,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 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # This file contains a list of revisions that are ignored by git blame 2 | # These revisions are unlikely what you are interested in when blaming. 3 | # You can set this file as a default ignore file for blame by running 4 | # the following command. 5 | # 6 | # $ git config blame.ignoreRevsFile .git-blame-ignore-revs 7 | 8 | # Mass change to apply clang-format to everything 9 | db9124f1de0478dcac525009b6f1589b44a7edd8 10 | -------------------------------------------------------------------------------- /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 $0 (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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lit/stdin-stdout.wast: -------------------------------------------------------------------------------- 1 | ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. 2 | ;; RUN: wasm-opt < %s - -S -o - | filecheck %s 3 | ;; RUN: wasm-opt < %s - -g -o - | wasm-opt - -S -o - | filecheck %s 4 | 5 | ;; Test that file `-` is interpreted as stdin and stdout. 6 | 7 | (module 8 | ;; CHECK: (func $foo 9 | ;; CHECK-NEXT: (nop) 10 | ;; CHECK-NEXT: ) 11 | (func $foo 12 | (nop) 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /test/lit/validation/pause.wast: -------------------------------------------------------------------------------- 1 | ;; Test that shared pause requires shared-everything threads 2 | 3 | ;; RUN: not wasm-opt %s 2>&1 | filecheck %s --check-prefix NO-SHARED 4 | ;; RUN: wasm-opt %s --enable-reference-types --enable-gc --enable-shared-everything -o - -S | filecheck %s --check-prefix SHARED 5 | 6 | ;; NO-SHARED: pause requires shared-everything [--enable-shared-everything] 7 | ;; SHARED: (pause) 8 | 9 | (module 10 | (func (pause)) 11 | ) 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 2 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lld/main_module_table_3.wat.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "table" (table $timport$9 1 funcref)) 4 | (import "env" "__stack_pointer" (global $sp (mut i32))) 5 | (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) 6 | (global $global i32 (i32.const 42)) 7 | (elem $0 (i32.const 0)) 8 | (export "__stdio_write" (func $__stdio_write)) 9 | (export "__data_end" (global $global)) 10 | (func $__stdio_write 11 | ) 12 | ) 13 | -------------------------------------------------------------------------------- /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 | (then 8 | (loop $label$0 9 | (local.set $0 10 | (i32.sub 11 | (i32.const 0) 12 | (i32.const 0) 13 | ) 14 | ) 15 | ) 16 | ) 17 | ) 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /test/lit/parse-bad-gc-br_on-novalue.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: not wasm-opt %s -all 2>&1 | filecheck %s 2 | 3 | ;; Check we error properly when a block has no value, but a br_on with a value 4 | ;; targets it. 5 | 6 | (module 7 | ;; CHECK: 10:7: error: br_on target does not expect a value 8 | (func $f 9 | (block $foo 10 | (br_on_cast $foo (ref eq) (ref eq) 11 | (ref.i31 12 | (i32.const 0) 13 | ) 14 | ) 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /test/lit/d8/fuzz_shell.wast: -------------------------------------------------------------------------------- 1 | ;; Test running a wasm file in fuzz_shell.js. 2 | 3 | (module 4 | (func $test (export "test") (result i32) 5 | (i32.const 42) 6 | ) 7 | ) 8 | 9 | ;; Build to a binary wasm. 10 | ;; 11 | ;; RUN: wasm-opt %s -o %t.wasm -q 12 | 13 | ;; Run in d8. 14 | ;; 15 | ;; RUN: v8 %S/../../../scripts/fuzz_shell.js -- %t.wasm | filecheck %s 16 | ;; 17 | ;; CHECK: [fuzz-exec] calling test 18 | ;; CHECK: [fuzz-exec] note result: test => 42 19 | 20 | -------------------------------------------------------------------------------- /test/lit/merge/memory_data.wat.second: -------------------------------------------------------------------------------- 1 | (module 2 | ;; Test that the import remains 3 | (import "import" "mem" (memory $imported 10000)) 4 | 5 | (memory $other 100) 6 | 7 | (memory $bar 1000) 8 | 9 | (data $a (memory $other) (i32.const 0) "a2") 10 | 11 | (data $b (memory $bar) (i32.const 0) "b2") 12 | 13 | (export "keepalive" (memory $other)) 14 | 15 | (export "keepalive1" (memory $bar)) 16 | 17 | (export "keepalive2" (memory $imported)) 18 | ) 19 | -------------------------------------------------------------------------------- /test/wasm2js/base64.2asm.js: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/gtest/json.cpp: -------------------------------------------------------------------------------- 1 | #include "support/json.h" 2 | #include "gtest/gtest.h" 3 | 4 | using JSONTest = ::testing::Test; 5 | 6 | TEST_F(JSONTest, Stringify) { 7 | // TODO: change the API to not require a copy 8 | auto input = "[\"hello\",\"world\"]"; 9 | auto* copy = strdup(input); 10 | json::Value value; 11 | value.parse(copy, json::Value::ASCII); 12 | std::stringstream ss; 13 | value.stringify(ss); 14 | EXPECT_EQ(ss.str(), input); 15 | free(copy); 16 | } 17 | -------------------------------------------------------------------------------- /test/lit/exec/second_retcall.wast.second: -------------------------------------------------------------------------------- 1 | (module 2 | (type $func (func)) 3 | 4 | (import "primary" "global" (global $gimport funcref)) 5 | 6 | (table $table 10 funcref) 7 | 8 | (func $caller (export "caller") 9 | ;; Do an indirect call from the table, writing the imported funcref first. 10 | (table.set $table 11 | (i32.const 1) 12 | (global.get $gimport) 13 | ) 14 | (return_call_indirect (type $func) 15 | (i32.const 1) 16 | ) 17 | ) 18 | ) 19 | 20 | -------------------------------------------------------------------------------- /test/lit/validation/ref-func-simd.wast: -------------------------------------------------------------------------------- 1 | ;; A function type that uses a SIMD type requires the SIMD feature. 2 | ;; RUN: not wasm-opt --enable-reference-types %s 2>&1 | filecheck %s 3 | 4 | ;; CHECK: all used types should be allowed 5 | 6 | (module 7 | (type $simd-user (func (param v128))) 8 | 9 | (global $g (ref null $simd-user) (ref.null func)) 10 | ) 11 | 12 | ;; But it passes with the feature enabled. 13 | ;; RUN: wasm-opt --enable-reference-types --enable-simd %s 14 | -------------------------------------------------------------------------------- /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 externref)) 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 | -------------------------------------------------------------------------------- /test/wasm2js/base64.2asm.js.opt: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/wasm2js/empty_table.2asm.js: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/wasm2js/i64-select.2asm.js: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/lit/node/fuzz_shell.wast: -------------------------------------------------------------------------------- 1 | ;; Test running a wasm file in fuzz_shell.js. 2 | 3 | (module 4 | (func $test (export "test") (result i32) 5 | (i32.const 42) 6 | ) 7 | ) 8 | 9 | ;; Build to a binary wasm. 10 | ;; 11 | ;; RUN: wasm-opt %s -o %t.wasm -q 12 | 13 | ;; Run in node. 14 | ;; 15 | ;; RUN: node %S/../../../scripts/fuzz_shell.js %t.wasm | filecheck %s 16 | ;; 17 | ;; CHECK: [fuzz-exec] calling test 18 | ;; CHECK: [fuzz-exec] note result: test => 42 19 | 20 | 21 | -------------------------------------------------------------------------------- /test/lit/validation/nn-tuples.wast: -------------------------------------------------------------------------------- 1 | ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. 2 | 3 | ;; RUN: wasm-opt %s -all -S -o - \ 4 | ;; RUN: | filecheck %s 5 | 6 | ;; Test for non-nullable types in tuples 7 | 8 | (module 9 | ;; CHECK: (func $foo (type $0) 10 | ;; CHECK-NEXT: (local $tuple (tuple (ref any) (ref any))) 11 | ;; CHECK-NEXT: ) 12 | (func $foo 13 | (local $tuple (tuple (ref any) (ref any))) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /test/metadce/segments.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32))) 3 | (import "env" "g1" (global $g1 i32)) 4 | (import "env" "g2" (global $g2 i32)) 5 | (memory $0 3) 6 | (data $0 (global.get $g2) "xxx") 7 | (table $tbl 1 funcref) 8 | (elem $0 (global.get $g1) $f) 9 | (export "f" (func $f)) 10 | (func $f (type $0) (param $0 i32) 11 | (call_indirect $tbl (type $0) 12 | (local.get $0) 13 | (i32.load8_u 14 | (i32.const 0) 15 | ) 16 | ) 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /test/stacky.wasm.fromBinary: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 $scratch i32) 7 | (i32.add 8 | (block (result i32) 9 | (local.set $scratch 10 | (local.get $0) 11 | ) 12 | (local.set $0 13 | (i32.const 100) 14 | ) 15 | (local.get $scratch) 16 | ) 17 | (local.get $1) 18 | ) 19 | ) 20 | ) 21 | 22 | -------------------------------------------------------------------------------- /test/wasm2js/i64-select.2asm.js.opt: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/wasm2js/if_unreachable.2asm.js: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/wasm2js/unreachable-if.2asm.js: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/wasm2js/unreachable-insts.2asm.js: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/ctor-eval/ignore-external-input.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (type $1 (func)) 4 | (import "wasi_snapshot_preview1" "something_else" (func $wasi_something_else (type $0) (result i32))) 5 | (memory $0 256 256) 6 | (data $0 (i32.const 28) "aaaa") 7 | (export "test3" (func $test3)) 8 | (func $test3 (type $1) 9 | (drop 10 | (call $wasi_something_else) 11 | ) 12 | (i32.store 13 | (i32.const 28) 14 | (i32.const 100) 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/lld/standalone-wasm3.wat.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32 i32) (result i32))) 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 | (memory $0 2) 7 | (export "memory" (memory $0)) 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 | (i32.const 0) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/wasm2js/if_unreachable.2asm.js.opt: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/wasm2js/reinterpret_scratch.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 1 1) 3 | (func $foo (export "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 | -------------------------------------------------------------------------------- /test/wasm2js/unreachable-get-cycle.2asm.js: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/wasm2js/unreachable-if.2asm.js.opt: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/wasm2js/unreachable-insts.2asm.js.opt: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/ctor-eval/partial-locals-tee.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (param i32 i32))) 3 | (type $1 (func)) 4 | (import "import" "import" (func $import (type $0) (param i32 i32))) 5 | (memory $0 256 256) 6 | (data $0 (i32.const 10) "__s______________") 7 | (export "test1" (func $test1_2)) 8 | (func $test1_2 (type $1) 9 | (call $import 10 | (i32.const 1) 11 | (i32.const 50) 12 | ) 13 | (i32.store8 14 | (i32.const 13) 15 | (i32.const 115) 16 | ) 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /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" (func $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 | -------------------------------------------------------------------------------- /test/lit/passes/custom-max-data-segments.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: wasm-opt %s --limit-segments --pass-arg=limit-segments@3 -S -o - | filecheck %s 2 | 3 | ;; Test that the data segments custom limit is respected. 4 | (module 5 | (memory 256 256) 6 | ;; CHECK: (data $0 (i32.const 0) "A") 7 | (data (i32.const 0) "A") 8 | ;; CHECK: (data $"" (i32.const 1) "AAAA") 9 | (data (i32.const 1) "A") 10 | (data (i32.const 2) "A") 11 | (data (i32.const 3) "A") 12 | (data (i32.const 4) "A") 13 | ) 14 | -------------------------------------------------------------------------------- /test/unit/test_fuzz_empty_data.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tempfile 3 | from scripts.test import shared 4 | from . import utils 5 | 6 | 7 | class EmptyDataFuzzTest(utils.BinaryenTestCase): 8 | def test_empty_data(self): 9 | try: 10 | temp = tempfile.NamedTemporaryFile(delete=False).name 11 | shared.run_process(shared.WASM_OPT + ['-ttf', temp], 12 | capture_output=True) 13 | finally: 14 | os.unlink(temp) 15 | -------------------------------------------------------------------------------- /test/wasm2js/empty_loop.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (global $g (mut i32) (i32.const 0)) 3 | 4 | (func $test (export "test") 5 | ;; Loops without labels. We should not emit anything invalid here (like a 6 | ;; null name, which would end up identical between the two, which is wrong). 7 | (loop 8 | (loop 9 | ;; Some content, so the loop is not trivial. 10 | (global.set $g 11 | (i32.const 0) 12 | ) 13 | (unreachable) 14 | ) 15 | (unreachable) 16 | ) 17 | ) 18 | ) 19 | -------------------------------------------------------------------------------- /test/wasm2js/unreachable-get-cycle.2asm.js.opt: -------------------------------------------------------------------------------- 1 | 2 | function asmFunc(imports) { 3 | var Math_imul = Math.imul; 4 | var Math_fround = Math.fround; 5 | var Math_abs = Math.abs; 6 | var Math_clz32 = Math.clz32; 7 | var Math_min = Math.min; 8 | var Math_max = Math.max; 9 | var Math_floor = Math.floor; 10 | var Math_ceil = Math.ceil; 11 | var Math_trunc = Math.trunc; 12 | var Math_sqrt = Math.sqrt; 13 | return { 14 | 15 | }; 16 | } 17 | 18 | var retasmFunc = asmFunc({ 19 | }); 20 | -------------------------------------------------------------------------------- /test/wasm2js/unreachable-if.wast: -------------------------------------------------------------------------------- 1 | ;; Regression test for bad assertion in autodrop that did not expect the if to 2 | ;; be finalized to unreachable. 3 | (module 4 | (func $test (result i32) 5 | (block $l (result i32) 6 | (drop 7 | (br_if $l 8 | (if (result i32) 9 | (unreachable) 10 | (then 11 | (i32.const 0) 12 | ) 13 | (else 14 | (i32.const 0) 15 | ) 16 | ) 17 | ) 18 | (i32.const 0) 19 | ) 20 | ) 21 | ) 22 | ) 23 | -------------------------------------------------------------------------------- /src/wasm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB wasm_HEADERS ../*.h) 2 | set(wasm_SOURCES 3 | literal.cpp 4 | parsing.cpp 5 | source-map.cpp 6 | wasm.cpp 7 | wasm-binary.cpp 8 | wasm-debug.cpp 9 | wasm-emscripten.cpp 10 | wasm-interpreter.cpp 11 | wasm-io.cpp 12 | wasm-ir-builder.cpp 13 | wasm-stack.cpp 14 | wasm-stack-opts.cpp 15 | wasm-type.cpp 16 | wasm-type-shape.cpp 17 | wasm-validator.cpp 18 | ${wasm_HEADERS} 19 | ) 20 | target_sources(binaryen PRIVATE ${wasm_SOURCES}) 21 | -------------------------------------------------------------------------------- /test/lit/passes/asyncify_pass-arg=asyncify-export-globals.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: wasm-opt --enable-mutable-globals --asyncify --pass-arg=asyncify-export-globals -S -o - | filecheck %s 2 | 3 | (module 4 | ) 5 | ;; CHECK: (global $__asyncify_state (mut i32) (i32.const 0)) 6 | 7 | ;; CHECK: (global $__asyncify_data (mut i32) (i32.const 0)) 8 | 9 | ;; CHECK: (export "__asyncify_state" (global $__asyncify_state)) 10 | 11 | ;; CHECK: (export "__asyncify_data" (global $__asyncify_data)) 12 | -------------------------------------------------------------------------------- /test/lit/passes/trace-calls_multi-value-result.wast: -------------------------------------------------------------------------------- 1 | ;; Test that a traced function with a multi-value result type 2 | ;; results in a useful error message 3 | 4 | ;; RUN: not wasm-opt --enable-simd --enable-multivalue --trace-calls=multi_param_result %s 2>&1 | filecheck %s 5 | 6 | ;; CHECK: Fatal: Failed to instrument function 'multi_param_result': Multi-value result type is not supported 7 | (module 8 | (import "env" "multi_param_result" (func $multi_param_result (result i32 i32))) 9 | ) 10 | -------------------------------------------------------------------------------- /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 $0 (func)) 12 | (func $if-loop-test 13 | (local $0 i32) 14 | (if 15 | (i32.const 0) 16 | (then 17 | (loop $label$0 18 | (local.set $0 19 | (i32.sub 20 | (i32.const 0) 21 | (i32.const 0) 22 | ) 23 | ) 24 | ) 25 | ) 26 | ) 27 | ) 28 | ) 29 | -------------------------------------------------------------------------------- /test/lit/validation/ref-gc-simd.wast: -------------------------------------------------------------------------------- 1 | ;; A gc type that uses a SIMD type requires the SIMD feature. 2 | ;; RUN: not wasm-opt --enable-reference-types --enable-gc %s 2>&1 | filecheck %s 3 | 4 | ;; CHECK: all used types should be allowed 5 | 6 | (module 7 | (type $simd-user (struct (field v128))) 8 | 9 | (global $g (ref null $simd-user) (ref.null $simd-user)) 10 | ) 11 | 12 | ;; But it passes with the feature enabled. 13 | ;; RUN: wasm-opt --enable-reference-types --enable-gc --enable-simd %s 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/googletest"] 2 | path = third_party/googletest 3 | url = https://github.com/google/googletest.git 4 | [submodule "test/spec/testsuite"] 5 | path = test/spec/testsuite 6 | url = https://github.com/WebAssembly/testsuite.git 7 | [submodule "third_party/fuzztest"] 8 | path = third_party/fuzztest 9 | url = https://github.com/google/fuzztest 10 | [submodule "third_party/mimalloc"] 11 | path = third_party/mimalloc 12 | url = https://github.com/microsoft/mimalloc.git 13 | -------------------------------------------------------------------------------- /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" (func $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 | -------------------------------------------------------------------------------- /test/lit/structref.wast: -------------------------------------------------------------------------------- 1 | ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. 2 | 3 | ;; RUN: wasm-opt -all %s -S -o - | filecheck %s 4 | 5 | ;; Check that `struct` is correctly parsed as an alias for `data`. 6 | (module 7 | ;; CHECK: (func $foo (type $0) (param $x structref) (param $y (ref struct)) 8 | ;; CHECK-NEXT: (unreachable) 9 | ;; CHECK-NEXT: ) 10 | (func $foo (param $x structref) (param $y (ref struct)) 11 | (unreachable) 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /test/passes/remove-imports.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $FUNCSIG$v (func)) 3 | (import "env" "table" (table $table 1 1 funcref)) 4 | (import "env" "memBase" (global $gimport$0 i32)) 5 | (import "somewhere" "waka-sneaky" (func $waka-sneaky)) 6 | (memory $0 1024 1024) 7 | (elem $0 (i32.const 0) $waka-sneaky) 8 | (func $nada 9 | (nop) 10 | (drop 11 | (i32.const 0) 12 | ) 13 | (drop 14 | (f64.const 0) 15 | ) 16 | (call_indirect (type $FUNCSIG$v) 17 | (i32.const 0) 18 | ) 19 | ) 20 | ) 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/binaryen.js/tag.js.txt: -------------------------------------------------------------------------------- 1 | GetTag is equal: true 2 | getTagInfo={"name":"a-tag","module":"","base":"","params":2,"results":0} 3 | (module 4 | (type $0 (func (param i32))) 5 | (type $1 (func (param i32 f32))) 6 | (import "module" "base" (tag $a-tag-imp (type $1) (param i32 f32))) 7 | (tag $a-tag (type $0) (param i32)) 8 | (export "a-tag-exp" (tag $a-tag)) 9 | ) 10 | 11 | (module 12 | (type $0 (func (param i32 f32))) 13 | (import "module" "base" (tag $a-tag-imp (type $0) (param i32 f32))) 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /test/calls.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | 5 | int inner(int x) { return x * x + 2; } 6 | 7 | int EMSCRIPTEN_KEEPALIVE simple(int x) { return inner(x); } 8 | 9 | int EMSCRIPTEN_KEEPALIVE fibo(int x) { 10 | if (x == 0 || x == 1) 11 | return 1; 12 | return fibo(x - 1) + fibo(x - 2); 13 | } 14 | 15 | int EMSCRIPTEN_KEEPALIVE run_script() { 16 | emscripten_run_script("Module.print('hello from called script')"); 17 | return emscripten_run_script_int("1+2+3+4-1"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/lit/passes/remove-memory-init.wast: -------------------------------------------------------------------------------- 1 | ;; RUN: wasm-opt %s --remove-memory-init -all -S -o - | filecheck %s 2 | 3 | (module 4 | (type $0 (func)) 5 | ;; CHECK: (memory $mem 2) 6 | (memory $mem 2) 7 | (data (memory $mem) (i32.const 0) "Hello, world\00") 8 | (func $__wasm_init_memory (type $0) 9 | (memory.fill 0 10 | (i32.const 0) 11 | (i32.const 0) 12 | (i32.const 0) 13 | ) 14 | ) 15 | (start $__wasm_init_memory) 16 | ) 17 | 18 | ;; CHECK-NOT: data 19 | ;; CHECK-NOT: __wasm_init_memory 20 | -------------------------------------------------------------------------------- /test/lit/validation/table-type.wast: -------------------------------------------------------------------------------- 1 | ;; Test that the features required by table types are checked 2 | 3 | ;; RUN: not wasm-opt %s -all --disable-shared-everything 2>&1 | filecheck %s --check-prefix NO-SHARED 4 | ;; RUN: wasm-opt %s -all -S -o - | filecheck %s --check-prefix SHARED 5 | 6 | ;; NO-SHARED: table type requires additional features 7 | ;; NO-SHARED: [--enable-shared-everything] 8 | ;; SHARED: (table $t 0 0 (ref null (shared func))) 9 | 10 | (module 11 | (table $t 0 0 (ref null (shared func))) 12 | ) 13 | -------------------------------------------------------------------------------- /test/lld/main_module_table_4.wat.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (import "env" "table" (table $timport$9 1 funcref)) 4 | (import "env" "__stack_pointer" (global $sp (mut i32))) 5 | (import "GOT.func" "__stdio_write" (global $gimport$9 (mut i32))) 6 | (import "env" "__table_base" (global $tb i32)) 7 | (global $global i32 (i32.const 42)) 8 | (elem $0 (global.get $tb)) 9 | (export "__stdio_write" (func $__stdio_write)) 10 | (export "__data_end" (global $global)) 11 | (func $__stdio_write 12 | ) 13 | ) 14 | -------------------------------------------------------------------------------- /test/passes/remove-unused-names_precompute.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/passes/pick-load-signs_all-features.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (memory $0 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 | -------------------------------------------------------------------------------- /test/lit/validation/elem-type.wast: -------------------------------------------------------------------------------- 1 | ;; Test that the features required by element segment types are checked 2 | 3 | ;; RUN: not wasm-opt %s -all --disable-shared-everything 2>&1 | filecheck %s --check-prefix NO-SHARED 4 | ;; RUN: wasm-opt %s -all -S -o - | filecheck %s --check-prefix SHARED 5 | 6 | ;; NO-SHARED: element segment type requires additional features 7 | ;; NO-SHARED: [--enable-shared-everything] 8 | ;; SHARED: (elem $e (ref null (shared func))) 9 | 10 | (module 11 | (elem $e (ref null (shared func))) 12 | ) 13 | -------------------------------------------------------------------------------- /test/metadce/table.wast.dced: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (type $array (array (mut funcref))) 4 | (table $table-used 10 funcref) 5 | (elem $elem (i32.const 0) $func) 6 | (elem $passive-elem-used func $func) 7 | (export "test" (func $func)) 8 | (func $func (type $0) 9 | (table.fill $table-used 10 | (i32.const 0) 11 | (ref.func $func) 12 | (i32.const 0) 13 | ) 14 | (drop 15 | (array.new_elem $array $passive-elem-used 16 | (i32.const 0) 17 | (i32.const 1) 18 | ) 19 | ) 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /test/passes/pick-load-signs_all-features.txt: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func (result i32))) 3 | (memory $0 16 16) 4 | (func $atomics-are-always-unsigned (type $0) (result i32) 5 | (local $0 i32) 6 | (drop 7 | (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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/ctor-eval/overlapping-segments.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $none_=>_i32 (func (result i32))) 3 | (type $1 (func)) 4 | (table $0 46 funcref) 5 | (elem $0 (i32.const 9) $1) 6 | (elem $1 (i32.const 9) $0) 7 | (export "test1" (func $2)) 8 | (func $0 (type $none_=>_i32) (result i32) 9 | (unreachable) 10 | ) 11 | (func $1 (type $none_=>_i32) (result i32) 12 | (i32.const 65) 13 | ) 14 | (func $2 (type $1) 15 | (drop 16 | (call_indirect $0 (type $none_=>_i32) 17 | (i32.const 9) 18 | ) 19 | ) 20 | ) 21 | ) 22 | -------------------------------------------------------------------------------- /test/lit/parse-bad-optional-memidx.wast: -------------------------------------------------------------------------------- 1 | ;; Regression test for a parser bug where the invalid memory index followed by 2 | ;; another immediate caused an assertion failure. 3 | 4 | ;; RUN: not wasm-opt -all %s 2>&1 | filecheck %s 5 | 6 | ;; CHECK: Fatal: {{.*}}:12:22: error: expected end of instruction 7 | 8 | (module 9 | (memory 1 1) 10 | 11 | (func $v128.load16_lane1 (param $0 i32) (param $1 v128) (result v128) 12 | (v128.load16_lane 1 0 ;; invalid memory index 13 | (local.get $0) 14 | (local.get $1) 15 | ) 16 | ) 17 | ) -------------------------------------------------------------------------------- /third_party/FP16/readme.txt: -------------------------------------------------------------------------------- 1 | This folder contains files from FP16. See LICENSE.TXT for their license. 2 | 3 | These files were synced from 4 | 5 | commit 98b0a46bce017382a6351a19577ec43a715b6835 (HEAD -> master, origin/master, origin/HEAD) 6 | Author: Marat Dukhan 7 | Date: Wed Jun 19 23:11:08 2024 -0700 8 | 9 | Support native conversions without __fp16/_Float16 types 10 | 11 | and also contain the patch from 12 | 13 | https://github.com/Maratyszcza/FP16/pull/31 616ad91f449a03d0b48a8a124f4d1baa94f869b2 14 | -------------------------------------------------------------------------------- /test/binaryen.js/debug-info.js.txt: -------------------------------------------------------------------------------- 1 | === default === 2 | debugInfo=false 3 | (module 4 | (type $0 (func)) 5 | (memory $0 0) 6 | (export "test" (func $0)) 7 | (func $0 8 | ) 9 | ) 10 | 11 | === with debug info === 12 | debugInfo=true 13 | (module 14 | (type $v (func)) 15 | (memory $0 0) 16 | (export "test" (func $test)) 17 | (func $test 18 | ) 19 | ) 20 | 21 | === without debug info === 22 | debugInfo=false 23 | (module 24 | (type $0 (func)) 25 | (memory $0 0) 26 | (export "test" (func $0)) 27 | (func $0 28 | ) 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /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 $0 (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 | -------------------------------------------------------------------------------- /test/ctor-eval/globals.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (global $g1 (mut i32) (i32.const 10)) 3 | (global $g2 (mut i32) (i32.const 20)) 4 | (func $test1 (export "test1") 5 | (global.set $g1 (i32.const 30)) 6 | (global.set $g2 (i32.const 40)) 7 | (global.set $g1 (i32.const 50)) ;; this overrides the previous 30 8 | ) 9 | (func $keepalive (export "keepalive") (result i32) 10 | ;; Keep the globals alive so we can see their values. 11 | (i32.add 12 | (global.get $g1) 13 | (global.get $g2) 14 | ) 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /test/lit/parse-bad-nominal-types.wast: -------------------------------------------------------------------------------- 1 | ;; Test that incorrect nominal types result in the expected parse errors 2 | 3 | ;; RUN: foreach %s %t not wasm-opt -all 2>&1 | filecheck %s 4 | 5 | ;; CHECK: 2:28: error: unknown type identifier 6 | (module 7 | (type $bad-func (sub $bad (func))) 8 | ) 9 | 10 | ;; CHECK: 2:30: error: unknown type identifier 11 | (module 12 | (type $bad-struct (sub $bad (struct))) 13 | ) 14 | 15 | ;; CHECK: 2:29: error: unknown type identifier 16 | (module 17 | (type $bad-array (sub $bad (array i32))) 18 | ) 19 | -------------------------------------------------------------------------------- /test/lit/table64.wast: -------------------------------------------------------------------------------- 1 | ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. 2 | ;; RUN: wasm-opt %s -all --roundtrip -S -o - | filecheck %s 3 | 4 | 5 | ;; Most table64 test coverage is handled by the spec tests. 6 | ;; Here we test what the spec doesn't cover, currently just the i64 flag 7 | ;; is preserved on table imports during roundtripping. 8 | (module 9 | (import "env" "table" (table i64 1 funcref)) 10 | ) 11 | ;; CHECK: (import "env" "table" (table $timport$0 i64 1 funcref)) 12 | -------------------------------------------------------------------------------- /test/lit/validation/fp16.wast: -------------------------------------------------------------------------------- 1 | ;; Test that fp16 operations require the fp16 feature. 2 | 3 | ;; RUN: not wasm-opt %s --enable-simd 2>&1 | filecheck %s --check-prefix NO-FP16 4 | ;; RUN: wasm-opt %s --enable-simd --enable-fp16 -o - -S | filecheck %s --check-prefix FP16 5 | 6 | ;; NO-FP16: FP16 operations require FP16 [--enable-fp16] 7 | ;; FP16: (type $0 (func (param v128 v128) (result v128))) 8 | 9 | (module 10 | (func (export "f16x8.add") (param $0 v128) (param $1 v128) (result v128) (f16x8.add (local.get $0) (local.get $1))) 11 | ) 12 | -------------------------------------------------------------------------------- /test/passes/reorder-locals_print_roundtrip.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $a 3 | (local $x i32) 4 | (local $y f64) 5 | ;; x appears twice 6 | (drop (local.get $x)) 7 | (drop (local.get $x)) 8 | (drop (local.get $y)) 9 | ) 10 | (func $b 11 | (local $x i32) 12 | (local $y f64) 13 | ;; y appears twice, so it will be reordered to be first, and that should be 14 | ;; preserved in the binary format 15 | (drop (local.get $x)) 16 | (drop (local.get $y)) 17 | (drop (local.get $y)) 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /test/ctor-eval/unsafe_call.wast.out: -------------------------------------------------------------------------------- 1 | (module 2 | (type $0 (func)) 3 | (memory $0 256 256) 4 | (data $0 (i32.const 10) "waka waka waka waka waka") 5 | (export "test1" (func $test1)) 6 | (func $test1 (type $0) 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 (type $0) 22 | (unreachable) 23 | ) 24 | ) 25 | -------------------------------------------------------------------------------- /test/lit/ctor-eval/flatten_overflow.wast: -------------------------------------------------------------------------------- 1 | ;; The data segment here is at an offset too large to fit into the memory due 2 | ;; to an overflow. That will cause us to fail during flatten, so there are no 3 | ;; changes to output here, but we should not error (if we don't check for 4 | ;; overflow, we'd segfault). 5 | 6 | ;; RUN: wasm-ctor-eval %s --ctors=test --kept-exports=test --quiet -all 7 | 8 | (module 9 | (memory $0 10 10) 10 | (data $0 (i32.const -1) "a") 11 | 12 | (export "test" (func $test)) 13 | 14 | (func $test 15 | ) 16 | ) 17 | -------------------------------------------------------------------------------- /test/passes/Os_print-stack-ir_all-features_disable-gc.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 | -------------------------------------------------------------------------------- /test/wasm2js/br_table_to_loop.wast: -------------------------------------------------------------------------------- 1 | (module 2 | (func $exp1 (export "exp1") 3 | (block $block 4 | ;; An infinite loop. When optimizing, wasm2js enables ignore-implicit-traps 5 | ;; and so it can simplify this. 6 | (loop $loop 7 | (br_table $block $loop $block (i32.const 1)) 8 | ) 9 | ) 10 | ) 11 | (func $exp2 (export "exp2") 12 | (block $block 13 | ;; A loop that never executes. This can be optimized into a nop. 14 | (loop $loop 15 | (br_table $loop $block $loop (i32.const 1)) 16 | ) 17 | ) 18 | ) 19 | ) 20 | -------------------------------------------------------------------------------- /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.ReadsTable=256 11 | SideEffects.WritesTable=512 12 | SideEffects.ImplicitTrap=1024 13 | SideEffects.IsAtomic=2048 14 | SideEffects.Throws=4096 15 | SideEffects.DanglingPop=8192 16 | SideEffects.TrapsNeverHappen=16384 17 | SideEffects.Any=32767 18 | --------------------------------------------------------------------------------