OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 8920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8931 | 8931 |
8932 static int NegativeComparisonResult(Condition cc) { | 8932 static int NegativeComparisonResult(Condition cc) { |
8933 ASSERT(cc != equal); | 8933 ASSERT(cc != equal); |
8934 ASSERT((cc == less) || (cc == less_equal) | 8934 ASSERT((cc == less) || (cc == less_equal) |
8935 || (cc == greater) || (cc == greater_equal)); | 8935 || (cc == greater) || (cc == greater_equal)); |
8936 return (cc == greater || cc == greater_equal) ? LESS : GREATER; | 8936 return (cc == greater || cc == greater_equal) ? LESS : GREATER; |
8937 } | 8937 } |
8938 | 8938 |
8939 | 8939 |
8940 void CompareStub::Generate(MacroAssembler* masm) { | 8940 void CompareStub::Generate(MacroAssembler* masm) { |
8941 Label call_builtin, done; | 8941 Label check_unequal_objects, done; |
8942 // The compare stub returns a positive, negative, or zero 64-bit integer | 8942 // The compare stub returns a positive, negative, or zero 64-bit integer |
8943 // value in rax, corresponding to result of comparing the two inputs. | 8943 // value in rax, corresponding to result of comparing the two inputs. |
8944 // NOTICE! This code is only reached after a smi-fast-case check, so | 8944 // NOTICE! This code is only reached after a smi-fast-case check, so |
8945 // it is certain that at least one operand isn't a smi. | 8945 // it is certain that at least one operand isn't a smi. |
8946 | 8946 |
8947 // Two identical objects are equal unless they are both NaN or undefined. | 8947 // Two identical objects are equal unless they are both NaN or undefined. |
8948 { | 8948 { |
8949 Label not_identical; | 8949 Label not_identical; |
8950 __ cmpq(rax, rdx); | 8950 __ cmpq(rax, rdx); |
8951 __ j(not_equal, ¬_identical); | 8951 __ j(not_equal, ¬_identical); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9106 BranchIfNonSymbol(masm, &check_for_strings, rdx, kScratchRegister); | 9106 BranchIfNonSymbol(masm, &check_for_strings, rdx, kScratchRegister); |
9107 | 9107 |
9108 // We've already checked for object identity, so if both operands | 9108 // We've already checked for object identity, so if both operands |
9109 // are symbols they aren't equal. Register eax (not rax) already holds a | 9109 // are symbols they aren't equal. Register eax (not rax) already holds a |
9110 // non-zero value, which indicates not equal, so just return. | 9110 // non-zero value, which indicates not equal, so just return. |
9111 __ ret(2 * kPointerSize); | 9111 __ ret(2 * kPointerSize); |
9112 } | 9112 } |
9113 | 9113 |
9114 __ bind(&check_for_strings); | 9114 __ bind(&check_for_strings); |
9115 | 9115 |
9116 __ JumpIfNotBothSequentialAsciiStrings(rdx, rax, rcx, rbx, &call_builtin); | 9116 __ JumpIfNotBothSequentialAsciiStrings(rdx, rax, rcx, rbx, &check_unequal_obje
cts); |
9117 | 9117 |
9118 // Inline comparison of ascii strings. | 9118 // Inline comparison of ascii strings. |
9119 StringCompareStub::GenerateCompareFlatAsciiStrings(masm, | 9119 StringCompareStub::GenerateCompareFlatAsciiStrings(masm, |
9120 rdx, | 9120 rdx, |
9121 rax, | 9121 rax, |
9122 rcx, | 9122 rcx, |
9123 rbx, | 9123 rbx, |
9124 rdi, | 9124 rdi, |
9125 r8); | 9125 r8); |
9126 | 9126 |
9127 #ifdef DEBUG | 9127 #ifdef DEBUG |
9128 __ Abort("Unexpected fall-through from string comparison"); | 9128 __ Abort("Unexpected fall-through from string comparison"); |
9129 #endif | 9129 #endif |
9130 | 9130 |
9131 __ bind(&call_builtin); | 9131 __ bind(&check_unequal_objects); |
| 9132 if (cc_ == equal && !strict_) { |
| 9133 // Not strict equality. Objects are unequal if |
| 9134 // they are both JSObjects and not undetectable, |
| 9135 // and their pointers are different. |
| 9136 Label not_both_objects, return_unequal; |
| 9137 // At most one is a smi, so we can test for smi by adding the two. |
| 9138 // A smi plus a heap object has the low bit set, a heap object plus |
| 9139 // a heap object has the low bit clear. |
| 9140 ASSERT_EQ(0, kSmiTag); |
| 9141 ASSERT_EQ(V8_UINT64_C(1), kSmiTagMask); |
| 9142 __ lea(rcx, Operand(rax, rdx, times_1, 0)); |
| 9143 __ testb(rcx, Immediate(kSmiTagMask)); |
| 9144 __ j(not_zero, ¬_both_objects); |
| 9145 __ CmpObjectType(rax, FIRST_JS_OBJECT_TYPE, rbx); |
| 9146 __ j(below, ¬_both_objects); |
| 9147 __ CmpObjectType(rdx, FIRST_JS_OBJECT_TYPE, rcx); |
| 9148 __ j(below, ¬_both_objects); |
| 9149 __ testb(FieldOperand(rbx, Map::kBitFieldOffset), |
| 9150 Immediate(1 << Map::kIsUndetectable)); |
| 9151 __ j(zero, &return_unequal); |
| 9152 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), |
| 9153 Immediate(1 << Map::kIsUndetectable)); |
| 9154 __ j(zero, &return_unequal); |
| 9155 // The objects are both undetectable, so they both compare as the value |
| 9156 // undefined, and are equal. |
| 9157 __ Set(rax, EQUAL); |
| 9158 __ bind(&return_unequal); |
| 9159 // Return non-equal by returning the non-zero object pointer in eax, |
| 9160 // or return equal if we fell through to here. |
| 9161 __ ret(2 * kPointerSize); // rax, rdx were pushed |
| 9162 __ bind(¬_both_objects); |
| 9163 } |
| 9164 |
9132 // must swap argument order | 9165 // must swap argument order |
9133 __ pop(rcx); | 9166 __ pop(rcx); |
9134 __ pop(rdx); | 9167 __ pop(rdx); |
9135 __ pop(rax); | 9168 __ pop(rax); |
9136 __ push(rdx); | 9169 __ push(rdx); |
9137 __ push(rax); | 9170 __ push(rax); |
9138 | 9171 |
9139 // Figure out which native to call and setup the arguments. | 9172 // Figure out which native to call and setup the arguments. |
9140 Builtins::JavaScript builtin; | 9173 Builtins::JavaScript builtin; |
9141 if (cc_ == equal) { | 9174 if (cc_ == equal) { |
(...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11915 } | 11948 } |
11916 | 11949 |
11917 #endif | 11950 #endif |
11918 | 11951 |
11919 | 11952 |
11920 #undef __ | 11953 #undef __ |
11921 | 11954 |
11922 } } // namespace v8::internal | 11955 } } // namespace v8::internal |
11923 | 11956 |
11924 #endif // V8_TARGET_ARCH_X64 | 11957 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |