| 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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 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 // Number of the cache entry, not scaled. | 19 // Number of the cache entry, not scaled. |
| 21 Register offset, Register scratch, Register scratch2, | 20 Register offset, Register scratch, Register scratch2, |
| 22 Register offset_scratch) { | 21 Register offset_scratch) { |
| 23 ExternalReference key_offset(stub_cache->key_reference(table)); | 22 ExternalReference key_offset(stub_cache->key_reference(table)); |
| 24 ExternalReference value_offset(stub_cache->value_reference(table)); | 23 ExternalReference value_offset(stub_cache->value_reference(table)); |
| 25 ExternalReference map_offset(stub_cache->map_reference(table)); | 24 ExternalReference map_offset(stub_cache->map_reference(table)); |
| 26 | 25 |
| 27 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); | 26 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); |
| 28 uintptr_t value_off_addr = | 27 uintptr_t value_off_addr = |
| 29 reinterpret_cast<uintptr_t>(value_offset.address()); | 28 reinterpret_cast<uintptr_t>(value_offset.address()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); | 64 __ LoadP(ip, MemOperand(base_addr, map_off_addr - key_off_addr)); |
| 66 __ LoadP(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 65 __ LoadP(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 67 __ cmp(ip, scratch2); | 66 __ cmp(ip, scratch2); |
| 68 __ bne(&miss); | 67 __ bne(&miss); |
| 69 | 68 |
| 70 // Get the code entry from the cache. | 69 // Get the code entry from the cache. |
| 71 Register code = scratch2; | 70 Register code = scratch2; |
| 72 scratch2 = no_reg; | 71 scratch2 = no_reg; |
| 73 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); | 72 __ LoadP(code, MemOperand(base_addr, value_off_addr - key_off_addr)); |
| 74 | 73 |
| 74 #ifdef DEBUG |
| 75 // Check that the flags match what we're looking for. | 75 // Check that the flags match what we're looking for. |
| 76 Code::Flags flags = Code::RemoveHolderFromFlags( |
| 77 Code::ComputeHandlerFlags(stub_cache->ic_kind())); |
| 76 Register flags_reg = base_addr; | 78 Register flags_reg = base_addr; |
| 77 base_addr = no_reg; | 79 base_addr = no_reg; |
| 78 __ lwz(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); | 80 __ lwz(flags_reg, FieldMemOperand(code, Code::kFlagsOffset)); |
| 79 | 81 |
| 80 DCHECK(!r0.is(flags_reg)); | 82 DCHECK(!r0.is(flags_reg)); |
| 81 __ li(r0, Operand(Code::kFlagsNotUsedInLookup)); | 83 __ li(r0, Operand(Code::kFlagsNotUsedInLookup)); |
| 82 __ andc(flags_reg, flags_reg, r0); | 84 __ andc(flags_reg, flags_reg, r0); |
| 83 __ mov(r0, Operand(flags)); | 85 __ mov(r0, Operand(flags)); |
| 84 __ cmpl(flags_reg, r0); | 86 __ cmpl(flags_reg, r0); |
| 85 __ bne(&miss); | 87 __ Check(eq, kUnexpectedValue); |
| 86 | 88 |
| 87 #ifdef DEBUG | |
| 88 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | 89 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { |
| 89 __ b(&miss); | 90 __ b(&miss); |
| 90 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | 91 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { |
| 91 __ b(&miss); | 92 __ b(&miss); |
| 92 } | 93 } |
| 93 #endif | 94 #endif |
| 94 | 95 |
| 95 // Jump to the first instruction in the code stub. | 96 // Jump to the first instruction in the code stub. |
| 96 __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag)); | 97 __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 97 __ mtctr(r0); | 98 __ mtctr(r0); |
| 98 __ bctr(); | 99 __ bctr(); |
| 99 | 100 |
| 100 // Miss: fall through. | 101 // Miss: fall through. |
| 101 __ bind(&miss); | 102 __ bind(&miss); |
| 102 } | 103 } |
| 103 | 104 |
| 104 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, | 105 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, |
| 105 Register name, Register scratch, Register extra, | 106 Register name, Register scratch, Register extra, |
| 106 Register extra2, Register extra3) { | 107 Register extra2, Register extra3) { |
| 107 Code::Flags flags = | |
| 108 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_)); | |
| 109 | |
| 110 Label miss; | 108 Label miss; |
| 111 | 109 |
| 112 #if V8_TARGET_ARCH_PPC64 | 110 #if V8_TARGET_ARCH_PPC64 |
| 113 // Make sure that code is valid. The multiplying code relies on the | 111 // Make sure that code is valid. The multiplying code relies on the |
| 114 // entry size being 24. | 112 // entry size being 24. |
| 115 DCHECK(sizeof(Entry) == 24); | 113 DCHECK(sizeof(Entry) == 24); |
| 116 #else | 114 #else |
| 117 // Make sure that code is valid. The multiplying code relies on the | 115 // Make sure that code is valid. The multiplying code relies on the |
| 118 // entry size being 12. | 116 // entry size being 12. |
| 119 DCHECK(sizeof(Entry) == 12); | 117 DCHECK(sizeof(Entry) == 12); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 150 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, | 148 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, |
| 151 extra3); | 149 extra3); |
| 152 | 150 |
| 153 // Check that the receiver isn't a smi. | 151 // Check that the receiver isn't a smi. |
| 154 __ JumpIfSmi(receiver, &miss); | 152 __ JumpIfSmi(receiver, &miss); |
| 155 | 153 |
| 156 // Get the map of the receiver and compute the hash. | 154 // Get the map of the receiver and compute the hash. |
| 157 __ lwz(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | 155 __ lwz(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); |
| 158 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 156 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
| 159 __ add(scratch, scratch, ip); | 157 __ add(scratch, scratch, ip); |
| 160 __ xori(scratch, scratch, Operand(flags)); | |
| 161 // The mask omits the last two bits because they are not part of the hash. | 158 // The mask omits the last two bits because they are not part of the hash. |
| 162 __ andi(scratch, scratch, | 159 __ andi(scratch, scratch, |
| 163 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); | 160 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); |
| 164 | 161 |
| 165 // Probe the primary table. | 162 // Probe the primary table. |
| 166 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, | 163 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2, |
| 167 extra2, extra3); | 164 extra3); |
| 168 | 165 |
| 169 // Primary miss: Compute hash for secondary probe. | 166 // Primary miss: Compute hash for secondary probe. |
| 170 __ sub(scratch, scratch, name); | 167 __ sub(scratch, scratch, name); |
| 171 __ addi(scratch, scratch, Operand(flags)); | 168 __ addi(scratch, scratch, Operand(kSecondaryMagic)); |
| 172 __ andi(scratch, scratch, | 169 __ andi(scratch, scratch, |
| 173 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); | 170 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); |
| 174 | 171 |
| 175 // Probe the secondary table. | 172 // Probe the secondary table. |
| 176 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, | 173 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2, |
| 177 extra2, extra3); | 174 extra3); |
| 178 | 175 |
| 179 // Cache miss: Fall-through and let caller handle the miss by | 176 // Cache miss: Fall-through and let caller handle the miss by |
| 180 // entering the runtime system. | 177 // entering the runtime system. |
| 181 __ bind(&miss); | 178 __ bind(&miss); |
| 182 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, | 179 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, |
| 183 extra3); | 180 extra3); |
| 184 } | 181 } |
| 185 | 182 |
| 186 | 183 |
| 187 #undef __ | 184 #undef __ |
| 188 } // namespace internal | 185 } // namespace internal |
| 189 } // namespace v8 | 186 } // namespace v8 |
| 190 | 187 |
| 191 #endif // V8_TARGET_ARCH_PPC | 188 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |