summaryrefslogtreecommitdiff
path: root/test/decompile
Commit message (Collapse)AuthorAgeFilesLines
* decompiler.cc: fix vector oob when if has empty then (#2334)Hyxogen2023-11-201-0/+5
|
* decompiler.cc: passive data segments do not have offsets (#2163)mannkdev2023-07-301-0/+9
|
* Add initial support for code metadata (#1840)Yuri Iozzelli2022-02-251-0/+17
| | | | | | | | | | | | | | | | | | | | | 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)
* Finish instruction renaming (#1792)Heejin Ahn2021-12-203-36/+36
| | | | | | | | | | | | | This finishes #985. This - replaces the old names in the tests with the new names - drops support for the deprecated names - renames test files to match new instruction names I don't think dropping support for the old names will be a problem at this point. #985 says the old names are supported for convenience but we should remove those too at some point; that "some point" may have well arrived given that three years have passed. The lists of names updated are in #933, #1564, WebAssembly/spec#720.
* wasm-decompile: Avoid trailing whitespace (#1714)relrelb2021-09-271-1/+1
| | | | | * wasm-decompile: Avoid trailing whitespace in data declarations * wasm-decompile: Avoid trailing whitespace in binary operators
* [decompiler] fixed blocks with params. (#1497)Wouter van Oortmerssen2020-07-231-2/+8
| | | | It would previously assume the blocktype is "simple" (at most a single result value), but now also supports function signatures. Also fixed it ignoring the validator result.
* Remove ref.is_null type parameter (#1474)Ben Smith2020-07-151-1/+1
| | | | | | | | | 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.
* Reference types changes to remove subtyping (#1407)Ben Smith2020-05-281-2/+2
| | | | | | | | 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`
* wasm-decompile: escape hatch for variables used outside scope. (#1322)Wouter van Oortmerssen2020-01-301-1/+21
| | | | | | | The decompiler assumes it can define a variable where it is first assigned to, which works for almost all cases, but occasionally there is a use of a variable outside of the scope where it was defined. This detects that case, and makes sure that variable is pre-declared.
* wasm-decompile: use symbols from linking section for names. (#1318)Wouter van Oortmerssen2020-01-271-0/+116
| | | | | | | | | | | | This allows wasm .o files to have more readable names, or even final linked modules if the linking information is preserved (with e.g. --emit-relocs in LLD). This is implemented as part of the WABT IR representation, so benefits wasm2wat as well. Named obtained this way are only set for functions if the function doesn't also have a name in the name section, but is preferred over the export name if there is one.
* wasm-decompile: name data sections with their content (#1309)Wouter van Oortmerssen2020-01-232-5/+9
| | | | | | This is a fun way to give somewhat meaningful names to sections containing strings. In the case of pure binary sections this likely generates random characters, but that's not any worse than the current generated names.
* wasm-decompile: absolute accesses refer to data segments (#1302)Wouter van Oortmerssen2020-01-162-1/+10
| | | | This makes them easier to look up than the large integer constants LLVM output is full of.
* wasm-decompile: wrap data declarations. (#1298)Wouter van Oortmerssen2020-01-131-0/+6
|
* wasm-decompile: support for pointers to single types. (#1296)Wouter van Oortmerssen2020-01-101-2/+2
| | | | | | | If deriving a "struct" from load/store ops fails, the next best thing is a typed pointer, if all accesses are to the same type. Also fixed some precedence related issues.
* wasm-decompile: friendlier general load/store ops. (#1284)Wouter van Oortmerssen2020-01-092-4/+47
| | | | | - Now has an index that is relative to the type. - Now detects the common case where the index is shifted to produce a new base address.
* wasm-decompile: blocks now represented as labels (#1282)Wouter van Oortmerssen2020-01-061-29/+28
| | | | | | | | | | | | | | | | | | What was before: `block L { STATS }` is now `{ STATS; label L: }` or when possible just: `STATS; label L:` The latter having no indentation at all, and thus automatically flattening all `br_table` nestings and other common patterns. It was initially attempted to create a proper switch out of `br_table`, but the typical LLVM output is so intertwined (with br/br_if jumping in and out of the br_table targets etc) that a switch could have only cleanly applied applied to a small subset of cases. The current simple label flattening works with all wasm code equally, but is a a bit more low level. Also rename `break` into `goto`, reflecting what it is really doing. Though here, `goto` only ever jumps downwards, backwards jumps to the `loop` construct are still called `continue`.
* wasm-decompile: supporting some more node types specifically. (#1279)Wouter van Oortmerssen2020-01-061-1/+67
| | | | | | | This outputs some more WABT IR node types with special purpose syntax, rather than the default catch-all of a function call. Still incomplete (especially for >MVP), more later. Reworking br_table will be a seperate PR.
* wasm-decompile: added precedence support. (#1277)Wouter van Oortmerssen2020-01-023-3/+50
| | | | | Previously it would simply bracket all binary exps. Now it has a precedence system that is in line with what people know from most programming languages.
* wasm-decompile: overhauled name filtering. (#1272)Wouter van Oortmerssen2019-12-231-4/+4
| | | | | | | The previous implementation was too simplistic, as it didn't do the renaming at the correct location (such that it can catch all occurrences), and was also very ineffective in cutting down gigantic STL signatures to something managable. This version creates more usable identifiers in almost all cases.
* wabt-decompile: cleaned up string composition. (#1265)Wouter van Oortmerssen2019-12-131-3/+3
| | | | | | | | | | | | | | | | The code had 3 ways of doing string composition: - Using + and += on string/string_view - ostringstream - wabt::Stream Of these, the first was by far the most widely used, simply because decompilation is a hierarchical process, which requires storing intermediate strings before knowing what surrounds them (thus unsuitable for streams). To make the code more uniform, everything was converted to use the first approach. To not get further performance degradations, some more efficient concatenation methods were added, that also work with wabt::string_view.
* wasm-decompile: Load/Store tracking for struct output. (#1258)Wouter van Oortmerssen2019-12-091-0/+83
| | | | | | | This tries to make code more readable by summarizing patterns of load/store ops into "struct" declarations. Initial version, can probably be improved, but has all essentials of the idea in place.
* wasm-decompile: Output of other sections + import/export. (#1233)Wouter van Oortmerssen2019-11-252-7/+41
| | | | | | | | | | | | | | * wasm-decompile: Output of other sections + import/export. This now outputs data, memories, globals, tables, and import/export of these (and functions). Changed the syntax to be more consistent and refactored how it is checked. * code-review fixes * Fixed printf format warning.
* wasm-decompile: Fixed arbitrary characters appearing in function names. (#1213)Wouter van Oortmerssen2019-11-111-0/+10
| | | | | In particular, LLD may stick entire C++ signatures in names, that WABT then uses with wasm2wat, but are not appropriate for wasm-decompile function names.
* wasm-decompile: reworked how "stacky" code gets decompiled. (#1205)Wouter van Oortmerssen2019-11-072-13/+80
| | | | | | | | | | | For example: multi-value, and void exps while there are non-void exps on the stack. It now uses temp variables instead of pseudo push/pop, as the latter weren't particularly readable and had an ordering problem that was hard to make intuitive. The new system covers all possible situations, generates as few variables as possible, has clearer comments, and tests.
* wasm-decompile: Added initial tests. (#1195)Wouter van Oortmerssen2019-10-241-0/+76
These are pretty minimal, more will be added as part of feature-PRs.