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

Side by Side Diff: src/ic/mips/stub-cache-mips.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 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_MIPS 5 #if V8_TARGET_ARCH_MIPS
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 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address()); 27 uint32_t key_off_addr = reinterpret_cast<uint32_t>(key_offset.address());
28 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address()); 28 uint32_t value_off_addr = reinterpret_cast<uint32_t>(value_offset.address());
29 uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address()); 29 uint32_t map_off_addr = reinterpret_cast<uint32_t>(map_offset.address());
30 30
31 // Check the relative positions of the address fields. 31 // Check the relative positions of the address fields.
32 DCHECK(value_off_addr > key_off_addr); 32 DCHECK(value_off_addr > key_off_addr);
33 DCHECK((value_off_addr - key_off_addr) % 4 == 0); 33 DCHECK((value_off_addr - key_off_addr) % 4 == 0);
34 DCHECK((value_off_addr - key_off_addr) < (256 * 4)); 34 DCHECK((value_off_addr - key_off_addr) < (256 * 4));
35 DCHECK(map_off_addr > key_off_addr); 35 DCHECK(map_off_addr > key_off_addr);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #endif 77 #endif
78 78
79 // Jump to the first instruction in the code stub. 79 // Jump to the first instruction in the code stub.
80 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); 80 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag));
81 __ Jump(at); 81 __ Jump(at);
82 82
83 // Miss: fall through. 83 // Miss: fall through.
84 __ bind(&miss); 84 __ bind(&miss);
85 } 85 }
86 86
87 87 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver,
88 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind,
89 Code::Flags flags, Register receiver,
90 Register name, Register scratch, Register extra, 88 Register name, Register scratch, Register extra,
91 Register extra2, Register extra3) { 89 Register extra2, Register extra3) {
92 Isolate* isolate = masm->isolate(); 90 Code::Flags flags =
91 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_));
92
93 Label miss; 93 Label miss;
94 94
95 // Make sure that code is valid. The multiplying code relies on the 95 // Make sure that code is valid. The multiplying code relies on the
96 // entry size being 12. 96 // entry size being 12.
97 DCHECK(sizeof(Entry) == 12); 97 DCHECK(sizeof(Entry) == 12);
98 98
99 // Make sure that there are no register conflicts. 99 // Make sure that there are no register conflicts.
100 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); 100 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3));
101 101
102 // Check register validity. 102 // Check register validity.
103 DCHECK(!scratch.is(no_reg)); 103 DCHECK(!scratch.is(no_reg));
104 DCHECK(!extra.is(no_reg)); 104 DCHECK(!extra.is(no_reg));
105 DCHECK(!extra2.is(no_reg)); 105 DCHECK(!extra2.is(no_reg));
106 DCHECK(!extra3.is(no_reg)); 106 DCHECK(!extra3.is(no_reg));
107 107
108 #ifdef DEBUG 108 #ifdef DEBUG
109 // If vector-based ics are in use, ensure that scratch, extra, extra2 and 109 // If vector-based ics are in use, ensure that scratch, extra, extra2 and
110 // extra3 don't conflict with the vector and slot registers, which need 110 // extra3 don't conflict with the vector and slot registers, which need
111 // to be preserved for a handler call or miss. 111 // to be preserved for a handler call or miss.
112 if (IC::ICUseVector(ic_kind)) { 112 if (IC::ICUseVector(ic_kind_)) {
113 Register vector, slot; 113 Register vector, slot;
114 if (ic_kind == Code::STORE_IC || ic_kind == Code::KEYED_STORE_IC) { 114 if (ic_kind_ == Code::STORE_IC || ic_kind_ == Code::KEYED_STORE_IC) {
115 vector = VectorStoreICDescriptor::VectorRegister(); 115 vector = VectorStoreICDescriptor::VectorRegister();
116 slot = VectorStoreICDescriptor::SlotRegister(); 116 slot = VectorStoreICDescriptor::SlotRegister();
117 } else { 117 } else {
118 DCHECK(ic_kind_ == Code::LOAD_IC || ic_kind_ == Code::KEYED_LOAD_IC);
118 vector = LoadWithVectorDescriptor::VectorRegister(); 119 vector = LoadWithVectorDescriptor::VectorRegister();
119 slot = LoadWithVectorDescriptor::SlotRegister(); 120 slot = LoadWithVectorDescriptor::SlotRegister();
120 } 121 }
121 DCHECK(!AreAliased(vector, slot, scratch, extra, extra2, extra3)); 122 DCHECK(!AreAliased(vector, slot, scratch, extra, extra2, extra3));
122 } 123 }
123 #endif 124 #endif
124 125
125 Counters* counters = masm->isolate()->counters(); 126 Counters* counters = masm->isolate()->counters();
126 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, 127 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2,
127 extra3); 128 extra3);
128 129
129 // Check that the receiver isn't a smi. 130 // Check that the receiver isn't a smi.
130 __ JumpIfSmi(receiver, &miss); 131 __ JumpIfSmi(receiver, &miss);
131 132
132 // Get the map of the receiver and compute the hash. 133 // Get the map of the receiver and compute the hash.
133 __ lw(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); 134 __ lw(scratch, FieldMemOperand(name, Name::kHashFieldOffset));
134 __ lw(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); 135 __ lw(at, FieldMemOperand(receiver, HeapObject::kMapOffset));
135 __ Addu(scratch, scratch, at); 136 __ Addu(scratch, scratch, at);
136 uint32_t mask = kPrimaryTableSize - 1; 137 uint32_t mask = kPrimaryTableSize - 1;
137 // We shift out the last two bits because they are not part of the hash and 138 // We shift out the last two bits because they are not part of the hash and
138 // they are always 01 for maps. 139 // they are always 01 for maps.
139 __ srl(scratch, scratch, kCacheIndexShift); 140 __ srl(scratch, scratch, kCacheIndexShift);
140 __ Xor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask)); 141 __ Xor(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask));
141 __ And(scratch, scratch, Operand(mask)); 142 __ And(scratch, scratch, Operand(mask));
142 143
143 // Probe the primary table. 144 // Probe the primary table.
144 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, scratch, extra, 145 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra,
145 extra2, extra3); 146 extra2, extra3);
146 147
147 // Primary miss: Compute hash for secondary probe. 148 // Primary miss: Compute hash for secondary probe.
148 __ srl(at, name, kCacheIndexShift); 149 __ srl(at, name, kCacheIndexShift);
149 __ Subu(scratch, scratch, at); 150 __ Subu(scratch, scratch, at);
150 uint32_t mask2 = kSecondaryTableSize - 1; 151 uint32_t mask2 = kSecondaryTableSize - 1;
151 __ Addu(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2)); 152 __ Addu(scratch, scratch, Operand((flags >> kCacheIndexShift) & mask2));
152 __ And(scratch, scratch, Operand(mask2)); 153 __ And(scratch, scratch, Operand(mask2));
153 154
154 // Probe the secondary table. 155 // Probe the secondary table.
155 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, scratch, extra, 156 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra,
156 extra2, extra3); 157 extra2, extra3);
157 158
158 // Cache miss: Fall-through and let caller handle the miss by 159 // Cache miss: Fall-through and let caller handle the miss by
159 // entering the runtime system. 160 // entering the runtime system.
160 __ bind(&miss); 161 __ bind(&miss);
161 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, 162 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2,
162 extra3); 163 extra3);
163 } 164 }
164 165
165 166
166 #undef __ 167 #undef __
167 } // namespace internal 168 } // namespace internal
168 } // namespace v8 169 } // namespace v8
169 170
170 #endif // V8_TARGET_ARCH_MIPS 171 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ic/mips/ic-mips.cc ('k') | src/ic/mips64/ic-mips64.cc » ('j') | src/ic/x64/stub-cache-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698