Reviewers: Mads Ager,

Message:
Unit test will be added.

Description:
Ensure that ToPrimitive is called on all objects involved in comparisons <, <=,
, >=.  Fixes bug in ia32 and x64 platforms.

Please review this at http://codereview.chromium.org/2834022/show

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/ia32/codegen-ia32.cc
  M     src/x64/codegen-x64.cc


Index: src/ia32/codegen-ia32.cc
===================================================================
--- src/ia32/codegen-ia32.cc    (revision 4943)
+++ src/ia32/codegen-ia32.cc    (working copy)
@@ -11686,16 +11686,17 @@
       __ Set(eax, Immediate(Smi::FromInt(EQUAL)));
       __ ret(0);
     } else {
-      Label return_equal;
       Label heap_number;
       // If it's not a heap number, then return equal.
       __ cmp(FieldOperand(edx, HeapObject::kMapOffset),
              Immediate(Factory::heap_number_map()));
-      __ j(equal, &heap_number);
-      __ bind(&return_equal);
-      __ Set(eax, Immediate(Smi::FromInt(EQUAL)));
-      __ ret(0);
-
+      if (cc_ == equal) {
+        __ j(equal, &heap_number);
+        __ Set(eax, Immediate(Smi::FromInt(EQUAL)));
+        __ ret(0);
+      } else {
+        __ j(not_equal, &not_identical);
+      }
       __ bind(&heap_number);
       // It is a heap number, so return non-equal if it's NaN and equal if
       // it's not NaN.
Index: src/x64/codegen-x64.cc
===================================================================
--- src/x64/codegen-x64.cc      (revision 4943)
+++ src/x64/codegen-x64.cc      (working copy)
@@ -8964,11 +8964,16 @@
       __ ret(0);
     } else {
       Label heap_number;
-      // If it's not a heap number, then return equal.
+ // If it's not a heap number, then return equal for (in)equality operator.
       __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset),
              Factory::heap_number_map());
-      __ j(equal, &heap_number);
-      __ ret(0);
+      if (cc_ == equal) {
+        __ j(equal, &heap_number);
+        __ ret(0);
+      } else {
+ // Identical objects must still be converted to primitive for < and >.
+        __ j(not_equal, &not_identical);
+      }

       __ bind(&heap_number);
       // It is a heap number, so return  equal if it's not NaN.


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to