OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( | 87 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( |
88 CodeStubDescriptor* descriptor) { | 88 CodeStubDescriptor* descriptor) { |
89 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); | 89 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); |
90 } | 90 } |
91 | 91 |
92 | 92 |
93 #define __ ACCESS_MASM(masm) | 93 #define __ ACCESS_MASM(masm) |
94 | 94 |
95 | 95 |
96 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, | 96 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
97 Condition cond, bool strong); | 97 Condition cond, Strength strength); |
98 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 98 static void EmitSmiNonsmiComparison(MacroAssembler* masm, |
99 Register lhs, | 99 Register lhs, |
100 Register rhs, | 100 Register rhs, |
101 Label* lhs_not_nan, | 101 Label* lhs_not_nan, |
102 Label* slow, | 102 Label* slow, |
103 bool strict); | 103 bool strict); |
104 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, | 104 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, |
105 Register lhs, | 105 Register lhs, |
106 Register rhs); | 106 Register rhs); |
107 | 107 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 231 |
232 __ Pop(scratch_high, scratch_low, scratch); | 232 __ Pop(scratch_high, scratch_low, scratch); |
233 __ Ret(); | 233 __ Ret(); |
234 } | 234 } |
235 | 235 |
236 | 236 |
237 // Handle the case where the lhs and rhs are the same object. | 237 // Handle the case where the lhs and rhs are the same object. |
238 // Equality is almost reflexive (everything but NaN), so this is a test | 238 // Equality is almost reflexive (everything but NaN), so this is a test |
239 // for "identity and not NaN". | 239 // for "identity and not NaN". |
240 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, | 240 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
241 Condition cond, bool strong) { | 241 Condition cond, Strength strength) { |
242 Label not_identical; | 242 Label not_identical; |
243 Label heap_number, return_equal; | 243 Label heap_number, return_equal; |
244 __ cmp(r0, r1); | 244 __ cmp(r0, r1); |
245 __ b(ne, ¬_identical); | 245 __ b(ne, ¬_identical); |
246 | 246 |
247 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), | 247 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), |
248 // so we do the second best thing - test it ourselves. | 248 // so we do the second best thing - test it ourselves. |
249 // They are both equal and they are not both Smis so both of them are not | 249 // They are both equal and they are not both Smis so both of them are not |
250 // Smis. If it's not a heap number, then return equal. | 250 // Smis. If it's not a heap number, then return equal. |
251 if (cond == lt || cond == gt) { | 251 if (cond == lt || cond == gt) { |
252 // Call runtime on identical JSObjects. | 252 // Call runtime on identical JSObjects. |
253 __ CompareObjectType(r0, r4, r4, FIRST_SPEC_OBJECT_TYPE); | 253 __ CompareObjectType(r0, r4, r4, FIRST_SPEC_OBJECT_TYPE); |
254 __ b(ge, slow); | 254 __ b(ge, slow); |
255 // Call runtime on identical symbols since we need to throw a TypeError. | 255 // Call runtime on identical symbols since we need to throw a TypeError. |
256 __ cmp(r4, Operand(SYMBOL_TYPE)); | 256 __ cmp(r4, Operand(SYMBOL_TYPE)); |
257 __ b(eq, slow); | 257 __ b(eq, slow); |
258 if (strong) { | 258 if (is_strong(strength)) { |
259 // Call the runtime on anything that is converted in the semantics, since | 259 // Call the runtime on anything that is converted in the semantics, since |
260 // we need to throw a TypeError. Smis have already been ruled out. | 260 // we need to throw a TypeError. Smis have already been ruled out. |
261 __ cmp(r4, Operand(HEAP_NUMBER_TYPE)); | 261 __ cmp(r4, Operand(HEAP_NUMBER_TYPE)); |
262 __ b(eq, &return_equal); | 262 __ b(eq, &return_equal); |
263 __ tst(r4, Operand(kIsNotStringMask)); | 263 __ tst(r4, Operand(kIsNotStringMask)); |
264 __ b(ne, slow); | 264 __ b(ne, slow); |
265 } | 265 } |
266 } else { | 266 } else { |
267 __ CompareObjectType(r0, r4, r4, HEAP_NUMBER_TYPE); | 267 __ CompareObjectType(r0, r4, r4, HEAP_NUMBER_TYPE); |
268 __ b(eq, &heap_number); | 268 __ b(eq, &heap_number); |
269 // Comparing JS objects with <=, >= is complicated. | 269 // Comparing JS objects with <=, >= is complicated. |
270 if (cond != eq) { | 270 if (cond != eq) { |
271 __ cmp(r4, Operand(FIRST_SPEC_OBJECT_TYPE)); | 271 __ cmp(r4, Operand(FIRST_SPEC_OBJECT_TYPE)); |
272 __ b(ge, slow); | 272 __ b(ge, slow); |
273 // Call runtime on identical symbols since we need to throw a TypeError. | 273 // Call runtime on identical symbols since we need to throw a TypeError. |
274 __ cmp(r4, Operand(SYMBOL_TYPE)); | 274 __ cmp(r4, Operand(SYMBOL_TYPE)); |
275 __ b(eq, slow); | 275 __ b(eq, slow); |
276 if (strong) { | 276 if (is_strong(strength)) { |
277 // Call the runtime on anything that is converted in the semantics, | 277 // Call the runtime on anything that is converted in the semantics, |
278 // since we need to throw a TypeError. Smis and heap numbers have | 278 // since we need to throw a TypeError. Smis and heap numbers have |
279 // already been ruled out. | 279 // already been ruled out. |
280 __ tst(r4, Operand(kIsNotStringMask)); | 280 __ tst(r4, Operand(kIsNotStringMask)); |
281 __ b(ne, slow); | 281 __ b(ne, slow); |
282 } | 282 } |
283 // Normally here we fall through to return_equal, but undefined is | 283 // Normally here we fall through to return_equal, but undefined is |
284 // special: (undefined == undefined) == true, but | 284 // special: (undefined == undefined) == true, but |
285 // (undefined <= undefined) == false! See ECMAScript 11.8.5. | 285 // (undefined <= undefined) == false! See ECMAScript 11.8.5. |
286 if (cond == le || cond == ge) { | 286 if (cond == le || cond == ge) { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 __ mov(r1, Operand(r1, ASR, 1)); | 570 __ mov(r1, Operand(r1, ASR, 1)); |
571 __ sub(r0, r1, Operand(r0, ASR, 1)); | 571 __ sub(r0, r1, Operand(r0, ASR, 1)); |
572 __ Ret(); | 572 __ Ret(); |
573 __ bind(¬_two_smis); | 573 __ bind(¬_two_smis); |
574 | 574 |
575 // NOTICE! This code is only reached after a smi-fast-case check, so | 575 // NOTICE! This code is only reached after a smi-fast-case check, so |
576 // it is certain that at least one operand isn't a smi. | 576 // it is certain that at least one operand isn't a smi. |
577 | 577 |
578 // Handle the case where the objects are identical. Either returns the answer | 578 // Handle the case where the objects are identical. Either returns the answer |
579 // or goes to slow. Only falls through if the objects were not identical. | 579 // or goes to slow. Only falls through if the objects were not identical. |
580 EmitIdenticalObjectComparison(masm, &slow, cc, strong()); | 580 EmitIdenticalObjectComparison(masm, &slow, cc, strength()); |
581 | 581 |
582 // If either is a Smi (we know that not both are), then they can only | 582 // If either is a Smi (we know that not both are), then they can only |
583 // be strictly equal if the other is a HeapNumber. | 583 // be strictly equal if the other is a HeapNumber. |
584 STATIC_ASSERT(kSmiTag == 0); | 584 STATIC_ASSERT(kSmiTag == 0); |
585 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); | 585 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); |
586 __ and_(r2, lhs, Operand(rhs)); | 586 __ and_(r2, lhs, Operand(rhs)); |
587 __ JumpIfNotSmi(r2, ¬_smis); | 587 __ JumpIfNotSmi(r2, ¬_smis); |
588 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: | 588 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: |
589 // 1) Return the answer. | 589 // 1) Return the answer. |
590 // 2) Go to slow. | 590 // 2) Go to slow. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 // Never falls through to here. | 672 // Never falls through to here. |
673 | 673 |
674 __ bind(&slow); | 674 __ bind(&slow); |
675 | 675 |
676 __ Push(lhs, rhs); | 676 __ Push(lhs, rhs); |
677 // Figure out which native to call and setup the arguments. | 677 // Figure out which native to call and setup the arguments. |
678 Builtins::JavaScript native; | 678 Builtins::JavaScript native; |
679 if (cc == eq) { | 679 if (cc == eq) { |
680 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; | 680 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; |
681 } else { | 681 } else { |
682 native = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE; | 682 native = |
| 683 is_strong(strength()) ? Builtins::COMPARE_STRONG : Builtins::COMPARE; |
683 int ncr; // NaN compare result | 684 int ncr; // NaN compare result |
684 if (cc == lt || cc == le) { | 685 if (cc == lt || cc == le) { |
685 ncr = GREATER; | 686 ncr = GREATER; |
686 } else { | 687 } else { |
687 DCHECK(cc == gt || cc == ge); // remaining cases | 688 DCHECK(cc == gt || cc == ge); // remaining cases |
688 ncr = LESS; | 689 ncr = LESS; |
689 } | 690 } |
690 __ mov(r0, Operand(Smi::FromInt(ncr))); | 691 __ mov(r0, Operand(Smi::FromInt(ncr))); |
691 __ push(r0); | 692 __ push(r0); |
692 } | 693 } |
(...skipping 2882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3575 __ b(vs, &unordered); | 3576 __ b(vs, &unordered); |
3576 | 3577 |
3577 // Return a result of -1, 0, or 1, based on status bits. | 3578 // Return a result of -1, 0, or 1, based on status bits. |
3578 __ mov(r0, Operand(EQUAL), LeaveCC, eq); | 3579 __ mov(r0, Operand(EQUAL), LeaveCC, eq); |
3579 __ mov(r0, Operand(LESS), LeaveCC, lt); | 3580 __ mov(r0, Operand(LESS), LeaveCC, lt); |
3580 __ mov(r0, Operand(GREATER), LeaveCC, gt); | 3581 __ mov(r0, Operand(GREATER), LeaveCC, gt); |
3581 __ Ret(); | 3582 __ Ret(); |
3582 | 3583 |
3583 __ bind(&unordered); | 3584 __ bind(&unordered); |
3584 __ bind(&generic_stub); | 3585 __ bind(&generic_stub); |
3585 CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC, | 3586 CompareICStub stub(isolate(), op(), strength(), CompareICState::GENERIC, |
3586 CompareICState::GENERIC, CompareICState::GENERIC); | 3587 CompareICState::GENERIC, CompareICState::GENERIC); |
3587 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 3588 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
3588 | 3589 |
3589 __ bind(&maybe_undefined1); | 3590 __ bind(&maybe_undefined1); |
3590 if (Token::IsOrderedRelationalCompareOp(op())) { | 3591 if (Token::IsOrderedRelationalCompareOp(op())) { |
3591 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); | 3592 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); |
3592 __ b(ne, &miss); | 3593 __ b(ne, &miss); |
3593 __ JumpIfSmi(r1, &unordered); | 3594 __ JumpIfSmi(r1, &unordered); |
3594 __ CompareObjectType(r1, r2, r2, HEAP_NUMBER_TYPE); | 3595 __ CompareObjectType(r1, r2, r2, HEAP_NUMBER_TYPE); |
3595 __ b(ne, &maybe_undefined2); | 3596 __ b(ne, &maybe_undefined2); |
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5359 MemOperand(fp, 6 * kPointerSize), NULL); | 5360 MemOperand(fp, 6 * kPointerSize), NULL); |
5360 } | 5361 } |
5361 | 5362 |
5362 | 5363 |
5363 #undef __ | 5364 #undef __ |
5364 | 5365 |
5365 } // namespace internal | 5366 } // namespace internal |
5366 } // namespace v8 | 5367 } // namespace v8 |
5367 | 5368 |
5368 #endif // V8_TARGET_ARCH_ARM | 5369 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |