summaryrefslogtreecommitdiff
path: root/src/passes/LegalizeJSInterface.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [NFC] Enforce use of `Type::` on type names (#2434)Thomas Lively2020-01-071-3/+3
|
* Add support for reference types proposal (#2451)Heejin Ahn2019-12-301-2/+31
| | | | | | | | | | | | This adds support for the reference type proposal. This includes support for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`) and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and new typed `select`. This also adds subtype relationship support between reference types. This does not include table instructions yet. This also does not include wasm2js support. Fixes #2444 and fixes #2447.
* Remove FunctionType (#2510)Thomas Lively2019-12-111-65/+55
| | | | | | | | | | | | | | | | | Function signatures were previously redundantly stored on Function objects as well as on FunctionType objects. These two signature representations had to always be kept in sync, which was error-prone and needlessly complex. This PR takes advantage of the new ability of Type to represent multiple value types by consolidating function signatures as a pair of Types (params and results) stored on the Function object. Since there are no longer module-global named function types, significant changes had to be made to the printing and emitting of function types, as well as their parsing and manipulation in various passes. The C and JS APIs and their tests also had to be updated to remove named function types.
* When legalizing, optionally export the original function too with orig$X (#2427)Alon Zakai2019-11-111-1/+28
| | | | | The original is necessary if we want to pass it to wasm, where it will be called directly, without JS legalization. For example the JS dynamic loader in emscripten needs this, emscripten-core/emscripten#9562
* Simpify PassRunner.add() and automatically parallelize parallel functions ↵Alon Zakai2019-07-191-4/+1
| | | | | | | | | (#2242) Main change here is in pass.h, everything else is changes to work with the new API. The add("name") remains as before, while the weird variadic add(..) which constructed the pass now just gets a std::unique_ptr of a pass. This also makes the memory management internally fully automatic. And it makes it trivial to parallelize WalkerPass::run on parallel passes. As a benefit, this allows removing a lot of code since in many cases there is no need to create a new pass runner, and running a pass can be just a single line.
* Reflect instruction renaming in code (#2128)Heejin Ahn2019-05-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* clang-tidy braces changes (#2075)Alon Zakai2019-05-011-5/+10
| | | 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-34/+52
| | | 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
* Remove f32 legalization from LegalizeJSInterface (#2052)Sam Clegg2019-04-251-18/+2
| | | | | As well as i64 splitting this pass was also converting f32 to f64 at the wasm boundry. However it appears this is not actually useful and makes somethings (such as dynamic linking) harder.
* wasm2js2 import fixes (#2031)Alon Zakai2019-04-191-3/+2
| | | | | | * Don't assume function types exist in legalize-js-interface. * Properly handle (ignore) imports in RemoveNonJSOps - do not try to recurse into them. * Run legalize-js-interface and remove-unused-module-elements in wasm2js, the first is necessary, the last is nice to have.
* Fix memory leaks (#1925)Bohdan2019-02-281-12/+13
| | | | | | Fixes #1921 Signed-off-by: Bogdan Vaneev <warchantua@gmail.com>
* legalize invokes even when doing minimal legalization, as js needs them (#1883)Alon Zakai2019-02-081-40/+47
| | | See [emscripten-core/emscripten#7679
* Require unique_ptr to Module::addFunctionType() (#1672)Paweł Bylica2019-01-101-3/+3
| | | | | 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.
* Partial legalization (#1824) review followup (#1832)Alon Zakai2018-12-171-2/+2
|
* Minimal JS legalization (#1824)Alon Zakai2018-12-141-40/+62
| | | | | Even when we don't want to fully legalize code for JS, we should still legalize things that only JS cares about. In particular, dynCall_* methods are used from JS to call into the wasm table, and if they exist they are only for JS, so we should only legalize them. The use case motivating this is that in dynamic linking you may want to disable legalization, so that wasm=>wasm module calls are fast even with i64s, but you do still need dynCalls to be legalized even in that case, otherwise an invoke with an i64 parameter would fail.
* Cleanup shared constants (#1784)Sam Clegg2018-11-291-5/+3
|
* Use getTempRet0/setTempRet0 in LegalizeJSInterface.cpp (#1709)Sam Clegg2018-11-201-57/+26
| | | | | | | | | | | | | | | | Its simpler if we always import these functions from the embedder rather then synthesizing them various placed. This is part of a 4 part change: LLVM: https://reviews.llvm.org/D53240 fastcomp: https://github.com/kripken/emscripten-fastcomp/pull/237 emscripten: https://github.com/kripken/emscripten/pull/7358 binaryen: https://github.com/kripken/emscripten/pull/7358 Fixes: https://github.com/kripken/emscripten/issues/7273 Fixes: https://github.com/kripken/emscripten/issues/7304
* Unify imported and non-imported things (#1678)Alon Zakai2018-09-191-44/+48
| | | | | | | | | | | | | | 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 replaced imports in LegalizeJSInterface (#1657)Sam Clegg2018-08-301-0/+4
| | | | This pass was replacing all the uses of certain imports but wasn't bothering to delete the old ones.
* Add i64 high bits (tempRet0) helper funcs when legalizing JS interface (#1428)Alon Zakai2018-02-221-0/+43
| | | | * add tempRet0 helpers when necessary in legalize-js-interface
* notation change: AST => IR (#1245)Alon Zakai2017-10-241-2/+2
| | | The IR is indeed a tree, but not an "abstract syntax tree" since there is no language for which it is the syntax (except in the most trivial and meaningless sense).
* Add Builder::makeGlobal for nicer global creation (#1221)Alon Zakai2017-10-101-6/+7
|
* Wasm h to cpp (#926)jgravelle-google2017-03-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | * Move WasmType function implementations to wasm.cpp * Move Literal methods to wasm.cpp * Reorder wasm.cpp shared constants back to top * Move expression functions to wasm.cpp * Finish moving things to wasm.cpp * Split out Literal into its own .h/.cpp. Also factor out common wasm-type module * Remove unneeded/transitive includes from wasm.h * Add comment to try/check methods * Rename tryX/checkX methods to getXOrNull * Add missing include that should fix appveyor build breakage * More appveyor
* fix BINARYEN_PASS_DEBUG option (#908)Alon Zakai2017-02-231-0/+1
| | | | | * fix BINARYEN_PASS_DEBUG option * Add isNested property to passRunner
* Default Walker subclasses to using Visitor<SubType> (#921)jgravelle-google2017-02-231-1/+1
| | | | Most module walkers use PostWalker<T, Visitor<T>>, let that pattern be expressed as simply PostWalker<T>
* clean up raw pointer import->functionType, make it a Name like everything ↵Alon Zakai2017-02-171-8/+10
| | | | else (#915)
* properly legalize imported table elementsAlon Zakai2016-12-071-0/+9
|
* fix legalization issues with f32sAlon Zakai2016-12-071-2/+2
|
* make legalizeJSInterface handle f32s as well, which are not valid in asm.js ffisAlon Zakai2016-12-071-2/+18
|
* add a RemoveUnusedModuleElements pass, and make LegalizeJSInterface create ↵Alon Zakai2016-12-071-13/+18
| | | | TempRet0 if needed (otherwise we might remove it before we use it)
* Refactor Import::Kind and Export::Kind into an ExternalKind enum class (#725)Alon Zakai2016-10-031-3/+3
|
* asm2wasm i64 support (#723)Alon Zakai2016-09-301-0/+211
* support i64 intrinsics from fastcomp, adding --wasm-only flag * refactor callImport logic in asm2wasm to avoid recomputing wasm types again * legalize illegal i64 params in exports and imports * do safe i64 binary ops depending on precision * fix addVar, only assert on names if we are using a name