summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Refactor type and function parsing (#2143)Heejin Ahn2019-05-24135-1660/+1740
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - Refactored & fixed typeuse parsing rules so now the rules more closely follow the spec. There have been multiple parsing rules that were different in subtle ways, which are supposed to be the same according to the spec. - Duplicate types, i.e., types with the same signature, in the type section are allowed as long as they don't have the same given name. If a name is given, we use it; if type name is not given, we generate one in the form of `$FUNCSIG$` + signature string. If the same generated name already exists in the type section, we append `_` at the end. This causes most of the changes in the autogenerated type names in test outputs. - A typeuse has to be in the order of (type) -> (param) -> (result), if more than one of them exist. In case of function definitions, (local) has to be after all of these. Fixed some test cases that violate this rule. - When only (param)/(result) are given, its type will be the type with the smallest existing type index whose parameter and result are the same. If there's no such type, a new type will be created and inserted. - Added a test case `duplicate_types.wast` to test type namings for duplicate types. - Refactored `parseFunction` function. - Add more overrides to helper functions: `getSig` and `ensureFunctionType`.
* Add `getGlobal` to binaryen.js (#2142)Heejin Ahn2019-05-246-2/+20
| | | | | We have `getFunction`, but not `getGlobal` because its name clashed with APIs for the deprecated instruction `get_global`. Now we have reflected instruction renaming in code, we can add it for consistency.
* Show line/col for parsing exceptions in gen-s-parser (#2138)Heejin Ahn2019-05-243-2/+20
|
* Inlining: exposed inlining thresholds as command-line parameters. (#2125)Wouter van Oortmerssen2019-05-233-23/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Inlining: exposed inlining thresholds as command-line parameters. This will allow easier experimentation with optimal settings. Also tweaked the default logic slightly to always inline single caller functions up to a certain size. The command-line arguments were tested to have the desired effect for example by the Makefile change in this commit: https://github.com/aardappel/lobster/commit/39ae393e27ff363ab095bbb26c90d6fe17570104 which in turn relies on: https://github.com/emscripten-core/emscripten/pull/8635 * Grouped inlining options & reverted defaults. Now uses same defaults for inlining as before for the sake of not having to redo a lot of tests. Added FIXME to indicate that the current inlining logic needs fixing. * Fixed default values now pulled from code. * clang-format
* Factor out elementStartsWith (NFC) (#2137)Heejin Ahn2019-05-233-32/+38
| | | | | Checking if a first string matches a certain string within a list element appears many times within the parser, so extracted it as a helper function.
* Disable clang static analyzer in clang-tidy (#2136)Heejin Ahn2019-05-231-1/+1
| | | | | | | | | | | | | clang-tidy by default enables two groups of checks: clang-diagnostic-* and clang-analyzer-*. Between the two, clang-analyzer is a static analyzer, but it seems to often produces false warnings. For example, when you write `object->someFunction()`, if it is not sure if object is not a NULL, i.e., if there's no assert(object) before, it produces a warning. This is sometimes annoying and inserting `assert` everywhere does not seem to be very appealing. I also noticed LLVM and V8 also disabled this analyzer. `-*` disables all checks. Then I re-enabled clang-diagnostic and readability-braces-around-statements.
* Add BinaryenModuleWriteSExpr to write a module to a string in s-expr format ↵Siddharth2019-05-214-0/+84
| | | | | (#2106) Fixes #2103.
* Don't use colons in filenames (#2134)Derek Schuff2019-05-214-4/+4
| | | Windows filenames can't contain colons. Use @ instead for passing arguments to passes.
* Reflect instruction renaming in code (#2128)Heejin Ahn2019-05-21181-1532/+1531
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* Remove old import/export parsing routines (NFC) (#2127)Heejin Ahn2019-05-211-26/+1
| | | These formats don't seem to be used now.
* Refactor type/signature/local parsing methods (NFC) (#2129)Heejin Ahn2019-05-212-89/+111
| | | | | - Created `parseParamOrLocals`, `parseNamedParamOrLocals`, `parseResult`, and `parseTypeRef` and make other methods use them - Deleted some unnecessary member variables
* Fix AvoidReinterprets on reinterpreted loads of fewer than the full size (#2123)Alon Zakai2019-05-173-3/+42
| | | | | | * fix * fix style
* Fix a vacuum bug with loads changing the type (#2124)Alon Zakai2019-05-173-1/+137
| | | This happened on wasm2js, where implicit traps are off by default, and this bug is specific to that (less-tested) mode.
* Remove llvm_autogenerated tests (#2120)Heejin Ahn2019-05-1754-12036/+0
| | | After s2wasm was removed, these tests don't seem to be used anymore.
* Fix misc. things for globals (#2119)Heejin Ahn2019-05-172-3/+2
|
* rename some C++ locals to camelCase for consistency (#2122)Alon Zakai2019-05-171-15/+15
|
* fix a dae fuzz bug (#2121)Alon Zakai2019-05-173-0/+105
|
* Fix an infinite loop in avoid-reinterprets in unreachable code with loops of ↵Alon Zakai2019-05-175-0/+104
| | | | | gets (#2118) In unreachable code, a get may have a single set that assigns to it, and that set may be assigned to by that very get.
* Features C/JS API (#2049)Thomas Lively2019-05-1711-3/+152
| | | | | Add feature handling to the C/JS APIs. No features are enabled by default, so all used features will have to be explicitly enabled in order for modules to validate.
* Allow color API to enable and disable colors (#2111)Siddharth2019-05-1715-15/+43
| | | | | | This is useful for front-ends which wish to selectively enable or disable coloring. Also expose these APIs from the C API.
* Add a fuzzer option to not emit code with OOB loads/indirect calls (#2113)Alon Zakai2019-05-173-4/+29
| | | | | This is useful for wasm2js, as we don't emit traps for OOB loads etc. like wasm (like we don't trap on bad float-to-int, as it's too hard in JS, and it's undefined behavior in C anyhow). It may also help general fuzzing, as those traps may make other interesting patterns less likely. Also add more wasm2js support in the fuzzer, which includes using this no-OOB option.
* Add globals to metrics (#2110)Heejin Ahn2019-05-167-2/+18
|
* Fix cmake install of binaryen.js (#2115)Sam Clegg2019-05-161-1/+1
| | | Oversight from #2105
* First stage of cleeanup in source tree pollution (#2105)Sam Clegg2019-05-167-56/+33
| | | | | | | | | | | Update build-js.sh to output to `out` directory. This is district from the `bin` directory which is used by the cmake build and may or may not live in the source tree. The `out` directory currently always lives in the source tree. As a followup change I hope to additionally move all test outout into this tree. See #2104
* wasm2js: more coercion optimization (#2109)Alon Zakai2019-05-155-19/+209
|
* wasm2js: remove unnecessary labels (#2108)Alon Zakai2019-05-156-15/+43
|
* wasm2js: optimize away unneeded load coercions (#2107)Alon Zakai2019-05-1597-20/+287
|
* wasm2js: Emit table in a way that is friendly to emscripten minification (#2102)Alon Zakai2019-05-133-4/+13
| | | Set it to a local in the asmFunc scope, so that minifiers can easily see it's a simple local value (instead of using it as an upvar from the parameters higher up, which was how the emscripten glue was emitting it).
* wasm2js: precompute bitwise operations (#2101)Alon Zakai2019-05-1316-183/+213
| | | This happens on e.g. an i32 load of a constant offset, then we have constant >> 2.
* Add missing methods for globals to binaryen.js (#2099)Heejin Ahn2019-05-1311-19/+151
| | | | | - Print `globals` array in the tracing mode like other arrays (`functions`, `exports`, `imports`, ...) - Add accessor functions for globals
* Delete WasmBinaryBuilder::mappedGlobals (NFC) (#2098)Heejin Ahn2019-05-122-37/+18
| | | | | | 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.
* Generate `dynCall` function for all signature used by `invoke` functions. ↵Sam Clegg2019-05-103-29/+46
| | | | | | | | | (#2095) Previously we were only creating `dynCall` functions for signatures that we have statically in the table. However for dynamic linking we may need to invoke functions that we don't have table entries for (e.g. table entries from a different module).
* Look through fallthrough values in precompute-propagate (#2093)Alon Zakai2019-05-1014-358/+107
| | | This helps quite a lot on wasm2js.
* wasm2js: avoid reinterprets (#2094)Alon Zakai2019-05-1021-326/+689
| | | | | In JS a reinterpret is especially expensive, as we implement it as a write to a temp buffer and a read using another view. This finds places where we load a value from memory, then reinterpret it later - in that case, we can load it using another view, at the cost of another load and another local. This is helpful on things like Box2D, where there are many reinterprets due to the main 2D vector class being an union over two floats/ints, and LLVM likes to do a single i64 load of them.
* Emit process ID in the filenames of byn* tempfiles (#1916)Alon Zakai2019-05-101-1/+10
| | | Helps to avoid trampling each other when binaryen is called multiple times from emcc, for example.
* Add except_ref type (#2081)Heejin Ahn2019-05-0733-9/+157
| | | | This adds except_ref type, which is a part of the exception handling proposal.
* wasm2js: optimize booleans (#2090)Alon Zakai2019-05-074-26/+78
|
* Make sexp instruction parser pass clang-tidy (#2088)Heejin Ahn2019-05-062-396/+396
| | | | | | Our current clang-tidy setting requires {} after ifs. Unlike clang-format, I couldn't find any directives or options that allow us to exclude the generated inc file from clang-tidy. Anyway adding a pair of braces is all it takes to make it pass.
* Fix formatting of some comments (NFC) (#2091)Heejin Ahn2019-05-062-5/+6
| | | A few things that were missing in #2048.
* Update readme with some wasm2js docs and other stuff (#2086)Alon Zakai2019-05-061-42/+58
|
* wasm2js: 'handle' saturating float to int conversions - we don't handle any ↵Alon Zakai2019-05-061-5/+12
| | | | of them precisely anyhow (#2087)
* Don't show stderr output of clang-tidy in Travis CI (#2089)Heejin Ahn2019-05-061-1/+1
| | | | | When we run clang-tidy for the second time to show the error, don't show stderr output because they are not very helpful and all error messages are printed in stdout.
* Add exception handling feature (#2083)Heejin Ahn2019-05-035-2/+19
| | | This only adds the feature and its flag and not the instructions yet.
* wasm2js: optimize loads (#2085)Alon Zakai2019-05-0396-127/+55
| | | | When loading a boolean, prefer the signed heap (which is more commonly used, and may be faster). We never use HEAPU32 (HEAP32 is always enough), just remove it.
* wasm2js: avoid some slow operations when not optimizing (#2082)Alon Zakai2019-05-0320-3751/+4087
| | | Without this PR, wasm2js0.test_printf in emscripten took an extremely long time to compile.
* wasm2js: don't emit obviously unnecessary parens (#2080)Alon Zakai2019-05-0250-8700/+5594
| | | A minifier would probably remove them later anyhow, but they make reading the code annoying and hard.
* wasm2js: ignore implicit traps (#2079)Alon Zakai2019-05-029-60/+41
| | | | | We don't actually try to emit traps for loads, stores, invalid float to ints, etc., so when optimizing we may as well do so under the assumption those traps do not exist. This lets us emit nice code for a select whose operands are loads, for example - otherwise, the values seem to have side effects.
* Optimize mutable globals (#2066)Alon Zakai2019-05-0221-69/+296
| | | | | | | If a global is marked mutable but not assigned to, make it immutable. If an immutable global is a copy of another, use the original, so we can remove the duplicates. Fixes #2011
* Add a pass to lower unaligned loads and stores (#2078)Alon Zakai2019-05-0211-148/+936
| | | | | This replaces the wasm2js code that lowered them to pessimistic (1-byte aligned) loads and stores. The new pass will do the optimal thing, keeping 2-byte alignment where possible. This is also nicer as a standalone pass, which has the simple property that after it runs all loads and stores are aligned, instead of some code scattered inside wasm2js.
* Reenable clang-tidy Travis CI hook (#2077)Heejin Ahn2019-05-011-1/+1
| | | Reenable the clang-tidy hook temporarily disabled by #2075.