summaryrefslogtreecommitdiff
path: root/src/support/utilities.h
Commit message (Collapse)AuthorAgeFilesLines
* [NFC] Remove our bespoke `make_unique` implementation (#5613)Thomas Lively2023-03-311-5/+0
| | | | This code predates our adoption of C++14 and can now be removed in favor of `std::make_unique`, which should be more efficient.
* Change `exit()` to `Fatal()`; make it possible to throw on `Fatal()`. (#5087)Brian Anderson2022-10-011-4/+21
| | | | | | | | | | | | | | | | This patch makes binaryen easier to call from other applications by making more errors recoverable instead of early-exiting. The main thing it does is change three calls to exit on I/O errors into calls to Fatal(), which is an existing custom abstraction for handling unrecoverable errors. Currently Fatal's destructor calls _Exit(1). My intent is to make it possible for Fatal to not exit, but to throw, allowing an embedding application to catch the exception. Because the previous early exits were exiting with error code EXIT_FAILURE, I also changed Fatal to exit with EXIT_FAILURE. The test suite continues to pass so I assume this is ok. Next I changed Fatal to buffer its error message until the destructor instead of immediately printing it to stderr. This is for ease of patching Fatal to throw instead. Finally, I also included the patch I need to make Fatal throw when THROW_ON_FATAL is defined at compile time. I can carry this patch out of tree, but it is a small patch, so perhaps you will be willing to take it. I am happy to remove it. Fixes #4938
* Fix bugs with copying expressions (#5099)Thomas Lively2022-09-301-1/+1
| | | | | | | | | | | | | | | | | It does not make sense to construct an `Expression` directly because all expressions must be specific expressions. However, we previously allowed constructing Expressions, and in particular we allowed them to be copy constructed. Unrelatedly, `Fatal::operator<<` took its argument by value. Together, these two facts produced UB when printing Expressions in fatal error messages because a new Expression would be copy constructed with the original expression ID but without any of the actual data from the original specific expression. For example, when trying to print a Block, the printing code would try to look at the expression list, but the expression list would be junk stack data because the copied Expression does not contain an expression list. Fix the problem by making Expression's constructors visible only to its subclasses and making `Fatal::operator<<` take its argument by forwarding reference instead of by value.
* Fix errors when building in C++20 mode (#4528)Jakub Szewczyk2022-03-181-6/+9
| | | | | | | * use [[noreturn]] available since C++11 instead of compiler-specific attributes * replace deprecated std::is_pod with is_trivial&&is_standard_layout (also available since C++11/14) * explicitly capture this in [=] lambdas * extra const functions in FeatureSet, fix implicit cast warning by using the features field directly * Use CMAKE_CXX_STANDARD to ensure the C++ standard parameter is set on all targets, remove manual compiler flag workaround.
* Clean up support/bits.h (#3177)Thomas Lively2020-09-301-1/+1
| | | | | Use overloads instead of templates where applicable and change function names from PascalCase to camelCase. Also puts the functions in the Bits namespace to avoid naming conflicts.
* Add string parameter to WASM_UNREACHABLE (#2499)Sam Clegg2019-12-051-0/+14
| | | | | This works more like llvm's unreachable handler in that is preserves information even in release builds.
* Apply format changes from #2048 (#2059)Alon Zakai2019-04-261-13/+8
| | | 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
* standardize on 'template<' over 'template <' (i.e., remove a space) (#1782)Alon Zakai2018-11-291-1/+1
|
* Don't call static desructors when Fatal() errors occur (#1722)Sam Clegg2018-11-021-1/+4
| | | | | This was causing a deadlock while destroying the thread pool.
* More simple math opts (#1414)Alon Zakai2018-02-141-5/+3
| | | | | | | | * optimize more simple math operations: mul of 0, or of 0, and of 0, mul of 1, mul of a power of 2, urem of a power of 2 * fix asm2wasm callImport parsing: the optimizer may get rid of the added offset to a function table * update js builds
* Log callImport fatal error to cerr so it is not buffered. (#1036)Sam Clegg2017-06-121-1/+3
| | | | | | | Use Fatal() rather than stdout or report callImport error Without this the write to stdout can be lost (Since the following line aborts)
* Move wasm-linker into its own cpp file (#375)Derek Schuff2016-04-211-0/+4
| | | | | | | Still making things nicer for #370 Pulling wasm-linker into its own file also necessitated pulling asm_v_wasm.h into a cpp file. It goes into a new lib directory, src/asmjs. No actual code changes in this PR.
* Move Fatal into utilities.h (#376)Derek Schuff2016-04-211-0/+18
| | | | | Follow-on from #372. Probably we should do even better for error handling, and that might mean a cpp file in support, but for now this is a small improvement.
* Factor linker-related functionality of S2WasmBuilder into its own class (#372)Derek Schuff2016-04-211-0/+6
| | | | | This is the first of a couple of refactorings in for #370 No functionality change, and minimal code change to make it work.
* Properly align the stack pointerDerek Schuff2016-04-061-0/+13
| | | | | | | | | | | | * Properly align the stack pointer By default (if no global base is given) the global base is 1, which seems wrong. In this case the stack pointer gets an address of 1, which is unaligned and definitely wrong. So, start the global base at 0 instead of 1 by default and align the stack pointer. Also factor allocation of statics into a function. * unconditionally allocate stack pointer; explicitly reserve address 0
* Factor out bit_cast.JF Bastien2016-01-281-0/+40