| 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 <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
| 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/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 sll(scratch, reg0, 11); | 612 sll(scratch, reg0, 11); |
| 613 Lsa(reg0, reg0, reg0, 3); | 613 Lsa(reg0, reg0, reg0, 3); |
| 614 addu(reg0, reg0, scratch); | 614 addu(reg0, reg0, scratch); |
| 615 | 615 |
| 616 // hash = hash ^ (hash >> 16); | 616 // hash = hash ^ (hash >> 16); |
| 617 srl(at, reg0, 16); | 617 srl(at, reg0, 16); |
| 618 xor_(reg0, reg0, at); | 618 xor_(reg0, reg0, at); |
| 619 And(reg0, reg0, Operand(0x3fffffff)); | 619 And(reg0, reg0, Operand(0x3fffffff)); |
| 620 } | 620 } |
| 621 | 621 |
| 622 | |
| 623 void MacroAssembler::LoadFromNumberDictionary(Label* miss, | |
| 624 Register elements, | |
| 625 Register key, | |
| 626 Register result, | |
| 627 Register reg0, | |
| 628 Register reg1, | |
| 629 Register reg2) { | |
| 630 // Register use: | |
| 631 // | |
| 632 // elements - holds the slow-case elements of the receiver on entry. | |
| 633 // Unchanged unless 'result' is the same register. | |
| 634 // | |
| 635 // key - holds the smi key on entry. | |
| 636 // Unchanged unless 'result' is the same register. | |
| 637 // | |
| 638 // | |
| 639 // result - holds the result on exit if the load succeeded. | |
| 640 // Allowed to be the same as 'key' or 'result'. | |
| 641 // Unchanged on bailout so 'key' or 'result' can be used | |
| 642 // in further computation. | |
| 643 // | |
| 644 // Scratch registers: | |
| 645 // | |
| 646 // reg0 - holds the untagged key on entry and holds the hash once computed. | |
| 647 // | |
| 648 // reg1 - Used to hold the capacity mask of the dictionary. | |
| 649 // | |
| 650 // reg2 - Used for the index into the dictionary. | |
| 651 // at - Temporary (avoid MacroAssembler instructions also using 'at'). | |
| 652 Label done; | |
| 653 | |
| 654 GetNumberHash(reg0, reg1); | |
| 655 | |
| 656 // Compute the capacity mask. | |
| 657 lw(reg1, FieldMemOperand(elements, SeededNumberDictionary::kCapacityOffset)); | |
| 658 sra(reg1, reg1, kSmiTagSize); | |
| 659 Subu(reg1, reg1, Operand(1)); | |
| 660 | |
| 661 // Generate an unrolled loop that performs a few probes before giving up. | |
| 662 for (int i = 0; i < kNumberDictionaryProbes; i++) { | |
| 663 // Use reg2 for index calculations and keep the hash intact in reg0. | |
| 664 mov(reg2, reg0); | |
| 665 // Compute the masked index: (hash + i + i * i) & mask. | |
| 666 if (i > 0) { | |
| 667 Addu(reg2, reg2, Operand(SeededNumberDictionary::GetProbeOffset(i))); | |
| 668 } | |
| 669 and_(reg2, reg2, reg1); | |
| 670 | |
| 671 // Scale the index by multiplying by the element size. | |
| 672 DCHECK(SeededNumberDictionary::kEntrySize == 3); | |
| 673 Lsa(reg2, reg2, reg2, 1); // reg2 = reg2 * 3. | |
| 674 | |
| 675 // Check if the key is identical to the name. | |
| 676 Lsa(reg2, elements, reg2, kPointerSizeLog2); | |
| 677 | |
| 678 lw(at, FieldMemOperand(reg2, SeededNumberDictionary::kElementsStartOffset)); | |
| 679 if (i != kNumberDictionaryProbes - 1) { | |
| 680 Branch(&done, eq, key, Operand(at)); | |
| 681 } else { | |
| 682 Branch(miss, ne, key, Operand(at)); | |
| 683 } | |
| 684 } | |
| 685 | |
| 686 bind(&done); | |
| 687 // Check that the value is a field property. | |
| 688 // reg2: elements + (index * kPointerSize). | |
| 689 const int kDetailsOffset = | |
| 690 SeededNumberDictionary::kElementsStartOffset + 2 * kPointerSize; | |
| 691 lw(reg1, FieldMemOperand(reg2, kDetailsOffset)); | |
| 692 DCHECK_EQ(DATA, 0); | |
| 693 And(at, reg1, Operand(Smi::FromInt(PropertyDetails::TypeField::kMask))); | |
| 694 Branch(miss, ne, at, Operand(zero_reg)); | |
| 695 | |
| 696 // Get the value at the masked, scaled index and return. | |
| 697 const int kValueOffset = | |
| 698 SeededNumberDictionary::kElementsStartOffset + kPointerSize; | |
| 699 lw(result, FieldMemOperand(reg2, kValueOffset)); | |
| 700 } | |
| 701 | |
| 702 | |
| 703 // --------------------------------------------------------------------------- | 622 // --------------------------------------------------------------------------- |
| 704 // Instruction macros. | 623 // Instruction macros. |
| 705 | 624 |
| 706 void MacroAssembler::Addu(Register rd, Register rs, const Operand& rt) { | 625 void MacroAssembler::Addu(Register rd, Register rs, const Operand& rt) { |
| 707 if (rt.is_reg()) { | 626 if (rt.is_reg()) { |
| 708 addu(rd, rs, rt.rm()); | 627 addu(rd, rs, rt.rm()); |
| 709 } else { | 628 } else { |
| 710 if (is_int16(rt.imm32_) && !MustUseReg(rt.rmode_)) { | 629 if (is_int16(rt.imm32_) && !MustUseReg(rt.rmode_)) { |
| 711 addiu(rd, rs, rt.imm32_); | 630 addiu(rd, rs, rt.imm32_); |
| 712 } else { | 631 } else { |
| (...skipping 4015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4728 Register filler) { | 4647 Register filler) { |
| 4729 Label loop, entry; | 4648 Label loop, entry; |
| 4730 Branch(&entry); | 4649 Branch(&entry); |
| 4731 bind(&loop); | 4650 bind(&loop); |
| 4732 sw(filler, MemOperand(current_address)); | 4651 sw(filler, MemOperand(current_address)); |
| 4733 Addu(current_address, current_address, kPointerSize); | 4652 Addu(current_address, current_address, kPointerSize); |
| 4734 bind(&entry); | 4653 bind(&entry); |
| 4735 Branch(&loop, ult, current_address, Operand(end_address)); | 4654 Branch(&loop, ult, current_address, Operand(end_address)); |
| 4736 } | 4655 } |
| 4737 | 4656 |
| 4738 | |
| 4739 void MacroAssembler::CheckFastElements(Register map, | |
| 4740 Register scratch, | |
| 4741 Label* fail) { | |
| 4742 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); | |
| 4743 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); | |
| 4744 STATIC_ASSERT(FAST_ELEMENTS == 2); | |
| 4745 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); | |
| 4746 lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset)); | |
| 4747 Branch(fail, hi, scratch, | |
| 4748 Operand(Map::kMaximumBitField2FastHoleyElementValue)); | |
| 4749 } | |
| 4750 | |
| 4751 | |
| 4752 void MacroAssembler::CheckFastObjectElements(Register map, | 4657 void MacroAssembler::CheckFastObjectElements(Register map, |
| 4753 Register scratch, | 4658 Register scratch, |
| 4754 Label* fail) { | 4659 Label* fail) { |
| 4755 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); | 4660 STATIC_ASSERT(FAST_SMI_ELEMENTS == 0); |
| 4756 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); | 4661 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == 1); |
| 4757 STATIC_ASSERT(FAST_ELEMENTS == 2); | 4662 STATIC_ASSERT(FAST_ELEMENTS == 2); |
| 4758 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); | 4663 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == 3); |
| 4759 lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset)); | 4664 lbu(scratch, FieldMemOperand(map, Map::kBitField2Offset)); |
| 4760 Branch(fail, ls, scratch, | 4665 Branch(fail, ls, scratch, |
| 4761 Operand(Map::kMaximumBitField2FastHoleySmiElementValue)); | 4666 Operand(Map::kMaximumBitField2FastHoleySmiElementValue)); |
| (...skipping 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6985 if (mag.shift > 0) sra(result, result, mag.shift); | 6890 if (mag.shift > 0) sra(result, result, mag.shift); |
| 6986 srl(at, dividend, 31); | 6891 srl(at, dividend, 31); |
| 6987 Addu(result, result, Operand(at)); | 6892 Addu(result, result, Operand(at)); |
| 6988 } | 6893 } |
| 6989 | 6894 |
| 6990 | 6895 |
| 6991 } // namespace internal | 6896 } // namespace internal |
| 6992 } // namespace v8 | 6897 } // namespace v8 |
| 6993 | 6898 |
| 6994 #endif // V8_TARGET_ARCH_MIPS | 6899 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |