| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 in data declarations
* wasm-decompile: Avoid trailing whitespace in binary operators
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
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`
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
This makes them easier to look up than the large integer
constants LLVM output is full of.
|
| |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
- 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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`.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
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.
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
These are pretty minimal, more will be added as part of feature-PRs.
|