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

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

Issue 500923002: x87: Move IC code into a subdir and move ic-compilation related code from stub-cache into ic-compil… (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@bleeding_edge
Patch Set: Created 6 years, 3 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 | « no previous file | src/ic/x87/ic-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_X87 7 #if V8_TARGET_ARCH_X87
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 isolate()), 299 isolate()),
485 3, 1); 300 3, 1);
486 return; 301 return;
487 } 302 }
488 303
489 // Update the map of the object. 304 // Update the map of the object.
490 __ mov(scratch1, Immediate(transition)); 305 __ mov(scratch1, Immediate(transition));
491 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1); 306 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1);
492 307
493 // Update the write barrier for the map field. 308 // Update the write barrier for the map field.
494 __ RecordWriteField(receiver_reg, 309 __ RecordWriteField(receiver_reg, HeapObject::kMapOffset, scratch1, scratch2,
495 HeapObject::kMapOffset, 310 OMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
496 scratch1,
497 scratch2,
498 OMIT_REMEMBERED_SET,
499 OMIT_SMI_CHECK);
500 311
501 if (details.type() == CONSTANT) { 312 if (details.type() == CONSTANT) {
502 DCHECK(value_reg.is(eax)); 313 DCHECK(value_reg.is(eax));
503 __ ret(0); 314 __ ret(0);
504 return; 315 return;
505 } 316 }
506 317
507 int index = transition->instance_descriptors()->GetFieldIndex( 318 int index = transition->instance_descriptors()->GetFieldIndex(
508 transition->LastAdded()); 319 transition->LastAdded());
509 320
510 // Adjust for the number of properties stored in the object. Even in the 321 // Adjust for the number of properties stored in the object. Even in the
511 // face of a transition we can use the old map here because the size of the 322 // face of a transition we can use the old map here because the size of the
512 // object and the number of in-object properties is not going to change. 323 // object and the number of in-object properties is not going to change.
513 index -= transition->inobject_properties(); 324 index -= transition->inobject_properties();
514 325
515 SmiCheck smi_check = representation.IsTagged() 326 SmiCheck smi_check =
516 ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; 327 representation.IsTagged() ? INLINE_SMI_CHECK : OMIT_SMI_CHECK;
517 // TODO(verwaest): Share this code as a code stub. 328 // TODO(verwaest): Share this code as a code stub.
518 if (index < 0) { 329 if (index < 0) {
519 // Set the property straight into the object. 330 // Set the property straight into the object.
520 int offset = transition->instance_size() + (index * kPointerSize); 331 int offset = transition->instance_size() + (index * kPointerSize);
521 if (representation.IsDouble()) { 332 if (representation.IsDouble()) {
522 __ mov(FieldOperand(receiver_reg, offset), storage_reg); 333 __ mov(FieldOperand(receiver_reg, offset), storage_reg);
523 } else { 334 } else {
524 __ mov(FieldOperand(receiver_reg, offset), value_reg); 335 __ mov(FieldOperand(receiver_reg, offset), value_reg);
525 } 336 }
526 337
527 if (!representation.IsSmi()) { 338 if (!representation.IsSmi()) {
528 // Update the write barrier for the array address. 339 // Update the write barrier for the array address.
529 if (!representation.IsDouble()) { 340 if (!representation.IsDouble()) {
530 __ mov(storage_reg, value_reg); 341 __ mov(storage_reg, value_reg);
531 } 342 }
532 __ RecordWriteField(receiver_reg, 343 __ RecordWriteField(receiver_reg, offset, storage_reg, scratch1,
533 offset, 344 EMIT_REMEMBERED_SET, smi_check);
534 storage_reg,
535 scratch1,
536 EMIT_REMEMBERED_SET,
537 smi_check);
538 } 345 }
539 } else { 346 } else {
540 // Write to the properties array. 347 // Write to the properties array.
541 int offset = index * kPointerSize + FixedArray::kHeaderSize; 348 int offset = index * kPointerSize + FixedArray::kHeaderSize;
542 // Get the properties array (optimistically). 349 // Get the properties array (optimistically).
543 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); 350 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset));
544 if (representation.IsDouble()) { 351 if (representation.IsDouble()) {
545 __ mov(FieldOperand(scratch1, offset), storage_reg); 352 __ mov(FieldOperand(scratch1, offset), storage_reg);
546 } else { 353 } else {
547 __ mov(FieldOperand(scratch1, offset), value_reg); 354 __ mov(FieldOperand(scratch1, offset), value_reg);
548 } 355 }
549 356
550 if (!representation.IsSmi()) { 357 if (!representation.IsSmi()) {
551 // Update the write barrier for the array address. 358 // Update the write barrier for the array address.
552 if (!representation.IsDouble()) { 359 if (!representation.IsDouble()) {
553 __ mov(storage_reg, value_reg); 360 __ mov(storage_reg, value_reg);
554 } 361 }
555 __ RecordWriteField(scratch1, 362 __ RecordWriteField(scratch1, offset, storage_reg, receiver_reg,
556 offset, 363 EMIT_REMEMBERED_SET, smi_check);
557 storage_reg,
558 receiver_reg,
559 EMIT_REMEMBERED_SET,
560 smi_check);
561 } 364 }
562 } 365 }
563 366
564 // Return the value (register eax). 367 // Return the value (register eax).
565 DCHECK(value_reg.is(eax)); 368 DCHECK(value_reg.is(eax));
566 __ ret(0); 369 __ ret(0);
567 } 370 }
568 371
569 372
570 void NamedStoreHandlerCompiler::GenerateStoreField(LookupIterator* lookup, 373 void NamedStoreHandlerCompiler::GenerateStoreField(LookupIterator* lookup,
(...skipping 21 matching lines...) Expand all
592 395
593 396
594 Register PropertyHandlerCompiler::CheckPrototypes( 397 Register PropertyHandlerCompiler::CheckPrototypes(
595 Register object_reg, Register holder_reg, Register scratch1, 398 Register object_reg, Register holder_reg, Register scratch1,
596 Register scratch2, Handle<Name> name, Label* miss, 399 Register scratch2, Handle<Name> name, Label* miss,
597 PrototypeCheckType check) { 400 PrototypeCheckType check) {
598 Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate())); 401 Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate()));
599 402
600 // Make sure there's no overlap between holder and object registers. 403 // Make sure there's no overlap between holder and object registers.
601 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg)); 404 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
602 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) 405 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) &&
603 && !scratch2.is(scratch1)); 406 !scratch2.is(scratch1));
604 407
605 // Keep track of the current object in register reg. 408 // Keep track of the current object in register reg.
606 Register reg = object_reg; 409 Register reg = object_reg;
607 int depth = 0; 410 int depth = 0;
608 411
609 Handle<JSObject> current = Handle<JSObject>::null(); 412 Handle<JSObject> current = Handle<JSObject>::null();
610 if (type()->IsConstant()) 413 if (type()->IsConstant())
611 current = Handle<JSObject>::cast(type()->AsConstant()->Value()); 414 current = Handle<JSObject>::cast(type()->AsConstant()->Value());
612 Handle<JSObject> prototype = Handle<JSObject>::null(); 415 Handle<JSObject> prototype = Handle<JSObject>::null();
613 Handle<Map> current_map = receiver_map; 416 Handle<Map> current_map = receiver_map;
(...skipping 11 matching lines...) Expand all
625 prototype = handle(JSObject::cast(current_map->prototype())); 428 prototype = handle(JSObject::cast(current_map->prototype()));
626 if (current_map->is_dictionary_map() && 429 if (current_map->is_dictionary_map() &&
627 !current_map->IsJSGlobalObjectMap()) { 430 !current_map->IsJSGlobalObjectMap()) {
628 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. 431 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast.
629 if (!name->IsUniqueName()) { 432 if (!name->IsUniqueName()) {
630 DCHECK(name->IsString()); 433 DCHECK(name->IsString());
631 name = factory()->InternalizeString(Handle<String>::cast(name)); 434 name = factory()->InternalizeString(Handle<String>::cast(name));
632 } 435 }
633 DCHECK(current.is_null() || 436 DCHECK(current.is_null() ||
634 current->property_dictionary()->FindEntry(name) == 437 current->property_dictionary()->FindEntry(name) ==
635 NameDictionary::kNotFound); 438 NameDictionary::kNotFound);
636 439
637 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, 440 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1,
638 scratch1, scratch2); 441 scratch2);
639 442
640 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); 443 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset));
641 reg = holder_reg; // From now on the object will be in holder_reg. 444 reg = holder_reg; // From now on the object will be in holder_reg.
642 __ mov(reg, FieldOperand(scratch1, Map::kPrototypeOffset)); 445 __ mov(reg, FieldOperand(scratch1, Map::kPrototypeOffset));
643 } else { 446 } else {
644 bool in_new_space = heap()->InNewSpace(*prototype); 447 bool in_new_space = heap()->InNewSpace(*prototype);
645 // Two possible reasons for loading the prototype from the map: 448 // Two possible reasons for loading the prototype from the map:
646 // (1) Can't store references to new space in code. 449 // (1) Can't store references to new space in code.
647 // (2) Handler is shared for all receivers with the same prototype 450 // (2) Handler is shared for all receivers with the same prototype
648 // map (but not necessarily the same prototype instance). 451 // map (but not necessarily the same prototype instance).
649 bool load_prototype_from_map = in_new_space || depth == 1; 452 bool load_prototype_from_map = in_new_space || depth == 1;
650 if (depth != 1 || check == CHECK_ALL_MAPS) { 453 if (depth != 1 || check == CHECK_ALL_MAPS) {
651 __ CheckMap(reg, current_map, miss, DONT_DO_SMI_CHECK); 454 __ CheckMap(reg, current_map, miss, DONT_DO_SMI_CHECK);
652 } 455 }
653 456
654 // Check access rights to the global object. This has to happen after 457 // Check access rights to the global object. This has to happen after
655 // the map check so that we know that the object is actually a global 458 // the map check so that we know that the object is actually a global
656 // object. 459 // object.
657 // This allows us to install generated handlers for accesses to the 460 // This allows us to install generated handlers for accesses to the
658 // global proxy (as opposed to using slow ICs). See corresponding code 461 // global proxy (as opposed to using slow ICs). See corresponding code
659 // in LookupForRead(). 462 // in LookupForRead().
660 if (current_map->IsJSGlobalProxyMap()) { 463 if (current_map->IsJSGlobalProxyMap()) {
661 __ CheckAccessGlobalProxy(reg, scratch1, scratch2, miss); 464 __ CheckAccessGlobalProxy(reg, scratch1, scratch2, miss);
662 } else if (current_map->IsJSGlobalObjectMap()) { 465 } else if (current_map->IsJSGlobalObjectMap()) {
663 GenerateCheckPropertyCell( 466 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current),
664 masm(), Handle<JSGlobalObject>::cast(current), name, 467 name, scratch2, miss);
665 scratch2, miss);
666 } 468 }
667 469
668 if (load_prototype_from_map) { 470 if (load_prototype_from_map) {
669 // Save the map in scratch1 for later. 471 // Save the map in scratch1 for later.
670 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset)); 472 __ mov(scratch1, FieldOperand(reg, HeapObject::kMapOffset));
671 } 473 }
672 474
673 reg = holder_reg; // From now on the object will be in holder_reg. 475 reg = holder_reg; // From now on the object will be in holder_reg.
674 476
675 if (load_prototype_from_map) { 477 if (load_prototype_from_map) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 // Call the JavaScript setter with receiver and value on the stack. 707 // Call the JavaScript setter with receiver and value on the stack.
906 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { 708 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
907 // Swap in the global receiver. 709 // Swap in the global receiver.
908 __ mov(receiver, 710 __ mov(receiver,
909 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); 711 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
910 } 712 }
911 __ push(receiver); 713 __ push(receiver);
912 __ push(value()); 714 __ push(value());
913 ParameterCount actual(1); 715 ParameterCount actual(1);
914 ParameterCount expected(setter); 716 ParameterCount expected(setter);
915 __ InvokeFunction(setter, expected, actual, 717 __ InvokeFunction(setter, expected, actual, CALL_FUNCTION,
916 CALL_FUNCTION, NullCallWrapper()); 718 NullCallWrapper());
917 } else { 719 } else {
918 // If we generate a global code snippet for deoptimization only, remember 720 // If we generate a global code snippet for deoptimization only, remember
919 // the place to continue after deoptimization. 721 // the place to continue after deoptimization.
920 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); 722 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset());
921 } 723 }
922 724
923 // We have to return the passed value, not the return value of the setter. 725 // We have to return the passed value, not the return value of the setter.
924 __ pop(eax); 726 __ pop(eax);
925 727
926 // Restore context register. 728 // Restore context register.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 777
976 // Return the generated code. 778 // Return the generated code.
977 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); 779 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
978 } 780 }
979 781
980 782
981 Register* PropertyAccessCompiler::load_calling_convention() { 783 Register* PropertyAccessCompiler::load_calling_convention() {
982 // receiver, name, scratch1, scratch2, scratch3, scratch4. 784 // receiver, name, scratch1, scratch2, scratch3, scratch4.
983 Register receiver = LoadIC::ReceiverRegister(); 785 Register receiver = LoadIC::ReceiverRegister();
984 Register name = LoadIC::NameRegister(); 786 Register name = LoadIC::NameRegister();
985 static Register registers[] = { receiver, name, ebx, eax, edi, no_reg }; 787 static Register registers[] = {receiver, name, ebx, eax, edi, no_reg};
986 return registers; 788 return registers;
987 } 789 }
988 790
989 791
990 Register* PropertyAccessCompiler::store_calling_convention() { 792 Register* PropertyAccessCompiler::store_calling_convention() {
991 // receiver, name, scratch1, scratch2, scratch3. 793 // receiver, name, scratch1, scratch2, scratch3.
992 Register receiver = StoreIC::ReceiverRegister(); 794 Register receiver = StoreIC::ReceiverRegister();
993 Register name = StoreIC::NameRegister(); 795 Register name = StoreIC::NameRegister();
994 DCHECK(ebx.is(KeyedStoreIC::MapRegister())); 796 DCHECK(ebx.is(KeyedStoreIC::MapRegister()));
995 static Register registers[] = { receiver, name, ebx, edi, no_reg }; 797 static Register registers[] = {receiver, name, ebx, edi, no_reg};
996 return registers; 798 return registers;
997 } 799 }
998 800
999 801
1000 Register NamedStoreHandlerCompiler::value() { return StoreIC::ValueRegister(); } 802 Register NamedStoreHandlerCompiler::value() { return StoreIC::ValueRegister(); }
1001 803
1002 804
1003 #undef __ 805 #undef __
1004 #define __ ACCESS_MASM(masm) 806 #define __ ACCESS_MASM(masm)
1005 807
1006 808
1007 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( 809 void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
1008 MacroAssembler* masm, Handle<HeapType> type, Register receiver, 810 MacroAssembler* masm, Handle<HeapType> type, Register receiver,
1009 Handle<JSFunction> getter) { 811 Handle<JSFunction> getter) {
1010 { 812 {
1011 FrameScope scope(masm, StackFrame::INTERNAL); 813 FrameScope scope(masm, StackFrame::INTERNAL);
1012 814
1013 if (!getter.is_null()) { 815 if (!getter.is_null()) {
1014 // Call the JavaScript getter with the receiver on the stack. 816 // Call the JavaScript getter with the receiver on the stack.
1015 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { 817 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
1016 // Swap in the global receiver. 818 // Swap in the global receiver.
1017 __ mov(receiver, 819 __ mov(receiver,
1018 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); 820 FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
1019 } 821 }
1020 __ push(receiver); 822 __ push(receiver);
1021 ParameterCount actual(0); 823 ParameterCount actual(0);
1022 ParameterCount expected(getter); 824 ParameterCount expected(getter);
1023 __ InvokeFunction(getter, expected, actual, 825 __ InvokeFunction(getter, expected, actual, CALL_FUNCTION,
1024 CALL_FUNCTION, NullCallWrapper()); 826 NullCallWrapper());
1025 } else { 827 } else {
1026 // If we generate a global code snippet for deoptimization only, remember 828 // If we generate a global code snippet for deoptimization only, remember
1027 // the place to continue after deoptimization. 829 // the place to continue after deoptimization.
1028 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset()); 830 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset());
1029 } 831 }
1030 832
1031 // Restore context register. 833 // Restore context register.
1032 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 834 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
1033 } 835 }
1034 __ ret(0); 836 __ ret(0);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 // ----------- S t a t e ------------- 975 // ----------- S t a t e -------------
1174 // -- ecx : key 976 // -- ecx : key
1175 // -- edx : receiver 977 // -- edx : receiver
1176 // -- esp[0] : return address 978 // -- esp[0] : return address
1177 // ----------------------------------- 979 // -----------------------------------
1178 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); 980 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss);
1179 } 981 }
1180 982
1181 983
1182 #undef __ 984 #undef __
1183 985 }
1184 } } // namespace v8::internal 986 } // namespace v8::internal
1185 987
1186 #endif // V8_TARGET_ARCH_X87 988 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | src/ic/x87/ic-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698