summaryrefslogtreecommitdiff
path: root/wasm2c/wasm-rt-impl.c
diff options
context:
space:
mode:
authorKeith Winstein <keithw@cs.stanford.edu>2022-07-11 17:12:49 -0700
committerGitHub <noreply@github.com>2022-07-11 17:12:49 -0700
commita7d484ef3d1f64649dd9f48cb1d5434f0fda561b (patch)
tree817862cfd2bbf1ac5290b9d0a55087ad6ccf8ebc /wasm2c/wasm-rt-impl.c
parent4132e35b51849678ac9e5592089e00057f260ccf (diff)
downloadwabt-a7d484ef3d1f64649dd9f48cb1d5434f0fda561b.tar.gz
wabt-a7d484ef3d1f64649dd9f48cb1d5434f0fda561b.tar.bz2
wabt-a7d484ef3d1f64649dd9f48cb1d5434f0fda561b.zip
wasm2c: run tests with -O2 on non-Windows (#1939)
Enable optimization when compiling the wasm2c output on non-Windows platforms (effectively GCC and clang). This required: - Preventing load instructions from being optimized away if their value is unused (using inline assembly with an input operand and empty code). This is necessary to force an OOB trap on platforms that use mprotect and the signal handler to detect OOB. - Disabling tail-call optimization in the compiler, to make sure that infinite recursion traps. (This required bumping the version of macOS in GitHub Actions to get a new-enough AppleClang. We should revert this back to 'macos-latest' as soon as that becomes the default.) - Using NaN-quieting versions of a bunch of FP ops that were previously only used on Windows, and adding floor/ceil and promotion/demotion. - Using the '-frounding-math' and '-fsignaling-nans' compiler flags to tell GCC and clang not to fold certain FP ops (e.g. subtracting zero, multiplying by 1). Fixes #1925.
Diffstat (limited to 'wasm2c/wasm-rt-impl.c')
-rw-r--r--wasm2c/wasm-rt-impl.c68
1 files changed, 0 insertions, 68 deletions
diff --git a/wasm2c/wasm-rt-impl.c b/wasm2c/wasm-rt-impl.c
index 7d70597c..14ca0e6f 100644
--- a/wasm2c/wasm-rt-impl.c
+++ b/wasm2c/wasm-rt-impl.c
@@ -290,74 +290,6 @@ void wasm_rt_free_memory(wasm_rt_memory_t* memory) {
#endif
}
-#ifdef _WIN32
-static float quiet_nanf(float x) {
- uint32_t tmp;
- memcpy(&tmp, &x, 4);
- tmp |= 0x7fc00000lu;
- memcpy(&x, &tmp, 4);
- return x;
-}
-
-static double quiet_nan(double x) {
- uint64_t tmp;
- memcpy(&tmp, &x, 8);
- tmp |= 0x7ff8000000000000llu;
- memcpy(&x, &tmp, 8);
- return x;
-}
-
-double wasm_rt_trunc(double x) {
- if (isnan(x)) {
- return quiet_nan(x);
- }
- return trunc(x);
-}
-
-float wasm_rt_truncf(float x) {
- if (isnan(x)) {
- return quiet_nanf(x);
- }
- return truncf(x);
-}
-
-float wasm_rt_nearbyintf(float x) {
- if (isnan(x)) {
- return quiet_nanf(x);
- }
- return nearbyintf(x);
-}
-
-double wasm_rt_nearbyint(double x) {
- if (isnan(x)) {
- return quiet_nan(x);
- }
- return nearbyint(x);
-}
-
-float wasm_rt_fabsf(float x) {
- if (isnan(x)) {
- uint32_t tmp;
- memcpy(&tmp, &x, 4);
- tmp = tmp & ~(1 << 31);
- memcpy(&x, &tmp, 4);
- return x;
- }
- return fabsf(x);
-}
-
-double wasm_rt_fabs(double x) {
- if (isnan(x)) {
- uint64_t tmp;
- memcpy(&tmp, &x, 8);
- tmp = tmp & ~(1ll << 63);
- memcpy(&x, &tmp, 8);
- return x;
- }
- return fabs(x);
-}
-#endif
-
void wasm_rt_allocate_table(wasm_rt_table_t* table,
uint32_t elements,
uint32_t max_elements) {