summaryrefslogtreecommitdiff
path: root/src/binary-reader.cc
Commit message (Collapse)AuthorAgeFilesLines
* Add initial support for code metadata (#1840)Yuri Iozzelli2022-02-251-0/+58
| | | | | | | | | | | | | | | | | | | | | See https://github.com/WebAssembly/tool-conventions/blob/main/CodeMetadata.md for the specification. In particular this pr implements the following: - Parsing code metadata sections in BinaryReader, providing appropriate callbacks that a BinaryReaderDelegate can implement: - BinaryReaderObjdump: show the sections in a human-readable form - BinaryReaderIr: add code metadata in the IR as expressions - Parsing code metadata annotations in text format, adding them in the IR like the BinaryReaderIR does - Writing the code metadata present in the IR in the proper sections when converting IR to binary - Support in wasm-decompiler for showing code metadata as comments in the pseudo-code All the features have corresponding tests. Support for code metadata is gated through the --enable-code-metadata feature. For reading/writing in the text format, --enable-annotations is also required. Missing features: Support for function-level code metadata (offset 0) Extensive validation in validator.cc (like making sure that all metadata instances are at the same code offset of an instruction)
* Use C++17 string_view (#1826)Sam Clegg2022-02-111-20/+20
| | | | | Now that we have C++17 we don't need our own string_view class anymore. Depends on #1825
* Update testsuite (#1795)Sam Clegg2022-01-101-2/+18
| | | | Remove test/binary/bad-function-missing-end.txt which is now covered upstream: https://github.com/WebAssembly/spec/pull/1405
* Fix type names for function references (#1787)Sam Clegg2021-12-131-1/+1
| | | | | | | | This requires `Type::GetName` to return to be dynamicllay created and return `std::string` rather then a `const char*` As this diff shows this type name is only used in textual output and error messages so should this change should not have a effect of binary parse time or the interpreter.
* wasm-objdump: Fix disassembly output of selectT instruction (#1777)Sam Clegg2021-12-081-3/+7
| | | | Use `LogOpcodeType` rather than LogOpcodeBare` when the select instruction has a type.
* Show tag names in objdump disassembly (#1774)Sam Clegg2021-12-071-0/+1
| | | | | | | | | Tag names are not officially part of the extended-name-section proposal (because it only deals with naming things that are in the spec already). However, I think its reasonable (and useful) to include these names under a speculative subsection ID, on the basis that tags can only exist when exceptions are enabled and that engines should ignore unknown name types.
* Perform init expression validation outside of the binary reader. NFC (#1770)Sam Clegg2021-12-021-94/+29
| | | | | | | | | | | | | | | | Rather than spocial casing them in the reader we now use the same instruction callbacks for instruction that appear in init expressions as instructions that appear in normal functions. The result of this change is the validation of init expressions is pushed further up the stack. For example, objdump will now quite happily dump modules that use arbitrary instructions in thier init expressions even though they are not valid. To me, this makes sense since objdump does not do instruction validation elsewhere. The change is pre-cursor to allowing a wider variety of instruction to be present in init expressions. See https://github.com/WebAssembly/extended-const
* Add multi-memory feature support (#1751)Yuhan Deng2021-11-301-32/+92
|
* Support function references in parameters and results of functions and ↵Dmitry Bezhetskov2021-11-161-1/+10
| | | | blocks. (#1695)
* Remove separate OnEndFunc vs OnEndExpr. (#1756)Sam Clegg2021-11-051-3/+1
| | | | We already have EndFunctionBody, and this extra distinction doesn't seem like it is needed.
* Fix a range of data type warning in gcc (#1702)Hyukwoo Park2021-10-261-2/+1
|
* Add support for target_features section (#1744)Sam Clegg2021-10-191-0/+19
|
* Support for import/export info in dylink section (#1741)Sam Clegg2021-10-191-3/+26
|
* Fix ub access of 0-size vector in data segment (#1725)Ng Zhi An2021-10-121-0/+1
| | | | If the module has no memory, the we try to copy the passive data segment to memories[0], and memories is a size 0 vector, which is UB.
* Support new dylink custom section format (#1707)Sam Clegg2021-09-101-0/+56
| | | | | | | | This section is now based on sub-sections making it more extensible. See also: llvm change: https://reviews.llvm.org/D109595 binaryen change: https://github.com/WebAssembly/binaryen/pull/4141
* Remove ununsed onSymbol callback. NFC (#1708)Sam Clegg2021-09-101-1/+0
| | | | We have the more specific OnFunctionSymbol, OnGlobalSymbol family of callbacks that is used by objdump.
* Begin support for typed function references proposal: added the flag and ↵Dmitry Bezhetskov2021-07-251-0/+5
| | | | supported call_ref (#1691)
* [EH] Remove `unwind` (#1682)Heejin Ahn2021-06-291-6/+0
| | | `unwind` was removed. See WebAssembly/exception-handling#156.
* [EH] Make tag attribute's encoding uint8 (#1681)Heejin Ahn2021-06-291-2/+2
| | | | | | | | | | | This changes the encoding of the `attribute` field, which currently only contains the value `0` denoting this tag is for an exception, from `varuint32` to `uint8`. This field is effectively unused at the moment and reserved for future use, and it is not likely to need `varuint32` even in future. See https://github.com/WebAssembly/exception-handling/pull/162. This does not change any encoded binaries because `0` is encoded in the same way both in `varuint32` and `uint8`.
* [EH] Replace event with tag (#1678)Heejin Ahn2021-06-221-32/+32
| | | | | | | | | | | We recently decided to change 'event' to 'tag', and 'event section' to 'tag section', out of the rationale that the section contains a generalized tag that references a type, which may be used for something other than exceptions, and the name 'event' can be confusing in the web context. See - https://github.com/WebAssembly/exception-handling/issues/159#issuecomment-857910130 - https://github.com/WebAssembly/exception-handling/pull/161
* [Memory64] Support reading/writing limits as 64-bit LEBs (#1664)Wouter van Oortmerssen2021-04-221-5/+16
|
* Memory64: support 64-bit data init-expr (#1656)Wouter van Oortmerssen2021-04-051-11/+11
|
* [simd] Implement store lane (#1647)Ng Zhi An2021-03-221-0/+15
|
* [simd] Implement load lane (#1646)Ng Zhi An2021-03-221-0/+15
| | | | | | | | | This is a new kind of ir/ast node/instruction. It has 3 immediates: memarg align, memarg offset, and lane index. This required new visitor functions in all the places. Drive-by cleanup to share the simd lane parsing logic between shuffle, lane op and this new load lane instructions. This requires rebasing some tests because the error messages are slightly different now.
* [simd] Implement v128.load{32,64}_zero (#1644)Ng Zhi An2021-03-171-0/+11
| | | | This requires a new ir type, and the relevant implementation of virtual mthods in the various visitors.
* [simd] Implement i64x2.extend_{low,high}_i32x4_{s,u} (#1643)Ng Zhi An2021-03-161-0/+4
| | | Unskip and rebase simd_int_to_int_extend.
* [simd] Implement i64x2 comparisons (#1642)Ng Zhi An2021-03-161-0/+6
| | | Rebase and unskip simd_i64x2_cmp.
* [simd] Implement i32x4.dot_i16x8_s (#1640)Ng Zhi An2021-03-161-0/+1
| | | Rebase and unskip simd_i32x4_dot_i16x8.
* [simd] Implement q15mulrsat_s (#1639)Ng Zhi An2021-03-161-0/+1
| | | Rebase and unskip simd_i16x8_q15mulr_sat_s.
* [simd] Implement extmul instructions (#1638)Ng Zhi An2021-03-121-0/+12
| | | | | | | Renumber floating point rounding instructions since they overlap with these new extmul instructions. Rebase simd_f32x4_rounding and simd_f64x2_rounding. Rebase and unskip simd extmul tests.
* [simd] Implement extadd instructions (#1637)Ng Zhi An2021-03-121-0/+4
| | | | Rebase and unskip simd_i16x8_extadd_pairwise_i8x16.txt and simd_i32x4_extadd_pairwise_i16x8.
* [simd] Implement i64x2.abs (#1636)Ng Zhi An2021-03-121-0/+1
| | | Rebase and unskip simd_i64x2_arith2.txt.
* [simd] Implement i32x4.trunc_sat_f64x2_[su]_zero (#1635)Ng Zhi An2021-03-121-0/+2
| | | | Rebase simd_i32x4_trunc_sat_f64x2.txt and simd_i32x4_trunc_sat_f32x4.txt.
* [simd] Rename widen to extend, implement some double precision ops (#1633)Ng Zhi An2021-03-111-8/+12
| | | | | | | | | | | | 4 double precision conversion instructions are implemented: - f32x4.demote_f64x2_zero - f64x2.demote_low_f32x4 - f64x2.convert_low_i32x4_s - f64x2.convert_low_i32x4_u This is now sufficient to unskip simd_conversions.txt. Rebase a bunch of tests due to the rename from widen to extend.
* Implement i8x16.popcnt and rebase simd_i8x16_arith2.txt (#1625)Ng Zhi An2021-03-111-0/+1
|
* Fix format-string warning for 32-bit compilation (#1629) (#1630)Steven Johnson2021-03-101-1/+1
|
* [simd] Rename any_true, implement i64x2 bitmask and all_true (#1624)Ng Zhi An2021-03-041-3/+3
| | | | | | | | | | | * Rename all any_true to v128.any_true * Add i64x2.bitmask and i64x2.all_true, rebase simd_boolean * Unskip spec/simd/simd_i16x8_arith2.txt since i64x2.abs is now implemented * Unskip spec/simd/simd_lane.txt * Update dump interp tests, rebase
* Bump testsuite version and fix tests (#1622)Ng Zhi An2021-03-041-1/+9
| | | | | | | | | This is an incremental bump of testsuite, the TOT has SIMD tests which won't work yet. The main fix is for a test added to the spec repo that has an invalid functype in the type section. Based on the spec, the functype should be a single byte 0x60. The leb encoding only comes into effect with the GC proposal.
* Update rethrow depth handling and catch_all opcode (#1608)Asumu Takikawa2021-02-181-0/+6
| | | | | | | | | | | | | Give `catch_all` its own opcode: Previously `catch_all` shared an opcode with `else`, but the spec now allocates it the 0x19 opcode. Adjust rethrow depth semantics: Previously this had interpreted the rethrow depth argument as counting only catch blocks, but the spec has clarified that it should count all blocks (in a similar fashion as `br` and related instructions).
* Update exception handling support to current proposal (#1596)Asumu Takikawa2021-02-101-14/+19
| | | | | | | | | | This PR updates the support of exception handling to the latest proposal (that is compatible with future 2-phase exception handling) described in https://github.com/WebAssembly/exception-handling/pull/137 and https://github.com/WebAssembly/exception-handling/pull/143. * Adds back tagged `catch $e`, `catch_all`, and `rethrow N` from a previous version of wabt, but with updates to match the current spec (e.g., `catch_all` shares an opcode with `else`, `rethrow`'s depth indexes only catch blocks, etc). * Adds `unwind` and `delegate` instructions. * Removes `exnref` and `br_on_exn`. * Updates relevant tests. There are some details that could still change (e.g., maybe how `delegate`'s depth is validated), but I'd be happy to submit further PRs if the spec details change.
* Port to big-endian platforms (s390x but others can be trivially added) (#1557)Soni L2020-12-071-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Initial attempt at s390x port * Second attempt at s390x port * Fix big-endian memory fill * Fix more memory location calculations * Improve SIMD * Implement big-endian memory grow * Fill relocation with 0x00, as per spec * Make wasm2c endianness work * Fix shuffle * Fix load endianness in wasm2c * Refactor into shared code * Clean up SwapBytesSized * Clean up MemcpyEndianAware * Clean up * "Fix" opcodecnt basic test
* Select instr. with multiple results is invalid (#1582)Ben Smith2020-12-031-9/+16
| | | | | | The reference-types proposal adds a select instruction with a type vector, but any number greater than 1 is invalid. Fixes #1577.
* Add new TLS relocation types (#1572)Sam Clegg2020-11-201-0/+2
| | | See https://reviews.llvm.org/D91276
* Rename atomic.notify, *.atomic.wait (#1564)Ben Smith2020-11-031-3/+3
| | | | | | | | atomic.notify -> memory.atomic.notify i32.atomic.wait -> memory.atomic.wait32 i64.atomic.wait -> memory.atomic.wait64 These were renamed upstream a while ago, but the new names were not added to wabt.
* Update SIMD support (#1553)Darin Morrison2020-10-261-20/+32
| | | | | | | | | | | | | * Update testsuite * Update test results * Disallow lane nums with optional + for simd ops * Update simd support * Mark `test/spec/func.txt` as failing Co-authored-by: Darin Morrison <darinmorrison@users.noreply.github.com>
* Add initial support for extended names sections (#1554)Sam Clegg2020-10-021-1/+32
| | | | | | | | See: https://github.com/WebAssembly/extended-name-section Although this is only a phase 1 proposal its seems pretty straight forward, and is already being implemented in binaryen.
* Add --relocatable support for tables (#1549) (#1549)Andy Wingo2020-10-011-1/+6
| | | | | | | | | | | | | We add relocations for table numbers on each place where we reify a table number (call_indirect, table.get, table.set...), but only if reference types are enabled. Also, fix symbol table generation with unnamed definitions, to allow for relocating references to anonymous functions or tables. As tests, add variants of the relocations and symbol-tables dump tests, with and without all features enabled. Enabling reference types causes relocs to be emitted. We also add --details to the relocations dump tests, so that we can see the target symbols for the relocations.
* Disallow "64-bit" flag if memory64 is disabled (#1547)Paweł Bylica2020-09-181-0/+2
| | | | Fixes regressions in binary reader introduced by the implementation of the memory64 extension: https://github.com/WebAssembly/wabt/pull/1500.
* Disallow non-zero memidx when bulk memory disabled (#1546)Paweł Bylica2020-09-171-0/+2
| | | | If bulk memory extension is disabled, do not allow memory index in the data segment other than zero.
* add missing case for R_WASM_GLOBAL_INDEX_I32 relocation (#1541)Dominic Chen2020-09-101-0/+1
|