Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: src/ic/ppc/stub-cache-ppc.cc

Issue 2123983004: [ic] Split megamorphic stub cache in two caches (for loads and for stores). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@flags-fix
Patch Set: Rebasing Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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(Isolate* isolate, MacroAssembler* masm, 17 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm,
18 Code::Flags flags, StubCache::Table table, 18 Code::Flags flags, StubCache::Table table,
19 Register receiver, Register name, 19 Register receiver, Register name,
20 // Number of the cache entry, not scaled. 20 // Number of the cache entry, not scaled.
21 Register offset, Register scratch, Register scratch2, 21 Register offset, Register scratch, Register scratch2,
22 Register offset_scratch) { 22 Register offset_scratch) {
23 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); 23 ExternalReference key_offset(stub_cache->key_reference(table));
24 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); 24 ExternalReference value_offset(stub_cache->value_reference(table));
25 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); 25 ExternalReference map_offset(stub_cache->map_reference(table));
26 26
27 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());
28 uintptr_t value_off_addr = 28 uintptr_t value_off_addr =
29 reinterpret_cast<uintptr_t>(value_offset.address()); 29 reinterpret_cast<uintptr_t>(value_offset.address());
30 uintptr_t map_off_addr = reinterpret_cast<uintptr_t>(map_offset.address()); 30 uintptr_t map_off_addr = reinterpret_cast<uintptr_t>(map_offset.address());
31 31
32 // Check the relative positions of the address fields. 32 // Check the relative positions of the address fields.
33 DCHECK(value_off_addr > key_off_addr); 33 DCHECK(value_off_addr > key_off_addr);
34 DCHECK((value_off_addr - key_off_addr) % 4 == 0); 34 DCHECK((value_off_addr - key_off_addr) % 4 == 0);
35 DCHECK((value_off_addr - key_off_addr) < (256 * 4)); 35 DCHECK((value_off_addr - key_off_addr) < (256 * 4));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 // Jump to the first instruction in the code stub. 95 // Jump to the first instruction in the code stub.
96 __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag)); 96 __ addi(r0, code, Operand(Code::kHeaderSize - kHeapObjectTag));
97 __ mtctr(r0); 97 __ mtctr(r0);
98 __ bctr(); 98 __ bctr();
99 99
100 // Miss: fall through. 100 // Miss: fall through.
101 __ bind(&miss); 101 __ bind(&miss);
102 } 102 }
103 103
104 104 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver,
105 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind,
106 Code::Flags flags, Register receiver,
107 Register name, Register scratch, Register extra, 105 Register name, Register scratch, Register extra,
108 Register extra2, Register extra3) { 106 Register extra2, Register extra3) {
109 Isolate* isolate = masm->isolate(); 107 Code::Flags flags =
108 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_));
109
110 Label miss; 110 Label miss;
111 111
112 #if V8_TARGET_ARCH_PPC64 112 #if V8_TARGET_ARCH_PPC64
113 // 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
114 // entry size being 24. 114 // entry size being 24.
115 DCHECK(sizeof(Entry) == 24); 115 DCHECK(sizeof(Entry) == 24);
116 #else 116 #else
117 // 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
118 // entry size being 12. 118 // entry size being 12.
119 DCHECK(sizeof(Entry) == 12); 119 DCHECK(sizeof(Entry) == 12);
120 #endif 120 #endif
121 121
122 // Make sure that there are no register conflicts. 122 // Make sure that there are no register conflicts.
123 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); 123 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3));
124 124
125 // Check scratch, extra and extra2 registers are valid. 125 // Check scratch, extra and extra2 registers are valid.
126 DCHECK(!scratch.is(no_reg)); 126 DCHECK(!scratch.is(no_reg));
127 DCHECK(!extra.is(no_reg)); 127 DCHECK(!extra.is(no_reg));
128 DCHECK(!extra2.is(no_reg)); 128 DCHECK(!extra2.is(no_reg));
129 DCHECK(!extra3.is(no_reg)); 129 DCHECK(!extra3.is(no_reg));
130 130
131 #ifdef DEBUG 131 #ifdef DEBUG
132 // If vector-based ics are in use, ensure that scratch, extra, extra2 and 132 // If vector-based ics are in use, ensure that scratch, extra, extra2 and
133 // extra3 don't conflict with the vector and slot registers, which need 133 // extra3 don't conflict with the vector and slot registers, which need
134 // to be preserved for a handler call or miss. 134 // to be preserved for a handler call or miss.
135 if (IC::ICUseVector(ic_kind)) { 135 if (IC::ICUseVector(ic_kind_)) {
136 Register vector, slot; 136 Register vector, slot;
137 if (ic_kind == Code::STORE_IC || ic_kind == Code::KEYED_STORE_IC) { 137 if (ic_kind_ == Code::STORE_IC || ic_kind_ == Code::KEYED_STORE_IC) {
138 vector = VectorStoreICDescriptor::VectorRegister(); 138 vector = VectorStoreICDescriptor::VectorRegister();
139 slot = VectorStoreICDescriptor::SlotRegister(); 139 slot = VectorStoreICDescriptor::SlotRegister();
140 } else { 140 } else {
141 DCHECK(ic_kind_ == Code::LOAD_IC || ic_kind_ == Code::KEYED_LOAD_IC);
141 vector = LoadWithVectorDescriptor::VectorRegister(); 142 vector = LoadWithVectorDescriptor::VectorRegister();
142 slot = LoadWithVectorDescriptor::SlotRegister(); 143 slot = LoadWithVectorDescriptor::SlotRegister();
143 } 144 }
144 DCHECK(!AreAliased(vector, slot, scratch, extra, extra2, extra3)); 145 DCHECK(!AreAliased(vector, slot, scratch, extra, extra2, extra3));
145 } 146 }
146 #endif 147 #endif
147 148
148 Counters* counters = masm->isolate()->counters(); 149 Counters* counters = masm->isolate()->counters();
149 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, 150 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2,
150 extra3); 151 extra3);
151 152
152 // Check that the receiver isn't a smi. 153 // Check that the receiver isn't a smi.
153 __ JumpIfSmi(receiver, &miss); 154 __ JumpIfSmi(receiver, &miss);
154 155
155 // Get the map of the receiver and compute the hash. 156 // Get the map of the receiver and compute the hash.
156 __ lwz(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); 157 __ lwz(scratch, FieldMemOperand(name, Name::kHashFieldOffset));
157 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset)); 158 __ LoadP(ip, FieldMemOperand(receiver, HeapObject::kMapOffset));
158 __ add(scratch, scratch, ip); 159 __ add(scratch, scratch, ip);
159 __ xori(scratch, scratch, Operand(flags)); 160 __ xori(scratch, scratch, Operand(flags));
160 // 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.
161 __ andi(scratch, scratch, 162 __ andi(scratch, scratch,
162 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); 163 Operand((kPrimaryTableSize - 1) << kCacheIndexShift));
163 164
164 // Probe the primary table. 165 // Probe the primary table.
165 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch, extra, 166 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra,
166 extra2, extra3); 167 extra2, extra3);
167 168
168 // Primary miss: Compute hash for secondary probe. 169 // Primary miss: Compute hash for secondary probe.
169 __ sub(scratch, scratch, name); 170 __ sub(scratch, scratch, name);
170 __ addi(scratch, scratch, Operand(flags)); 171 __ addi(scratch, scratch, Operand(flags));
171 __ andi(scratch, scratch, 172 __ andi(scratch, scratch,
172 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); 173 Operand((kSecondaryTableSize - 1) << kCacheIndexShift));
173 174
174 // Probe the secondary table. 175 // Probe the secondary table.
175 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch, extra, 176 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra,
176 extra2, extra3); 177 extra2, extra3);
177 178
178 // Cache miss: Fall-through and let caller handle the miss by 179 // Cache miss: Fall-through and let caller handle the miss by
179 // entering the runtime system. 180 // entering the runtime system.
180 __ bind(&miss); 181 __ bind(&miss);
181 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, 182 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2,
182 extra3); 183 extra3);
183 } 184 }
184 185
185 186
186 #undef __ 187 #undef __
187 } // namespace internal 188 } // namespace internal
188 } // namespace v8 189 } // namespace v8
189 190
190 #endif // V8_TARGET_ARCH_PPC 191 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ic/ppc/ic-ppc.cc ('k') | src/ic/s390/ic-s390.cc » ('j') | src/ic/x64/stub-cache-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698