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_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 85 |
86 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( | 86 void InternalArrayNArgumentsConstructorStub::InitializeDescriptor( |
87 CodeStubDescriptor* descriptor) { | 87 CodeStubDescriptor* descriptor) { |
88 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); | 88 InitializeInternalArrayConstructorDescriptor(isolate(), descriptor, -1); |
89 } | 89 } |
90 | 90 |
91 | 91 |
92 #define __ ACCESS_MASM(masm) | 92 #define __ ACCESS_MASM(masm) |
93 | 93 |
94 | 94 |
95 static void EmitIdenticalObjectComparison(MacroAssembler* masm, | 95 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
96 Label* slow, | 96 Condition cc, bool strong); |
97 Condition cc); | |
98 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 97 static void EmitSmiNonsmiComparison(MacroAssembler* masm, |
99 Register lhs, | 98 Register lhs, |
100 Register rhs, | 99 Register rhs, |
101 Label* rhs_not_nan, | 100 Label* rhs_not_nan, |
102 Label* slow, | 101 Label* slow, |
103 bool strict); | 102 bool strict); |
104 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, | 103 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, |
105 Register lhs, | 104 Register lhs, |
106 Register rhs); | 105 Register rhs); |
107 | 106 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 __ bind(&done); | 264 __ bind(&done); |
266 | 265 |
267 __ Pop(scratch, scratch2, scratch3); | 266 __ Pop(scratch, scratch2, scratch3); |
268 __ Ret(); | 267 __ Ret(); |
269 } | 268 } |
270 | 269 |
271 | 270 |
272 // Handle the case where the lhs and rhs are the same object. | 271 // Handle the case where the lhs and rhs are the same object. |
273 // Equality is almost reflexive (everything but NaN), so this is a test | 272 // Equality is almost reflexive (everything but NaN), so this is a test |
274 // for "identity and not NaN". | 273 // for "identity and not NaN". |
275 static void EmitIdenticalObjectComparison(MacroAssembler* masm, | 274 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
276 Label* slow, | 275 Condition cc, bool strong) { |
277 Condition cc) { | |
278 Label not_identical; | 276 Label not_identical; |
279 Label heap_number, return_equal; | 277 Label heap_number, return_equal; |
280 Register exp_mask_reg = t1; | 278 Register exp_mask_reg = t1; |
281 | 279 |
282 __ Branch(¬_identical, ne, a0, Operand(a1)); | 280 __ Branch(¬_identical, ne, a0, Operand(a1)); |
283 | 281 |
284 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask)); | 282 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask)); |
285 | 283 |
286 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), | 284 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), |
287 // so we do the second best thing - test it ourselves. | 285 // so we do the second best thing - test it ourselves. |
288 // They are both equal and they are not both Smis so both of them are not | 286 // They are both equal and they are not both Smis so both of them are not |
289 // Smis. If it's not a heap number, then return equal. | 287 // Smis. If it's not a heap number, then return equal. |
290 __ GetObjectType(a0, t0, t0); | 288 __ GetObjectType(a0, t0, t0); |
291 if (cc == less || cc == greater) { | 289 if (cc == less || cc == greater) { |
| 290 // Call runtime on identical JSObjects. |
292 __ Branch(slow, greater, t0, Operand(FIRST_SPEC_OBJECT_TYPE)); | 291 __ Branch(slow, greater, t0, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 292 // Call runtime on identical symbols since we need to throw a TypeError. |
293 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE)); | 293 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE)); |
| 294 if (strong) { |
| 295 // Call the runtime on anything that is converted in the semantics, since |
| 296 // we need to throw a TypeError. Smis have already been ruled out. |
| 297 __ Branch(&return_equal, eq, t0, Operand(HEAP_NUMBER_TYPE)); |
| 298 __ And(t0, t0, Operand(kIsNotStringMask)); |
| 299 __ Branch(slow, ne, t0, Operand(zero_reg)); |
| 300 } |
294 } else { | 301 } else { |
295 __ Branch(&heap_number, eq, t0, Operand(HEAP_NUMBER_TYPE)); | 302 __ Branch(&heap_number, eq, t0, Operand(HEAP_NUMBER_TYPE)); |
296 // Comparing JS objects with <=, >= is complicated. | 303 // Comparing JS objects with <=, >= is complicated. |
297 if (cc != eq) { | 304 if (cc != eq) { |
298 __ Branch(slow, greater, t0, Operand(FIRST_SPEC_OBJECT_TYPE)); | 305 __ Branch(slow, greater, t0, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 306 // Call runtime on identical symbols since we need to throw a TypeError. |
299 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE)); | 307 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE)); |
| 308 if (strong) { |
| 309 // Call the runtime on anything that is converted in the semantics, |
| 310 // since we need to throw a TypeError. Smis and heap numbers have |
| 311 // already been ruled out. |
| 312 __ And(t0, t0, Operand(kIsNotStringMask)); |
| 313 __ Branch(slow, ne, t0, Operand(zero_reg)); |
| 314 } |
300 // Normally here we fall through to return_equal, but undefined is | 315 // Normally here we fall through to return_equal, but undefined is |
301 // special: (undefined == undefined) == true, but | 316 // special: (undefined == undefined) == true, but |
302 // (undefined <= undefined) == false! See ECMAScript 11.8.5. | 317 // (undefined <= undefined) == false! See ECMAScript 11.8.5. |
303 if (cc == less_equal || cc == greater_equal) { | 318 if (cc == less_equal || cc == greater_equal) { |
304 __ Branch(&return_equal, ne, t0, Operand(ODDBALL_TYPE)); | 319 __ Branch(&return_equal, ne, t0, Operand(ODDBALL_TYPE)); |
305 __ LoadRoot(a6, Heap::kUndefinedValueRootIndex); | 320 __ LoadRoot(a6, Heap::kUndefinedValueRootIndex); |
306 __ Branch(&return_equal, ne, a0, Operand(a6)); | 321 __ Branch(&return_equal, ne, a0, Operand(a6)); |
307 DCHECK(is_int16(GREATER) && is_int16(LESS)); | 322 DCHECK(is_int16(GREATER) && is_int16(LESS)); |
308 __ Ret(USE_DELAY_SLOT); | 323 __ Ret(USE_DELAY_SLOT); |
309 if (cc == le) { | 324 if (cc == le) { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 | 588 |
574 __ Ret(USE_DELAY_SLOT); | 589 __ Ret(USE_DELAY_SLOT); |
575 __ dsubu(v0, a1, a0); | 590 __ dsubu(v0, a1, a0); |
576 __ bind(¬_two_smis); | 591 __ bind(¬_two_smis); |
577 | 592 |
578 // NOTICE! This code is only reached after a smi-fast-case check, so | 593 // NOTICE! This code is only reached after a smi-fast-case check, so |
579 // it is certain that at least one operand isn't a smi. | 594 // it is certain that at least one operand isn't a smi. |
580 | 595 |
581 // Handle the case where the objects are identical. Either returns the answer | 596 // Handle the case where the objects are identical. Either returns the answer |
582 // or goes to slow. Only falls through if the objects were not identical. | 597 // or goes to slow. Only falls through if the objects were not identical. |
583 EmitIdenticalObjectComparison(masm, &slow, cc); | 598 EmitIdenticalObjectComparison(masm, &slow, cc, strong()); |
584 | 599 |
585 // If either is a Smi (we know that not both are), then they can only | 600 // If either is a Smi (we know that not both are), then they can only |
586 // be strictly equal if the other is a HeapNumber. | 601 // be strictly equal if the other is a HeapNumber. |
587 STATIC_ASSERT(kSmiTag == 0); | 602 STATIC_ASSERT(kSmiTag == 0); |
588 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); | 603 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); |
589 __ And(a6, lhs, Operand(rhs)); | 604 __ And(a6, lhs, Operand(rhs)); |
590 __ JumpIfNotSmi(a6, ¬_smis, a4); | 605 __ JumpIfNotSmi(a6, ¬_smis, a4); |
591 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: | 606 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: |
592 // 1) Return the answer. | 607 // 1) Return the answer. |
593 // 2) Go to slow. | 608 // 2) Go to slow. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 716 |
702 __ bind(&slow); | 717 __ bind(&slow); |
703 // Prepare for call to builtin. Push object pointers, a0 (lhs) first, | 718 // Prepare for call to builtin. Push object pointers, a0 (lhs) first, |
704 // a1 (rhs) second. | 719 // a1 (rhs) second. |
705 __ Push(lhs, rhs); | 720 __ Push(lhs, rhs); |
706 // Figure out which native to call and setup the arguments. | 721 // Figure out which native to call and setup the arguments. |
707 Builtins::JavaScript native; | 722 Builtins::JavaScript native; |
708 if (cc == eq) { | 723 if (cc == eq) { |
709 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; | 724 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; |
710 } else { | 725 } else { |
711 native = Builtins::COMPARE; | 726 native = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE; |
712 int ncr; // NaN compare result. | 727 int ncr; // NaN compare result. |
713 if (cc == lt || cc == le) { | 728 if (cc == lt || cc == le) { |
714 ncr = GREATER; | 729 ncr = GREATER; |
715 } else { | 730 } else { |
716 DCHECK(cc == gt || cc == ge); // Remaining cases. | 731 DCHECK(cc == gt || cc == ge); // Remaining cases. |
717 ncr = LESS; | 732 ncr = LESS; |
718 } | 733 } |
719 __ li(a0, Operand(Smi::FromInt(ncr))); | 734 __ li(a0, Operand(Smi::FromInt(ncr))); |
720 __ push(a0); | 735 __ push(a0); |
721 } | 736 } |
(...skipping 3057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3779 __ bind(&fpu_eq); | 3794 __ bind(&fpu_eq); |
3780 __ Ret(USE_DELAY_SLOT); | 3795 __ Ret(USE_DELAY_SLOT); |
3781 __ li(v0, Operand(EQUAL)); | 3796 __ li(v0, Operand(EQUAL)); |
3782 | 3797 |
3783 __ bind(&fpu_lt); | 3798 __ bind(&fpu_lt); |
3784 __ Ret(USE_DELAY_SLOT); | 3799 __ Ret(USE_DELAY_SLOT); |
3785 __ li(v0, Operand(LESS)); | 3800 __ li(v0, Operand(LESS)); |
3786 | 3801 |
3787 __ bind(&unordered); | 3802 __ bind(&unordered); |
3788 __ bind(&generic_stub); | 3803 __ bind(&generic_stub); |
3789 CompareICStub stub(isolate(), op(), CompareICState::GENERIC, | 3804 CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC, |
3790 CompareICState::GENERIC, CompareICState::GENERIC); | 3805 CompareICState::GENERIC, CompareICState::GENERIC); |
3791 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 3806 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
3792 | 3807 |
3793 __ bind(&maybe_undefined1); | 3808 __ bind(&maybe_undefined1); |
3794 if (Token::IsOrderedRelationalCompareOp(op())) { | 3809 if (Token::IsOrderedRelationalCompareOp(op())) { |
3795 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 3810 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
3796 __ Branch(&miss, ne, a0, Operand(at)); | 3811 __ Branch(&miss, ne, a0, Operand(at)); |
3797 __ JumpIfSmi(a1, &unordered); | 3812 __ JumpIfSmi(a1, &unordered); |
3798 __ GetObjectType(a1, a2, a2); | 3813 __ GetObjectType(a1, a2, a2); |
3799 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE)); | 3814 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE)); |
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5543 kStackUnwindSpace, kInvalidStackOffset, | 5558 kStackUnwindSpace, kInvalidStackOffset, |
5544 MemOperand(fp, 6 * kPointerSize), NULL); | 5559 MemOperand(fp, 6 * kPointerSize), NULL); |
5545 } | 5560 } |
5546 | 5561 |
5547 | 5562 |
5548 #undef __ | 5563 #undef __ |
5549 | 5564 |
5550 } } // namespace v8::internal | 5565 } } // namespace v8::internal |
5551 | 5566 |
5552 #endif // V8_TARGET_ARCH_MIPS64 | 5567 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |