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

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

Issue 767743002: Hydrogen code stubs for vector-based ICs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 6 years 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/ic-x64.cc ('k') | src/ic/x87/handler-compiler-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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/ic.h"
10 #include "src/ic/stub-cache.h" 11 #include "src/ic/stub-cache.h"
12 #include "src/interface-descriptors.h"
11 13
12 namespace v8 { 14 namespace v8 {
13 namespace internal { 15 namespace internal {
14 16
15 #define __ ACCESS_MASM(masm) 17 #define __ ACCESS_MASM(masm)
16 18
17 19
18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, 20 static void ProbeTable(Isolate* isolate, MacroAssembler* masm,
19 Code::Flags flags, bool leave_frame, 21 Code::Kind ic_kind, Code::Flags flags, bool leave_frame,
20 StubCache::Table table, Register receiver, Register name, 22 StubCache::Table table, Register receiver, Register name,
21 // The offset is scaled by 4, based on 23 // The offset is scaled by 4, based on
22 // kCacheIndexShift, which is two bits 24 // kCacheIndexShift, which is two bits
23 Register offset) { 25 Register offset) {
24 // We need to scale up the pointer by 2 when the offset is scaled by less 26 // We need to scale up the pointer by 2 when the offset is scaled by less
25 // than the pointer size. 27 // than the pointer size.
26 DCHECK(kPointerSize == kInt64Size 28 DCHECK(kPointerSize == kInt64Size
27 ? kPointerSizeLog2 == StubCache::kCacheIndexShift + 1 29 ? kPointerSizeLog2 == StubCache::kCacheIndexShift + 1
28 : kPointerSizeLog2 == StubCache::kCacheIndexShift); 30 : kPointerSizeLog2 == StubCache::kCacheIndexShift);
29 ScaleFactor scale_factor = kPointerSize == kInt64Size ? times_2 : times_1; 31 ScaleFactor scale_factor = kPointerSize == kInt64Size ? times_2 : times_1;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 if (leave_frame) __ leave(); 77 if (leave_frame) __ leave();
76 78
77 // Jump to the first instruction in the code stub. 79 // Jump to the first instruction in the code stub.
78 __ addp(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag)); 80 __ addp(kScratchRegister, Immediate(Code::kHeaderSize - kHeapObjectTag));
79 __ jmp(kScratchRegister); 81 __ jmp(kScratchRegister);
80 82
81 __ bind(&miss); 83 __ bind(&miss);
82 } 84 }
83 85
84 86
85 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Flags flags, 87 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind,
86 bool leave_frame, Register receiver, 88 Code::Flags flags, bool leave_frame,
87 Register name, Register scratch, Register extra, 89 Register receiver, Register name,
88 Register extra2, Register extra3) { 90 Register scratch, Register extra, Register extra2,
91 Register extra3) {
89 Isolate* isolate = masm->isolate(); 92 Isolate* isolate = masm->isolate();
90 Label miss; 93 Label miss;
91 USE(extra); // The register extra is not used on the X64 platform. 94 USE(extra); // The register extra is not used on the X64 platform.
92 USE(extra2); // The register extra2 is not used on the X64 platform. 95 USE(extra2); // The register extra2 is not used on the X64 platform.
93 USE(extra3); // The register extra2 is not used on the X64 platform. 96 USE(extra3); // The register extra2 is not used on the X64 platform.
94 // Make sure that code is valid. The multiplying code relies on the 97 // Make sure that code is valid. The multiplying code relies on the
95 // entry size being 3 * kPointerSize. 98 // entry size being 3 * kPointerSize.
96 DCHECK(sizeof(Entry) == 3 * kPointerSize); 99 DCHECK(sizeof(Entry) == 3 * kPointerSize);
97 100
98 // Make sure the flags do not name a specific type. 101 // Make sure the flags do not name a specific type.
99 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); 102 DCHECK(Code::ExtractTypeFromFlags(flags) == 0);
100 103
101 // Make sure that there are no register conflicts. 104 // Make sure that there are no register conflicts.
102 DCHECK(!scratch.is(receiver)); 105 DCHECK(!scratch.is(receiver));
103 DCHECK(!scratch.is(name)); 106 DCHECK(!scratch.is(name));
104 107
105 // Check scratch register is valid, extra and extra2 are unused. 108 // Check scratch register is valid, extra and extra2 are unused.
106 DCHECK(!scratch.is(no_reg)); 109 DCHECK(!scratch.is(no_reg));
107 DCHECK(extra2.is(no_reg)); 110 DCHECK(extra2.is(no_reg));
108 DCHECK(extra3.is(no_reg)); 111 DCHECK(extra3.is(no_reg));
109 112
113 #ifdef DEBUG
114 // If vector-based ics are in use, ensure that scratch doesn't conflict with
115 // the vector and slot registers, which need to be preserved for a handler
116 // call or miss.
117 if (IC::ICUseVector(ic_kind)) {
118 Register vector = VectorLoadICDescriptor::VectorRegister();
119 Register slot = VectorLoadICDescriptor::SlotRegister();
120 DCHECK(!AreAliased(vector, slot, scratch));
121 }
122 #endif
123
110 Counters* counters = masm->isolate()->counters(); 124 Counters* counters = masm->isolate()->counters();
111 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1); 125 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1);
112 126
113 // Check that the receiver isn't a smi. 127 // Check that the receiver isn't a smi.
114 __ JumpIfSmi(receiver, &miss); 128 __ JumpIfSmi(receiver, &miss);
115 129
116 // Get the map of the receiver and compute the hash. 130 // Get the map of the receiver and compute the hash.
117 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); 131 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset));
118 // Use only the low 32 bits of the map pointer. 132 // Use only the low 32 bits of the map pointer.
119 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); 133 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset));
120 __ xorp(scratch, Immediate(flags)); 134 __ xorp(scratch, Immediate(flags));
121 // We mask out the last two bits because they are not part of the hash and 135 // We mask out the last two bits because they are not part of the hash and
122 // they are always 01 for maps. Also in the two 'and' instructions below. 136 // they are always 01 for maps. Also in the two 'and' instructions below.
123 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); 137 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift));
124 138
125 // Probe the primary table. 139 // Probe the primary table.
126 ProbeTable(isolate, masm, flags, leave_frame, kPrimary, receiver, name, 140 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kPrimary, receiver,
127 scratch); 141 name, scratch);
128 142
129 // Primary miss: Compute hash for secondary probe. 143 // Primary miss: Compute hash for secondary probe.
130 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset)); 144 __ movl(scratch, FieldOperand(name, Name::kHashFieldOffset));
131 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); 145 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset));
132 __ xorp(scratch, Immediate(flags)); 146 __ xorp(scratch, Immediate(flags));
133 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift)); 147 __ andp(scratch, Immediate((kPrimaryTableSize - 1) << kCacheIndexShift));
134 __ subl(scratch, name); 148 __ subl(scratch, name);
135 __ addl(scratch, Immediate(flags)); 149 __ addl(scratch, Immediate(flags));
136 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift)); 150 __ andp(scratch, Immediate((kSecondaryTableSize - 1) << kCacheIndexShift));
137 151
138 // Probe the secondary table. 152 // Probe the secondary table.
139 ProbeTable(isolate, masm, flags, leave_frame, kSecondary, receiver, name, 153 ProbeTable(isolate, masm, ic_kind, flags, leave_frame, kSecondary, receiver,
140 scratch); 154 name, scratch);
141 155
142 // Cache miss: Fall-through and let caller handle the miss by 156 // Cache miss: Fall-through and let caller handle the miss by
143 // entering the runtime system. 157 // entering the runtime system.
144 __ bind(&miss); 158 __ bind(&miss);
145 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); 159 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1);
146 } 160 }
147 161
148 162
149 #undef __ 163 #undef __
150 } 164 }
151 } // namespace v8::internal 165 } // namespace v8::internal
152 166
153 #endif // V8_TARGET_ARCH_X64 167 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ic/x64/ic-x64.cc ('k') | src/ic/x87/handler-compiler-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698