summaryrefslogtreecommitdiff
path: root/src/binary-reader.cc
Commit message (Collapse)AuthorAgeFilesLines
...
* [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
|
* Implement simd bitmask instructions (#1530)Ben Smith2020-08-311-0/+3
|
* Fix integer overflow in objdump name tracking (#1524)Sam Clegg2020-08-191-4/+6
| | | | Fixes: #1520
* Added initial "memory64" proposal support (#1500)Wouter van Oortmerssen2020-08-071-22/+76
|
* Reformat code in binary-reader.cc (#1506)Paweł Bylica2020-07-311-5/+3
|
* Detect malformed memory/table limits flag (#1505)Paweł Bylica2020-07-311-6/+12
| | | | | | | | | | | | | | * Read memory/table limits flags as uint8_t In the wasm spec the limits flag is a single byte, not a LEB128 encoded value. * Detect malformed memory/table limits flag * Disallow shared memory when threads are disabled This adds additional check to disallow "is_shared" (0x2) flag for memory limits when threads extensions is not enabled. Previously this flag was unconditionally accepted.
* Fix reading of section code (#1501)Paweł Bylica2020-07-311-2/+2
| | | | The section code is just a single byte, not a LEB128-encoded value. With this fix the section code is now read correctly with ReadU8().
* Detect malformed import kind in binary reader (#1504)Paweł Bylica2020-07-301-0/+4
|
* Remove ref.is_null type parameter (#1474)Ben Smith2020-07-151-6/+3
| | | | | | | | | See https://github.com/WebAssembly/reference-types/issues/99. This change also updates the testsuite, so the spec tests pass too. In addition, the behavior of `br_table` is no longer different from MVP, and has a text to confirm this. That is now fixed in `type-checker.cc` too.
* Check for malformed alignment (#1454)Ben Smith2020-06-091-10/+22
| | | Fixes issue #1453.
* [wasm2wat] Write select type immediate (#1451)Ben Smith2020-05-291-1/+1
| | | | | | | | | | | | | | | The main fix is in `wat-writer.cc`, where the type immediate was never being printed. But I've also included a change to how `select` type immediates are represented in wabt. Previously, a bare `select` instruction would be stored with the type `Type::Any`. This is not a real wasm type, and is primarily used for type validation. The spec instead considers this form of `select` to have an empty type immediate, which is closer to the `Type::Void` type. This commit now uses `Type::Void` (or an empty `TypeVector`) to represent the bare `select` instruction. Fixes #1444.
* Reference types changes to remove subtyping (#1407)Ben Smith2020-05-281-20/+32
| | | | | | | | Main changes: * Rename `anyref` -> `externref` * Remove `nullref` * Rename `hostref` -> `externref` * `ref.null` and `ref.is_null` now have "ref kind" parameter * Add ref kind keywords: `func`, `extern`, `exn`
* Prevent large allocation in br_table instruction (#1415)Ben Smith2020-05-111-1/+1
| | | | | | | | | The binary reader tries to allocate a vector for all of the branch targets, but wasn't checking whether the length was excessively long. There's already a function to do this: `ReadCount`, which errors out if the count is longer than the section (this assumes each element requires at least one byte). Fixes issue #1386.
* Add support for atomic.fence from the threads proposal (#1231)Andy Wingo2020-04-201-0/+10
| | | | | See https://github.com/WebAssembly/threads/pull/141 for the binary encoding. This patch does add a field to AtomicFenceExpr for the consistency model, though without a type for the time being.
* Add exnref value type to parser (#1389)Ben Smith2020-04-141-2/+1
| | | | | | | | | | | | The exnref type was already supported in the type checker, and other parts of the code, but there was no way to name the type in the text format. This PR also fixes makes binary-reader.cc check for just the exceptions_enabled flag to enable exnref. The exception-handling proposal depends on the reference types proposal, but that is now handled at a higher level, in the `UpdateDependencies` function. Fixes issue #1388.
* Update testsuite (#1381)Ben Smith2020-03-271-0/+3
| | | | * Add i{8x16,16x8,32x4}.abs instructions * Implement IntAbs in interp-math.h
* Parse ArrayTypes (#1364)Ben Smith2020-03-231-12/+28
| | | | | | | | | | The following formats are supported: * (type (array i32)) * (type (array (field i32))) * (type (array (field (mut i32)))) This PR adds support for reading/writing binary and text, but no interpreter support yet.
* Parse struct fields (#1355)Ben Smith2020-03-161-3/+23
| | | | | | | | | | | This allows the following field formats: * `(struct (field $name i32))` * `(struct (field $name (mut i32)))` * `(struct (field i32))` * `(struct (field (mut i32)))` * `(struct (mut i32))` * `(struct i32)`
* Remove validation from the BinaryReader (#1354)Ben Smith2020-03-111-136/+36
| | | | | | | Validation should only happen in ValidateModule, BinaryReader should only check whether the binary is malformed. This change also fixes a few places in BinaryReaderIR where an index is assumed to be valid.
* Initial pass parsing/reading struct (#1352)Ben Smith2020-03-091-33/+49
| | | | | | | | | | | | | | | | | | This parses just the format `(struct)` as a new type. I added a test for this using `wat2wasm`, but that requires a rudimentary binary format. The test runner automatically attempts to rountrip all wat2wasm tests, so this required implementing the wat writing and binary reading too. Here's a summary of the changes: * binary-reader:h: Rename `BinaryReader::OnType` callbacks to `OnFuncType` * binary-reader.h: Add `BinaryReader::OnStructType` * binary-reader.cc: Use a switch after reading the type form to determine whether we're reading a function or struct. * tokens.def: Add new `TokenType::Struct` * lexer-keywords.txt: Add new `struct` keyword * type.h: Add `Type::Struct` type form * wast-parser.cc: Parse `(struct)` in text format * wat-writer.cc: Write Func or Struct type forms
* Convert Type from an enum into a class (#1350)Ben Smith2020-02-281-6/+6
| | | | | | | | | | | | | | | | | This is similar to the way Opcode is structured, which allows us to hang member functions off of the enumeration. The primary motivator for this change is the GC proposal (and the function-references proposal) where a Type can be parameterized: (type $T (struct ...)) (func (local (ref $T) ... ) In this case the type is ref, with a parameter of the type index. Making Type a class will make it easier to store this additional information.
* Update testsuite (w/ reference-types changes) (#1351)Ben Smith2020-02-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new table-sub test, checks whether the subtyping is handled properly w/ table.init and table.copy instructions. The BeginElemSegment callback can't pass the element type anymore, since it's not known yet. The callback also can't be deferred, since the BeginElemSegmentInitExpr callback has to happen after the BeginElemSegment callback, but the reference type is not always known until after the initializer expression is read. To work around this, I added a new OnElemSegmentElemType callback. Other element segment changes: * The element type must be tracked in the SharedValidator * A subtle fix: when writing out the segment flags, we need to take into account whether the element type of the segment is not funcref, even if there are no element expressions. In that case, we have to use flag bit 0x4 (SegUseElemExprs). In addition, the TableCopy and TableInit instructions weren't handling table indexes fully. * TableCopy variables are read in the parser (both optional) * TableCopy names are now resolved + applied * TableCopy indexes are now validated * TableInit table variables are read in the parser; this is subtle, since the text format has order $table $segment, but the $table is optional.
* Fix memory/table check to include imported+defined (#1336)Ben Smith2020-02-191-4/+18
|
* Update testsuite (#1327)Sam Clegg2020-02-051-2/+0
| | | | | The main change here is the addition of declared elem sections.