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

Side by Side Diff: src/ic/ia32/ic-compiler-ia32.cc

Issue 483683005: Move IC code into a subdir and move ic-compilation related code from stub-cache into ic-compiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix BUILD.gn Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/ic/arm64/stub-cache-arm64.cc ('k') | src/ic/ia32/ic-ia32.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 2014 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_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/codegen.h" 9 #include "src/ic/ic-compiler.h"
10 #include "src/ic-inl.h"
11 #include "src/stub-cache.h"
12 10
13 namespace v8 { 11 namespace v8 {
14 namespace internal { 12 namespace internal {
15 13
16 #define __ ACCESS_MASM(masm) 14 #define __ ACCESS_MASM(masm)
17 15
18
19 static void ProbeTable(Isolate* isolate,
20 MacroAssembler* masm,
21 Code::Flags flags,
22 StubCache::Table table,
23 Register name,
24 Register receiver,
25 // Number of the cache entry pointer-size scaled.
26 Register offset,
27 Register extra) {
28 ExternalReference key_offset(isolate->stub_cache()->key_reference(table));
29 ExternalReference value_offset(isolate->stub_cache()->value_reference(table));
30 ExternalReference map_offset(isolate->stub_cache()->map_reference(table));
31
32 Label miss;
33
34 // Multiply by 3 because there are 3 fields per entry (name, code, map).
35 __ lea(offset, Operand(offset, offset, times_2, 0));
36
37 if (extra.is_valid()) {
38 // Get the code entry from the cache.
39 __ mov(extra, Operand::StaticArray(offset, times_1, value_offset));
40
41 // Check that the key in the entry matches the name.
42 __ cmp(name, Operand::StaticArray(offset, times_1, key_offset));
43 __ j(not_equal, &miss);
44
45 // Check the map matches.
46 __ mov(offset, Operand::StaticArray(offset, times_1, map_offset));
47 __ cmp(offset, FieldOperand(receiver, HeapObject::kMapOffset));
48 __ j(not_equal, &miss);
49
50 // Check that the flags match what we're looking for.
51 __ mov(offset, FieldOperand(extra, Code::kFlagsOffset));
52 __ and_(offset, ~Code::kFlagsNotUsedInLookup);
53 __ cmp(offset, flags);
54 __ j(not_equal, &miss);
55
56 #ifdef DEBUG
57 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) {
58 __ jmp(&miss);
59 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
60 __ jmp(&miss);
61 }
62 #endif
63
64 // Jump to the first instruction in the code stub.
65 __ add(extra, Immediate(Code::kHeaderSize - kHeapObjectTag));
66 __ jmp(extra);
67
68 __ bind(&miss);
69 } else {
70 // Save the offset on the stack.
71 __ push(offset);
72
73 // Check that the key in the entry matches the name.
74 __ cmp(name, Operand::StaticArray(offset, times_1, key_offset));
75 __ j(not_equal, &miss);
76
77 // Check the map matches.
78 __ mov(offset, Operand::StaticArray(offset, times_1, map_offset));
79 __ cmp(offset, FieldOperand(receiver, HeapObject::kMapOffset));
80 __ j(not_equal, &miss);
81
82 // Restore offset register.
83 __ mov(offset, Operand(esp, 0));
84
85 // Get the code entry from the cache.
86 __ mov(offset, Operand::StaticArray(offset, times_1, value_offset));
87
88 // Check that the flags match what we're looking for.
89 __ mov(offset, FieldOperand(offset, Code::kFlagsOffset));
90 __ and_(offset, ~Code::kFlagsNotUsedInLookup);
91 __ cmp(offset, flags);
92 __ j(not_equal, &miss);
93
94 #ifdef DEBUG
95 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) {
96 __ jmp(&miss);
97 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) {
98 __ jmp(&miss);
99 }
100 #endif
101
102 // Restore offset and re-load code entry from cache.
103 __ pop(offset);
104 __ mov(offset, Operand::StaticArray(offset, times_1, value_offset));
105
106 // Jump to the first instruction in the code stub.
107 __ add(offset, Immediate(Code::kHeaderSize - kHeapObjectTag));
108 __ jmp(offset);
109
110 // Pop at miss.
111 __ bind(&miss);
112 __ pop(offset);
113 }
114 }
115
116
117 void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup( 16 void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup(
118 MacroAssembler* masm, Label* miss_label, Register receiver, 17 MacroAssembler* masm, Label* miss_label, Register receiver,
119 Handle<Name> name, Register scratch0, Register scratch1) { 18 Handle<Name> name, Register scratch0, Register scratch1) {
120 DCHECK(name->IsUniqueName()); 19 DCHECK(name->IsUniqueName());
121 DCHECK(!receiver.is(scratch0)); 20 DCHECK(!receiver.is(scratch0));
122 Counters* counters = masm->isolate()->counters(); 21 Counters* counters = masm->isolate()->counters();
123 __ IncrementCounter(counters->negative_lookups(), 1); 22 __ IncrementCounter(counters->negative_lookups(), 1);
124 __ IncrementCounter(counters->negative_lookups_miss(), 1); 23 __ IncrementCounter(counters->negative_lookups_miss(), 1);
125 24
126 __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset)); 25 __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset));
(...skipping 13 matching lines...) Expand all
140 // Load properties array. 39 // Load properties array.
141 Register properties = scratch0; 40 Register properties = scratch0;
142 __ mov(properties, FieldOperand(receiver, JSObject::kPropertiesOffset)); 41 __ mov(properties, FieldOperand(receiver, JSObject::kPropertiesOffset));
143 42
144 // Check that the properties array is a dictionary. 43 // Check that the properties array is a dictionary.
145 __ cmp(FieldOperand(properties, HeapObject::kMapOffset), 44 __ cmp(FieldOperand(properties, HeapObject::kMapOffset),
146 Immediate(masm->isolate()->factory()->hash_table_map())); 45 Immediate(masm->isolate()->factory()->hash_table_map()));
147 __ j(not_equal, miss_label); 46 __ j(not_equal, miss_label);
148 47
149 Label done; 48 Label done;
150 NameDictionaryLookupStub::GenerateNegativeLookup(masm, 49 NameDictionaryLookupStub::GenerateNegativeLookup(masm, miss_label, &done,
151 miss_label, 50 properties, name, scratch1);
152 &done,
153 properties,
154 name,
155 scratch1);
156 __ bind(&done); 51 __ bind(&done);
157 __ DecrementCounter(counters->negative_lookups_miss(), 1); 52 __ DecrementCounter(counters->negative_lookups_miss(), 1);
158 } 53 }
159 54
160 55
161 void StubCache::GenerateProbe(MacroAssembler* masm,
162 Code::Flags flags,
163 Register receiver,
164 Register name,
165 Register scratch,
166 Register extra,
167 Register extra2,
168 Register extra3) {
169 Label miss;
170
171 // Assert that code is valid. The multiplying code relies on the entry size
172 // being 12.
173 DCHECK(sizeof(Entry) == 12);
174
175 // Assert the flags do not name a specific type.
176 DCHECK(Code::ExtractTypeFromFlags(flags) == 0);
177
178 // Assert that there are no register conflicts.
179 DCHECK(!scratch.is(receiver));
180 DCHECK(!scratch.is(name));
181 DCHECK(!extra.is(receiver));
182 DCHECK(!extra.is(name));
183 DCHECK(!extra.is(scratch));
184
185 // Assert scratch and extra registers are valid, and extra2/3 are unused.
186 DCHECK(!scratch.is(no_reg));
187 DCHECK(extra2.is(no_reg));
188 DCHECK(extra3.is(no_reg));
189
190 Register offset = scratch;
191 scratch = no_reg;
192
193 Counters* counters = masm->isolate()->counters();
194 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1);
195
196 // Check that the receiver isn't a smi.
197 __ JumpIfSmi(receiver, &miss);
198
199 // Get the map of the receiver and compute the hash.
200 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset));
201 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset));
202 __ xor_(offset, flags);
203 // We mask out the last two bits because they are not part of the hash and
204 // they are always 01 for maps. Also in the two 'and' instructions below.
205 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift);
206 // ProbeTable expects the offset to be pointer scaled, which it is, because
207 // the heap object tag size is 2 and the pointer size log 2 is also 2.
208 DCHECK(kCacheIndexShift == kPointerSizeLog2);
209
210 // Probe the primary table.
211 ProbeTable(isolate(), masm, flags, kPrimary, name, receiver, offset, extra);
212
213 // Primary miss: Compute hash for secondary probe.
214 __ mov(offset, FieldOperand(name, Name::kHashFieldOffset));
215 __ add(offset, FieldOperand(receiver, HeapObject::kMapOffset));
216 __ xor_(offset, flags);
217 __ and_(offset, (kPrimaryTableSize - 1) << kCacheIndexShift);
218 __ sub(offset, name);
219 __ add(offset, Immediate(flags));
220 __ and_(offset, (kSecondaryTableSize - 1) << kCacheIndexShift);
221
222 // Probe the secondary table.
223 ProbeTable(
224 isolate(), masm, flags, kSecondary, name, receiver, offset, extra);
225
226 // Cache miss: Fall-through and let caller handle the miss by
227 // entering the runtime system.
228 __ bind(&miss);
229 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1);
230 }
231
232
233 void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype( 56 void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype(
234 MacroAssembler* masm, int index, Register prototype, Label* miss) { 57 MacroAssembler* masm, int index, Register prototype, Label* miss) {
235 // Get the global function with the given index. 58 // Get the global function with the given index.
236 Handle<JSFunction> function( 59 Handle<JSFunction> function(
237 JSFunction::cast(masm->isolate()->native_context()->get(index))); 60 JSFunction::cast(masm->isolate()->native_context()->get(index)));
238 // Check we're still in the same context. 61 // Check we're still in the same context.
239 Register scratch = prototype; 62 Register scratch = prototype;
240 const int offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX); 63 const int offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX);
241 __ mov(scratch, Operand(esi, offset)); 64 __ mov(scratch, Operand(esi, offset));
242 __ mov(scratch, FieldOperand(scratch, GlobalObject::kNativeContextOffset)); 65 __ mov(scratch, FieldOperand(scratch, GlobalObject::kNativeContextOffset));
243 __ cmp(Operand(scratch, Context::SlotOffset(index)), function); 66 __ cmp(Operand(scratch, Context::SlotOffset(index)), function);
244 __ j(not_equal, miss); 67 __ j(not_equal, miss);
245 68
246 // Load its initial map. The global functions all have initial maps. 69 // Load its initial map. The global functions all have initial maps.
247 __ Move(prototype, Immediate(Handle<Map>(function->initial_map()))); 70 __ Move(prototype, Immediate(Handle<Map>(function->initial_map())));
248 // Load the prototype from the initial map. 71 // Load the prototype from the initial map.
249 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); 72 __ mov(prototype, FieldOperand(prototype, Map::kPrototypeOffset));
250 } 73 }
251 74
252 75
253 void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype( 76 void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(
254 MacroAssembler* masm, Register receiver, Register scratch1, 77 MacroAssembler* masm, Register receiver, Register scratch1,
255 Register scratch2, Label* miss_label) { 78 Register scratch2, Label* miss_label) {
256 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); 79 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label);
257 __ mov(eax, scratch1); 80 __ mov(eax, scratch1);
258 __ ret(0); 81 __ ret(0);
259 } 82 }
260 83
261 84
262 static void PushInterceptorArguments(MacroAssembler* masm, 85 static void PushInterceptorArguments(MacroAssembler* masm, Register receiver,
263 Register receiver, 86 Register holder, Register name,
264 Register holder,
265 Register name,
266 Handle<JSObject> holder_obj) { 87 Handle<JSObject> holder_obj) {
267 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0); 88 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
268 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1); 89 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
269 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2); 90 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
270 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3); 91 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
271 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4); 92 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
272 __ push(name); 93 __ push(name);
273 Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); 94 Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
274 DCHECK(!masm->isolate()->heap()->InNewSpace(*interceptor)); 95 DCHECK(!masm->isolate()->heap()->InNewSpace(*interceptor));
275 Register scratch = name; 96 Register scratch = name;
276 __ mov(scratch, Immediate(interceptor)); 97 __ mov(scratch, Immediate(interceptor));
277 __ push(scratch); 98 __ push(scratch);
278 __ push(receiver); 99 __ push(receiver);
279 __ push(holder); 100 __ push(holder);
280 } 101 }
281 102
282 103
283 static void CompileCallLoadPropertyWithInterceptor( 104 static void CompileCallLoadPropertyWithInterceptor(
284 MacroAssembler* masm, 105 MacroAssembler* masm, Register receiver, Register holder, Register name,
285 Register receiver, 106 Handle<JSObject> holder_obj, IC::UtilityId id) {
286 Register holder,
287 Register name,
288 Handle<JSObject> holder_obj,
289 IC::UtilityId id) {
290 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); 107 PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
291 __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()), 108 __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
292 NamedLoadHandlerCompiler::kInterceptorArgsLength); 109 NamedLoadHandlerCompiler::kInterceptorArgsLength);
293 } 110 }
294 111
295 112
296 // Generate call to api function. 113 // Generate call to api function.
297 // This function uses push() to generate smaller, faster code than 114 // This function uses push() to generate smaller, faster code than
298 // the version above. It is an optimization that should will be removed 115 // the version above. It is an optimization that should will be removed
299 // when api call ICs are generated in hydrogen. 116 // when api call ICs are generated in hydrogen.
300 void PropertyHandlerCompiler::GenerateFastApiCall( 117 void PropertyHandlerCompiler::GenerateFastApiCall(
301 MacroAssembler* masm, const CallOptimization& optimization, 118 MacroAssembler* masm, const CallOptimization& optimization,
302 Handle<Map> receiver_map, Register receiver, Register scratch_in, 119 Handle<Map> receiver_map, Register receiver, Register scratch_in,
303 bool is_store, int argc, Register* values) { 120 bool is_store, int argc, Register* values) {
304 // Copy return value. 121 // Copy return value.
305 __ pop(scratch_in); 122 __ pop(scratch_in);
306 // receiver 123 // receiver
307 __ push(receiver); 124 __ push(receiver);
308 // Write the arguments to stack frame. 125 // Write the arguments to stack frame.
309 for (int i = 0; i < argc; i++) { 126 for (int i = 0; i < argc; i++) {
310 Register arg = values[argc-1-i]; 127 Register arg = values[argc - 1 - i];
311 DCHECK(!receiver.is(arg)); 128 DCHECK(!receiver.is(arg));
312 DCHECK(!scratch_in.is(arg)); 129 DCHECK(!scratch_in.is(arg));
313 __ push(arg); 130 __ push(arg);
314 } 131 }
315 __ push(scratch_in); 132 __ push(scratch_in);
316 // Stack now matches JSFunction abi. 133 // Stack now matches JSFunction abi.
317 DCHECK(optimization.is_simple_api_call()); 134 DCHECK(optimization.is_simple_api_call());
318 135
319 // Abi for CallApiFunctionStub. 136 // Abi for CallApiFunctionStub.
320 Register callee = eax; 137 Register callee = eax;
321 Register call_data = ebx; 138 Register call_data = ebx;
322 Register holder = ecx; 139 Register holder = ecx;
323 Register api_function_address = edx; 140 Register api_function_address = edx;
324 Register scratch = edi; // scratch_in is no longer valid. 141 Register scratch = edi; // scratch_in is no longer valid.
325 142
326 // Put holder in place. 143 // Put holder in place.
327 CallOptimization::HolderLookup holder_lookup; 144 CallOptimization::HolderLookup holder_lookup;
328 Handle<JSObject> api_holder = optimization.LookupHolderOfExpectedType( 145 Handle<JSObject> api_holder =
329 receiver_map, 146 optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
330 &holder_lookup);
331 switch (holder_lookup) { 147 switch (holder_lookup) {
332 case CallOptimization::kHolderIsReceiver: 148 case CallOptimization::kHolderIsReceiver:
333 __ Move(holder, receiver); 149 __ Move(holder, receiver);
334 break; 150 break;
335 case CallOptimization::kHolderFound: 151 case CallOptimization::kHolderFound:
336 __ LoadHeapObject(holder, api_holder); 152 __ LoadHeapObject(holder, api_holder);
337 break; 153 break;
338 case CallOptimization::kHolderNotFound: 154 case CallOptimization::kHolderNotFound:
339 UNREACHABLE(); 155 UNREACHABLE();
340 break; 156 break;
341 } 157 }
342 158
343 Isolate* isolate = masm->isolate(); 159 Isolate* isolate = masm->isolate();
344 Handle<JSFunction> function = optimization.constant_function(); 160 Handle<JSFunction> function = optimization.constant_function();
345 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); 161 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
346 Handle<Object> call_data_obj(api_call_info->data(), isolate); 162 Handle<Object> call_data_obj(api_call_info->data(), isolate);
347 163
(...skipping 21 matching lines...) Expand all
369 __ TailCallStub(&stub); 185 __ TailCallStub(&stub);
370 } 186 }
371 187
372 188
373 // Generate code to check that a global property cell is empty. Create 189 // Generate code to check that a global property cell is empty. Create
374 // the property cell at compilation time if no cell exists for the 190 // the property cell at compilation time if no cell exists for the
375 // property. 191 // property.
376 void PropertyHandlerCompiler::GenerateCheckPropertyCell( 192 void PropertyHandlerCompiler::GenerateCheckPropertyCell(
377 MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name, 193 MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name,
378 Register scratch, Label* miss) { 194 Register scratch, Label* miss) {
379 Handle<PropertyCell> cell = 195 Handle<PropertyCell> cell = JSGlobalObject::EnsurePropertyCell(global, name);
380 JSGlobalObject::EnsurePropertyCell(global, name);
381 DCHECK(cell->value()->IsTheHole()); 196 DCHECK(cell->value()->IsTheHole());
382 Handle<Oddball> the_hole = masm->isolate()->factory()->the_hole_value(); 197 Handle<Oddball> the_hole = masm->isolate()->factory()->the_hole_value();
383 if (masm->serializer_enabled()) { 198 if (masm->serializer_enabled()) {
384 __ mov(scratch, Immediate(cell)); 199 __ mov(scratch, Immediate(cell));
385 __ cmp(FieldOperand(scratch, PropertyCell::kValueOffset), 200 __ cmp(FieldOperand(scratch, PropertyCell::kValueOffset),
386 Immediate(the_hole)); 201 Immediate(the_hole));
387 } else { 202 } else {
388 __ cmp(Operand::ForCell(cell), Immediate(the_hole)); 203 __ cmp(Operand::ForCell(cell), Immediate(the_hole));
389 } 204 }
390 __ j(not_equal, miss); 205 __ j(not_equal, miss);
(...skipping 29 matching lines...) Expand all
420 DescriptorArray* descriptors = transition->instance_descriptors(); 235 DescriptorArray* descriptors = transition->instance_descriptors();
421 PropertyDetails details = descriptors->GetDetails(descriptor); 236 PropertyDetails details = descriptors->GetDetails(descriptor);
422 Representation representation = details.representation(); 237 Representation representation = details.representation();
423 DCHECK(!representation.IsNone()); 238 DCHECK(!representation.IsNone());
424 239
425 if (details.type() == CONSTANT) { 240 if (details.type() == CONSTANT) {
426 Handle<Object> constant(descriptors->GetValue(descriptor), isolate()); 241 Handle<Object> constant(descriptors->GetValue(descriptor), isolate());
427 __ CmpObject(value_reg, constant); 242 __ CmpObject(value_reg, constant);
428 __ j(not_equal, miss_label); 243 __ j(not_equal, miss_label);
429 } else if (representation.IsSmi()) { 244 } else if (representation.IsSmi()) {
430 __ JumpIfNotSmi(value_reg, miss_label); 245 __ JumpIfNotSmi(value_reg, miss_label);
431 } else if (representation.IsHeapObject()) { 246 } else if (representation.IsHeapObject()) {
432 __ JumpIfSmi(value_reg, miss_label); 247 __ JumpIfSmi(value_reg, miss_label);
433 HeapType* field_type = descriptors->GetFieldType(descriptor); 248 HeapType* field_type = descriptors->GetFieldType(descriptor);
434 HeapType::Iterator<Map> it = field_type->Classes(); 249 HeapType::Iterator<Map> it = field_type->Classes();
435 if (!it.Done()) { 250 if (!it.Done()) {
436 Label do_store; 251 Label do_store;
437 while (true) { 252 while (true) {
438 __ CompareMap(value_reg, it.Current()); 253 __ CompareMap(value_reg, it.Current());
439 it.Advance(); 254 it.Advance();
440 if (it.Done()) { 255 if (it.Done()) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 isolate()), 297 isolate()),
483 3, 1); 298 3, 1);
484 return; 299 return;
485 } 300 }
486 301
487 // Update the map of the object. 302 // Update the map of the object.
488 __ mov(scratch1, Immediate(transition)); 303 __ mov(scratch1, Immediate(transition));
489 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1); 304 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1);
490 305
491 // Update the write barrier for the map field. 306 // Update the write barrier for the map field.
492 __ RecordWriteField(receiver_reg, 307 __ RecordWriteField(receiver_reg, HeapObject::kMapOffset, scratch1, scratch2,
493 HeapObject::kMapOffset, 308 kDontSaveFPRegs, OMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
494 scratch1,
495 scratch2,
496 kDontSaveFPRegs,
497 OMIT_REMEMBERED_SET,
498 OMIT_SMI_CHECK);
499 309
500 if (details.type() == CONSTANT) { 310 if (details.type() == CONSTANT) {
501 DCHECK(value_reg.is(eax)); 311 DCHECK(value_reg.is(eax));
502 __ ret(0); 312 __ ret(0);
503 return; 313 return;
504 } 314 }
505 315
506 int index = transition->instance_descriptors()->GetFieldIndex( 316 int index = transition->instance_descriptors()->GetFieldIndex(
507 transition->LastAdded()); 317 transition->LastAdded());
508 318
509 // Adjust for the number of properties stored in the object. Even in the 319 // Adjust for the number of properties stored in the object. Even in the
510 // face of a transition we can use the old map here because the size of the 320 // face of a transition we can use the old map here because the size of the
511 // object and the number of in-object properties is not going to change. 321 // object and the number of in-object properties is not going to change.
512 index -= transition->inobject_properties(); 322 index -= transition->inobject_properties();
513 323
514 SmiCheck smi_check = representation.IsTagged() 324 SmiCheck smi_check =
515 ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; 325 representation.IsTagged() ? INLINE_SMI_CHECK : OMIT_SMI_CHECK;
516 // TODO(verwaest): Share this code as a code stub. 326 // TODO(verwaest): Share this code as a code stub.
517 if (index < 0) { 327 if (index < 0) {
518 // Set the property straight into the object. 328 // Set the property straight into the object.
519 int offset = transition->instance_size() + (index * kPointerSize); 329 int offset = transition->instance_size() + (index * kPointerSize);
520 if (representation.IsDouble()) { 330 if (representation.IsDouble()) {
521 __ mov(FieldOperand(receiver_reg, offset), storage_reg); 331 __ mov(FieldOperand(receiver_reg, offset), storage_reg);
522 } else { 332 } else {
523 __ mov(FieldOperand(receiver_reg, offset), value_reg); 333 __ mov(FieldOperand(receiver_reg, offset), value_reg);
524 } 334 }
525 335
526 if (!representation.IsSmi()) { 336 if (!representation.IsSmi()) {
527 // Update the write barrier for the array address. 337 // Update the write barrier for the array address.
528 if (!representation.IsDouble()) { 338 if (!representation.IsDouble()) {
529 __ mov(storage_reg, value_reg); 339 __ mov(storage_reg, value_reg);
530 } 340 }
531 __ RecordWriteField(receiver_reg, 341 __ RecordWriteField(receiver_reg, offset, storage_reg, scratch1,
532 offset, 342 kDontSaveFPRegs, EMIT_REMEMBERED_SET, smi_check);
533 storage_reg,
534 scratch1,
535 kDontSaveFPRegs,
536 EMIT_REMEMBERED_SET,
537 smi_check);
538 } 343 }
539 } else { 344 } else {
540 // Write to the properties array. 345 // Write to the properties array.
541 int offset = index * kPointerSize + FixedArray::kHeaderSize; 346 int offset = index * kPointerSize + FixedArray::kHeaderSize;
542 // Get the properties array (optimistically). 347 // Get the properties array (optimistically).
543 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); 348 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset));
544 if (representation.IsDouble()) { 349 if (representation.IsDouble()) {
545 __ mov(FieldOperand(scratch1, offset), storage_reg); 350 __ mov(FieldOperand(scratch1, offset), storage_reg);
546 } else { 351 } else {
547 __ mov(FieldOperand(scratch1, offset), value_reg); 352 __ mov(FieldOperand(scratch1, offset), value_reg);
548 } 353 }
549 354
550 if (!representation.IsSmi()) { 355 if (!representation.IsSmi()) {
551 // Update the write barrier for the array address. 356 // Update the write barrier for the array address.
552 if (!representation.IsDouble()) { 357 if (!representation.IsDouble()) {
553 __ mov(storage_reg, value_reg); 358 __ mov(storage_reg, value_reg);
554 } 359 }
555 __ RecordWriteField(scratch1, 360 __ RecordWriteField(scratch1, offset, storage_reg, receiver_reg,
556 offset, 361 kDontSaveFPRegs, EMIT_REMEMBERED_SET, smi_check);
557 storage_reg,
558 receiver_reg,
559 kDontSaveFPRegs,
560 EMIT_REMEMBERED_SET,
561 smi_check);
562 } 362 }
563 } 363 }
564 364
565 // Return the value (register eax). 365 // Return the value (register eax).
566 DCHECK(value_reg.is(eax)); 366 DCHECK(value_reg.is(eax));
567 __ ret(0); 367 __ ret(0);
568 } 368 }
569 369
570 370
571 void NamedStoreHandlerCompiler::GenerateStoreField(LookupIterator* lookup, 371 void NamedStoreHandlerCompiler::GenerateStoreField(LookupIterator* lookup,
(...skipping 21 matching lines...) Expand all
593 393
594 394
595 Register PropertyHandlerCompiler::CheckPrototypes( 395 Register PropertyHandlerCompiler::CheckPrototypes(
596 Register object_reg, Register holder_reg, Register scratch1, 396 Register object_reg, Register holder_reg, Register scratch1,
597 Register scratch2, Handle<Name> name, Label* miss, 397 Register scratch2, Handle<Name> name, Label* miss,
598 PrototypeCheckType check) { 398 PrototypeCheckType check) {
599 Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate())); 399 Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate()));
600 400
601 // Make sure there's no overlap between holder and object registers. 401 // Make sure there's no overlap between holder and object registers.
602 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); 402 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
603 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) 403 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) &&
604 && !scratch2.is(scratch1)); 404 !scratch2.is(scratch1));
605 405
606 // Keep track of the current object in register reg. 406 // Keep track of the current object in register reg.
607 Register reg = object_reg; 407 Register reg = object_reg;
608 int depth = 0; 408 int depth = 0;
609 409
610 Handle<JSObject> current = Handle<JSObject>::null(); 410 Handle<JSObject> current = Handle<JSObject>::null();
611 if (type()->IsConstant()) 411 if (type()->IsConstant())
612 current = Handle<JSObject>::cast(type()->AsConstant()->Value()); 412 current = Handle<JSObject>::cast(type()->AsConstant()->Value());
613 Handle<JSObject> prototype = Handle<JSObject>::null(); 413 Handle<JSObject> prototype = Handle<JSObject>::null();
614 Handle<Map> current_map = receiver_map; 414 Handle<Map> current_map = receiver_map;
(...skipping 11 matching lines...) Expand all
626 prototype = handle(JSObject::cast(current_map->prototype())); 426 prototype = handle(JSObject::cast(current_map->prototype()));
627 if (current_map->is_dictionary_map() && 427 if (current_map->is_dictionary_map() &&
628 !current_map->IsJSGlobalObjectMap()) { 428 !current_map->IsJSGlobalObjectMap()) {
629 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. 429 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast.
630 if (!name->IsUniqueName()) { 430 if (!name->IsUniqueName()) {
631 DCHECK(name->IsString()); 431 DCHECK(name->IsString());
632 name = factory()->InternalizeString(Handle<String>::cast(name)); 432 name = factory()->InternalizeString(Handle<String>::cast(name));
633 } 433 }
634 DCHECK(current.is_null() || 434 DCHECK(current.is_null() ||
635 current->property_dictionary()->FindEntry(name) == 435 current->property_dictionary()->FindEntry(name) ==
636 NameDictionary::kNotFound); 436 NameDictionary::kNotFound);
637 437
638 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, 438 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1,
639 scratch1, scratch2); 439 scratch2);
640 440
641 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); 441 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset));
642 reg = holder_reg; // From now on the object will be in holder_reg. 442 reg = holder_reg; // From now on the object will be in holder_reg.
643 __ mov(reg, FieldOperand(scratch1, Map::kPrototypeOffset)); 443 __ mov(reg, FieldOperand(scratch1, Map::kPrototypeOffset));
644 } else { 444 } else {
645 bool in_new_space = heap()->InNewSpace(*prototype); 445 bool in_new_space = heap()->InNewSpace(*prototype);
646 // Two possible reasons for loading the prototype from the map: 446 // Two possible reasons for loading the prototype from the map:
647 // (1) Can't store references to new space in code. 447 // (1) Can't store references to new space in code.
648 // (2) Handler is shared for all receivers with the same prototype 448 // (2) Handler is shared for all receivers with the same prototype
649 // map (but not necessarily the same prototype instance). 449 // map (but not necessarily the same prototype instance).
650 bool load_prototype_from_map = in_new_space || depth == 1; 450 bool load_prototype_from_map = in_new_space || depth == 1;
651 if (depth != 1 || check == CHECK_ALL_MAPS) { 451 if (depth != 1 || check == CHECK_ALL_MAPS) {
652 __ CheckMap(reg, current_map, miss, DONT_DO_SMI_CHECK); 452 __ CheckMap(reg, current_map, miss, DONT_DO_SMI_CHECK);
653 } 453 }
654 454
655 // Check access rights to the global object. This has to happen after 455 // Check access rights to the global object. This has to happen after
656 // the map check so that we know that the object is actually a global 456 // the map check so that we know that the object is actually a global
657 // object. 457 // object.
658 // This allows us to install generated handlers for accesses to the 458 // This allows us to install generated handlers for accesses to the
659 // global proxy (as opposed to using slow ICs). See corresponding code 459 // global proxy (as opposed to using slow ICs). See corresponding code
660 // in LookupForRead(). 460 // in LookupForRead().
661 if (current_map->IsJSGlobalProxyMap()) { 461 if (current_map->IsJSGlobalProxyMap()) {
662 __ CheckAccessGlobalProxy(reg, scratch1, scratch2, miss); 462 __ CheckAccessGlobalProxy(reg, scratch1, scratch2, miss);
663 } else if (current_map->IsJSGlobalObjectMap()) { 463 } else if (current_map->IsJSGlobalObjectMap()) {
664 GenerateCheckPropertyCell( 464 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current),
665 masm(), Handle<JSGlobalObject>::cast(current), name, 465 name, scratch2, miss);
666 scratch2, miss);
667 } 466 }
668 467
669 if (load_prototype_from_map) { 468 if (load_prototype_from_map) {
670 // Save the map in scratch1 for later. 469 // Save the map in scratch1 for later.
671 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); 470 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset));
672 } 471 }
673 472
674 reg = holder_reg; // From now on the object will be in holder_reg. 473 reg = holder_reg; // From now on the object will be in holder_reg.
675 474
676 if (load_prototype_from_map) { 475 if (load_prototype_from_map) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 // Call the JavaScript setter with receiver and value on the stack. 705 // Call the JavaScript setter with receiver and value on the stack.
907 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { 706 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
908 // Swap in the global receiver. 707 // Swap in the global receiver.
909 __ mov(receiver, 708 __ mov(receiver,
910 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); 709 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
911 } 710 }
912 __ push(receiver); 711 __ push(receiver);
913 __ push(value()); 712 __ push(value());
914 ParameterCount actual(1); 713 ParameterCount actual(1);
915 ParameterCount expected(setter); 714 ParameterCount expected(setter);
916 __ InvokeFunction(setter, expected, actual, 715 __ InvokeFunction(setter, expected, actual, CALL_FUNCTION,
917 CALL_FUNCTION, NullCallWrapper()); 716 NullCallWrapper());
918 } else { 717 } else {
919 // If we generate a global code snippet for deoptimization only, remember 718 // If we generate a global code snippet for deoptimization only, remember
920 // the place to continue after deoptimization. 719 // the place to continue after deoptimization.
921 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); 720 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset());
922 } 721 }
923 722
924 // We have to return the passed value, not the return value of the setter. 723 // We have to return the passed value, not the return value of the setter.
925 __ pop(eax); 724 __ pop(eax);
926 725
927 // Restore context register. 726 // Restore context register.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 775
977 // Return the generated code. 776 // Return the generated code.
978 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); 777 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
979 } 778 }
980 779
981 780
982 Register* PropertyAccessCompiler::load_calling_convention() { 781 Register* PropertyAccessCompiler::load_calling_convention() {
983 // receiver, name, scratch1, scratch2, scratch3, scratch4. 782 // receiver, name, scratch1, scratch2, scratch3, scratch4.
984 Register receiver = LoadIC::ReceiverRegister(); 783 Register receiver = LoadIC::ReceiverRegister();
985 Register name = LoadIC::NameRegister(); 784 Register name = LoadIC::NameRegister();
986 static Register registers[] = { receiver, name, ebx, eax, edi, no_reg }; 785 static Register registers[] = {receiver, name, ebx, eax, edi, no_reg};
987 return registers; 786 return registers;
988 } 787 }
989 788
990 789
991 Register* PropertyAccessCompiler::store_calling_convention() { 790 Register* PropertyAccessCompiler::store_calling_convention() {
992 // receiver, name, scratch1, scratch2, scratch3. 791 // receiver, name, scratch1, scratch2, scratch3.
993 Register receiver = StoreIC::ReceiverRegister(); 792 Register receiver = StoreIC::ReceiverRegister();
994 Register name = StoreIC::NameRegister(); 793 Register name = StoreIC::NameRegister();
995 DCHECK(ebx.is(KeyedStoreIC::MapRegister())); 794 DCHECK(ebx.is(KeyedStoreIC::MapRegister()));
996 static Register registers[] = { receiver, name, ebx, edi, no_reg }; 795 static Register registers[] = {receiver, name, ebx, edi, no_reg};
997 return registers; 796 return registers;
998 } 797 }
999 798
1000 799
1001 Register NamedStoreHandlerCompiler::value() { return StoreIC::ValueRegister(); } 800 Register NamedStoreHandlerCompiler::value() { return StoreIC::ValueRegister(); }
1002 801
1003 802
1004 #undef __ 803 #undef __
1005 #define __ ACCESS_MASM(masm) 804 #define __ ACCESS_MASM(masm)
1006 805
1007 806
1008 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( 807 void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
1009 MacroAssembler* masm, Handle<HeapType> type, Register receiver, 808 MacroAssembler* masm, Handle<HeapType> type, Register receiver,
1010 Handle<JSFunction> getter) { 809 Handle<JSFunction> getter) {
1011 { 810 {
1012 FrameScope scope(masm, StackFrame::INTERNAL); 811 FrameScope scope(masm, StackFrame::INTERNAL);
1013 812
1014 if (!getter.is_null()) { 813 if (!getter.is_null()) {
1015 // Call the JavaScript getter with the receiver on the stack. 814 // Call the JavaScript getter with the receiver on the stack.
1016 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { 815 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
1017 // Swap in the global receiver. 816 // Swap in the global receiver.
1018 __ mov(receiver, 817 __ mov(receiver,
1019 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); 818 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
1020 } 819 }
1021 __ push(receiver); 820 __ push(receiver);
1022 ParameterCount actual(0); 821 ParameterCount actual(0);
1023 ParameterCount expected(getter); 822 ParameterCount expected(getter);
1024 __ InvokeFunction(getter, expected, actual, 823 __ InvokeFunction(getter, expected, actual, CALL_FUNCTION,
1025 CALL_FUNCTION, NullCallWrapper()); 824 NullCallWrapper());
1026 } else { 825 } else {
1027 // If we generate a global code snippet for deoptimization only, remember 826 // If we generate a global code snippet for deoptimization only, remember
1028 // the place to continue after deoptimization. 827 // the place to continue after deoptimization.
1029 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset()); 828 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset());
1030 } 829 }
1031 830
1032 // Restore context register. 831 // Restore context register.
1033 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 832 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
1034 } 833 }
1035 __ ret(0); 834 __ ret(0);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 // ----------- S t a t e ------------- 973 // ----------- S t a t e -------------
1175 // -- ecx : key 974 // -- ecx : key
1176 // -- edx : receiver 975 // -- edx : receiver
1177 // -- esp[0] : return address 976 // -- esp[0] : return address
1178 // ----------------------------------- 977 // -----------------------------------
1179 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); 978 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss);
1180 } 979 }
1181 980
1182 981
1183 #undef __ 982 #undef __
1184 983 }
1185 } } // namespace v8::internal 984 } // namespace v8::internal
1186 985
1187 #endif // V8_TARGET_ARCH_IA32 986 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ic/arm64/stub-cache-arm64.cc ('k') | src/ic/ia32/ic-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698