summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix event section order (#2202)Heejin Ahn2019-07-021-1/+1
| | | | | | The event section should be between the global section and the export section, if present. Here tests are missing, but we don't have a very good way of testing validity of binary anyway. We are planning to add d8 tests in a separate PR.
* Make feature section errors into warnings (#2175)Alon Zakai2019-06-181-14/+18
| | | | Otherwise there is no way to view a wasm object file in binaryen.
* Use BinaryIndexes instead of copies in BinaryWriter (NFC) (#2161)Heejin Ahn2019-06-041-20/+10
|
* Add event section (#2151)Heejin Ahn2019-05-311-0/+95
| | | | | | | | | | | | | | | | | | This adds support for the event and the event section, as specified in https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model. Wasm events are features that suspend the current execution and transfer the control flow to a corresponding handler. Currently the only supported event kind is exceptions. For events, this includes support for - Binary file reading/writing - Wast file reading/writing - Binaryen.js API - Fuzzer - Validation - Metadce - Passes: metrics, minify-imports-and-exports, remove-unused-module-elements
* Reflect instruction renaming in code (#2128)Heejin Ahn2019-05-211-33/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Reflected new renamed instruction names in code and tests: - `get_local` -> `local.get` - `set_local` -> `local.set` - `tee_local` -> `local.tee` - `get_global` -> `global.get` - `set_global` -> `global.set` - `current_memory` -> `memory.size` - `grow_memory` -> `memory.grow` - Removed APIs related to old instruction names in Binaryen.js and added APIs with new names if they are missing. - Renamed `typedef SortedVector LocalSet` to `SetsOfLocals` to prevent name clashes. - Resolved several TODO renaming items in wasm-binary.h: - `TableSwitch` -> `BrTable` - `I32ConvertI64` -> `I32WrapI64` - `I64STruncI32` -> `I64SExtendI32` - `I64UTruncI32` -> `I64UExtendI32` - `F32ConvertF64` -> `F32DemoteI64` - `F64ConvertF32` -> `F64PromoteF32` - Renamed `BinaryenGetFeatures` and `BinaryenSetFeatures` to `BinaryenModuleGetFeatures` and `BinaryenModuleSetFeatures` for consistency.
* Fix misc. things for globals (#2119)Heejin Ahn2019-05-171-2/+1
|
* Delete WasmBinaryBuilder::mappedGlobals (NFC) (#2098)Heejin Ahn2019-05-121-31/+14
| | | | | | It doesn't seem to be used anywhere and I don't know why the implementation for `WasmBinaryBuilder::getGlobalName` and `WasmBinaryBuilder::getFunctionIndexName` are different. Renamed `getFunctionIndexName` to `getFunctionName` for consistency.
* Add except_ref type (#2081)Heejin Ahn2019-05-071-0/+2
| | | | This adds except_ref type, which is a part of the exception handling proposal.
* Add exception handling feature (#2083)Heejin Ahn2019-05-031-1/+3
| | | This only adds the feature and its flag and not the instructions yet.
* clang-tidy braces changes (#2075)Alon Zakai2019-05-011-217/+434
| | | Applies the changes in #2065, and temprarily disables the hook since it's too slow to run on a change this large. We should re-enable it in a later commit.
* Apply format changes from #2048 (#2059)Alon Zakai2019-04-261-694/+1905
| | | Mass change to apply clang-format to everything. We are applying this in a PR by me so the (git) blame is all mine ;) but @aheejin did all the work to get clang-format set up and all the manual work to tidy up some things to make the output nicer in #2048
* Finish bulk memory support (#2030)Thomas Lively2019-04-221-1/+4
| | | | | | | Implement interpretation of remaining bulk memory ops, add bulk memory spec tests with light modifications, fix bugs preventing the fuzzer from running correctly with bulk memory, and fix bugs found by the fuzzer.
* Reland emitting of DataCount section (#2027)Thomas Lively2019-04-181-8/+3
| | | | | | This reverts commit cb2d63586c08a3dd194d2b733ceb3f5051c081f8. The issues with feature validation were mostly resolved in #1993, and this PR finishes the job by adding feature flags to wasm-as to avoid emitting the DataCount section when bulk-memory is not enabled.
* Do not emit the DataCount section (#2010)Thomas Lively2019-04-151-3/+8
| | | | | Its presence was causing validation errors in the Emscripten test suite. This should be reverted once the default feature set is no longer All.
* DataCount section (#2006)Thomas Lively2019-04-151-0/+24
| | | | | | | | * DataCount section Read the DataCount section and verify that it agrees with the data section. Also emit the DataCount section when bulk-memory is enabled and there are a nonzero number of segments. Factor out some shared unit test code.
* Move features from passOptions to Module (#2001)Thomas Lively2019-04-121-2/+84
| | | | | This allows us to emit a (potentially modified) target features section and conditionally emit other sections such as the DataCount section based on the presence of features.
* Better memory fuzzing (#1987)Alon Zakai2019-04-081-1/+1
| | | | | | | | Hash the contents of all of memory and log that out in random places in the fuzzer, so we are more sensitive there and can catch memory bugs. Fix UB that was uncovered by this in the binary writing code - if a segment is empty, we should not look at &vector[0], and instead use vector.data(). Add Builder::addExport convenience method.
* Move segment merging to fit web limits into its own pass (#1980)Thomas Lively2019-04-081-100/+8
| | | | | | It was previously part of writing a binary, but changing the number of segments at such a late stage would not work in the presence of bulk memory's datacount section. Also updates the memory packing pass to respect the web's limits on the number of data segments.
* Passive segments (#1976)Thomas Lively2019-04-051-19/+48
| | | | | Adds support for the bulk memory proposal's passive segments. Uses a new (data passive ...) s-expression syntax to mark sections as passive.
* Use target features section in wasm-opt (#1967)Thomas Lively2019-04-031-1/+1
| | | | | | | If the user does not supply features explicitly on the command line, read and use the features in the target features section for validation and passes. If the user does supply features explicitly, error if they are not a superset of the features marked as used in the target features section and the user does not explicitly handle this.
* Rename atomic wait/notify instructions (#1972)Heejin Ahn2019-03-301-7/+7
| | | | | | | | This renames the following: - `i32.wait` -> `i32.atomic.wait` - `i64.wait` -> `i64.atomic.wait` - `wake` -> `atomic.notify` to match the spec.
* avoid risky iterator addition (#1970)Alon Zakai2019-03-291-1/+1
| | | Not an actual problem, but hits an assertion in D_GLIBCXX_DEBUG, and is likely UB.
* remove getString, which is not used, and was insecure to boot (#1966)Alon Zakai2019-03-261-8/+0
|
* Fix a fuzz bug with peeking forward in binary reading. (#1902)Alon Zakai2019-02-071-2/+1
| | | Fixes #1900
* Bulk memory operations (#1892)Thomas Lively2019-02-051-2/+66
| | | | | | Bulk memory operations The only parts missing are the interpreter implementation and spec tests.
* Strip the producers section in --strip-producers (#1875)Alon Zakai2019-01-311-1/+1
| | | | | | | | WebAssembly/tool-conventions#93 has a summary of emscripten's current thinking on this. For Binaryen, we don't want to do anything to the producers section by default, but do want it to be possible to optionally remove it. To achieve that, this PR * creates a --strip-producers pass that removes that section. * creates a --strip-debug pass that removes debug info, same as the old --strip, which is still around but deprecated. A followup in emscripten will use this pass by default.
* validate all function indexes in binary reading (#1887)Alon Zakai2019-01-241-3/+3
| | | fixes bug reported in comment on e63c4a7 , #1885 (comment) , #1879 (comment)
* More misc ASAN fixes (#1882)Alon Zakai2019-01-221-0/+3
| | | | | | | | | | * fix buffer overflow in simple_ast.h printing. * check wasm binary format reading of function export indexes for errors. * check if s-expr format imports have a non-empty module and base. Fixes #1876 Fixes #1877 Fixes #1879
* Show a proper error on an invalid type in binary reading ; fixes #1872 (#1874)Alon Zakai2019-01-191-2/+2
|
* Misc minor ASAN fixes (#1869)Alon Zakai2019-01-161-3/+11
| | | | | | | | | | * handle end of input in skipWhitespace in s-parser. fixes #1863 * ignore debug locations when not in a function ; fixes #1867 * error properly on invalid user section sizes ; fixes #1866 * throw a proper error on invalid call offsets in binary reading ; fixes #1865
* Require unique_ptr to Module::addFunctionType() (#1672)Paweł Bylica2019-01-101-2/+2
| | | | | This fixes the memory leak in WasmBinaryBuilder::readSignatures() caused probably the exception thrown there before the FunctionType object is safe. This also makes it clear that the Module becomes the owner of the FunctionType objects.
* Massive renaming (#1855)Thomas Lively2019-01-071-4/+4
| | | | | | Automated renaming according to https://github.com/WebAssembly/spec/issues/884#issuecomment-426433329.
* Rename `idx` to `index` in SIMD code for consistency (#1836)Thomas Lively2018-12-181-17/+17
|
* Fuzzing v128 and associated bug fixes (#1827)Thomas Lively2018-12-141-0/+2
| | | | * Fuzzing v128 and associated bug fixes
* SIMD (#1820)Thomas Lively2018-12-131-4/+299
| | | | | | | | | Implement and test the following functionality for SIMD. - Parsing and printing - Assembling and disassembling - Interpretation - C API - JS API
* Don't error on too many locals - just oom (#1822)Alon Zakai2018-12-131-8/+0
| | | I think I added this error for fuzzing, but it is harmful as it prevents a module with too many locals from being loaded - if we could load it, we might be able to optimize it to have fewer locals...
* Warn if linking section is present, as we cannot handle it yet (#1798)Alon Zakai2018-12-041-0/+3
|
* Implement nontrapping float-to-int instructions (#1780)Thomas Lively2018-12-041-0/+26
|
* Add support for a mutable globals as a Feature (#1785)Sam Clegg2018-11-301-2/+1
| | | | | This picks up from #1644 and indeed borrows the test case from there.
* Remove default cases (#1757)Thomas Lively2018-11-271-1/+3
| | | | | | Where reasonable from a readability perspective, remove default cases in switches over types and instructions. This makes future feature additions easier by making the compiler complain about each location where new types and instructions are not yet handled.
* initialize binary writer debug info even without a source map, as debug info ↵Alon Zakai2018-11-261-1/+5
| | | | may exist without a source map (#1733)
* clean up unnecessary type setting in binary format loading - finalize() will ↵Alon Zakai2018-11-141-62/+61
| | | | do it properly later (#1744)
* Support 4GB Memories (#1702)Alon Zakai2018-10-151-8/+8
| | | This fixes asm2wasm parsing of the max to allow 4GB, and also changes the internal Memory::kMaxValue values to reflect that. We used to use kMaxValue to also represent "no limit", so I split that out into kUnlimitedValue.
* Unify imported and non-imported things (#1678)Alon Zakai2018-09-191-159/+113
| | | | | | | | | | | | | | Fixes #1649 This moves us to a single object for functions, which can be imported or nor, and likewise for globals (as a result, GetGlobals do not need to check if the global is imported or not, etc.). All imported things now inherit from Importable, which has the module and base of the import, and if they are set then it is an import. For convenient iteration, there are a few helpers like ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) { .. use global .. }); as often iteration only cares about imported or defined (non-imported) things.
* Add debug information locations to the function prolog/epilog (#1674)Yury Delendik2018-09-171-49/+70
| | | | | | | The current patch: * Preserves the debug locations from function prolog and epilog * Preserves the debug locations of the nested blocks
* Misc tiny fuzz fixes (#1668)Alon Zakai2018-09-121-0/+1
| | | | | | | | | | | | * show a proper error for an empty asm2wasm input * handle end of input in processExpressions in binary reading * memory segment sizes should be unsigned * validate input in wasm-ctor-eval * update tests
* Binary format local parsing fixes (#1664)Alon Zakai2018-09-111-8/+11
| | | | | | * Error if there are more locals than browsers allow (50,000). We usually just warn about stuff like this, but we do need some limit (or else we hang or OOM), and if so, why not use the agreed-upon Web limit. * Do not generate nice string names for locals in binary parsing - the name is just $var$x instead of $x, so not much benefit, and worse as our names are interned this is actually slow (which is why the fuzz testcase here hangs instead of OOMing). Testcases and bugreport in #1663.
* Fix findField (#1660)Yury Delendik2018-08-311-0/+2
|
* Fix read-write of dylink section (#1648)Alon Zakai2018-08-311-7/+26
| | | | | | The 'dylink' user section must be emitted before all other sections, per the spec (to allow simple parsing by loaders) This PR makes reading and writing of a dynamic library remain a valid dynamic library.
* Escape name section ids in binary format reading/writing to be WebAssembly ↵Yury Delendik2018-08-311-2/+68
| | | | spec compatible. (#1646)