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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
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, | 96 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
97 Label* slow, | 97 Condition cond, bool strong); |
98 Condition cond); | |
99 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 98 static void EmitSmiNonsmiComparison(MacroAssembler* masm, |
100 Register lhs, | 99 Register lhs, |
101 Register rhs, | 100 Register rhs, |
102 Label* lhs_not_nan, | 101 Label* lhs_not_nan, |
103 Label* slow, | 102 Label* slow, |
104 bool strict); | 103 bool strict); |
105 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, | 104 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, |
106 Register lhs, | 105 Register lhs, |
107 Register rhs); | 106 Register rhs); |
108 | 107 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 __ bind(&done); | 230 __ bind(&done); |
232 | 231 |
233 __ Pop(scratch_high, scratch_low, scratch); | 232 __ Pop(scratch_high, scratch_low, scratch); |
234 __ Ret(); | 233 __ Ret(); |
235 } | 234 } |
236 | 235 |
237 | 236 |
238 // 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. |
239 // 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 |
240 // for "identity and not NaN". | 239 // for "identity and not NaN". |
241 static void EmitIdenticalObjectComparison(MacroAssembler* masm, | 240 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
242 Label* slow, | 241 Condition cond, bool strong) { |
243 Condition cond) { | |
244 Label not_identical; | 242 Label not_identical; |
245 Label heap_number, return_equal; | 243 Label heap_number, return_equal; |
246 __ cmp(r0, r1); | 244 __ cmp(r0, r1); |
247 __ b(ne, ¬_identical); | 245 __ b(ne, ¬_identical); |
248 | 246 |
249 // 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(), |
250 // so we do the second best thing - test it ourselves. | 248 // so we do the second best thing - test it ourselves. |
251 // 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 |
252 // Smis. If it's not a heap number, then return equal. | 250 // Smis. If it's not a heap number, then return equal. |
253 if (cond == lt || cond == gt) { | 251 if (cond == lt || cond == gt) { |
| 252 // Call runtime on identical JSObjects. |
254 __ CompareObjectType(r0, r4, r4, FIRST_SPEC_OBJECT_TYPE); | 253 __ CompareObjectType(r0, r4, r4, FIRST_SPEC_OBJECT_TYPE); |
255 __ b(ge, slow); | 254 __ b(ge, slow); |
| 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) { |
| 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. |
| 261 __ cmp(r4, Operand(HEAP_NUMBER_TYPE)); |
| 262 __ b(eq, &return_equal); |
| 263 __ tst(r4, Operand(kIsNotStringMask)); |
| 264 __ b(ne, slow); |
| 265 } |
258 } else { | 266 } else { |
259 __ CompareObjectType(r0, r4, r4, HEAP_NUMBER_TYPE); | 267 __ CompareObjectType(r0, r4, r4, HEAP_NUMBER_TYPE); |
260 __ b(eq, &heap_number); | 268 __ b(eq, &heap_number); |
261 // Comparing JS objects with <=, >= is complicated. | 269 // Comparing JS objects with <=, >= is complicated. |
262 if (cond != eq) { | 270 if (cond != eq) { |
263 __ cmp(r4, Operand(FIRST_SPEC_OBJECT_TYPE)); | 271 __ cmp(r4, Operand(FIRST_SPEC_OBJECT_TYPE)); |
264 __ b(ge, slow); | 272 __ b(ge, slow); |
| 273 // Call runtime on identical symbols since we need to throw a TypeError. |
265 __ cmp(r4, Operand(SYMBOL_TYPE)); | 274 __ cmp(r4, Operand(SYMBOL_TYPE)); |
266 __ b(eq, slow); | 275 __ b(eq, slow); |
| 276 if (strong) { |
| 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 |
| 279 // already been ruled out. |
| 280 __ tst(r4, Operand(kIsNotStringMask)); |
| 281 __ b(ne, slow); |
| 282 } |
267 // Normally here we fall through to return_equal, but undefined is | 283 // Normally here we fall through to return_equal, but undefined is |
268 // special: (undefined == undefined) == true, but | 284 // special: (undefined == undefined) == true, but |
269 // (undefined <= undefined) == false! See ECMAScript 11.8.5. | 285 // (undefined <= undefined) == false! See ECMAScript 11.8.5. |
270 if (cond == le || cond == ge) { | 286 if (cond == le || cond == ge) { |
271 __ cmp(r4, Operand(ODDBALL_TYPE)); | 287 __ cmp(r4, Operand(ODDBALL_TYPE)); |
272 __ b(ne, &return_equal); | 288 __ b(ne, &return_equal); |
273 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 289 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
274 __ cmp(r0, r2); | 290 __ cmp(r0, r2); |
275 __ b(ne, &return_equal); | 291 __ b(ne, &return_equal); |
276 if (cond == le) { | 292 if (cond == le) { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 __ mov(r1, Operand(r1, ASR, 1)); | 570 __ mov(r1, Operand(r1, ASR, 1)); |
555 __ sub(r0, r1, Operand(r0, ASR, 1)); | 571 __ sub(r0, r1, Operand(r0, ASR, 1)); |
556 __ Ret(); | 572 __ Ret(); |
557 __ bind(¬_two_smis); | 573 __ bind(¬_two_smis); |
558 | 574 |
559 // 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 |
560 // 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. |
561 | 577 |
562 // 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 |
563 // 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. |
564 EmitIdenticalObjectComparison(masm, &slow, cc); | 580 EmitIdenticalObjectComparison(masm, &slow, cc, strong()); |
565 | 581 |
566 // 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 |
567 // be strictly equal if the other is a HeapNumber. | 583 // be strictly equal if the other is a HeapNumber. |
568 STATIC_ASSERT(kSmiTag == 0); | 584 STATIC_ASSERT(kSmiTag == 0); |
569 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); | 585 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); |
570 __ and_(r2, lhs, Operand(rhs)); | 586 __ and_(r2, lhs, Operand(rhs)); |
571 __ JumpIfNotSmi(r2, ¬_smis); | 587 __ JumpIfNotSmi(r2, ¬_smis); |
572 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: | 588 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: |
573 // 1) Return the answer. | 589 // 1) Return the answer. |
574 // 2) Go to slow. | 590 // 2) Go to slow. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 // Never falls through to here. | 672 // Never falls through to here. |
657 | 673 |
658 __ bind(&slow); | 674 __ bind(&slow); |
659 | 675 |
660 __ Push(lhs, rhs); | 676 __ Push(lhs, rhs); |
661 // Figure out which native to call and setup the arguments. | 677 // Figure out which native to call and setup the arguments. |
662 Builtins::JavaScript native; | 678 Builtins::JavaScript native; |
663 if (cc == eq) { | 679 if (cc == eq) { |
664 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; | 680 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; |
665 } else { | 681 } else { |
666 native = Builtins::COMPARE; | 682 native = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE; |
667 int ncr; // NaN compare result | 683 int ncr; // NaN compare result |
668 if (cc == lt || cc == le) { | 684 if (cc == lt || cc == le) { |
669 ncr = GREATER; | 685 ncr = GREATER; |
670 } else { | 686 } else { |
671 DCHECK(cc == gt || cc == ge); // remaining cases | 687 DCHECK(cc == gt || cc == ge); // remaining cases |
672 ncr = LESS; | 688 ncr = LESS; |
673 } | 689 } |
674 __ mov(r0, Operand(Smi::FromInt(ncr))); | 690 __ mov(r0, Operand(Smi::FromInt(ncr))); |
675 __ push(r0); | 691 __ push(r0); |
676 } | 692 } |
(...skipping 2883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3560 __ b(vs, &unordered); | 3576 __ b(vs, &unordered); |
3561 | 3577 |
3562 // 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. |
3563 __ mov(r0, Operand(EQUAL), LeaveCC, eq); | 3579 __ mov(r0, Operand(EQUAL), LeaveCC, eq); |
3564 __ mov(r0, Operand(LESS), LeaveCC, lt); | 3580 __ mov(r0, Operand(LESS), LeaveCC, lt); |
3565 __ mov(r0, Operand(GREATER), LeaveCC, gt); | 3581 __ mov(r0, Operand(GREATER), LeaveCC, gt); |
3566 __ Ret(); | 3582 __ Ret(); |
3567 | 3583 |
3568 __ bind(&unordered); | 3584 __ bind(&unordered); |
3569 __ bind(&generic_stub); | 3585 __ bind(&generic_stub); |
3570 CompareICStub stub(isolate(), op(), CompareICState::GENERIC, | 3586 CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC, |
3571 CompareICState::GENERIC, CompareICState::GENERIC); | 3587 CompareICState::GENERIC, CompareICState::GENERIC); |
3572 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 3588 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
3573 | 3589 |
3574 __ bind(&maybe_undefined1); | 3590 __ bind(&maybe_undefined1); |
3575 if (Token::IsOrderedRelationalCompareOp(op())) { | 3591 if (Token::IsOrderedRelationalCompareOp(op())) { |
3576 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); | 3592 __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); |
3577 __ b(ne, &miss); | 3593 __ b(ne, &miss); |
3578 __ JumpIfSmi(r1, &unordered); | 3594 __ JumpIfSmi(r1, &unordered); |
3579 __ CompareObjectType(r1, r2, r2, HEAP_NUMBER_TYPE); | 3595 __ CompareObjectType(r1, r2, r2, HEAP_NUMBER_TYPE); |
3580 __ b(ne, &maybe_undefined2); | 3596 __ b(ne, &maybe_undefined2); |
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5293 kStackUnwindSpace, NULL, | 5309 kStackUnwindSpace, NULL, |
5294 MemOperand(fp, 6 * kPointerSize), NULL); | 5310 MemOperand(fp, 6 * kPointerSize), NULL); |
5295 } | 5311 } |
5296 | 5312 |
5297 | 5313 |
5298 #undef __ | 5314 #undef __ |
5299 | 5315 |
5300 } } // namespace v8::internal | 5316 } } // namespace v8::internal |
5301 | 5317 |
5302 #endif // V8_TARGET_ARCH_ARM | 5318 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |