| 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 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
| 6 | 6 |
| 7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
| 8 #include "src/ic/ic.h" | 8 #include "src/ic/ic.h" |
| 9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
| 10 #include "src/interface-descriptors.h" | 10 #include "src/interface-descriptors.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 #define __ ACCESS_MASM(masm) | 15 #define __ ACCESS_MASM(masm) |
| 16 | 16 |
| 17 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, | 17 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, |
| 18 Code::Flags flags, StubCache::Table table, | 18 StubCache::Table table, Register receiver, Register name, |
| 19 Register receiver, Register name, | |
| 20 // The offset is scaled by 4, based on | 19 // The offset is scaled by 4, based on |
| 21 // kCacheIndexShift, which is two bits | 20 // kCacheIndexShift, which is two bits |
| 22 Register offset, Register scratch, Register scratch2, | 21 Register offset, Register scratch, Register scratch2, |
| 23 Register offset_scratch) { | 22 Register offset_scratch) { |
| 24 ExternalReference key_offset(stub_cache->key_reference(table)); | 23 ExternalReference key_offset(stub_cache->key_reference(table)); |
| 25 ExternalReference value_offset(stub_cache->value_reference(table)); | 24 ExternalReference value_offset(stub_cache->value_reference(table)); |
| 26 ExternalReference map_offset(stub_cache->map_reference(table)); | 25 ExternalReference map_offset(stub_cache->map_reference(table)); |
| 27 | 26 |
| 28 uint64_t key_off_addr = reinterpret_cast<uint64_t>(key_offset.address()); | 27 uint64_t key_off_addr = reinterpret_cast<uint64_t>(key_offset.address()); |
| 29 uint64_t value_off_addr = reinterpret_cast<uint64_t>(value_offset.address()); | 28 uint64_t value_off_addr = reinterpret_cast<uint64_t>(value_offset.address()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 58 static_cast<int32_t>(map_off_addr - key_off_addr))); | 57 static_cast<int32_t>(map_off_addr - key_off_addr))); |
| 59 __ ld(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 58 __ ld(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 60 __ Branch(&miss, ne, at, Operand(scratch2)); | 59 __ Branch(&miss, ne, at, Operand(scratch2)); |
| 61 | 60 |
| 62 // Get the code entry from the cache. | 61 // Get the code entry from the cache. |
| 63 Register code = scratch2; | 62 Register code = scratch2; |
| 64 scratch2 = no_reg; | 63 scratch2 = no_reg; |
| 65 __ ld(code, MemOperand(base_addr, | 64 __ ld(code, MemOperand(base_addr, |
| 66 static_cast<int32_t>(value_off_addr - key_off_addr))); | 65 static_cast<int32_t>(value_off_addr - key_off_addr))); |
| 67 | 66 |
| 68 // Check that the flags match what we're looking for. | |
| 69 Register flags_reg = base_addr; | |
| 70 base_addr = no_reg; | |
| 71 __ lw(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); | |
| 72 __ And(flags_reg, flags_reg, Operand(~Code::kFlagsNotUsedInLookup)); | |
| 73 __ Branch(&miss, ne, flags_reg, Operand(flags)); | |
| 74 | |
| 75 #ifdef DEBUG | 67 #ifdef DEBUG |
| 76 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 68 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
| 77 __ jmp(&miss); | 69 __ jmp(&miss); |
| 78 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 70 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
| 79 __ jmp(&miss); | 71 __ jmp(&miss); |
| 80 } | 72 } |
| 81 #endif | 73 #endif |
| 82 | 74 |
| 83 // Jump to the first instruction in the code stub. | 75 // Jump to the first instruction in the code stub. |
| 84 __ Daddu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 76 __ Daddu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 85 __ Jump(at); | 77 __ Jump(at); |
| 86 | 78 |
| 87 // Miss: fall through. | 79 // Miss: fall through. |
| 88 __ bind(&miss); | 80 __ bind(&miss); |
| 89 } | 81 } |
| 90 | 82 |
| 91 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, | 83 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
| 92 Register name, Register scratch, Register extra, | 84 Register name, Register scratch, Register extra, |
| 93 Register extra2, Register extra3) { | 85 Register extra2, Register extra3) { |
| 94 Code::Flags flags = | |
| 95 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); | |
| 96 | |
| 97 Label miss; | 86 Label miss; |
| 98 | 87 |
| 99 // Make sure that code is valid. The multiplying code relies on the | 88 // Make sure that code is valid. The multiplying code relies on the |
| 100 // entry size being 12. | 89 // entry size being 12. |
| 101 // DCHECK(sizeof(Entry) == 12); | 90 // DCHECK(sizeof(Entry) == 12); |
| 102 // DCHECK(sizeof(Entry) == 3 * kPointerSize); | 91 // DCHECK(sizeof(Entry) == 3 * kPointerSize); |
| 103 | 92 |
| 104 // Make sure that there are no register conflicts. | 93 // Make sure that there are no register conflicts. |
| 105 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); | 94 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); |
| 106 | 95 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 132 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, | 121 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, |
| 133 extra3); | 122 extra3); |
| 134 | 123 |
| 135 // Check that the receiver isn't a smi. | 124 // Check that the receiver isn't a smi. |
| 136 __ JumpIfSmi(receiver, &miss); | 125 __ JumpIfSmi(receiver, &miss); |
| 137 | 126 |
| 138 // Get the map of the receiver and compute the hash. | 127 // Get the map of the receiver and compute the hash. |
| 139 __ lwu(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 128 __ lwu(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
| 140 __ ld(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 129 __ ld(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 141 __ Addu(scratch, scratch, at); | 130 __ Addu(scratch, scratch, at); |
| 142 __ Xor(scratch, scratch, Operand(flags)); | 131 __ Xor(scratch, scratch, Operand(kPrimaryMagic)); |
| 143 __ And(scratch, scratch, | 132 __ And(scratch, scratch, |
| 144 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); | 133 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); |
| 145 | 134 |
| 146 // Probe the primary table. | 135 // Probe the primary table. |
| 147 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, | 136 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2, |
| 148 extra2, extra3); | 137 extra3); |
| 149 | 138 |
| 150 // Primary miss: Compute hash for secondary probe. | 139 // Primary miss: Compute hash for secondary probe. |
| 151 __ Subu(scratch, scratch, name); | 140 __ Subu(scratch, scratch, name); |
| 152 __ Addu(scratch, scratch, flags); | 141 __ Addu(scratch, scratch, kSecondaryMagic); |
| 153 __ And(scratch, scratch, | 142 __ And(scratch, scratch, |
| 154 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); | 143 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); |
| 155 | 144 |
| 156 // Probe the secondary table. | 145 // Probe the secondary table. |
| 157 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, | 146 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2, |
| 158 extra2, extra3); | 147 extra3); |
| 159 | 148 |
| 160 // Cache miss: Fall-through and let caller handle the miss by | 149 // Cache miss: Fall-through and let caller handle the miss by |
| 161 // entering the runtime system. | 150 // entering the runtime system. |
| 162 __ bind(&miss); | 151 __ bind(&miss); |
| 163 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 152 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
| 164 extra3); | 153 extra3); |
| 165 } | 154 } |
| 166 | 155 |
| 167 | 156 |
| 168 #undef __ | 157 #undef __ |
| 169 } // namespace internal | 158 } // namespace internal |
| 170 } // namespace v8 | 159 } // namespace v8 |
| 171 | 160 |
| 172 #endif // V8_TARGET_ARCH_MIPS64 | 161 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |