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

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

Issue 2167493003: [ic] [stubs] Don't use Code::flags in megamorphic stub cache hash computations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@stub-cache-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
« no previous file with comments | « src/ic/x64/stub-cache-x64.cc ('k') | src/type-info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_X87 5 #if V8_TARGET_ARCH_X87
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::Kind ic_kind, Code::Flags flags,
19 StubCache::Table table, Register name, Register receiver, 18 StubCache::Table table, Register name, Register receiver,
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 extra) { 21 Register offset, Register extra) {
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 ExternalReference virtual_register = 25 ExternalReference virtual_register =
27 ExternalReference::virtual_handler_register(masm->isolate()); 26 ExternalReference::virtual_handler_register(masm->isolate());
28 27
29 Label miss; 28 Label miss;
29 Code::Kind ic_kind = stub_cache->ic_kind();
30 bool is_vector_store = 30 bool is_vector_store =
31 IC::ICUseVector(ic_kind) && 31 IC::ICUseVector(ic_kind) &&
32 (ic_kind == Code::STORE_IC || ic_kind == Code::KEYED_STORE_IC); 32 (ic_kind == Code::STORE_IC || ic_kind == Code::KEYED_STORE_IC);
33 33
34 // Multiply by 3 because there are 3 fields per entry (name, code, map). 34 // Multiply by 3 because there are 3 fields per entry (name, code, map).
35 __ lea(offset, Operand(offset, offset, times_2, 0)); 35 __ lea(offset, Operand(offset, offset, times_2, 0));
36 36
37 if (extra.is_valid()) { 37 if (extra.is_valid()) {
38 // Get the code entry from the cache. 38 // Get the code entry from the cache.
39 __ mov(extra, Operand::StaticArray(offset, times_1, value_offset)); 39 __ mov(extra, Operand::StaticArray(offset, times_1, value_offset));
40 40
41 // Check that the key in the entry matches the name. 41 // Check that the key in the entry matches the name.
42 __ cmp(name, Operand::StaticArray(offset, times_1, key_offset)); 42 __ cmp(name, Operand::StaticArray(offset, times_1, key_offset));
43 __ j(not_equal, &miss); 43 __ j(not_equal, &miss);
44 44
45 // Check the map matches. 45 // Check the map matches.
46 __ mov(offset, Operand::StaticArray(offset, times_1, map_offset)); 46 __ mov(offset, Operand::StaticArray(offset, times_1, map_offset));
47 __ cmp(offset, FieldOperand(receiver, HeapObject::kMapOffset)); 47 __ cmp(offset, FieldOperand(receiver, HeapObject::kMapOffset));
48 __ j(not_equal, &miss); 48 __ j(not_equal, &miss);
49 49
50 // Check that the flags match what we're looking for.
51 __ mov(offset, FieldOperand(extra, Code::kFlagsOffset));
52 __ and_(offset, ~Code::kFlagsNotUsedInLookup);
53 __ cmp(offset, flags);
54 __ j(not_equal, &miss);
55
56 #ifdef DEBUG 50 #ifdef DEBUG
57 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { 51 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) {
58 __ jmp(&miss); 52 __ jmp(&miss);
59 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { 53 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
60 __ jmp(&miss); 54 __ jmp(&miss);
61 } 55 }
62 #endif 56 #endif
63 57
64 // The vector and slot were pushed onto the stack before starting the 58 // The vector and slot were pushed onto the stack before starting the
65 // probe, and need to be dropped before calling the handler. 59 // probe, and need to be dropped before calling the handler.
(...skipping 29 matching lines...) Expand all
95 __ mov(offset, Operand::StaticArray(offset, times_1, map_offset)); 89 __ mov(offset, Operand::StaticArray(offset, times_1, map_offset));
96 __ cmp(offset, FieldOperand(receiver, HeapObject::kMapOffset)); 90 __ cmp(offset, FieldOperand(receiver, HeapObject::kMapOffset));
97 __ j(not_equal, &miss); 91 __ j(not_equal, &miss);
98 92
99 // Restore offset register. 93 // Restore offset register.
100 __ mov(offset, Operand(esp, 0)); 94 __ mov(offset, Operand(esp, 0));
101 95
102 // Get the code entry from the cache. 96 // Get the code entry from the cache.
103 __ mov(offset, Operand::StaticArray(offset, times_1, value_offset)); 97 __ mov(offset, Operand::StaticArray(offset, times_1, value_offset));
104 98
105 // Check that the flags match what we're looking for.
106 __ mov(offset, FieldOperand(offset, Code::kFlagsOffset));
107 __ and_(offset, ~Code::kFlagsNotUsedInLookup);
108 __ cmp(offset, flags);
109 __ j(not_equal, &miss);
110
111 #ifdef DEBUG 99 #ifdef DEBUG
112 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { 100 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) {
113 __ jmp(&miss); 101 __ jmp(&miss);
114 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { 102 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
115 __ jmp(&miss); 103 __ jmp(&miss);
116 } 104 }
117 #endif 105 #endif
118 106
119 // Restore offset and re-load code entry from cache. 107 // Restore offset and re-load code entry from cache.
120 __ pop(offset); 108 __ pop(offset);
(...skipping 17 matching lines...) Expand all
138 126
139 // Pop at miss. 127 // Pop at miss.
140 __ bind(&miss); 128 __ bind(&miss);
141 __ pop(offset); 129 __ pop(offset);
142 } 130 }
143 } 131 }
144 132
145 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, 133 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver,
146 Register name, Register scratch, Register extra, 134 Register name, Register scratch, Register extra,
147 Register extra2, Register extra3) { 135 Register extra2, Register extra3) {
148 Code::Flags flags =
149 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_));
150
151 Label miss; 136 Label miss;
152 137
153 // Assert that code is valid. The multiplying code relies on the entry size 138 // Assert that code is valid. The multiplying code relies on the entry size
154 // being 12. 139 // being 12.
155 DCHECK(sizeof(Entry) == 12); 140 DCHECK(sizeof(Entry) == 12);
156 141
157 // Assert that there are no register conflicts. 142 // Assert that there are no register conflicts.
158 DCHECK(!scratch.is(receiver)); 143 DCHECK(!scratch.is(receiver));
159 DCHECK(!scratch.is(name)); 144 DCHECK(!scratch.is(name));
160 DCHECK(!extra.is(receiver)); 145 DCHECK(!extra.is(receiver));
(...skipping 10 matching lines...) Expand all
171 156
172 Counters* counters = masm->isolate()->counters(); 157 Counters* counters = masm->isolate()->counters();
173 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1); 158 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1);
174 159
175 // Check that the receiver isn't a smi. 160 // Check that the receiver isn't a smi.
176 __ JumpIfSmi(receiver, &miss); 161 __ JumpIfSmi(receiver, &miss);
177 162
178 // Get the map of the receiver and compute the hash. 163 // Get the map of the receiver and compute the hash.
179 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset)); 164 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset));
180 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); 165 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset));
181 __ xor_(offset, flags); 166 __ xor_(offset, kPrimaryMagic);
182 // We mask out the last two bits because they are not part of the hash and 167 // We mask out the last two bits because they are not part of the hash and
183 // they are always 01 for maps. Also in the two 'and' instructions below. 168 // they are always 01 for maps. Also in the two 'and' instructions below.
184 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); 169 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift);
185 // ProbeTable expects the offset to be pointer scaled, which it is, because 170 // ProbeTable expects the offset to be pointer scaled, which it is, because
186 // the heap object tag size is 2 and the pointer size log 2 is also 2. 171 // the heap object tag size is 2 and the pointer size log 2 is also 2.
187 DCHECK(kCacheIndexShift == kPointerSizeLog2); 172 DCHECK(kCacheIndexShift == kPointerSizeLog2);
188 173
189 // Probe the primary table. 174 // Probe the primary table.
190 ProbeTable(this, masm, ic_kind_, flags, kPrimary, name, receiver, offset, 175 ProbeTable(this, masm, kPrimary, name, receiver, offset, extra);
191 extra);
192 176
193 // Primary miss: Compute hash for secondary probe. 177 // Primary miss: Compute hash for secondary probe.
194 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset)); 178 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset));
195 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); 179 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset));
196 __ xor_(offset, flags); 180 __ xor_(offset, kPrimaryMagic);
197 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); 181 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift);
198 __ sub(offset, name); 182 __ sub(offset, name);
199 __ add(offset, Immediate(flags)); 183 __ add(offset, Immediate(kSecondaryMagic));
200 __ and_(offset, (kSecondaryTableSize - 1) << kCacheIndexShift); 184 __ and_(offset, (kSecondaryTableSize - 1) << kCacheIndexShift);
201 185
202 // Probe the secondary table. 186 // Probe the secondary table.
203 ProbeTable(this, masm, ic_kind_, flags, kSecondary, name, receiver, offset, 187 ProbeTable(this, masm, kSecondary, name, receiver, offset, extra);
204 extra);
205 188
206 // Cache miss: Fall-through and let caller handle the miss by 189 // Cache miss: Fall-through and let caller handle the miss by
207 // entering the runtime system. 190 // entering the runtime system.
208 __ bind(&miss); 191 __ bind(&miss);
209 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); 192 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1);
210 } 193 }
211 194
212 195
213 #undef __ 196 #undef __
214 } // namespace internal 197 } // namespace internal
215 } // namespace v8 198 } // namespace v8
216 199
217 #endif // V8_TARGET_ARCH_X87 200 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/ic/x64/stub-cache-x64.cc ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698