From 94ae0087392d9b9c0d0a04d336f33f843c24fcdf Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Thu, 1 Jul 2010 15:18:07 +0000 Subject: [PATCH] Let relational comparison operators quickly compare a string with itself. Review URL: http://codereview.chromium.org/2802028 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5000 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/ia32/codegen-ia32.cc | 16 ++++++++-------- src/x64/codegen-x64.cc | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index d01b939d46..fa09dd88a4 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -11689,15 +11689,15 @@ void CompareStub::Generate(MacroAssembler* masm) { Label heap_number; __ cmp(FieldOperand(edx, HeapObject::kMapOffset), Immediate(Factory::heap_number_map())); - if (cc_ == equal) { - __ j(equal, &heap_number); - // Identical objects are equal for operators ==, !=, and ===. - __ Set(eax, Immediate(Smi::FromInt(EQUAL))); - __ ret(0); - } else { - // Identical objects must call ToPrimitive for <, <=, >, and >=. - __ j(not_equal, ¬_identical); + __ j(equal, &heap_number); + if (cc_ != equal) { + // Call runtime on identical JSObjects. Otherwise return equal. + __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, ecx); + __ j(above_equal, ¬_identical); } + __ Set(eax, Immediate(Smi::FromInt(EQUAL))); + __ ret(0); + __ bind(&heap_number); // It is a heap number, so return non-equal if it's NaN and equal if // it's not NaN. diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index 2c65dc74df..e7f3a448c7 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -9077,14 +9077,14 @@ void CompareStub::Generate(MacroAssembler* masm) { // If it's not a heap number, then return equal for (in)equality operator. __ Cmp(FieldOperand(rdx, HeapObject::kMapOffset), Factory::heap_number_map()); - if (cc_ == equal) { - __ j(equal, &heap_number); - __ Set(rax, EQUAL); - __ ret(0); - } else { - // Identical objects must still be converted to primitive for < and >. - __ j(not_equal, ¬_identical); + __ j(equal, &heap_number); + if (cc_ != equal) { + // Call runtime on identical JSObjects. Otherwise return equal. + __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rcx); + __ j(above_equal, ¬_identical); } + __ Set(rax, EQUAL); + __ ret(0); __ bind(&heap_number); // It is a heap number, so return equal if it's not NaN.