Reviewers: Jakob,

Description:
Version 3.29.88.16 (merged r25125)

x87: Set the FPU precision control to double-precision.

[email protected]
BUG=

Please review this at https://codereview.chromium.org/700943004/

Base URL: https://v8.googlecode.com/svn/branches/3.29

Affected files (+13, -7 lines):
  M src/version.cc
  M src/x87/lithium-codegen-x87.cc
  M src/x87/macro-assembler-x87.h
  M src/x87/macro-assembler-x87.cc


Index: src/version.cc
diff --git a/src/version.cc b/src/version.cc
index 75846224d48c48edd84b037c4d00572e8884dfd2..461a65362471ca91ddd19678451f3e8b9bdb1bbf 100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
 #define MAJOR_VERSION     3
 #define MINOR_VERSION     29
 #define BUILD_NUMBER      88
-#define PATCH_LEVEL       15
+#define PATCH_LEVEL       16
 // Use 1 for candidates and 0 otherwise.
 // (Boolean macro values are not supported by all preprocessors.)
 #define IS_CANDIDATE_VERSION 0
Index: src/x87/lithium-codegen-x87.cc
diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc
index 00bbe5e72bab8245367fd7619bdd6c09b94b1414..75bf0a9e0d218ea127a8932e16e2fbd4f761b209 100644
--- a/src/x87/lithium-codegen-x87.cc
+++ b/src/x87/lithium-codegen-x87.cc
@@ -2272,6 +2272,8 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
   if (instr->op() != Token::MOD) {
     X87PrepareBinaryOp(left, right, result);
   }
+  // Set the precision control to double-precision.
+  __ X87SetFPUCW(0x027F);
   switch (instr->op()) {
     case Token::ADD:
       __ fadd_i(1);
@@ -2306,12 +2308,8 @@ void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
       break;
   }

- // Only always explicitly storing to memory to force the round-down for double
-  // arithmetic.
-  __ lea(esp, Operand(esp, -kDoubleSize));
-  __ fstp_d(Operand(esp, 0));
-  __ fld_d(Operand(esp, 0));
-  __ lea(esp, Operand(esp, kDoubleSize));
+  // Restore the default value of control word.
+  __ X87SetFPUCW(0x037F);
 }


Index: src/x87/macro-assembler-x87.cc
diff --git a/src/x87/macro-assembler-x87.cc b/src/x87/macro-assembler-x87.cc
index 47a46d4e3697d6b9f58dca6d22264dcd43a59bad..a1fa3317d4534afae90c20f52352133e2479f959 100644
--- a/src/x87/macro-assembler-x87.cc
+++ b/src/x87/macro-assembler-x87.cc
@@ -767,6 +767,13 @@ void MacroAssembler::X87SetRC(int rc) {
 }


+void MacroAssembler::X87SetFPUCW(int cw) {
+  push(Immediate(cw));
+  fldcw(MemOperand(esp, 0));
+  add(esp, Immediate(kPointerSize));
+}
+
+
 void MacroAssembler::AssertNumber(Register object) {
   if (emit_debug_code()) {
     Label ok;
Index: src/x87/macro-assembler-x87.h
diff --git a/src/x87/macro-assembler-x87.h b/src/x87/macro-assembler-x87.h
index ed0b7c17455191742e9c2d029a5b82e414d83ac0..c9e9087f9be19f5fd3022a63c40e941d43751124 100644
--- a/src/x87/macro-assembler-x87.h
+++ b/src/x87/macro-assembler-x87.h
@@ -425,6 +425,7 @@ class MacroAssembler: public Assembler {
   void FXamSign();
   void X87CheckIA();
   void X87SetRC(int rc);
+  void X87SetFPUCW(int cw);

   void ClampUint8(Register reg);
   void ClampTOSToUint8(Register result_reg);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to