Index: src/arm/simulator-arm.cc |
diff --git a/src/arm/simulator-arm.cc b/src/arm/simulator-arm.cc |
index def18186305f102da97890f23af79d7facc14bdf..f2d304ba1af95a115826599491bd5de548dd402f 100644 |
--- a/src/arm/simulator-arm.cc |
+++ b/src/arm/simulator-arm.cc |
@@ -26,6 +26,7 @@ |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
#include <stdlib.h> |
+#include <fpu_control.h> |
#include <cmath> |
#include <cstdarg> |
#include "v8.h" |
@@ -736,6 +737,8 @@ void Simulator::Initialize(Isolate* isolate) { |
Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { |
+ set_host_fp_precision(); |
+ |
i_cache_ = isolate_->simulator_i_cache(); |
if (i_cache_ == NULL) { |
i_cache_ = new v8::internal::HashMap(&ICacheMatch); |
@@ -3854,6 +3857,21 @@ uintptr_t Simulator::PopAddress() { |
return address; |
} |
+ |
+void Simulator::set_host_fp_precision() { |
+#if !V8_HOST_ARCH_ARM |
+ // Set Intel x87 FPU mode to 64-bit double. |
+ // The default FPU mode is extended (80-bit), |
+ // which can lead to unexpected precision failures. |
+ fpu_control_t cw; |
+ _FPU_GETCW(cw); |
+ cw &= ~_FPU_EXTENDED; |
+ cw |= _FPU_DOUBLE; |
+ _FPU_SETCW(cw); |
+#endif |
+} |
+ |
+ |
} } // namespace v8::internal |
#endif // USE_SIMULATOR |