diff options
author | Nathan Froyd <froydnj@gmail.com> | 2018-03-16 12:25:47 -0400 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2018-03-16 09:25:47 -0700 |
commit | 8fd854d6f60c6c711c3c04e1d30c74a6b2f1821b (patch) | |
tree | 85f62151664890b4c29f5109c956bb08241e983f /src | |
parent | 8faa79c0dafe2c358a7949910bb1a225a3b32ede (diff) | |
download | binaryen-8fd854d6f60c6c711c3c04e1d30c74a6b2f1821b.tar.gz binaryen-8fd854d6f60c6c711c3c04e1d30c74a6b2f1821b.tar.bz2 binaryen-8fd854d6f60c6c711c3c04e1d30c74a6b2f1821b.zip |
create Math_{min,max} variables for wasm2asm-generated JS (#1476)
We were using Math_{min,max} in wasm2asm-generated files without
declaring said functions. This decision created problems for tests,
because Math_min (resp. max) would first be used on f32s, thus returning
f32, and then validation would fail when it was used on f64s.
The resulting changes make wasm2asm tests pass with MOZJS asm.js
validation, which moves #1443 forward.
Diffstat (limited to 'src')
-rw-r--r-- | src/asmjs/shared-constants.cpp | 2 | ||||
-rw-r--r-- | src/asmjs/shared-constants.h | 2 | ||||
-rw-r--r-- | src/wasm2asm.h | 2 |
3 files changed, 6 insertions, 0 deletions
diff --git a/src/asmjs/shared-constants.cpp b/src/asmjs/shared-constants.cpp index 09452805c..c6efe64f9 100644 --- a/src/asmjs/shared-constants.cpp +++ b/src/asmjs/shared-constants.cpp @@ -40,6 +40,8 @@ cashew::IString GLOBAL("global"), CLZ32("clz32"), FROUND("fround"), ASM2WASM("asm2wasm"), + MIN("min"), + MAX("max"), F64_REM("f64-rem"), F64_TO_INT("f64-to-int"), F64_TO_UINT("f64-to-uint"), diff --git a/src/asmjs/shared-constants.h b/src/asmjs/shared-constants.h index 06946c7f5..28142fecc 100644 --- a/src/asmjs/shared-constants.h +++ b/src/asmjs/shared-constants.h @@ -43,6 +43,8 @@ extern cashew::IString GLOBAL, CLZ32, FROUND, ASM2WASM, + MIN, + MAX, F64_REM, F64_TO_INT, F64_TO_UINT, diff --git a/src/wasm2asm.h b/src/wasm2asm.h index 3c2cfcb6e..8a17c415d 100644 --- a/src/wasm2asm.h +++ b/src/wasm2asm.h @@ -472,6 +472,8 @@ void Wasm2AsmBuilder::addBasics(Ref ast) { addMath(MATH_FROUND, FROUND); addMath(MATH_ABS, ABS); addMath(MATH_CLZ32, CLZ32); + addMath(MATH_MIN, MIN); + addMath(MATH_MAX, MAX); } void Wasm2AsmBuilder::addImport(Ref ast, Import* import) { |