Index: src/codegen.cc |
diff --git a/src/codegen.cc b/src/codegen.cc |
index 66b605a4206658d2feebf56c084d2ff03b2e530c..178ba4a69df8d1e423a6d9611518c11307135678 100644 |
--- a/src/codegen.cc |
+++ b/src/codegen.cc |
@@ -4,6 +4,9 @@ |
#include "src/v8.h" |
+#if defined(V8_OS_AIX) |
+#include <fenv.h> |
+#endif |
#include "src/bootstrapper.h" |
#include "src/codegen.h" |
#include "src/compiler.h" |
@@ -48,7 +51,15 @@ double modulo(double x, double y) { |
#else // POSIX |
double modulo(double x, double y) { |
+#if defined(V8_OS_AIX) |
+ // AIX raises an underflow exception for (Number.MIN_VALUE % Number.MAX_VALUE) |
+ feclearexcept(FE_ALL_EXCEPT); |
+ double result = std::fmod(x, y); |
+ int exception = fetestexcept(FE_UNDERFLOW); |
+ return (exception ? x : result); |
+#else |
return std::fmod(x, y); |
+#endif |
} |
#endif // defined(_WIN64) |