summaryrefslogtreecommitdiff
path: root/src/binaryen-c.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Features C/JS API (#2049)Thomas Lively2019-05-171-2/+42
| | | | | 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-171-0/+5
| | | | | | This is useful for front-ends which wish to selectively enable or disable coloring. Also expose these APIs from the C API.
* Add missing methods for globals to binaryen.js (#2099)Heejin Ahn2019-05-131-5/+47
| | | | | - Print `globals` array in the tracing mode like other arrays (`functions`, `exports`, `imports`, ...) - Add accessor functions for globals
* Add except_ref type (#2081)Heejin Ahn2019-05-071-0/+5
| | | | This adds except_ref type, which is a part of the exception handling proposal.
* clang-tidy braces changes (#2075)Alon Zakai2019-05-011-39/+73
| | | 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-411/+1079
| | | 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
* wasm2js: more js optimization (#2050)Alon Zakai2019-04-241-1/+1
| | | | | | * Emit ints as signed, so -1 isn't a big unsigned number. * x - -c (where c is a constant) is larger than x + c in js (but not wasm) * +(+x) => +x * Avoid unnecessary coercions on calls, return, load, etc. - we just need coercions when entering or exiting "wasm" (not internally), and on actual operations that need them.
* Move features from passOptions to Module (#2001)Thomas Lively2019-04-121-3/+3
| | | | | 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.
* Wasm2js refactoring (#1997)Alon Zakai2019-04-111-4/+7
| | | | | | | | | | | | | Early work for #1929 * Leave core wasm module - the "asm.js function" - to Wasm2JSBuilder, and add Wasm2JSGlue which emits the code before and after that. Currently that's some ES6 code, but we may want to change that later. * Add add AssertionEmitter class for the sole purpose of emitting modules + assertions for testing. This avoids some hacks from before like starting from index 1 (assuming the module at first position was already parsed and printed) and printing of the f32Equal etc. functions not at the very top (which was due to technical limitations before). Logic-wise, there should be no visible change, except some whitespace and reodering, and that I made the exceptions print out the source of the assertion that failed from the wast: -if (!check2()) fail2(); +if (!check2()) throw 'assertion failed: ( assert_return ( call add ( i32.const 1 ) ( i32.const 1 ) ) ( i32.const 2 ) )'; (fail2 etc. did not exist, and seems to just have given a unique number for each assertion?)
* Passive segments (#1976)Thomas Lively2019-04-051-3/+10
| | | | | Adds support for the bulk memory proposal's passive segments. Uses a new (data passive ...) s-expression syntax to mark sections as passive.
* Rename atomic wait/notify instructions (#1972)Heejin Ahn2019-03-301-13/+13
| | | | | | | | This renames the following: - `i32.wait` -> `i32.atomic.wait` - `i64.wait` -> `i64.atomic.wait` - `wake` -> `atomic.notify` to match the spec.
* Add BinaryenConstGetValueV128 to C/JS-API (#1931)Daniel Wirtz2019-03-131-1/+16
| | | | | | | This PR adds void BinaryenConstGetValueV128(BinaryenExpressionRef expr, uint8_t* out); to the C-API and uses it in Binaryen.getExpressionInfo in the JS-API.
* fix binaryen.js bindings handling of literals (#1896)Alon Zakai2019-02-061-0/+13
| | | The hardcoded 16 size was no longer valid. This was broken for a while, but happened to not overwrite important memory. Testing with the wasm backend did hit breakage.
* Bulk memory operations (#1892)Thomas Lively2019-02-051-0/+138
| | | | | | Bulk memory operations The only parts missing are the interpreter implementation and spec tests.
* Require unique_ptr to Module::addFunctionType() (#1672)Paweł Bylica2019-01-101-10/+6
| | | | | 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.
* Rename `idx` to `index` in SIMD code for consistency (#1836)Thomas Lively2018-12-181-12/+12
|
* SIMD (#1820)Thomas Lively2018-12-131-30/+399
| | | | | | | | | Implement and test the following functionality for SIMD. - Parsing and printing - Assembling and disassembling - Interpretation - C API - JS API
* Use template magic for tracing expressions (#1815)Thomas Lively2018-12-101-89/+106
|
* Implement nontrapping float-to-int instructions (#1780)Thomas Lively2018-12-041-0/+8
|
* Feature options (#1797)Thomas Lively2018-12-031-1/+1
| | | | Add feature flags and struct interface. Default feature set has all feature enabled.
* Add v128 type (#1777)Thomas Lively2018-11-291-0/+2
|
* Remove default cases (#1757)Thomas Lively2018-11-271-3/+7
| | | | | | 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.
* fix some () vs (void) C warnings in the C API (#1768)Alon Zakai2018-11-261-3/+3
| | | Fixes #1766
* Relooper CFG optimizations (#1759)Alon Zakai2018-11-211-6/+7
| | | | | | | | | | | | | | | | Previously the relooper would do some optimizations when deciding when to use an if vs a switch, how to group blocks, etc. This PR adds an additional pre-optimization phase with some basic but useful simplify-cfg style passes, * Skip empty blocks when they have just one exit. * Merge exiting branches when they are equivalent. * Canonicalize block contents to make such comparisons more useful. * Turn a trivial one-target switch into a simple branch. This can help in noticeable ways when running the rereloop pass, e.g. on LLVM wasm backend output. Also: * Binaryen C API changes to the relooper, which now gets a Module for its constructor. It needs it for the optimizations, as it may construct new nodes. * Many relooper-fuzzer improvements. * Clean up HashType usage.
* Shared memory support for add memory import and set memory functions. (#1686)Nidin Vinayakan2018-10-111-4/+6
|
* Add BinaryenRemoveGlobal / Module.removeGlobal to C/JS API (#1692)Daniel Wirtz2018-10-091-0/+8
|
* Add initial/maximum table size parameters to C/JS API (#1687)Daniel Wirtz2018-09-281-4/+5
|
* Unify imported and non-imported things (#1678)Alon Zakai2018-09-191-150/+54
| | | | | | | | | | | | | | 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.
* remove PageSize and HasFeature, which wasm removed a while back (#1667)Alon Zakai2018-09-121-2/+0
| | | From #1665 (a fuzz bug noticed they were not handled in stack.h).
* BinaryenSetFunctionTable now accepts array of func names not funcs. (#1650)Jay Phelps2018-09-011-20/+19
| | | | | This allows using imports in the table. Fixes #1645
* Rename `wasm2asm` to `wasm2js`, emit ESM by default (#1642)Alex Crichton2018-08-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | * Rename the `wasm2asm` tool to `wasm2js` This commit performs a relatively simple rename of the `wasm2asm` tool to `wasm2js`. The functionality of the tool doesn't change just yet but it's intended that we'll start generating an ES module instead of just an `asm.js` function soon. * wasm2js: Support `*.wasm` input files Previously `wasm2js` only supported `*.wast` files but to make it a bit easier to use in tooling pipelines this commit adds support for reading in a `*.wasm` file directly. Determining which parser to use depends on the input filename, where the binary parser is used with `*.wasm` files and the wast parser is used for all other files. * wasm2js: Emit ESM imports/exports by default This commit alters the default behavior of `wasm2js` to emit an ESM by default, either importing items from the environment or exporting. Items like initialization of memory are also handled here.
* Proper error handling in add* and get* methods (#1570)Alon Zakai2018-07-101-0/+8
| | | | | | | See #1479 (comment) Also a one-line readme update, remove an obsolete compiler (mir2wasm) and add a new one (asterius). Also improve warning and error reporting in binaryen.js - show a stack trace when relevant (instead of node.js process.exit), and avoid atexit warning spam in debug builds.
* Add a way to remove function types to Binaryen-C/.js (#1536)Daniel Wirtz2018-05-081-0/+17
|
* Expose sign extension ops in Binaryen-C/.js (#1534)Daniel Wirtz2018-05-071-1/+6
|
* Rename WasmType => Type (#1398)Alon Zakai2018-02-021-31/+31
| | | | * rename WasmType to Type. it's in the wasm:: namespace anyhow, and without Wasm- it fits in better alongside Index, Address, Expression, Module, etc.
* Fix hard-wired buffer limit in the JS API (#1394)Daniel Wirtz2018-02-011-1/+28
|
* Sourcemap support for Binaryen C/JS (#1392)Daniel Wirtz2018-01-291-6/+65
| | | | | | * Initial source map support for C/JS * Also test getDebugInfoFileName
* Atomic wait/wake fixes (#1383)Alon Zakai2018-01-221-2/+2
| | | | | | | | * fix wait and wake binary format support, they have alignments and offsets * don't emit unreachable parts of atomic operations, for simplicity and to avoid special handling * don't emit atomic waits by default in the fuzzer, they hang in native vm support
* Also clear imports and exports maps in BinaryenModuleDispose (#1372)Daniel Wirtz2018-01-191-0/+2
| | | | | | fixes #1369 * Update binaries and kitchen-sink test
* Refactor optimization defaults (#1366)Alon Zakai2018-01-171-24/+14
| | | | | Followup to #1357. This moves the optimization settings into pass.h, and uses it from there in the various places. This also splits up huge lines from the tracing code, which put all block children (whose number can be arbitrarily large) on one line. This seems to have caused random errors on the bots, I suspect from overflowing a buffer. Anyhow, it's much more clear to split the lines at a reasonable length.
* Add optimize, shrink level and debug info options to C/JS (#1357)Daniel Wirtz2018-01-171-0/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add optimize, shrink level and debug info options to C/JS * Add instantiate functionality for creating additional unique instances of the API * Use a workaround when running tests in node Tests misuse a module as a script by concatenating, so instead of catching this case in the library, catch it there * Update sieve test Seems optimized output changed due to running with optimize levels 2/1 now * Use the options with all pass runners * Update relooper-fuzz C-API test * Share defaults between tools and the C-API * Add a test for optimize levels * Unify node test support in check.by and auto_update_tests.py * Also add getters for optimize levels and test them * Also test debugInfo * Add debug info to C tests that used it as well * Fix missing NODEJS import in auto_update_tests * Detect node.js version (WASM support) * Update hello-world JS test (now also runs with node) * feature-test WebAssembly in node instead * Document that these options apply globally, and where * Make sure hello-world.js output doesn't differ between mozjs/node
* runFunction => runOnFunction (we run on the function, not run the function) ↵Alon Zakai2018-01-101-2/+2
| | | | (#1356)
* Add getters for various specific expression fields to C/JS (#1332)Daniel Wirtz2017-12-201-36/+944
|
* Provide AddImport/AddExport for each element in the C-API (#1292)Daniel Wirtz2017-11-221-5/+115
| | | | * Provide AddImport/AddExport for each element in the C-API
* Running passes on a single function in binaryen-c/.js (#1295)Daniel Wirtz2017-11-211-0/+60
| | | * Also other function utilities in C and JS APIs
* Add atomic load/store to binaryen-c/.js (#1298)Daniel Wirtz2017-11-201-1/+23
|
* Add const expression utilities to binaryen-c/.js (#1288)Daniel Wirtz2017-11-151-0/+54
|
* Fix yet another BinaryenAddGlobal tracing issue (#1283)Daniel Wirtz2017-11-131-1/+1
| | | Now also includes a test.
* Added expression utility functions to binaryen-c/.js (#1269)Daniel Wirtz2017-11-111-0/+47
|
* Fixed use of undefined 'types' array in BinaryenAddGlobal tracing (#1279)Daniel Wirtz2017-11-101-1/+1
| | | | | | * Fixed use of undefined 'types' array in BinaryenAddGlobal tracing * also fix use of 'expressions'