summaryrefslogtreecommitdiff
path: root/src/s2wasm.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove s2wasm (#1607)Sam Clegg2018-06-281-1460/+0
| | | | s2wasm is no longer used my emscripten and as far as I know now as no other users.
* Move the renaming of llvm-generated __invoke_XX functions from s2wasm into ↵Sam Clegg2018-05-101-78/+7
| | | | | | | | | wasm-emscripten (#1539) This allows the same functionality to be used also in wasm-emscripten-finalize (i.e. the lld path).
* Use .set instead of = for aliases (#1491)Heejin Ahn2018-03-301-26/+27
| | | | | | | | | | | | llvm-mirror/llvm@9273bb3([Phabricator](https://reviews.llvm.org/D44256)) changed alias assignment syntax from ``` x = y ``` to ``` .set x, y ``` This patch reflects the change.
* 'std::string &' => 'std::string& ' (#1403)Alon Zakai2018-02-051-2/+2
| | | The & on the type is the proper convention.
* Rename WasmType => Type (#1398)Alon Zakai2018-02-021-23/+23
| | | | * rename WasmType to Type. it's in the wasm:: namespace anyhow, and without Wasm- it fits in better alongside Index, Address, Expression, Module, etc.
* address some MSVC warnings (#1386)Nathan Froyd2018-01-251-3/+3
| | | | | | | | | | | | | | | | | | | | | | * fix unused variable warnings in wasm2asm.cpp No need to give the bad_alloc exception a name when we do nothing with it. * add appropriate casts for shift operands MSVC complains about implicitly converting results from 32 bits to 64 bits here, so we might as well make it clear that we intended the 64-bit shift to happen in the first place. * disable C4722 on MSVC We annotated Fatal::~Fatal with WASM_NORETURN, yet MSVC still warns, so take the next step and silence the warning completely. * don't warn about "deprecated" POSIX functions with MSVC Non-Windows platforms don't have the names MSVC recommends using, and everybody understands the POSIX names, so just silence the warning.
* Fixed parseFile() skipping every other line (#1223)Alexander Meißner2017-10-161-29/+10
| | | | | | | | * Fixed parseFile() skipping every other line Was caused by "s = strchr(s, '\n')" Also replaced recordFile() by parseFile() as they do exactly the same * Added parseFile() to process() in s2wasm.h
* Add atomic loads and stores (#1077)Derek Schuff2017-06-281-0/+2
| | | | | Add IR, wast and binary support for atomic loads and stores. Currently all IR generated by means other than parsing wast and binary files always generates non-atomic accesses, and optimizations have not yet been made aware of atomics, so they are certainly not ready to be used yet.
* Exporting/importing debug location information from .wast/.asm.js/.s formats ↵Yury Delendik2017-06-011-6/+21
| | | | | | | | (#1017) * Extends wasm-as, wasm-dis and s2wasm to consume debug locations. * Exports source map from asm2wasm
* Validate finalization (#1014)Alon Zakai2017-05-181-2/+3
| | | | | | | * validate that types are properly finalized, when in pass-debug mode (BINARYEN_PASS_DEBUG env var): check after each pass is run that the type of each node is equal to the proper type (when finalizing it, i.e., fully recomputing the type). * fix many fuzz bugs found by that. * in particular, fix dce bugs with type changes not being fully updated during code removal. add a new TypeUpdater helper class that lets a pass update types efficiently, by the helper tracking deps between blocks and branches etc., and updating/propagating type changes only as necessary.
* disallow empty blocks with a type - if they return a type, they must have ↵Alon Zakai2017-05-021-0/+4
| | | | contents. make s2wasm avoid outputting that as well (#992)
* Skip .size directives that follow .import_global directives (#949)jgravelle-google2017-03-161-1/+7
|
* Wasm h to cpp (#926)jgravelle-google2017-03-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * 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
* Handle importing globals in s2wasm (#843)jgravelle-google2016-11-301-29/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Handle importing globals in s2wasm * Make importedGlobals a set of Names, make Names hashable * Revert "Make importedGlobals a set of Names, make Names hashable" This reverts commit 1d0ca7a5e3839b15ca60593330979864c9c3ed60. * Refactor relocation parsing to handle expressions directly * PR Feedback - Move comment where it belongs - Add comment about ownership to addRelocation - Remove do-nothing parseImportGlobal * Reword "imported globals" to "imported objects" - Flip isObjectImported to isObjectImplemented, for consistency * Add tests for s2wasm globals. Also implement import relocation expression handling * Simplify globals.s test * Fix memory leak of relocation * Use unique_ptr instead of delete in getRelocatableExpression
* Set the type of the implicit blocks we use for a loop body in s2wasm (#810)jgravelle-google2016-10-271-0/+1
| | | | | | | Loops are modeled in Binaryen IR as having a Block as a body. The block is added to module walkers and validated like a normal block. In s2wasm when we add the blocks, we need to make sure that the type of the loop body matches the type of the loop itself, or we run into issues.
* Update s2wasm for reordered call_indirect (#802)jgravelle-google2016-10-241-3/+2
| | | | | | | | | | | | | | | * Update s2wasm for reordered call_indirect https://reviews.llvm.org/D25708 fixed call_indirect for 0xc by reordering the operands. s2wasm needs to be aware of that too. * Update llvm_autogenerated tests * Update torture-s tests * run auto_update_tests * update handwritten dot_s test that had call_indirect with args
* Dot s block signatures (#747)jgravelle-google2016-10-061-3/+26
| | | | | | | | | | * Support block signatures in s2wasm's .s format * Autogenerate tests * update cfg-stackify tests * Remove conflict files
* Update for removal of loop's bottom label from LLVM (#750)Derek Schuff2016-10-061-11/+0
| | | | Corresponds to LLVM change https://reviews.llvm.org/D25122, r283502
* Update s2wasm for removal of store results (#749)Derek Schuff2016-10-061-6/+9
| | | | Corresponds to LLVM change https://reviews.llvm.org/D25122
* s2wasm: Do not add drops for void values (#718)Derek Schuff2016-09-281-1/+5
| | | Fixes #708
* Update s2wasm for 0xc changes (#698)Derek Schuff2016-09-151-15/+15
| | | | | | | | | | | Several updates for s2wasm and its tests: Add explicit drops where they are emitted by LLVM already Convert loops (which are still modeled in the old way by LLVM) to wrap them in an explicit block (for the exit label). This also allows simplifying the loop creation (no need to post-process the implicit block which is the loop's body). After the engines update to 0xc we should update LLVM to model loops in the 0xc way, but for now it remains compatible with 0xb and 0xc. Fix the order of the calls to setTee() when creating tee_locals Add an explicit drop when creating the _start entry function wrapper if needed Update dot_s and llvm_autogenerated tests to remove store-results optimization (and few other minor updates) Fix the test auto-updater to fail if subprocesses fail There still seems to be a validation failure when building libc (I think it's from the stricter drop rules, but it may be in the source rather than the compiler), but this at least makes Binaryen's tests pa
* loops no longer have an out label and other upstream loop updatesAlon Zakai2016-09-071-4/+3
|
* add drop and tee expressionsAlon Zakai2016-09-071-1/+4
|
* Method name fixaheejin2016-08-301-2/+2
|
* asm.js-style setjmp/longjmp handling for wasm: add handling foraheejin2016-08-301-9/+50
| | | | emscripten_longjmp_jmpbuf name
* Fix alignment bug in .lcomm (#680)Heejin Ahn2016-08-261-2/+3
| | | | | | | | | | | | When parsing .lcomm directives, s2wasm does not parse the alignment number and skip it. This causes alignment bugs in some cases. (In the test case attached, 'buf' should be 4 bytes aligned, but it does not align it properly, so this code was generated: ``` (call $foo (i32.const 13) ) ``` 13 is not 4-bytes aligned. This patch fixes this bug.
* Implement asm.js style exception handling for Wasm (#664)Heejin Ahn2016-08-111-8/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Implement asm.js style exception handling for Wasm Converts invoke wrapper names generated by LLVM backend to real invoke wrapper names that are expected by JavaScript glue code. This is required to support wasm exception handling (asm.js style). LLVM backend lowers invoke @func(arg1, arg2) to label %invoke.cont unwind label %lpad into ... (some code) call @invoke_SIG(func, arg1, arg2) ... (some code) SIG is a mangled string generated based on the LLVM IR-level function signature. In LLVM IR, types are not lowered yet, so this mangling scheme simply takes LLVM's string representtion of parameter types and concatenate them with '_'. For example, the name of an invoke wrapper for function void foo(struct mystruct*, int) will be "__invoke_void_%struct.mystruct*_int". This function converts the names of invoke wrappers based on their lowered argument types and a return type. In the example above, the resulting new wrapper name becomes "invoke_vii". * Address comments Change variable names to camelcase Add a small (semi-)handwritten test case * Export malloc and free from wasm when available * Add a test case for exporting malloc/free feature + cosmetic 'file' name change in text_before_type.s * fixInvokeWrapper -> fixEmExceptionInvoke * Add a TODO
* Fix a parsing bug introduced by #615 (#661)Heejin Ahn2016-08-051-0/+4
| | | | | | | | | | | | | | | Name lhs = getStrToSep(); if (!skipEqual()){ s = strchr(s, '\n'); if (!s) break; continue; } The above code snippet introduced by #615 has a bug when there is only one word (e.g. ".text") in a line. If there is only one word in a line, skipEqual() also skips the newline character at the end of the line, and strchr(s, '\n') moves the cursor to the end of the next line, effectively skipping the whole next line.
* support pre-assigning indexes for functions that are called indirectly (#616)Dominic Chen2016-08-021-0/+7
| | | This patch adds support for an ".indidx" primitive that pre-assigns table indexes for functions that are called indirectly. It is used by the upstream LLVM WebAssembly backend to support fine-grained control-flow integrity for indirect function calls by emitting instrumentation at each indirect call site to check that the destination index is within certain ranges that correspond to disjoint equivalence classes of indirect call targets. The reason that this primitive is necessary is because the layout of the table section isn't determined until the WebAssembly linker is executed, but indirect function to table index mappings need to be known when opt is executed to generate the correct range checking in the LLVM IR.
* Fix trailing whitespace, single-character strings, checking map element ↵Dominic Chen2016-07-221-1/+0
| | | | presence, and eliminate explicit index counter (#633)
* Handle aliases without size (e.g. weak symbol), add redefinition warnings (#630)Dominic Chen2016-07-131-12/+7
|
* add support for symbol assignments, closes #4422 (#615)Dominic Chen2016-07-111-18/+85
| | | Adds support for aliases to objects, to go along with the existing support for aliases to functions.
* s2wasm: Validate the result module (#574)Derek Schuff2016-06-101-0/+6
| | | | Add an s2wasm option `--no-validate` to disable validation for debugging purposes. Also fix several validation errors by adding calls to `finalize()` after creating expressions, and ensuring that an import is created earlier in `Linker::getImportThunk`.
* Fixed missing type assignment of host operations in s2wasm (#572)Alexander Meißner2016-06-061-0/+1
|
* Fix leak of FunctionType from parseFuncType when not already in the module ↵Derek Schuff2016-06-031-2/+8
| | | | | (#563) Pass ownership into the wasm module.
* Generate thunks for address-taken imports (#554)Derek Schuff2016-06-021-4/+26
| | | | | | | | | | | Under emscripten, C code can take the address of a function implemented in Javascript (which is exposed via an import in wasm). Because imports do not have linear memory address in wasm, we need to generate a thunk to be the target of the indirect call; it call the import directly. This is facilited by a new .s directive (.functype) which declares the types of functions which are declared but not defined. Fixes https://github.com/WebAssembly/binaryen/issues/392
* Allows parsing of debug information in .S filesYury Delendik2016-05-261-12/+84
| | | | Currently it ignores this information. Also it allows parse files with -asm-verbose=true.
* Update s2wasm for LLVM changes, and regenerate tests. (#532)Dan Gohman2016-05-201-6/+7
|
* Allow implicit function returns. (#529)Dan Gohman2016-05-191-0/+4
|
* Avoid double dollarsigns in s2wasm local names. (#527)Dan Gohman2016-05-191-5/+9
| | | | | | | | | * Avoid double dollarsigns in s2wasm local names. Recognize '$' as part of the .s syntax for register names, and exclude it when forming the wasm local name. This changes names like "$$0" to "$0". * Fix a comment.
* finalize s2wasm blocks once at their end, not constantlyAlon Zakai2016-05-181-1/+2
|
* use separate internal opcodes for binary variantsAlon Zakai2016-05-181-33/+36
|
* use separate internal opcodes for unary variantsAlon Zakai2016-05-181-11/+11
|
* spec test updates, and many validation fixesAlon Zakai2016-05-181-1/+1
|
* Use a class with implicit overflow checks for Address (#486)Derek Schuff2016-05-121-6/+7
| | | | It includes implicit conversion from u64 and implicit conversion to address_t. This makes it easier to use without ugly casting and but still gets the overflow checks.
* Fix VC warning in s2wasm.h (#481)BSalita2016-05-121-1/+1
|
* Introduce a separate type for linear memory addresses (#477)Derek Schuff2016-05-111-13/+13
| | | | | | | We've been using size_t (and other things) for addresses, which is generally wrong because it depends on the host, when it should in fact depend on the target. This is a partial fix for #278 (i.e. it's the right fix, I don't think it's applied quite everywhere yet).
* [Linker] Handle archive filesDerek Schuff2016-05-051-6/+12
| | | | | | | | Add a class to parse archive files. Support linking archive files, with archive semantics (i.e. an archive member is linked in if it satisfies an undefined reference). Archive files must be gnu-format archives containing .s files. Add tests for linking semantics.
* Harmonize the internal opcodes with the binary format (#433)Alon Zakai2016-05-031-10/+12
| | | | | | * harmonize the internal opcodes with the binary format, so they clearly parallel, and also this helps us avoid needing the type to disambiguate * comment on GetLocal in C API
* Fix alignment UB (#425)JF Bastien2016-05-021-3/+6
| | | There may be some other places which are broken, but they don't trigger ubsan right now. This is another fix for #404.