Revision: 16909
Author:   [email protected]
Date:     Tue Sep 24 09:29:00 2013 UTC
Log:      Fix invalid X87 stack depth after LCompareNumericAndBranch.

[email protected]

Review URL: https://codereview.chromium.org/23456044
http://code.google.com/p/v8/source/detail?r=16909

Modified:
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h

=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Mon Sep 23 18:57:32 2013 UTC +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Sep 24 09:29:00 2013 UTC
@@ -416,6 +416,13 @@
         x87_stack_.LeavingBlock(current_block_, LGoto::cast(instr));
       } else if (FLAG_debug_code && FLAG_enable_slow_asserts &&
                  !instr->IsGap() && !instr->IsReturn()) {
+        if (instr->ClobbersDoubleRegisters()) {
+          if (instr->HasDoubleRegisterResult()) {
+            ASSERT_EQ(1, x87_stack_.depth());
+          } else {
+            ASSERT_EQ(0, x87_stack_.depth());
+          }
+        }
         __ VerifyX87StackDepth(x87_stack_.depth());
       }
     }
@@ -559,6 +566,16 @@
   x87_stack_.Fxch(reg);
   x87_stack_.pop();
 }
+
+
+void LCodeGen::X87LoadForUsage(X87Register reg1, X87Register reg2) {
+  ASSERT(x87_stack_.Contains(reg1));
+  ASSERT(x87_stack_.Contains(reg2));
+  x87_stack_.Fxch(reg1, 1);
+  x87_stack_.Fxch(reg2);
+  x87_stack_.pop();
+  x87_stack_.pop();
+}


 void LCodeGen::X87Stack::Fxch(X87Register reg, int other_slot) {
@@ -2572,10 +2589,7 @@
         CpuFeatureScope scope(masm(), SSE2);
         __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right));
       } else {
-        X87Fxch(ToX87Register(right));
-        X87Fxch(ToX87Register(left), 1);
-        __ fld(0);
-        __ fld(2);
+        X87LoadForUsage(ToX87Register(right), ToX87Register(left));
         __ FCmp();
       }
       // Don't base result on EFLAGS when a NaN is involved. Instead
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Fri Sep 20 06:01:25 2013 UTC +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Tue Sep 24 09:29:00 2013 UTC
@@ -129,6 +129,7 @@
       X87Register left, X87Register right, X87Register result);

   void X87LoadForUsage(X87Register reg);
+  void X87LoadForUsage(X87Register reg1, X87Register reg2);
void X87PrepareToWrite(X87Register reg) { x87_stack_.PrepareToWrite(reg); }
   void X87CommitWrite(X87Register reg) { x87_stack_.CommitWrite(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/groups/opt_out.

Reply via email to