| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 7 #if V8_TARGET_ARCH_PPC |
| 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, Register lhs, | 98 static void EmitSmiNonsmiComparison(MacroAssembler* masm, Register lhs, |
| 99 Register rhs, Label* lhs_not_nan, | 99 Register rhs, Label* lhs_not_nan, |
| 100 Label* slow, bool strict); | 100 Label* slow, bool strict); |
| 101 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs, | 101 static void EmitStrictTwoHeapObjectCompare(MacroAssembler* masm, Register lhs, |
| 102 Register rhs); | 102 Register rhs); |
| 103 | 103 |
| 104 | 104 |
| 105 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, | 105 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm, |
| 106 ExternalReference miss) { | 106 ExternalReference miss) { |
| 107 // Update the static counter each time a new code stub is generated. | 107 // Update the static counter each time a new code stub is generated. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 __ pop(scratch); | 242 __ pop(scratch); |
| 243 | 243 |
| 244 __ Ret(); | 244 __ Ret(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 | 247 |
| 248 // Handle the case where the lhs and rhs are the same object. | 248 // Handle the case where the lhs and rhs are the same object. |
| 249 // Equality is almost reflexive (everything but NaN), so this is a test | 249 // Equality is almost reflexive (everything but NaN), so this is a test |
| 250 // for "identity and not NaN". | 250 // for "identity and not NaN". |
| 251 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, | 251 static void EmitIdenticalObjectComparison(MacroAssembler* masm, Label* slow, |
| 252 Condition cond, bool strong) { | 252 Condition cond, Strength strength) { |
| 253 Label not_identical; | 253 Label not_identical; |
| 254 Label heap_number, return_equal; | 254 Label heap_number, return_equal; |
| 255 __ cmp(r3, r4); | 255 __ cmp(r3, r4); |
| 256 __ bne(¬_identical); | 256 __ bne(¬_identical); |
| 257 | 257 |
| 258 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), | 258 // Test for NaN. Sadly, we can't just compare to Factory::nan_value(), |
| 259 // so we do the second best thing - test it ourselves. | 259 // so we do the second best thing - test it ourselves. |
| 260 // They are both equal and they are not both Smis so both of them are not | 260 // They are both equal and they are not both Smis so both of them are not |
| 261 // Smis. If it's not a heap number, then return equal. | 261 // Smis. If it's not a heap number, then return equal. |
| 262 if (cond == lt || cond == gt) { | 262 if (cond == lt || cond == gt) { |
| 263 // Call runtime on identical JSObjects. | 263 // Call runtime on identical JSObjects. |
| 264 __ CompareObjectType(r3, r7, r7, FIRST_SPEC_OBJECT_TYPE); | 264 __ CompareObjectType(r3, r7, r7, FIRST_SPEC_OBJECT_TYPE); |
| 265 __ bge(slow); | 265 __ bge(slow); |
| 266 // Call runtime on identical symbols since we need to throw a TypeError. | 266 // Call runtime on identical symbols since we need to throw a TypeError. |
| 267 __ cmpi(r7, Operand(SYMBOL_TYPE)); | 267 __ cmpi(r7, Operand(SYMBOL_TYPE)); |
| 268 __ beq(slow); | 268 __ beq(slow); |
| 269 if (strong) { | 269 if (is_strong(strength)) { |
| 270 // Call the runtime on anything that is converted in the semantics, since | 270 // Call the runtime on anything that is converted in the semantics, since |
| 271 // we need to throw a TypeError. Smis have already been ruled out. | 271 // we need to throw a TypeError. Smis have already been ruled out. |
| 272 __ cmpi(r7, Operand(HEAP_NUMBER_TYPE)); | 272 __ cmpi(r7, Operand(HEAP_NUMBER_TYPE)); |
| 273 __ beq(&return_equal); | 273 __ beq(&return_equal); |
| 274 __ andi(r0, r7, Operand(kIsNotStringMask)); | 274 __ andi(r0, r7, Operand(kIsNotStringMask)); |
| 275 __ bne(slow, cr0); | 275 __ bne(slow, cr0); |
| 276 } | 276 } |
| 277 } else { | 277 } else { |
| 278 __ CompareObjectType(r3, r7, r7, HEAP_NUMBER_TYPE); | 278 __ CompareObjectType(r3, r7, r7, HEAP_NUMBER_TYPE); |
| 279 __ beq(&heap_number); | 279 __ beq(&heap_number); |
| 280 // Comparing JS objects with <=, >= is complicated. | 280 // Comparing JS objects with <=, >= is complicated. |
| 281 if (cond != eq) { | 281 if (cond != eq) { |
| 282 __ cmpi(r7, Operand(FIRST_SPEC_OBJECT_TYPE)); | 282 __ cmpi(r7, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 283 __ bge(slow); | 283 __ bge(slow); |
| 284 // Call runtime on identical symbols since we need to throw a TypeError. | 284 // Call runtime on identical symbols since we need to throw a TypeError. |
| 285 __ cmpi(r7, Operand(SYMBOL_TYPE)); | 285 __ cmpi(r7, Operand(SYMBOL_TYPE)); |
| 286 __ beq(slow); | 286 __ beq(slow); |
| 287 if (strong) { | 287 if (is_strong(strength)) { |
| 288 // Call the runtime on anything that is converted in the semantics, | 288 // Call the runtime on anything that is converted in the semantics, |
| 289 // since we need to throw a TypeError. Smis and heap numbers have | 289 // since we need to throw a TypeError. Smis and heap numbers have |
| 290 // already been ruled out. | 290 // already been ruled out. |
| 291 __ andi(r0, r7, Operand(kIsNotStringMask)); | 291 __ andi(r0, r7, Operand(kIsNotStringMask)); |
| 292 __ bne(slow, cr0); | 292 __ bne(slow, cr0); |
| 293 } | 293 } |
| 294 // Normally here we fall through to return_equal, but undefined is | 294 // Normally here we fall through to return_equal, but undefined is |
| 295 // special: (undefined == undefined) == true, but | 295 // special: (undefined == undefined) == true, but |
| 296 // (undefined <= undefined) == false! See ECMAScript 11.8.5. | 296 // (undefined <= undefined) == false! See ECMAScript 11.8.5. |
| 297 if (cond == le || cond == ge) { | 297 if (cond == le || cond == ge) { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 __ SmiUntag(r3); | 587 __ SmiUntag(r3); |
| 588 __ sub(r3, r4, r3); | 588 __ sub(r3, r4, r3); |
| 589 __ Ret(); | 589 __ Ret(); |
| 590 __ bind(¬_two_smis); | 590 __ bind(¬_two_smis); |
| 591 | 591 |
| 592 // NOTICE! This code is only reached after a smi-fast-case check, so | 592 // NOTICE! This code is only reached after a smi-fast-case check, so |
| 593 // it is certain that at least one operand isn't a smi. | 593 // it is certain that at least one operand isn't a smi. |
| 594 | 594 |
| 595 // Handle the case where the objects are identical. Either returns the answer | 595 // Handle the case where the objects are identical. Either returns the answer |
| 596 // or goes to slow. Only falls through if the objects were not identical. | 596 // or goes to slow. Only falls through if the objects were not identical. |
| 597 EmitIdenticalObjectComparison(masm, &slow, cc, strong()); | 597 EmitIdenticalObjectComparison(masm, &slow, cc, strength()); |
| 598 | 598 |
| 599 // If either is a Smi (we know that not both are), then they can only | 599 // If either is a Smi (we know that not both are), then they can only |
| 600 // be strictly equal if the other is a HeapNumber. | 600 // be strictly equal if the other is a HeapNumber. |
| 601 STATIC_ASSERT(kSmiTag == 0); | 601 STATIC_ASSERT(kSmiTag == 0); |
| 602 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); | 602 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); |
| 603 __ and_(r5, lhs, rhs); | 603 __ and_(r5, lhs, rhs); |
| 604 __ JumpIfNotSmi(r5, ¬_smis); | 604 __ JumpIfNotSmi(r5, ¬_smis); |
| 605 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: | 605 // One operand is a smi. EmitSmiNonsmiComparison generates code that can: |
| 606 // 1) Return the answer. | 606 // 1) Return the answer. |
| 607 // 2) Go to slow. | 607 // 2) Go to slow. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 // Never falls through to here. | 698 // Never falls through to here. |
| 699 | 699 |
| 700 __ bind(&slow); | 700 __ bind(&slow); |
| 701 | 701 |
| 702 __ Push(lhs, rhs); | 702 __ Push(lhs, rhs); |
| 703 // Figure out which native to call and setup the arguments. | 703 // Figure out which native to call and setup the arguments. |
| 704 Builtins::JavaScript native; | 704 Builtins::JavaScript native; |
| 705 if (cc == eq) { | 705 if (cc == eq) { |
| 706 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; | 706 native = strict() ? Builtins::STRICT_EQUALS : Builtins::EQUALS; |
| 707 } else { | 707 } else { |
| 708 native = strong() ? Builtins::COMPARE_STRONG : Builtins::COMPARE; | 708 native = |
| 709 is_strong(strength()) ? Builtins::COMPARE_STRONG : Builtins::COMPARE; |
| 709 int ncr; // NaN compare result | 710 int ncr; // NaN compare result |
| 710 if (cc == lt || cc == le) { | 711 if (cc == lt || cc == le) { |
| 711 ncr = GREATER; | 712 ncr = GREATER; |
| 712 } else { | 713 } else { |
| 713 DCHECK(cc == gt || cc == ge); // remaining cases | 714 DCHECK(cc == gt || cc == ge); // remaining cases |
| 714 ncr = LESS; | 715 ncr = LESS; |
| 715 } | 716 } |
| 716 __ LoadSmiLiteral(r3, Smi::FromInt(ncr)); | 717 __ LoadSmiLiteral(r3, Smi::FromInt(ncr)); |
| 717 __ push(r3); | 718 __ push(r3); |
| 718 } | 719 } |
| (...skipping 3079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3798 __ bind(&equal); | 3799 __ bind(&equal); |
| 3799 __ li(r3, Operand(EQUAL)); | 3800 __ li(r3, Operand(EQUAL)); |
| 3800 __ Ret(); | 3801 __ Ret(); |
| 3801 __ bind(&less_than); | 3802 __ bind(&less_than); |
| 3802 __ li(r3, Operand(LESS)); | 3803 __ li(r3, Operand(LESS)); |
| 3803 __ Ret(); | 3804 __ Ret(); |
| 3804 } | 3805 } |
| 3805 | 3806 |
| 3806 __ bind(&unordered); | 3807 __ bind(&unordered); |
| 3807 __ bind(&generic_stub); | 3808 __ bind(&generic_stub); |
| 3808 CompareICStub stub(isolate(), op(), strong(), CompareICState::GENERIC, | 3809 CompareICStub stub(isolate(), op(), strength(), CompareICState::GENERIC, |
| 3809 CompareICState::GENERIC, CompareICState::GENERIC); | 3810 CompareICState::GENERIC, CompareICState::GENERIC); |
| 3810 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); | 3811 __ Jump(stub.GetCode(), RelocInfo::CODE_TARGET); |
| 3811 | 3812 |
| 3812 __ bind(&maybe_undefined1); | 3813 __ bind(&maybe_undefined1); |
| 3813 if (Token::IsOrderedRelationalCompareOp(op())) { | 3814 if (Token::IsOrderedRelationalCompareOp(op())) { |
| 3814 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); | 3815 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); |
| 3815 __ bne(&miss); | 3816 __ bne(&miss); |
| 3816 __ JumpIfSmi(r4, &unordered); | 3817 __ JumpIfSmi(r4, &unordered); |
| 3817 __ CompareObjectType(r4, r5, r5, HEAP_NUMBER_TYPE); | 3818 __ CompareObjectType(r4, r5, r5, HEAP_NUMBER_TYPE); |
| 3818 __ bne(&maybe_undefined2); | 3819 __ bne(&maybe_undefined2); |
| (...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5664 kStackUnwindSpace, NULL, | 5665 kStackUnwindSpace, NULL, |
| 5665 MemOperand(fp, 6 * kPointerSize), NULL); | 5666 MemOperand(fp, 6 * kPointerSize), NULL); |
| 5666 } | 5667 } |
| 5667 | 5668 |
| 5668 | 5669 |
| 5669 #undef __ | 5670 #undef __ |
| 5670 } // namespace internal | 5671 } // namespace internal |
| 5671 } // namespace v8 | 5672 } // namespace v8 |
| 5672 | 5673 |
| 5673 #endif // V8_TARGET_ARCH_PPC | 5674 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |