| 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_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
| 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 cc, bool strong); | 97 Condition cc, 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* rhs_not_nan, | 101 Label* rhs_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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 __ Pop(scratch, scratch2, scratch3); | 270 __ Pop(scratch, scratch2, scratch3); |
| 271 __ Ret(); | 271 __ Ret(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 | 274 |
| 275 // Handle the case where the lhs and rhs are the same object. | 275 // Handle the case where the lhs and rhs are the same object. |
| 276 // Equality is almost reflexive (everything but NaN), so this is a test | 276 // Equality is almost reflexive (everything but NaN), so this is a test |
| 277 // for "identity and not NaN". | 277 // for "identity and not NaN". |
| 278 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, | 278 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
| 279 Condition cc, bool strong) { | 279 Condition cc, Strength strength) { |
| 280 Label not_identical; | 280 Label not_identical; |
| 281 Label heap_number, return_equal; | 281 Label heap_number, return_equal; |
| 282 Register exp_mask_reg = t5; | 282 Register exp_mask_reg = t5; |
| 283 | 283 |
| 284 __ Branch(¬_identical, ne, a0, Operand(a1)); | 284 __ Branch(¬_identical, ne, a0, Operand(a1)); |
| 285 | 285 |
| 286 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask)); | 286 __ li(exp_mask_reg, Operand(HeapNumber::kExponentMask)); |
| 287 | 287 |
| 288 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), | 288 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), |
| 289 // so we do the second best thing - test it ourselves. | 289 // so we do the second best thing - test it ourselves. |
| 290 // They are both equal and they are not both Smis so both of them are not | 290 // They are both equal and they are not both Smis so both of them are not |
| 291 // Smis. If it's not a heap number, then return equal. | 291 // Smis. If it's not a heap number, then return equal. |
| 292 __ GetObjectType(a0, t4, t4); | 292 __ GetObjectType(a0, t4, t4); |
| 293 if (cc == less || cc == greater) { | 293 if (cc == less || cc == greater) { |
| 294 // Call runtime on identical JSObjects. | 294 // Call runtime on identical JSObjects. |
| 295 __ Branch(slow, greater, t4, Operand(FIRST_SPEC_OBJECT_TYPE)); | 295 __ Branch(slow, greater, t4, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 296 // Call runtime on identical symbols since we need to throw a TypeError. | 296 // Call runtime on identical symbols since we need to throw a TypeError. |
| 297 __ Branch(slow, eq, t4, Operand(SYMBOL_TYPE)); | 297 __ Branch(slow, eq, t4, Operand(SYMBOL_TYPE)); |
| 298 if (strong) { | 298 if (is_strong(strength)) { |
| 299 // Call the runtime on anything that is converted in the semantics, since | 299 // Call the runtime on anything that is converted in the semantics, since |
| 300 // we need to throw a TypeError. Smis have already been ruled out. | 300 // we need to throw a TypeError. Smis have already been ruled out. |
| 301 __ Branch(&return_equal, eq, t4, Operand(HEAP_NUMBER_TYPE)); | 301 __ Branch(&return_equal, eq, t4, Operand(HEAP_NUMBER_TYPE)); |
| 302 __ And(t4, t4, Operand(kIsNotStringMask)); | 302 __ And(t4, t4, Operand(kIsNotStringMask)); |
| 303 __ Branch(slow, ne, t4, Operand(zero_reg)); | 303 __ Branch(slow, ne, t4, Operand(zero_reg)); |
| 304 } | 304 } |
| 305 } else { | 305 } else { |
| 306 __ Branch(&heap_number, eq, t4, Operand(HEAP_NUMBER_TYPE)); | 306 __ Branch(&heap_number, eq, t4, Operand(HEAP_NUMBER_TYPE)); |
| 307 // Comparing JS objects with <=, >= is complicated. | 307 // Comparing JS objects with <=, >= is complicated. |
| 308 if (cc != eq) { | 308 if (cc != eq) { |
| 309 __ Branch(slow, greater, t4, Operand(FIRST_SPEC_OBJECT_TYPE)); | 309 __ Branch(slow, greater, t4, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 310 // Call runtime on identical symbols since we need to throw a TypeError. | 310 // Call runtime on identical symbols since we need to throw a TypeError. |
| 311 __ Branch(slow, eq, t4, Operand(SYMBOL_TYPE)); | 311 __ Branch(slow, eq, t4, Operand(SYMBOL_TYPE)); |
| 312 if (strong) { | 312 if (is_strong(strength)) { |
| 313 // Call the runtime on anything that is converted in the semantics, | 313 // Call the runtime on anything that is converted in the semantics, |
| 314 // since we need to throw a TypeError. Smis and heap numbers have | 314 // since we need to throw a TypeError. Smis and heap numbers have |
| 315 // already been ruled out. | 315 // already been ruled out. |
| 316 __ And(t4, t4, Operand(kIsNotStringMask)); | 316 __ And(t4, t4, Operand(kIsNotStringMask)); |
| 317 __ Branch(slow, ne, t4, Operand(zero_reg)); | 317 __ Branch(slow, ne, t4, Operand(zero_reg)); |
| 318 } | 318 } |
| 319 // Normally here we fall through to return_equal, but undefined is | 319 // Normally here we fall through to return_equal, but undefined is |
| 320 // special: (undefined == undefined) == true, but | 320 // special: (undefined == undefined) == true, but |
| 321 // (undefined <= undefined) == false! See ECMAScript 11.8.5. | 321 // (undefined <= undefined) == false! See ECMAScript 11.8.5. |
| 322 if (cc == less_equal || cc == greater_equal) { | 322 if (cc == less_equal || cc == greater_equal) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 __ sra(a0, a0, 1); | 593 __ sra(a0, a0, 1); |
| 594 __ Ret(USE_DELAY_SLOT); | 594 __ Ret(USE_DELAY_SLOT); |
| 595 __ subu(v0, a1, a0); | 595 __ subu(v0, a1, a0); |
| 596 __ bind(¬_two_smis); | 596 __ bind(¬_two_smis); |
| 597 | 597 |
| 598 // NOTICE! This code is only reached after a smi-fast-case check, so | 598 // NOTICE! This code is only reached after a smi-fast-case check, so |
| 599 // it is certain that at least one operand isn't a smi. | 599 // it is certain that at least one operand isn't a smi. |
| 600 | 600 |
| 601 // Handle the case where the objects are identical. Either returns the answer | 601 // Handle the case where the objects are identical. Either returns the answer |
| 602 // or goes to slow. Only falls through if the objects were not identical. | 602 // or goes to slow. Only falls through if the objects were not identical. |
| 603 EmitIdenticalObjectComparison(masm, &slow, cc, strong()); | 603 EmitIdenticalObjectComparison(masm, &slow, cc, strength()); |
| 604 | 604 |
| 605 // If either is a Smi (we know that not both are), then they can only | 605 // If either is a Smi (we know that not both are), then they can only |
| 606 // be strictly equal if the other is a HeapNumber. | 606 // be strictly equal if the other is a HeapNumber. |
| 607 STATIC_ASSERT(kSmiTag == 0); | 607 STATIC_ASSERT(kSmiTag == 0); |
| 608 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); | 608 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); |
| 609 __ And(t2, lhs, Operand(rhs)); | 609 __ And(t2, lhs, Operand(rhs)); |
| 610 __ JumpIfNotSmi(t2, ¬_smis, t0); | 610 __ JumpIfNotSmi(t2, ¬_smis, t0); |
| 611 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: | 611 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: |
| 612 // 1) Return the answer. | 612 // 1) Return the answer. |
| 613 // 2) Go to slow. | 613 // 2) Go to slow. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 | 721 |
| 722 __ bind(&slow); | 722 __ bind(&slow); |
| 723 // Prepare for call to builtin. Push object pointers, a0 (lhs) first, | 723 // Prepare for call to builtin. Push object pointers, a0 (lhs) first, |
| 724 // a1 (rhs) second. | 724 // a1 (rhs) second. |
| 725 __ Push(lhs, rhs); | 725 __ Push(lhs, rhs); |
| 726 // Figure out which native to call and setup the arguments. | 726 // Figure out which native to call and setup the arguments. |
| 727 Builtins::JavaScript native; | 727 Builtins::JavaScript native; |
| 728 if (cc == eq) { | 728 if (cc == eq) { |
| 729 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; | 729 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; |
| 730 } else { | 730 } else { |
| 731 native = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE; | 731 native = |
| 732 is_strong(strength()) ? Builtins::COMPARE_STRONG : Builtins::COMPARE; |
| 732 int ncr; // NaN compare result. | 733 int ncr; // NaN compare result. |
| 733 if (cc == lt || cc == le) { | 734 if (cc == lt || cc == le) { |
| 734 ncr = GREATER; | 735 ncr = GREATER; |
| 735 } else { | 736 } else { |
| 736 DCHECK(cc == gt || cc == ge); // Remaining cases. | 737 DCHECK(cc == gt || cc == ge); // Remaining cases. |
| 737 ncr = LESS; | 738 ncr = LESS; |
| 738 } | 739 } |
| 739 __ li(a0, Operand(Smi::FromInt(ncr))); | 740 __ li(a0, Operand(Smi::FromInt(ncr))); |
| 740 __ push(a0); | 741 __ push(a0); |
| 741 } | 742 } |
| (...skipping 3008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3750 __ bind(&fpu_eq); | 3751 __ bind(&fpu_eq); |
| 3751 __ Ret(USE_DELAY_SLOT); | 3752 __ Ret(USE_DELAY_SLOT); |
| 3752 __ li(v0, Operand(EQUAL)); | 3753 __ li(v0, Operand(EQUAL)); |
| 3753 | 3754 |
| 3754 __ bind(&fpu_lt); | 3755 __ bind(&fpu_lt); |
| 3755 __ Ret(USE_DELAY_SLOT); | 3756 __ Ret(USE_DELAY_SLOT); |
| 3756 __ li(v0, Operand(LESS)); | 3757 __ li(v0, Operand(LESS)); |
| 3757 | 3758 |
| 3758 __ bind(&unordered); | 3759 __ bind(&unordered); |
| 3759 __ bind(&generic_stub); | 3760 __ bind(&generic_stub); |
| 3760 CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC, | 3761 CompareICStub stub(isolate(), op(), strength(), CompareICState::GENERIC, |
| 3761 CompareICState::GENERIC, CompareICState::GENERIC); | 3762 CompareICState::GENERIC, CompareICState::GENERIC); |
| 3762 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 3763 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 3763 | 3764 |
| 3764 __ bind(&maybe_undefined1); | 3765 __ bind(&maybe_undefined1); |
| 3765 if (Token::IsOrderedRelationalCompareOp(op())) { | 3766 if (Token::IsOrderedRelationalCompareOp(op())) { |
| 3766 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); | 3767 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); |
| 3767 __ Branch(&miss, ne, a0, Operand(at)); | 3768 __ Branch(&miss, ne, a0, Operand(at)); |
| 3768 __ JumpIfSmi(a1, &unordered); | 3769 __ JumpIfSmi(a1, &unordered); |
| 3769 __ GetObjectType(a1, a2, a2); | 3770 __ GetObjectType(a1, a2, a2); |
| 3770 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE)); | 3771 __ Branch(&maybe_undefined2, ne, a2, Operand(HEAP_NUMBER_TYPE)); |
| (...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5565 MemOperand(fp, 6 * kPointerSize), NULL); | 5566 MemOperand(fp, 6 * kPointerSize), NULL); |
| 5566 } | 5567 } |
| 5567 | 5568 |
| 5568 | 5569 |
| 5569 #undef __ | 5570 #undef __ |
| 5570 | 5571 |
| 5571 } // namespace internal | 5572 } // namespace internal |
| 5572 } // namespace v8 | 5573 } // namespace v8 |
| 5573 | 5574 |
| 5574 #endif // V8_TARGET_ARCH_MIPS | 5575 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |