aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/JSBackend/CallHandlers.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/JSBackend/CallHandlers.h')
-rw-r--r--lib/Target/JSBackend/CallHandlers.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Target/JSBackend/CallHandlers.h b/lib/Target/JSBackend/CallHandlers.h
index e1e8cbb46f..8ae8c26c1d 100644
--- a/lib/Target/JSBackend/CallHandlers.h
+++ b/lib/Target/JSBackend/CallHandlers.h
@@ -101,8 +101,14 @@ DEF_CALL_HANDLER(__default__, {
}
if (NumArgs > 0) text += ",";
}
- // this is an ffi call if we need casts, and it is not a Math_ builtin (with just 1 arg - Math with more args is different XXX)
- bool FFI = NeedCasts && (NumArgs > 1 || Name.find("Math_") != 0);
+ // this is an ffi call if we need casts, and it is not a special Math_ builtin
+ bool FFI = NeedCasts;
+ if (FFI && Name.find("Math_") == 0) {
+ if (Name == "Math_ceil" || Name == "Math_floor" || Name == "Math_min" || Name == "Math_max" || Name == "Math_sqrt" || Name == "Math_abs") {
+ // This special Math builtin is optimizable with all types, including floats, so can treat it as non-ffi
+ FFI = false;
+ }
+ }
unsigned FFI_OUT = FFI ? ASM_FFI_OUT : 0;
for (int i = 0; i < NumArgs; i++) {
if (!NeedCasts) {