OLD | NEW |
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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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 | 17 |
18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, | 18 static void ProbeTable(Isolate* isolate, MacroAssembler* masm, |
19 Code::Kind ic_kind, Code::Flags flags, bool leave_frame, | 19 Code::Kind ic_kind, Code::Flags flags, |
20 StubCache::Table table, Register name, Register receiver, | 20 StubCache::Table table, Register name, Register receiver, |
21 // Number of the cache entry pointer-size scaled. | 21 // Number of the cache entry pointer-size scaled. |
22 Register offset, Register extra) { | 22 Register offset, Register extra) { |
23 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); | 23 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
24 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); | 24 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); |
25 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); | 25 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); |
26 | 26 |
27 Label miss; | 27 Label miss; |
28 | 28 |
29 // Multiply by 3 because there are 3 fields per entry (name, code, map). | 29 // Multiply by 3 because there are 3 fields per entry (name, code, map). |
(...skipping 26 matching lines...) Expand all Loading... |
56 } | 56 } |
57 #endif | 57 #endif |
58 | 58 |
59 if (IC::ICUseVector(ic_kind)) { | 59 if (IC::ICUseVector(ic_kind)) { |
60 // The vector and slot were pushed onto the stack before starting the | 60 // The vector and slot were pushed onto the stack before starting the |
61 // probe, and need to be dropped before calling the handler. | 61 // probe, and need to be dropped before calling the handler. |
62 __ pop(LoadWithVectorDescriptor::VectorRegister()); | 62 __ pop(LoadWithVectorDescriptor::VectorRegister()); |
63 __ pop(LoadDescriptor::SlotRegister()); | 63 __ pop(LoadDescriptor::SlotRegister()); |
64 } | 64 } |
65 | 65 |
66 if (leave_frame) __ leave(); | |
67 | |
68 // Jump to the first instruction in the code stub. | 66 // Jump to the first instruction in the code stub. |
69 __ add(extra, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 67 __ add(extra, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
70 __ jmp(extra); | 68 __ jmp(extra); |
71 | 69 |
72 __ bind(&miss); | 70 __ bind(&miss); |
73 } else { | 71 } else { |
74 // Save the offset on the stack. | 72 // Save the offset on the stack. |
75 __ push(offset); | 73 __ push(offset); |
76 | 74 |
77 // Check that the key in the entry matches the name. | 75 // Check that the key in the entry matches the name. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // The vector and slot were pushed onto the stack before starting the | 109 // The vector and slot were pushed onto the stack before starting the |
112 // probe, and need to be dropped before calling the handler. | 110 // probe, and need to be dropped before calling the handler. |
113 Register vector = LoadWithVectorDescriptor::VectorRegister(); | 111 Register vector = LoadWithVectorDescriptor::VectorRegister(); |
114 Register slot = LoadDescriptor::SlotRegister(); | 112 Register slot = LoadDescriptor::SlotRegister(); |
115 DCHECK(!offset.is(vector) && !offset.is(slot)); | 113 DCHECK(!offset.is(vector) && !offset.is(slot)); |
116 | 114 |
117 __ pop(vector); | 115 __ pop(vector); |
118 __ pop(slot); | 116 __ pop(slot); |
119 } | 117 } |
120 | 118 |
121 if (leave_frame) __ leave(); | |
122 | |
123 // Jump to the first instruction in the code stub. | 119 // Jump to the first instruction in the code stub. |
124 __ add(offset, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 120 __ add(offset, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
125 __ jmp(offset); | 121 __ jmp(offset); |
126 | 122 |
127 // Pop at miss. | 123 // Pop at miss. |
128 __ bind(&miss); | 124 __ bind(&miss); |
129 __ pop(offset); | 125 __ pop(offset); |
130 } | 126 } |
131 } | 127 } |
132 | 128 |
133 | 129 |
134 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, | 130 void StubCache::GenerateProbe(MacroAssembler* masm, Code::Kind ic_kind, |
135 Code::Flags flags, bool leave_frame, | 131 Code::Flags flags, Register receiver, |
136 Register receiver, Register name, | 132 Register name, Register scratch, Register extra, |
137 Register scratch, Register extra, Register extra2, | 133 Register extra2, Register extra3) { |
138 Register extra3) { | |
139 Label miss; | 134 Label miss; |
140 | 135 |
141 // Assert that code is valid. The multiplying code relies on the entry size | 136 // Assert that code is valid. The multiplying code relies on the entry size |
142 // being 12. | 137 // being 12. |
143 DCHECK(sizeof(Entry) == 12); | 138 DCHECK(sizeof(Entry) == 12); |
144 | 139 |
145 // Assert the flags do not name a specific type. | 140 // Assert the flags do not name a specific type. |
146 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); | 141 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); |
147 | 142 |
148 // Assert that there are no register conflicts. | 143 // Assert that there are no register conflicts. |
(...skipping 22 matching lines...) Expand all Loading... |
171 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); | 166 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); |
172 __ xor_(offset, flags); | 167 __ xor_(offset, flags); |
173 // We mask out the last two bits because they are not part of the hash and | 168 // We mask out the last two bits because they are not part of the hash and |
174 // they are always 01 for maps. Also in the two 'and' instructions below. | 169 // they are always 01 for maps. Also in the two 'and' instructions below. |
175 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); | 170 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); |
176 // ProbeTable expects the offset to be pointer scaled, which it is, because | 171 // ProbeTable expects the offset to be pointer scaled, which it is, because |
177 // the heap object tag size is 2 and the pointer size log 2 is also 2. | 172 // the heap object tag size is 2 and the pointer size log 2 is also 2. |
178 DCHECK(kCacheIndexShift == kPointerSizeLog2); | 173 DCHECK(kCacheIndexShift == kPointerSizeLog2); |
179 | 174 |
180 // Probe the primary table. | 175 // Probe the primary table. |
181 ProbeTable(isolate(), masm, ic_kind, flags, leave_frame, kPrimary, name, | 176 ProbeTable(isolate(), masm, ic_kind, flags, kPrimary, name, receiver, offset, |
182 receiver, offset, extra); | 177 extra); |
183 | 178 |
184 // Primary miss: Compute hash for secondary probe. | 179 // Primary miss: Compute hash for secondary probe. |
185 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset)); | 180 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset)); |
186 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); | 181 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset)); |
187 __ xor_(offset, flags); | 182 __ xor_(offset, flags); |
188 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); | 183 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift); |
189 __ sub(offset, name); | 184 __ sub(offset, name); |
190 __ add(offset, Immediate(flags)); | 185 __ add(offset, Immediate(flags)); |
191 __ and_(offset, (kSecondaryTableSize - 1) << kCacheIndexShift); | 186 __ and_(offset, (kSecondaryTableSize - 1) << kCacheIndexShift); |
192 | 187 |
193 // Probe the secondary table. | 188 // Probe the secondary table. |
194 ProbeTable(isolate(), masm, ic_kind, flags, leave_frame, kSecondary, name, | 189 ProbeTable(isolate(), masm, ic_kind, flags, kSecondary, name, receiver, |
195 receiver, offset, extra); | 190 offset, extra); |
196 | 191 |
197 // Cache miss: Fall-through and let caller handle the miss by | 192 // Cache miss: Fall-through and let caller handle the miss by |
198 // entering the runtime system. | 193 // entering the runtime system. |
199 __ bind(&miss); | 194 __ bind(&miss); |
200 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); | 195 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1); |
201 } | 196 } |
202 | 197 |
203 | 198 |
204 #undef __ | 199 #undef __ |
205 } // namespace internal | 200 } // namespace internal |
206 } // namespace v8 | 201 } // namespace v8 |
207 | 202 |
208 #endif // V8_TARGET_ARCH_IA32 | 203 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |