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

Side by Side Diff: src/ic/mips/stub-cache-mips.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/ic.cc ('k') | src/ic/mips64/stub-cache-mips64.cc » ('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_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(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 // 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 scratch, Register scratch2, 21 Register offset, Register scratch, Register scratch2,
23 Register offset_scratch) { 22 Register offset_scratch) {
24 ExternalReference key_offset(stub_cache->key_reference(table)); 23 ExternalReference key_offset(stub_cache->key_reference(table));
25 ExternalReference value_offset(stub_cache->value_reference(table)); 24 ExternalReference value_offset(stub_cache->value_reference(table));
26 ExternalReference map_offset(stub_cache->map_reference(table)); 25 ExternalReference map_offset(stub_cache->map_reference(table));
27 26
28 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());
29 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());
(...skipping 25 matching lines...) Expand all
55 // Check the map matches. 54 // Check the map matches.
56 __ lw(at, MemOperand(base_addr, map_off_addr - key_off_addr)); 55 __ lw(at, MemOperand(base_addr, map_off_addr - key_off_addr));
57 __ lw(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset)); 56 __ lw(scratch2, FieldMemOperand(receiver, HeapObject::kMapOffset));
58 __ Branch(&miss, ne, at, Operand(scratch2)); 57 __ Branch(&miss, ne, at, Operand(scratch2));
59 58
60 // Get the code entry from the cache. 59 // Get the code entry from the cache.
61 Register code = scratch2; 60 Register code = scratch2;
62 scratch2 = no_reg; 61 scratch2 = no_reg;
63 __ lw(code, MemOperand(base_addr, value_off_addr - key_off_addr)); 62 __ lw(code, MemOperand(base_addr, value_off_addr - key_off_addr));
64 63
65 // Check that the flags match what we're looking for.
66 Register flags_reg = base_addr;
67 base_addr = no_reg;
68 __ lw(flags_reg, FieldMemOperand(code, Code::kFlagsOffset));
69 __ And(flags_reg, flags_reg, Operand(~Code::kFlagsNotUsedInLookup));
70 __ Branch(&miss, ne, flags_reg, Operand(flags));
71
72 #ifdef DEBUG 64 #ifdef DEBUG
73 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { 65 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) {
74 __ jmp(&miss); 66 __ jmp(&miss);
75 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { 67 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
76 __ jmp(&miss); 68 __ jmp(&miss);
77 } 69 }
78 #endif 70 #endif
79 71
80 // Jump to the first instruction in the code stub. 72 // Jump to the first instruction in the code stub.
81 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag)); 73 __ Addu(at, code, Operand(Code::kHeaderSize - kHeapObjectTag));
82 __ Jump(at); 74 __ Jump(at);
83 75
84 // Miss: fall through. 76 // Miss: fall through.
85 __ bind(&miss); 77 __ bind(&miss);
86 } 78 }
87 79
88 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, 80 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver,
89 Register name, Register scratch, Register extra, 81 Register name, Register scratch, Register extra,
90 Register extra2, Register extra3) { 82 Register extra2, Register extra3) {
91 Code::Flags flags =
92 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_));
93
94 Label miss; 83 Label miss;
95 84
96 // Make sure that code is valid. The multiplying code relies on the 85 // Make sure that code is valid. The multiplying code relies on the
97 // entry size being 12. 86 // entry size being 12.
98 DCHECK(sizeof(Entry) == 12); 87 DCHECK(sizeof(Entry) == 12);
99 88
100 // Make sure that there are no register conflicts. 89 // Make sure that there are no register conflicts.
101 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); 90 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3));
102 91
103 // Check register validity. 92 // Check register validity.
(...skipping 24 matching lines...) Expand all
128 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, 117 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2,
129 extra3); 118 extra3);
130 119
131 // Check that the receiver isn't a smi. 120 // Check that the receiver isn't a smi.
132 __ JumpIfSmi(receiver, &miss); 121 __ JumpIfSmi(receiver, &miss);
133 122
134 // Get the map of the receiver and compute the hash. 123 // Get the map of the receiver and compute the hash.
135 __ lw(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); 124 __ lw(scratch, FieldMemOperand(name, Name::kHashFieldOffset));
136 __ lw(at, FieldMemOperand(receiver, HeapObject::kMapOffset)); 125 __ lw(at, FieldMemOperand(receiver, HeapObject::kMapOffset));
137 __ Addu(scratch, scratch, at); 126 __ Addu(scratch, scratch, at);
138 __ Xor(scratch, scratch, Operand(flags)); 127 __ Xor(scratch, scratch, Operand(kPrimaryMagic));
139 __ And(scratch, scratch, 128 __ And(scratch, scratch,
140 Operand((kPrimaryTableSize - 1) << kCacheIndexShift)); 129 Operand((kPrimaryTableSize - 1) << kCacheIndexShift));
141 130
142 // Probe the primary table. 131 // Probe the primary table.
143 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, 132 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2,
144 extra2, extra3); 133 extra3);
145 134
146 // Primary miss: Compute hash for secondary probe. 135 // Primary miss: Compute hash for secondary probe.
147 __ Subu(scratch, scratch, name); 136 __ Subu(scratch, scratch, name);
148 __ Addu(scratch, scratch, Operand(flags)); 137 __ Addu(scratch, scratch, Operand(kSecondaryMagic));
149 __ And(scratch, scratch, 138 __ And(scratch, scratch,
150 Operand((kSecondaryTableSize - 1) << kCacheIndexShift)); 139 Operand((kSecondaryTableSize - 1) << kCacheIndexShift));
151 140
152 // Probe the secondary table. 141 // Probe the secondary table.
153 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, 142 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2,
154 extra2, extra3); 143 extra3);
155 144
156 // Cache miss: Fall-through and let caller handle the miss by 145 // Cache miss: Fall-through and let caller handle the miss by
157 // entering the runtime system. 146 // entering the runtime system.
158 __ bind(&miss); 147 __ bind(&miss);
159 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, 148 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2,
160 extra3); 149 extra3);
161 } 150 }
162 151
163 152
164 #undef __ 153 #undef __
165 } // namespace internal 154 } // namespace internal
166 } // namespace v8 155 } // namespace v8
167 156
168 #endif // V8_TARGET_ARCH_MIPS 157 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/ic/mips64/stub-cache-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698