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