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

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

Issue 2147433002: [ic] [stubs] Don't use Code::flags in megamorphic stub cache hash computations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@split-stub-cache
Patch Set: 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 5 #if V8_TARGET_ARCH_ARM64
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 15
16 #define __ ACCESS_MASM(masm) 16 #define __ ACCESS_MASM(masm)
17 17
18 18
19 // Probe primary or secondary table. 19 // Probe primary or secondary table.
20 // If the entry is found in the cache, the generated code jump to the first 20 // If the entry is found in the cache, the generated code jump to the first
21 // instruction of the stub in the cache. 21 // instruction of the stub in the cache.
22 // If there is a miss the code fall trough. 22 // If there is a miss the code fall trough.
23 // 23 //
24 // 'receiver', 'name' and 'offset' registers are preserved on miss. 24 // 'receiver', 'name' and 'offset' registers are preserved on miss.
25 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm, 25 static void ProbeTable(StubCache* stub_cache, MacroAssembler* masm,
26 Code::Flags flags, StubCache::Table table, 26 StubCache::Table table, Register receiver, Register name,
27 Register receiver, Register name, Register offset, 27 Register offset, Register scratch, Register scratch2,
28 Register scratch, Register scratch2, Register scratch3) { 28 Register scratch3) {
29 // Some code below relies on the fact that the Entry struct contains 29 // Some code below relies on the fact that the Entry struct contains
30 // 3 pointers (name, code, map). 30 // 3 pointers (name, code, map).
31 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize)); 31 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize));
32 32
33 ExternalReference key_offset(stub_cache->key_reference(table)); 33 ExternalReference key_offset(stub_cache->key_reference(table));
34 ExternalReference value_offset(stub_cache->value_reference(table)); 34 ExternalReference value_offset(stub_cache->value_reference(table));
35 ExternalReference map_offset(stub_cache->map_reference(table)); 35 ExternalReference map_offset(stub_cache->map_reference(table));
36 36
37 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); 37 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address());
38 uintptr_t value_off_addr = 38 uintptr_t value_off_addr =
(...skipping 18 matching lines...) Expand all
57 57
58 // Check the map matches. 58 // Check the map matches.
59 __ Ldr(scratch2, MemOperand(scratch, map_off_addr - key_off_addr)); 59 __ Ldr(scratch2, MemOperand(scratch, map_off_addr - key_off_addr));
60 __ Ldr(scratch3, FieldMemOperand(receiver, HeapObject::kMapOffset)); 60 __ Ldr(scratch3, FieldMemOperand(receiver, HeapObject::kMapOffset));
61 __ Cmp(scratch2, scratch3); 61 __ Cmp(scratch2, scratch3);
62 __ B(ne, &miss); 62 __ B(ne, &miss);
63 63
64 // Get the code entry from the cache. 64 // Get the code entry from the cache.
65 __ Ldr(scratch, MemOperand(scratch, value_off_addr - key_off_addr)); 65 __ Ldr(scratch, MemOperand(scratch, value_off_addr - key_off_addr));
66 66
67 #ifdef DEBUG
67 // Check that the flags match what we're looking for. 68 // Check that the flags match what we're looking for.
69 Code::Flags flags = Code::RemoveHolderFromFlags(
70 Code::ComputeHandlerFlags(stub_cache->ic_kind()));
68 __ Ldr(scratch2.W(), FieldMemOperand(scratch, Code::kFlagsOffset)); 71 __ Ldr(scratch2.W(), FieldMemOperand(scratch, Code::kFlagsOffset));
69 __ Bic(scratch2.W(), scratch2.W(), Code::kFlagsNotUsedInLookup); 72 __ Bic(scratch2.W(), scratch2.W(), Code::kFlagsNotUsedInLookup);
70 __ Cmp(scratch2.W(), flags); 73 __ Cmp(scratch2.W(), flags);
71 __ B(ne, &miss); 74 __ B(ne, &miss);
75 __ Check(eq, kUnexpectedValue);
72 76
73 #ifdef DEBUG
74 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { 77 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) {
75 __ B(&miss); 78 __ B(&miss);
76 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { 79 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
77 __ B(&miss); 80 __ B(&miss);
78 } 81 }
79 #endif 82 #endif
80 83
81 // Jump to the first instruction in the code stub. 84 // Jump to the first instruction in the code stub.
82 __ Add(scratch, scratch, Code::kHeaderSize - kHeapObjectTag); 85 __ Add(scratch, scratch, Code::kHeaderSize - kHeapObjectTag);
83 __ Br(scratch); 86 __ Br(scratch);
84 87
85 // Miss: fall through. 88 // Miss: fall through.
86 __ Bind(&miss); 89 __ Bind(&miss);
87 } 90 }
88 91
89 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, 92 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver,
90 Register name, Register scratch, Register extra, 93 Register name, Register scratch, Register extra,
91 Register extra2, Register extra3) { 94 Register extra2, Register extra3) {
92 Code::Flags flags =
93 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_));
94
95 Label miss; 95 Label miss;
96 96
97 // Make sure that there are no register conflicts. 97 // Make sure that there are no register conflicts.
98 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); 98 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3));
99 99
100 // Make sure extra and extra2 registers are valid. 100 // Make sure extra and extra2 registers are valid.
101 DCHECK(!extra.is(no_reg)); 101 DCHECK(!extra.is(no_reg));
102 DCHECK(!extra2.is(no_reg)); 102 DCHECK(!extra2.is(no_reg));
103 DCHECK(!extra3.is(no_reg)); 103 DCHECK(!extra3.is(no_reg));
104 104
(...skipping 19 matching lines...) Expand all
124 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2, 124 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, extra2,
125 extra3); 125 extra3);
126 126
127 // Check that the receiver isn't a smi. 127 // Check that the receiver isn't a smi.
128 __ JumpIfSmi(receiver, &miss); 128 __ JumpIfSmi(receiver, &miss);
129 129
130 // Compute the hash for primary table. 130 // Compute the hash for primary table.
131 __ Ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); 131 __ Ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset));
132 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset)); 132 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset));
133 __ Add(scratch, scratch, extra); 133 __ Add(scratch, scratch, extra);
134 __ Eor(scratch, scratch, flags);
135 // We shift out the last two bits because they are not part of the hash. 134 // We shift out the last two bits because they are not part of the hash.
136 __ Ubfx(scratch, scratch, kCacheIndexShift, 135 __ Ubfx(scratch, scratch, kCacheIndexShift,
137 CountTrailingZeros(kPrimaryTableSize, 64)); 136 CountTrailingZeros(kPrimaryTableSize, 64));
138 137
139 // Probe the primary table. 138 // Probe the primary table.
140 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch, extra, 139 ProbeTable(this, masm, kPrimary, receiver, name, scratch, extra, extra2,
141 extra2, extra3); 140 extra3);
142 141
143 // Primary miss: Compute hash for secondary table. 142 // Primary miss: Compute hash for secondary table.
144 __ Sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); 143 __ Sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift));
145 __ Add(scratch, scratch, flags >> kCacheIndexShift);
146 __ And(scratch, scratch, kSecondaryTableSize - 1); 144 __ And(scratch, scratch, kSecondaryTableSize - 1);
147 145
148 // Probe the secondary table. 146 // Probe the secondary table.
149 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch, extra, 147 ProbeTable(this, masm, kSecondary, receiver, name, scratch, extra, extra2,
150 extra2, extra3); 148 extra3);
151 149
152 // Cache miss: Fall-through and let caller handle the miss by 150 // Cache miss: Fall-through and let caller handle the miss by
153 // entering the runtime system. 151 // entering the runtime system.
154 __ Bind(&miss); 152 __ Bind(&miss);
155 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2, 153 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, extra2,
156 extra3); 154 extra3);
157 } 155 }
158 } // namespace internal 156 } // namespace internal
159 } // namespace v8 157 } // namespace v8
160 158
161 #endif // V8_TARGET_ARCH_ARM64 159 #endif // V8_TARGET_ARCH_ARM64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698