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

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

Issue 2147213004: Revert of [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
« no previous file with comments | « src/ic/stub-cache.cc ('k') | src/ic/x87/stub-cache-x87.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_X64 5 #if V8_TARGET_ARCH_X64
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 StubCache::Table table, Register receiver, Register name, 18 Code::Flags flags, StubCache::Table table,
19 Register receiver, Register name,
19 // The offset is scaled by 4, based on 20 // The offset is scaled by 4, based on
20 // kCacheIndexShift, which is two bits 21 // kCacheIndexShift, which is two bits
21 Register offset) { 22 Register offset) {
22 // We need to scale up the pointer by 2 when the offset is scaled by less 23 // We need to scale up the pointer by 2 when the offset is scaled by less
23 // than the pointer size. 24 // than the pointer size.
24 DCHECK(kPointerSize == kInt64Size 25 DCHECK(kPointerSize == kInt64Size
25 ? kPointerSizeLog2 == StubCache::kCacheIndexShift + 1 26 ? kPointerSizeLog2 == StubCache::kCacheIndexShift + 1
26 : kPointerSizeLog2 == StubCache::kCacheIndexShift); 27 : kPointerSizeLog2 == StubCache::kCacheIndexShift);
27 ScaleFactor scale_factor = kPointerSize == kInt64Size ? times_2 : times_1; 28 ScaleFactor scale_factor = kPointerSize == kInt64Size ? times_2 : times_1;
28 29
(...skipping 20 matching lines...) Expand all
49 kPointerSize * 2); 50 kPointerSize * 2);
50 __ movp(kScratchRegister, 51 __ movp(kScratchRegister,
51 Operand(kScratchRegister, offset, scale_factor, kPointerSize * 2)); 52 Operand(kScratchRegister, offset, scale_factor, kPointerSize * 2));
52 __ cmpp(kScratchRegister, FieldOperand(receiver, HeapObject::kMapOffset)); 53 __ cmpp(kScratchRegister, FieldOperand(receiver, HeapObject::kMapOffset));
53 __ j(not_equal, &miss); 54 __ j(not_equal, &miss);
54 55
55 // Get the code entry from the cache. 56 // Get the code entry from the cache.
56 __ LoadAddress(kScratchRegister, value_offset); 57 __ LoadAddress(kScratchRegister, value_offset);
57 __ movp(kScratchRegister, Operand(kScratchRegister, offset, scale_factor, 0)); 58 __ movp(kScratchRegister, Operand(kScratchRegister, offset, scale_factor, 0));
58 59
59 #ifdef DEBUG
60 // Check that the flags match what we're looking for. 60 // Check that the flags match what we're looking for.
61 Code::Flags flags = Code::RemoveHolderFromFlags(
62 Code::ComputeHandlerFlags(stub_cache->ic_kind()));
63 __ movl(offset, FieldOperand(kScratchRegister, Code::kFlagsOffset)); 61 __ movl(offset, FieldOperand(kScratchRegister, Code::kFlagsOffset));
64 __ andp(offset, Immediate(~Code::kFlagsNotUsedInLookup)); 62 __ andp(offset, Immediate(~Code::kFlagsNotUsedInLookup));
65 __ cmpl(offset, Immediate(flags)); 63 __ cmpl(offset, Immediate(flags));
66 __ Check(equal, kUnexpectedValue); 64 __ j(not_equal, &miss);
67 65
66 #ifdef DEBUG
68 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { 67 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) {
69 __ jmp(&miss); 68 __ jmp(&miss);
70 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { 69 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
71 __ jmp(&miss); 70 __ jmp(&miss);
72 } 71 }
73 #endif 72 #endif
74 73
75 // Jump to the first instruction in the code stub. 74 // Jump to the first instruction in the code stub.
76 __ addp(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag)); 75 __ addp(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag));
77 __ jmp(kScratchRegister); 76 __ jmp(kScratchRegister);
78 77
79 __ bind(&miss); 78 __ bind(&miss);
80 } 79 }
81 80
82 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver, 81 void StubCache::GenerateProbe(MacroAssembler* masm, Register receiver,
83 Register name, Register scratch, Register extra, 82 Register name, Register scratch, Register extra,
84 Register extra2, Register extra3) { 83 Register extra2, Register extra3) {
84 Code::Flags flags =
85 Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind_));
86
85 Label miss; 87 Label miss;
86 USE(extra); // The register extra is not used on the X64 platform. 88 USE(extra); // The register extra is not used on the X64 platform.
87 USE(extra2); // The register extra2 is not used on the X64 platform. 89 USE(extra2); // The register extra2 is not used on the X64 platform.
88 USE(extra3); // The register extra2 is not used on the X64 platform. 90 USE(extra3); // The register extra2 is not used on the X64 platform.
89 // Make sure that code is valid. The multiplying code relies on the 91 // Make sure that code is valid. The multiplying code relies on the
90 // entry size being 3 * kPointerSize. 92 // entry size being 3 * kPointerSize.
91 DCHECK(sizeof(Entry) == 3 * kPointerSize); 93 DCHECK(sizeof(Entry) == 3 * kPointerSize);
92 94
93 // Make sure that there are no register conflicts. 95 // Make sure that there are no register conflicts.
94 DCHECK(!scratch.is(receiver)); 96 DCHECK(!scratch.is(receiver));
(...skipping 25 matching lines...) Expand all
120 Counters* counters = masm->isolate()->counters(); 122 Counters* counters = masm->isolate()->counters();
121 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1); 123 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1);
122 124
123 // Check that the receiver isn't a smi. 125 // Check that the receiver isn't a smi.
124 __ JumpIfSmi(receiver, &miss); 126 __ JumpIfSmi(receiver, &miss);
125 127
126 // Get the map of the receiver and compute the hash. 128 // Get the map of the receiver and compute the hash.
127 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); 129 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset));
128 // Use only the low 32 bits of the map pointer. 130 // Use only the low 32 bits of the map pointer.
129 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); 131 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset));
132 __ xorp(scratch, Immediate(flags));
130 // We mask out the last two bits because they are not part of the hash and 133 // We mask out the last two bits because they are not part of the hash and
131 // they are always 01 for maps. Also in the two 'and' instructions below. 134 // they are always 01 for maps. Also in the two 'and' instructions below.
132 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); 135 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift));
133 136
134 // Probe the primary table. 137 // Probe the primary table.
135 ProbeTable(this, masm, kPrimary, receiver, name, scratch); 138 ProbeTable(this, masm, flags, kPrimary, receiver, name, scratch);
136 139
137 // Primary miss: Compute hash for secondary probe. 140 // Primary miss: Compute hash for secondary probe.
138 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); 141 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset));
139 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); 142 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset));
143 __ xorp(scratch, Immediate(flags));
140 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); 144 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift));
141 __ subl(scratch, name); 145 __ subl(scratch, name);
146 __ addl(scratch, Immediate(flags));
142 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift)); 147 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift));
143 148
144 // Probe the secondary table. 149 // Probe the secondary table.
145 ProbeTable(this, masm, kSecondary, receiver, name, scratch); 150 ProbeTable(this, masm, flags, kSecondary, receiver, name, scratch);
146 151
147 // Cache miss: Fall-through and let caller handle the miss by 152 // Cache miss: Fall-through and let caller handle the miss by
148 // entering the runtime system. 153 // entering the runtime system.
149 __ bind(&miss); 154 __ bind(&miss);
150 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); 155 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1);
151 } 156 }
152 157
153 158
154 #undef __ 159 #undef __
155 } // namespace internal 160 } // namespace internal
156 } // namespace v8 161 } // namespace v8
157 162
158 #endif // V8_TARGET_ARCH_X64 163 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ic/stub-cache.cc ('k') | src/ic/x87/stub-cache-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698