| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, Label* slow, | 95 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
| 96 Condition cc, bool strong); | 96 Condition cc, Strength strength); |
| 97 static void EmitSmiNonsmiComparison(MacroAssembler* masm, | 97 static void EmitSmiNonsmiComparison(MacroAssembler* masm, |
| 98 Register lhs, | 98 Register lhs, |
| 99 Register rhs, | 99 Register rhs, |
| 100 Label* rhs_not_nan, | 100 Label* rhs_not_nan, |
| 101 Label* slow, | 101 Label* slow, |
| 102 bool strict); | 102 bool strict); |
| 103 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, | 103 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, |
| 104 Register lhs, | 104 Register lhs, |
| 105 Register rhs); | 105 Register rhs); |
| 106 | 106 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 265 |
| 266 __ Pop(scratch, scratch2, scratch3); | 266 __ Pop(scratch, scratch2, scratch3); |
| 267 __ Ret(); | 267 __ Ret(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 | 270 |
| 271 // 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. |
| 272 // 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 |
| 273 // for "identity and not NaN". | 273 // for "identity and not NaN". |
| 274 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, | 274 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
| 275 Condition cc, bool strong) { | 275 Condition cc, Strength strength) { |
| 276 Label not_identical; | 276 Label not_identical; |
| 277 Label heap_number, return_equal; | 277 Label heap_number, return_equal; |
| 278 Register exp_mask_reg = t1; | 278 Register exp_mask_reg = t1; |
| 279 | 279 |
| 280 __ Branch(¬_identical, ne, a0, Operand(a1)); | 280 __ Branch(¬_identical, ne, a0, Operand(a1)); |
| 281 | 281 |
| 282 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask)); | 282 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask)); |
| 283 | 283 |
| 284 // 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(), |
| 285 // so we do the second best thing - test it ourselves. | 285 // so we do the second best thing - test it ourselves. |
| 286 // 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 |
| 287 // Smis. If it's not a heap number, then return equal. | 287 // Smis. If it's not a heap number, then return equal. |
| 288 __ GetObjectType(a0, t0, t0); | 288 __ GetObjectType(a0, t0, t0); |
| 289 if (cc == less || cc == greater) { | 289 if (cc == less || cc == greater) { |
| 290 // Call runtime on identical JSObjects. | 290 // Call runtime on identical JSObjects. |
| 291 __ 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. | 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) { | 294 if (is_strong(strength)) { |
| 295 // Call the runtime on anything that is converted in the semantics, since | 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. | 296 // we need to throw a TypeError. Smis have already been ruled out. |
| 297 __ Branch(&return_equal, eq, t0, Operand(HEAP_NUMBER_TYPE)); | 297 __ Branch(&return_equal, eq, t0, Operand(HEAP_NUMBER_TYPE)); |
| 298 __ And(t0, t0, Operand(kIsNotStringMask)); | 298 __ And(t0, t0, Operand(kIsNotStringMask)); |
| 299 __ Branch(slow, ne, t0, Operand(zero_reg)); | 299 __ Branch(slow, ne, t0, Operand(zero_reg)); |
| 300 } | 300 } |
| 301 } else { | 301 } else { |
| 302 __ Branch(&heap_number, eq, t0, Operand(HEAP_NUMBER_TYPE)); | 302 __ Branch(&heap_number, eq, t0, Operand(HEAP_NUMBER_TYPE)); |
| 303 // Comparing JS objects with <=, >= is complicated. | 303 // Comparing JS objects with <=, >= is complicated. |
| 304 if (cc != eq) { | 304 if (cc != eq) { |
| 305 __ 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. | 306 // Call runtime on identical symbols since we need to throw a TypeError. |
| 307 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE)); | 307 __ Branch(slow, eq, t0, Operand(SYMBOL_TYPE)); |
| 308 if (strong) { | 308 if (is_strong(strength)) { |
| 309 // Call the runtime on anything that is converted in the semantics, | 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 | 310 // since we need to throw a TypeError. Smis and heap numbers have |
| 311 // already been ruled out. | 311 // already been ruled out. |
| 312 __ And(t0, t0, Operand(kIsNotStringMask)); | 312 __ And(t0, t0, Operand(kIsNotStringMask)); |
| 313 __ Branch(slow, ne, t0, Operand(zero_reg)); | 313 __ Branch(slow, ne, t0, Operand(zero_reg)); |
| 314 } | 314 } |
| 315 // Normally here we fall through to return_equal, but undefined is | 315 // Normally here we fall through to return_equal, but undefined is |
| 316 // special: (undefined == undefined) == true, but | 316 // special: (undefined == undefined) == true, but |
| 317 // (undefined <= undefined) == false! See ECMAScript 11.8.5. | 317 // (undefined <= undefined) == false! See ECMAScript 11.8.5. |
| 318 if (cc == less_equal || cc == greater_equal) { | 318 if (cc == less_equal || cc == greater_equal) { |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 | 588 |
| 589 __ Ret(USE_DELAY_SLOT); | 589 __ Ret(USE_DELAY_SLOT); |
| 590 __ dsubu(v0, a1, a0); | 590 __ dsubu(v0, a1, a0); |
| 591 __ bind(¬_two_smis); | 591 __ bind(¬_two_smis); |
| 592 | 592 |
| 593 // 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 |
| 594 // 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. |
| 595 | 595 |
| 596 // 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 |
| 597 // 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. |
| 598 EmitIdenticalObjectComparison(masm, &slow, cc, strong()); | 598 EmitIdenticalObjectComparison(masm, &slow, cc, strength()); |
| 599 | 599 |
| 600 // 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 |
| 601 // be strictly equal if the other is a HeapNumber. | 601 // be strictly equal if the other is a HeapNumber. |
| 602 STATIC_ASSERT(kSmiTag == 0); | 602 STATIC_ASSERT(kSmiTag == 0); |
| 603 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); | 603 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); |
| 604 __ And(a6, lhs, Operand(rhs)); | 604 __ And(a6, lhs, Operand(rhs)); |
| 605 __ JumpIfNotSmi(a6, ¬_smis, a4); | 605 __ JumpIfNotSmi(a6, ¬_smis, a4); |
| 606 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: | 606 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: |
| 607 // 1) Return the answer. | 607 // 1) Return the answer. |
| 608 // 2) Go to slow. | 608 // 2) Go to slow. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 | 716 |
| 717 __ bind(&slow); | 717 __ bind(&slow); |
| 718 // Prepare for call to builtin. Push object pointers, a0 (lhs) first, | 718 // Prepare for call to builtin. Push object pointers, a0 (lhs) first, |
| 719 // a1 (rhs) second. | 719 // a1 (rhs) second. |
| 720 __ Push(lhs, rhs); | 720 __ Push(lhs, rhs); |
| 721 // Figure out which native to call and setup the arguments. | 721 // Figure out which native to call and setup the arguments. |
| 722 Builtins::JavaScript native; | 722 Builtins::JavaScript native; |
| 723 if (cc == eq) { | 723 if (cc == eq) { |
| 724 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; | 724 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; |
| 725 } else { | 725 } else { |
| 726 native = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE; | 726 native = |
| 727 is_strong(strength()) ? Builtins::COMPARE_STRONG : Builtins::COMPARE; |
| 727 int ncr; // NaN compare result. | 728 int ncr; // NaN compare result. |
| 728 if (cc == lt || cc == le) { | 729 if (cc == lt || cc == le) { |
| 729 ncr = GREATER; | 730 ncr = GREATER; |
| 730 } else { | 731 } else { |
| 731 DCHECK(cc == gt || cc == ge); // Remaining cases. | 732 DCHECK(cc == gt || cc == ge); // Remaining cases. |
| 732 ncr = LESS; | 733 ncr = LESS; |
| 733 } | 734 } |
| 734 __ li(a0, Operand(Smi::FromInt(ncr))); | 735 __ li(a0, Operand(Smi::FromInt(ncr))); |
| 735 __ push(a0); | 736 __ push(a0); |
| 736 } | 737 } |
| (...skipping 3056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3793 __ bind(&fpu_eq); | 3794 __ bind(&fpu_eq); |
| 3794 __ Ret(USE_DELAY_SLOT); | 3795 __ Ret(USE_DELAY_SLOT); |
| 3795 __ li(v0, Operand(EQUAL)); | 3796 __ li(v0, Operand(EQUAL)); |
| 3796 | 3797 |
| 3797 __ bind(&fpu_lt); | 3798 __ bind(&fpu_lt); |
| 3798 __ Ret(USE_DELAY_SLOT); | 3799 __ Ret(USE_DELAY_SLOT); |
| 3799 __ li(v0, Operand(LESS)); | 3800 __ li(v0, Operand(LESS)); |
| 3800 | 3801 |
| 3801 __ bind(&unordered); | 3802 __ bind(&unordered); |
| 3802 __ bind(&generic_stub); | 3803 __ bind(&generic_stub); |
| 3803 CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC, | 3804 CompareICStub stub(isolate(), op(), strength(), CompareICState::GENERIC, |
| 3804 CompareICState::GENERIC, CompareICState::GENERIC); | 3805 CompareICState::GENERIC, CompareICState::GENERIC); |
| 3805 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 3806 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 3806 | 3807 |
| 3807 __ bind(&maybe_undefined1); | 3808 __ bind(&maybe_undefined1); |
| 3808 if (Token::IsOrderedRelationalCompareOp(op())) { | 3809 if (Token::IsOrderedRelationalCompareOp(op())) { |
| 3809 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 3810 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
| 3810 __ Branch(&miss, ne, a0, Operand(at)); | 3811 __ Branch(&miss, ne, a0, Operand(at)); |
| 3811 __ JumpIfSmi(a1, &unordered); | 3812 __ JumpIfSmi(a1, &unordered); |
| 3812 __ GetObjectType(a1, a2, a2); | 3813 __ GetObjectType(a1, a2, a2); |
| 3813 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE)); | 3814 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE)); |
| (...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5608 MemOperand(fp, 6 * kPointerSize), NULL); | 5609 MemOperand(fp, 6 * kPointerSize), NULL); |
| 5609 } | 5610 } |
| 5610 | 5611 |
| 5611 | 5612 |
| 5612 #undef __ | 5613 #undef __ |
| 5613 | 5614 |
| 5614 } // namespace internal | 5615 } // namespace internal |
| 5615 } // namespace v8 | 5616 } // namespace v8 |
| 5616 | 5617 |
| 5617 #endif // V8_TARGET_ARCH_MIPS64 | 5618 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |