OLD | NEW |
| (Empty) |
1 // Copyright 2013 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "src/v8.h" | |
6 | |
7 #if V8_TARGET_ARCH_ARM64 | |
8 | |
9 #include "src/codegen.h" | |
10 #include "src/ic-inl.h" | |
11 #include "src/stub-cache.h" | |
12 | |
13 namespace v8 { | |
14 namespace internal { | |
15 | |
16 | |
17 #define __ ACCESS_MASM(masm) | |
18 | |
19 | |
20 void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup( | |
21 MacroAssembler* masm, Label* miss_label, Register receiver, | |
22 Handle<Name> name, Register scratch0, Register scratch1) { | |
23 DCHECK(!AreAliased(receiver, scratch0, scratch1)); | |
24 DCHECK(name->IsUniqueName()); | |
25 Counters* counters = masm->isolate()->counters(); | |
26 __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1); | |
27 __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); | |
28 | |
29 Label done; | |
30 | |
31 const int kInterceptorOrAccessCheckNeededMask = | |
32 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded); | |
33 | |
34 // Bail out if the receiver has a named interceptor or requires access checks. | |
35 Register map = scratch1; | |
36 __ Ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
37 __ Ldrb(scratch0, FieldMemOperand(map, Map::kBitFieldOffset)); | |
38 __ Tst(scratch0, kInterceptorOrAccessCheckNeededMask); | |
39 __ B(ne, miss_label); | |
40 | |
41 // Check that receiver is a JSObject. | |
42 __ Ldrb(scratch0, FieldMemOperand(map, Map::kInstanceTypeOffset)); | |
43 __ Cmp(scratch0, FIRST_SPEC_OBJECT_TYPE); | |
44 __ B(lt, miss_label); | |
45 | |
46 // Load properties array. | |
47 Register properties = scratch0; | |
48 __ Ldr(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | |
49 // Check that the properties array is a dictionary. | |
50 __ Ldr(map, FieldMemOperand(properties, HeapObject::kMapOffset)); | |
51 __ JumpIfNotRoot(map, Heap::kHashTableMapRootIndex, miss_label); | |
52 | |
53 NameDictionaryLookupStub::GenerateNegativeLookup(masm, | |
54 miss_label, | |
55 &done, | |
56 receiver, | |
57 properties, | |
58 name, | |
59 scratch1); | |
60 __ Bind(&done); | |
61 __ DecrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1); | |
62 } | |
63 | |
64 | |
65 // Probe primary or secondary table. | |
66 // If the entry is found in the cache, the generated code jump to the first | |
67 // instruction of the stub in the cache. | |
68 // If there is a miss the code fall trough. | |
69 // | |
70 // 'receiver', 'name' and 'offset' registers are preserved on miss. | |
71 static void ProbeTable(Isolate* isolate, | |
72 MacroAssembler* masm, | |
73 Code::Flags flags, | |
74 StubCache::Table table, | |
75 Register receiver, | |
76 Register name, | |
77 Register offset, | |
78 Register scratch, | |
79 Register scratch2, | |
80 Register scratch3) { | |
81 // Some code below relies on the fact that the Entry struct contains | |
82 // 3 pointers (name, code, map). | |
83 STATIC_ASSERT(sizeof(StubCache::Entry) == (3 * kPointerSize)); | |
84 | |
85 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); | |
86 ExternalReference value_offset(isolate->stub_cache()->value_reference(table)); | |
87 ExternalReference map_offset(isolate->stub_cache()->map_reference(table)); | |
88 | |
89 uintptr_t key_off_addr = reinterpret_cast<uintptr_t>(key_offset.address()); | |
90 uintptr_t value_off_addr = | |
91 reinterpret_cast<uintptr_t>(value_offset.address()); | |
92 uintptr_t map_off_addr = reinterpret_cast<uintptr_t>(map_offset.address()); | |
93 | |
94 Label miss; | |
95 | |
96 DCHECK(!AreAliased(name, offset, scratch, scratch2, scratch3)); | |
97 | |
98 // Multiply by 3 because there are 3 fields per entry. | |
99 __ Add(scratch3, offset, Operand(offset, LSL, 1)); | |
100 | |
101 // Calculate the base address of the entry. | |
102 __ Mov(scratch, key_offset); | |
103 __ Add(scratch, scratch, Operand(scratch3, LSL, kPointerSizeLog2)); | |
104 | |
105 // Check that the key in the entry matches the name. | |
106 __ Ldr(scratch2, MemOperand(scratch)); | |
107 __ Cmp(name, scratch2); | |
108 __ B(ne, &miss); | |
109 | |
110 // Check the map matches. | |
111 __ Ldr(scratch2, MemOperand(scratch, map_off_addr - key_off_addr)); | |
112 __ Ldr(scratch3, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
113 __ Cmp(scratch2, scratch3); | |
114 __ B(ne, &miss); | |
115 | |
116 // Get the code entry from the cache. | |
117 __ Ldr(scratch, MemOperand(scratch, value_off_addr - key_off_addr)); | |
118 | |
119 // Check that the flags match what we're looking for. | |
120 __ Ldr(scratch2.W(), FieldMemOperand(scratch, Code::kFlagsOffset)); | |
121 __ Bic(scratch2.W(), scratch2.W(), Code::kFlagsNotUsedInLookup); | |
122 __ Cmp(scratch2.W(), flags); | |
123 __ B(ne, &miss); | |
124 | |
125 #ifdef DEBUG | |
126 if (FLAG_test_secondary_stub_cache && table == StubCache::kPrimary) { | |
127 __ B(&miss); | |
128 } else if (FLAG_test_primary_stub_cache && table == StubCache::kSecondary) { | |
129 __ B(&miss); | |
130 } | |
131 #endif | |
132 | |
133 // Jump to the first instruction in the code stub. | |
134 __ Add(scratch, scratch, Code::kHeaderSize - kHeapObjectTag); | |
135 __ Br(scratch); | |
136 | |
137 // Miss: fall through. | |
138 __ Bind(&miss); | |
139 } | |
140 | |
141 | |
142 void StubCache::GenerateProbe(MacroAssembler* masm, | |
143 Code::Flags flags, | |
144 Register receiver, | |
145 Register name, | |
146 Register scratch, | |
147 Register extra, | |
148 Register extra2, | |
149 Register extra3) { | |
150 Isolate* isolate = masm->isolate(); | |
151 Label miss; | |
152 | |
153 // Make sure the flags does not name a specific type. | |
154 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); | |
155 | |
156 // Make sure that there are no register conflicts. | |
157 DCHECK(!AreAliased(receiver, name, scratch, extra, extra2, extra3)); | |
158 | |
159 // Make sure extra and extra2 registers are valid. | |
160 DCHECK(!extra.is(no_reg)); | |
161 DCHECK(!extra2.is(no_reg)); | |
162 DCHECK(!extra3.is(no_reg)); | |
163 | |
164 Counters* counters = masm->isolate()->counters(); | |
165 __ IncrementCounter(counters->megamorphic_stub_cache_probes(), 1, | |
166 extra2, extra3); | |
167 | |
168 // Check that the receiver isn't a smi. | |
169 __ JumpIfSmi(receiver, &miss); | |
170 | |
171 // Compute the hash for primary table. | |
172 __ Ldr(scratch, FieldMemOperand(name, Name::kHashFieldOffset)); | |
173 __ Ldr(extra, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
174 __ Add(scratch, scratch, extra); | |
175 __ Eor(scratch, scratch, flags); | |
176 // We shift out the last two bits because they are not part of the hash. | |
177 __ Ubfx(scratch, scratch, kCacheIndexShift, | |
178 CountTrailingZeros(kPrimaryTableSize, 64)); | |
179 | |
180 // Probe the primary table. | |
181 ProbeTable(isolate, masm, flags, kPrimary, receiver, name, | |
182 scratch, extra, extra2, extra3); | |
183 | |
184 // Primary miss: Compute hash for secondary table. | |
185 __ Sub(scratch, scratch, Operand(name, LSR, kCacheIndexShift)); | |
186 __ Add(scratch, scratch, flags >> kCacheIndexShift); | |
187 __ And(scratch, scratch, kSecondaryTableSize - 1); | |
188 | |
189 // Probe the secondary table. | |
190 ProbeTable(isolate, masm, flags, kSecondary, receiver, name, | |
191 scratch, extra, extra2, extra3); | |
192 | |
193 // Cache miss: Fall-through and let caller handle the miss by | |
194 // entering the runtime system. | |
195 __ Bind(&miss); | |
196 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, | |
197 extra2, extra3); | |
198 } | |
199 | |
200 | |
201 void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype( | |
202 MacroAssembler* masm, int index, Register prototype, Label* miss) { | |
203 Isolate* isolate = masm->isolate(); | |
204 // Get the global function with the given index. | |
205 Handle<JSFunction> function( | |
206 JSFunction::cast(isolate->native_context()->get(index))); | |
207 | |
208 // Check we're still in the same context. | |
209 Register scratch = prototype; | |
210 __ Ldr(scratch, GlobalObjectMemOperand()); | |
211 __ Ldr(scratch, FieldMemOperand(scratch, GlobalObject::kNativeContextOffset)); | |
212 __ Ldr(scratch, ContextMemOperand(scratch, index)); | |
213 __ Cmp(scratch, Operand(function)); | |
214 __ B(ne, miss); | |
215 | |
216 // Load its initial map. The global functions all have initial maps. | |
217 __ Mov(prototype, Operand(Handle<Map>(function->initial_map()))); | |
218 // Load the prototype from the initial map. | |
219 __ Ldr(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); | |
220 } | |
221 | |
222 | |
223 void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype( | |
224 MacroAssembler* masm, Register receiver, Register scratch1, | |
225 Register scratch2, Label* miss_label) { | |
226 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | |
227 // TryGetFunctionPrototype can't put the result directly in x0 because the | |
228 // 3 inputs registers can't alias and we call this function from | |
229 // LoadIC::GenerateFunctionPrototype, where receiver is x0. So we explicitly | |
230 // move the result in x0. | |
231 __ Mov(x0, scratch1); | |
232 __ Ret(); | |
233 } | |
234 | |
235 | |
236 // Generate code to check that a global property cell is empty. Create | |
237 // the property cell at compilation time if no cell exists for the | |
238 // property. | |
239 void PropertyHandlerCompiler::GenerateCheckPropertyCell( | |
240 MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name, | |
241 Register scratch, Label* miss) { | |
242 Handle<Cell> cell = JSGlobalObject::EnsurePropertyCell(global, name); | |
243 DCHECK(cell->value()->IsTheHole()); | |
244 __ Mov(scratch, Operand(cell)); | |
245 __ Ldr(scratch, FieldMemOperand(scratch, Cell::kValueOffset)); | |
246 __ JumpIfNotRoot(scratch, Heap::kTheHoleValueRootIndex, miss); | |
247 } | |
248 | |
249 | |
250 static void PushInterceptorArguments(MacroAssembler* masm, Register receiver, | |
251 Register holder, Register name, | |
252 Handle<JSObject> holder_obj) { | |
253 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0); | |
254 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1); | |
255 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2); | |
256 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3); | |
257 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4); | |
258 | |
259 __ Push(name); | |
260 Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor()); | |
261 DCHECK(!masm->isolate()->heap()->InNewSpace(*interceptor)); | |
262 Register scratch = name; | |
263 __ Mov(scratch, Operand(interceptor)); | |
264 __ Push(scratch, receiver, holder); | |
265 } | |
266 | |
267 | |
268 static void CompileCallLoadPropertyWithInterceptor( | |
269 MacroAssembler* masm, Register receiver, Register holder, Register name, | |
270 Handle<JSObject> holder_obj, IC::UtilityId id) { | |
271 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | |
272 | |
273 __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()), | |
274 NamedLoadHandlerCompiler::kInterceptorArgsLength); | |
275 } | |
276 | |
277 | |
278 // Generate call to api function. | |
279 void PropertyHandlerCompiler::GenerateFastApiCall( | |
280 MacroAssembler* masm, const CallOptimization& optimization, | |
281 Handle<Map> receiver_map, Register receiver, Register scratch, | |
282 bool is_store, int argc, Register* values) { | |
283 DCHECK(!AreAliased(receiver, scratch)); | |
284 | |
285 MacroAssembler::PushPopQueue queue(masm); | |
286 queue.Queue(receiver); | |
287 // Write the arguments to the stack frame. | |
288 for (int i = 0; i < argc; i++) { | |
289 Register arg = values[argc - 1 - i]; | |
290 DCHECK(!AreAliased(receiver, scratch, arg)); | |
291 queue.Queue(arg); | |
292 } | |
293 queue.PushQueued(); | |
294 | |
295 DCHECK(optimization.is_simple_api_call()); | |
296 | |
297 // Abi for CallApiFunctionStub. | |
298 Register callee = x0; | |
299 Register call_data = x4; | |
300 Register holder = x2; | |
301 Register api_function_address = x1; | |
302 | |
303 // Put holder in place. | |
304 CallOptimization::HolderLookup holder_lookup; | |
305 Handle<JSObject> api_holder = | |
306 optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup); | |
307 switch (holder_lookup) { | |
308 case CallOptimization::kHolderIsReceiver: | |
309 __ Mov(holder, receiver); | |
310 break; | |
311 case CallOptimization::kHolderFound: | |
312 __ LoadObject(holder, api_holder); | |
313 break; | |
314 case CallOptimization::kHolderNotFound: | |
315 UNREACHABLE(); | |
316 break; | |
317 } | |
318 | |
319 Isolate* isolate = masm->isolate(); | |
320 Handle<JSFunction> function = optimization.constant_function(); | |
321 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | |
322 Handle<Object> call_data_obj(api_call_info->data(), isolate); | |
323 | |
324 // Put callee in place. | |
325 __ LoadObject(callee, function); | |
326 | |
327 bool call_data_undefined = false; | |
328 // Put call_data in place. | |
329 if (isolate->heap()->InNewSpace(*call_data_obj)) { | |
330 __ LoadObject(call_data, api_call_info); | |
331 __ Ldr(call_data, FieldMemOperand(call_data, CallHandlerInfo::kDataOffset)); | |
332 } else if (call_data_obj->IsUndefined()) { | |
333 call_data_undefined = true; | |
334 __ LoadRoot(call_data, Heap::kUndefinedValueRootIndex); | |
335 } else { | |
336 __ LoadObject(call_data, call_data_obj); | |
337 } | |
338 | |
339 // Put api_function_address in place. | |
340 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | |
341 ApiFunction fun(function_address); | |
342 ExternalReference ref = ExternalReference( | |
343 &fun, ExternalReference::DIRECT_API_CALL, masm->isolate()); | |
344 __ Mov(api_function_address, ref); | |
345 | |
346 // Jump to stub. | |
347 CallApiFunctionStub stub(isolate, is_store, call_data_undefined, argc); | |
348 __ TailCallStub(&stub); | |
349 } | |
350 | |
351 | |
352 void PropertyAccessCompiler::GenerateTailCall(MacroAssembler* masm, | |
353 Handle<Code> code) { | |
354 __ Jump(code, RelocInfo::CODE_TARGET); | |
355 } | |
356 | |
357 | |
358 #undef __ | |
359 #define __ ACCESS_MASM(masm()) | |
360 | |
361 | |
362 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label, | |
363 Handle<Name> name) { | |
364 if (!label->is_unused()) { | |
365 __ Bind(label); | |
366 __ Mov(this->name(), Operand(name)); | |
367 } | |
368 } | |
369 | |
370 | |
371 // Generate StoreTransition code, value is passed in x0 register. | |
372 // When leaving generated code after success, the receiver_reg and storage_reg | |
373 // may be clobbered. Upon branch to miss_label, the receiver and name registers | |
374 // have their original values. | |
375 void NamedStoreHandlerCompiler::GenerateStoreTransition( | |
376 Handle<Map> transition, Handle<Name> name, Register receiver_reg, | |
377 Register storage_reg, Register value_reg, Register scratch1, | |
378 Register scratch2, Register scratch3, Label* miss_label, Label* slow) { | |
379 Label exit; | |
380 | |
381 DCHECK(!AreAliased(receiver_reg, storage_reg, value_reg, | |
382 scratch1, scratch2, scratch3)); | |
383 | |
384 // We don't need scratch3. | |
385 scratch3 = NoReg; | |
386 | |
387 int descriptor = transition->LastAdded(); | |
388 DescriptorArray* descriptors = transition->instance_descriptors(); | |
389 PropertyDetails details = descriptors->GetDetails(descriptor); | |
390 Representation representation = details.representation(); | |
391 DCHECK(!representation.IsNone()); | |
392 | |
393 if (details.type() == CONSTANT) { | |
394 Handle<Object> constant(descriptors->GetValue(descriptor), isolate()); | |
395 __ LoadObject(scratch1, constant); | |
396 __ Cmp(value_reg, scratch1); | |
397 __ B(ne, miss_label); | |
398 } else if (representation.IsSmi()) { | |
399 __ JumpIfNotSmi(value_reg, miss_label); | |
400 } else if (representation.IsHeapObject()) { | |
401 __ JumpIfSmi(value_reg, miss_label); | |
402 HeapType* field_type = descriptors->GetFieldType(descriptor); | |
403 HeapType::Iterator<Map> it = field_type->Classes(); | |
404 if (!it.Done()) { | |
405 __ Ldr(scratch1, FieldMemOperand(value_reg, HeapObject::kMapOffset)); | |
406 Label do_store; | |
407 while (true) { | |
408 __ CompareMap(scratch1, it.Current()); | |
409 it.Advance(); | |
410 if (it.Done()) { | |
411 __ B(ne, miss_label); | |
412 break; | |
413 } | |
414 __ B(eq, &do_store); | |
415 } | |
416 __ Bind(&do_store); | |
417 } | |
418 } else if (representation.IsDouble()) { | |
419 UseScratchRegisterScope temps(masm()); | |
420 DoubleRegister temp_double = temps.AcquireD(); | |
421 __ SmiUntagToDouble(temp_double, value_reg, kSpeculativeUntag); | |
422 | |
423 Label do_store; | |
424 __ JumpIfSmi(value_reg, &do_store); | |
425 | |
426 __ CheckMap(value_reg, scratch1, Heap::kHeapNumberMapRootIndex, | |
427 miss_label, DONT_DO_SMI_CHECK); | |
428 __ Ldr(temp_double, FieldMemOperand(value_reg, HeapNumber::kValueOffset)); | |
429 | |
430 __ Bind(&do_store); | |
431 __ AllocateHeapNumber(storage_reg, slow, scratch1, scratch2, temp_double, | |
432 NoReg, MUTABLE); | |
433 } | |
434 | |
435 // Stub never generated for objects that require access checks. | |
436 DCHECK(!transition->is_access_check_needed()); | |
437 | |
438 // Perform map transition for the receiver if necessary. | |
439 if (details.type() == FIELD && | |
440 Map::cast(transition->GetBackPointer())->unused_property_fields() == 0) { | |
441 // The properties must be extended before we can store the value. | |
442 // We jump to a runtime call that extends the properties array. | |
443 __ Mov(scratch1, Operand(transition)); | |
444 __ Push(receiver_reg, scratch1, value_reg); | |
445 __ TailCallExternalReference( | |
446 ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage), | |
447 isolate()), | |
448 3, 1); | |
449 return; | |
450 } | |
451 | |
452 // Update the map of the object. | |
453 __ Mov(scratch1, Operand(transition)); | |
454 __ Str(scratch1, FieldMemOperand(receiver_reg, HeapObject::kMapOffset)); | |
455 | |
456 // Update the write barrier for the map field. | |
457 __ RecordWriteField(receiver_reg, | |
458 HeapObject::kMapOffset, | |
459 scratch1, | |
460 scratch2, | |
461 kLRHasNotBeenSaved, | |
462 kDontSaveFPRegs, | |
463 OMIT_REMEMBERED_SET, | |
464 OMIT_SMI_CHECK); | |
465 | |
466 if (details.type() == CONSTANT) { | |
467 DCHECK(value_reg.is(x0)); | |
468 __ Ret(); | |
469 return; | |
470 } | |
471 | |
472 int index = transition->instance_descriptors()->GetFieldIndex( | |
473 transition->LastAdded()); | |
474 | |
475 // Adjust for the number of properties stored in the object. Even in the | |
476 // face of a transition we can use the old map here because the size of the | |
477 // object and the number of in-object properties is not going to change. | |
478 index -= transition->inobject_properties(); | |
479 | |
480 // TODO(verwaest): Share this code as a code stub. | |
481 SmiCheck smi_check = representation.IsTagged() | |
482 ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; | |
483 Register prop_reg = representation.IsDouble() ? storage_reg : value_reg; | |
484 if (index < 0) { | |
485 // Set the property straight into the object. | |
486 int offset = transition->instance_size() + (index * kPointerSize); | |
487 __ Str(prop_reg, FieldMemOperand(receiver_reg, offset)); | |
488 | |
489 if (!representation.IsSmi()) { | |
490 // Update the write barrier for the array address. | |
491 if (!representation.IsDouble()) { | |
492 __ Mov(storage_reg, value_reg); | |
493 } | |
494 __ RecordWriteField(receiver_reg, | |
495 offset, | |
496 storage_reg, | |
497 scratch1, | |
498 kLRHasNotBeenSaved, | |
499 kDontSaveFPRegs, | |
500 EMIT_REMEMBERED_SET, | |
501 smi_check); | |
502 } | |
503 } else { | |
504 // Write to the properties array. | |
505 int offset = index * kPointerSize + FixedArray::kHeaderSize; | |
506 // Get the properties array | |
507 __ Ldr(scratch1, | |
508 FieldMemOperand(receiver_reg, JSObject::kPropertiesOffset)); | |
509 __ Str(prop_reg, FieldMemOperand(scratch1, offset)); | |
510 | |
511 if (!representation.IsSmi()) { | |
512 // Update the write barrier for the array address. | |
513 if (!representation.IsDouble()) { | |
514 __ Mov(storage_reg, value_reg); | |
515 } | |
516 __ RecordWriteField(scratch1, | |
517 offset, | |
518 storage_reg, | |
519 receiver_reg, | |
520 kLRHasNotBeenSaved, | |
521 kDontSaveFPRegs, | |
522 EMIT_REMEMBERED_SET, | |
523 smi_check); | |
524 } | |
525 } | |
526 | |
527 __ Bind(&exit); | |
528 // Return the value (register x0). | |
529 DCHECK(value_reg.is(x0)); | |
530 __ Ret(); | |
531 } | |
532 | |
533 | |
534 void NamedStoreHandlerCompiler::GenerateStoreField(LookupIterator* lookup, | |
535 Register value_reg, | |
536 Label* miss_label) { | |
537 DCHECK(lookup->representation().IsHeapObject()); | |
538 __ JumpIfSmi(value_reg, miss_label); | |
539 HeapType::Iterator<Map> it = lookup->GetFieldType()->Classes(); | |
540 __ Ldr(scratch1(), FieldMemOperand(value_reg, HeapObject::kMapOffset)); | |
541 Label do_store; | |
542 while (true) { | |
543 __ CompareMap(scratch1(), it.Current()); | |
544 it.Advance(); | |
545 if (it.Done()) { | |
546 __ B(ne, miss_label); | |
547 break; | |
548 } | |
549 __ B(eq, &do_store); | |
550 } | |
551 __ Bind(&do_store); | |
552 | |
553 StoreFieldStub stub(isolate(), lookup->GetFieldIndex(), | |
554 lookup->representation()); | |
555 GenerateTailCall(masm(), stub.GetCode()); | |
556 } | |
557 | |
558 | |
559 Register PropertyHandlerCompiler::CheckPrototypes( | |
560 Register object_reg, Register holder_reg, Register scratch1, | |
561 Register scratch2, Handle<Name> name, Label* miss, | |
562 PrototypeCheckType check) { | |
563 Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate())); | |
564 | |
565 // object_reg and holder_reg registers can alias. | |
566 DCHECK(!AreAliased(object_reg, scratch1, scratch2)); | |
567 DCHECK(!AreAliased(holder_reg, scratch1, scratch2)); | |
568 | |
569 // Keep track of the current object in register reg. | |
570 Register reg = object_reg; | |
571 int depth = 0; | |
572 | |
573 Handle<JSObject> current = Handle<JSObject>::null(); | |
574 if (type()->IsConstant()) { | |
575 current = Handle<JSObject>::cast(type()->AsConstant()->Value()); | |
576 } | |
577 Handle<JSObject> prototype = Handle<JSObject>::null(); | |
578 Handle<Map> current_map = receiver_map; | |
579 Handle<Map> holder_map(holder()->map()); | |
580 // Traverse the prototype chain and check the maps in the prototype chain for | |
581 // fast and global objects or do negative lookup for normal objects. | |
582 while (!current_map.is_identical_to(holder_map)) { | |
583 ++depth; | |
584 | |
585 // Only global objects and objects that do not require access | |
586 // checks are allowed in stubs. | |
587 DCHECK(current_map->IsJSGlobalProxyMap() || | |
588 !current_map->is_access_check_needed()); | |
589 | |
590 prototype = handle(JSObject::cast(current_map->prototype())); | |
591 if (current_map->is_dictionary_map() && | |
592 !current_map->IsJSGlobalObjectMap()) { | |
593 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast. | |
594 if (!name->IsUniqueName()) { | |
595 DCHECK(name->IsString()); | |
596 name = factory()->InternalizeString(Handle<String>::cast(name)); | |
597 } | |
598 DCHECK(current.is_null() || | |
599 (current->property_dictionary()->FindEntry(name) == | |
600 NameDictionary::kNotFound)); | |
601 | |
602 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, | |
603 scratch1, scratch2); | |
604 | |
605 __ Ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); | |
606 reg = holder_reg; // From now on the object will be in holder_reg. | |
607 __ Ldr(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset)); | |
608 } else { | |
609 // Two possible reasons for loading the prototype from the map: | |
610 // (1) Can't store references to new space in code. | |
611 // (2) Handler is shared for all receivers with the same prototype | |
612 // map (but not necessarily the same prototype instance). | |
613 bool load_prototype_from_map = | |
614 heap()->InNewSpace(*prototype) || depth == 1; | |
615 Register map_reg = scratch1; | |
616 __ Ldr(map_reg, FieldMemOperand(reg, HeapObject::kMapOffset)); | |
617 | |
618 if (depth != 1 || check == CHECK_ALL_MAPS) { | |
619 __ CheckMap(map_reg, current_map, miss, DONT_DO_SMI_CHECK); | |
620 } | |
621 | |
622 // Check access rights to the global object. This has to happen after | |
623 // the map check so that we know that the object is actually a global | |
624 // object. | |
625 // This allows us to install generated handlers for accesses to the | |
626 // global proxy (as opposed to using slow ICs). See corresponding code | |
627 // in LookupForRead(). | |
628 if (current_map->IsJSGlobalProxyMap()) { | |
629 UseScratchRegisterScope temps(masm()); | |
630 __ CheckAccessGlobalProxy(reg, scratch2, temps.AcquireX(), miss); | |
631 } else if (current_map->IsJSGlobalObjectMap()) { | |
632 GenerateCheckPropertyCell( | |
633 masm(), Handle<JSGlobalObject>::cast(current), name, | |
634 scratch2, miss); | |
635 } | |
636 | |
637 reg = holder_reg; // From now on the object will be in holder_reg. | |
638 | |
639 if (load_prototype_from_map) { | |
640 __ Ldr(reg, FieldMemOperand(map_reg, Map::kPrototypeOffset)); | |
641 } else { | |
642 __ Mov(reg, Operand(prototype)); | |
643 } | |
644 } | |
645 | |
646 // Go to the next object in the prototype chain. | |
647 current = prototype; | |
648 current_map = handle(current->map()); | |
649 } | |
650 | |
651 // Log the check depth. | |
652 LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); | |
653 | |
654 // Check the holder map. | |
655 if (depth != 0 || check == CHECK_ALL_MAPS) { | |
656 // Check the holder map. | |
657 __ CheckMap(reg, scratch1, current_map, miss, DONT_DO_SMI_CHECK); | |
658 } | |
659 | |
660 // Perform security check for access to the global object. | |
661 DCHECK(current_map->IsJSGlobalProxyMap() || | |
662 !current_map->is_access_check_needed()); | |
663 if (current_map->IsJSGlobalProxyMap()) { | |
664 __ CheckAccessGlobalProxy(reg, scratch1, scratch2, miss); | |
665 } | |
666 | |
667 // Return the register containing the holder. | |
668 return reg; | |
669 } | |
670 | |
671 | |
672 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { | |
673 if (!miss->is_unused()) { | |
674 Label success; | |
675 __ B(&success); | |
676 | |
677 __ Bind(miss); | |
678 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
679 | |
680 __ Bind(&success); | |
681 } | |
682 } | |
683 | |
684 | |
685 void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) { | |
686 if (!miss->is_unused()) { | |
687 Label success; | |
688 __ B(&success); | |
689 | |
690 GenerateRestoreName(miss, name); | |
691 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
692 | |
693 __ Bind(&success); | |
694 } | |
695 } | |
696 | |
697 | |
698 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) { | |
699 // Return the constant value. | |
700 __ LoadObject(x0, value); | |
701 __ Ret(); | |
702 } | |
703 | |
704 | |
705 void NamedLoadHandlerCompiler::GenerateLoadCallback( | |
706 Register reg, Handle<ExecutableAccessorInfo> callback) { | |
707 DCHECK(!AreAliased(scratch2(), scratch3(), scratch4(), reg)); | |
708 | |
709 // Build ExecutableAccessorInfo::args_ list on the stack and push property | |
710 // name below the exit frame to make GC aware of them and store pointers to | |
711 // them. | |
712 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); | |
713 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); | |
714 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); | |
715 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); | |
716 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4); | |
717 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5); | |
718 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6); | |
719 | |
720 __ Push(receiver()); | |
721 | |
722 if (heap()->InNewSpace(callback->data())) { | |
723 __ Mov(scratch3(), Operand(callback)); | |
724 __ Ldr(scratch3(), FieldMemOperand(scratch3(), | |
725 ExecutableAccessorInfo::kDataOffset)); | |
726 } else { | |
727 __ Mov(scratch3(), Operand(Handle<Object>(callback->data(), isolate()))); | |
728 } | |
729 __ LoadRoot(scratch4(), Heap::kUndefinedValueRootIndex); | |
730 __ Mov(scratch2(), Operand(ExternalReference::isolate_address(isolate()))); | |
731 __ Push(scratch3(), scratch4(), scratch4(), scratch2(), reg, name()); | |
732 | |
733 Register args_addr = scratch2(); | |
734 __ Add(args_addr, __ StackPointer(), kPointerSize); | |
735 | |
736 // Stack at this point: | |
737 // sp[40] callback data | |
738 // sp[32] undefined | |
739 // sp[24] undefined | |
740 // sp[16] isolate | |
741 // args_addr -> sp[8] reg | |
742 // sp[0] name | |
743 | |
744 // Abi for CallApiGetter. | |
745 Register getter_address_reg = x2; | |
746 | |
747 // Set up the call. | |
748 Address getter_address = v8::ToCData<Address>(callback->getter()); | |
749 ApiFunction fun(getter_address); | |
750 ExternalReference::Type type = ExternalReference::DIRECT_GETTER_CALL; | |
751 ExternalReference ref = ExternalReference(&fun, type, isolate()); | |
752 __ Mov(getter_address_reg, ref); | |
753 | |
754 CallApiGetterStub stub(isolate()); | |
755 __ TailCallStub(&stub); | |
756 } | |
757 | |
758 | |
759 void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup( | |
760 LookupIterator* it, Register holder_reg) { | |
761 DCHECK(!AreAliased(receiver(), this->name(), | |
762 scratch1(), scratch2(), scratch3())); | |
763 DCHECK(holder()->HasNamedInterceptor()); | |
764 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); | |
765 | |
766 // Compile the interceptor call, followed by inline code to load the | |
767 // property from further up the prototype chain if the call fails. | |
768 // Check that the maps haven't changed. | |
769 DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1())); | |
770 | |
771 // Preserve the receiver register explicitly whenever it is different from the | |
772 // holder and it is needed should the interceptor return without any result. | |
773 // The ACCESSOR case needs the receiver to be passed into C++ code, the FIELD | |
774 // case might cause a miss during the prototype check. | |
775 bool must_perform_prototype_check = | |
776 !holder().is_identical_to(it->GetHolder<JSObject>()); | |
777 bool must_preserve_receiver_reg = | |
778 !receiver().is(holder_reg) && | |
779 (it->property_kind() == LookupIterator::ACCESSOR || | |
780 must_perform_prototype_check); | |
781 | |
782 // Save necessary data before invoking an interceptor. | |
783 // Requires a frame to make GC aware of pushed pointers. | |
784 { | |
785 FrameScope frame_scope(masm(), StackFrame::INTERNAL); | |
786 if (must_preserve_receiver_reg) { | |
787 __ Push(receiver(), holder_reg, this->name()); | |
788 } else { | |
789 __ Push(holder_reg, this->name()); | |
790 } | |
791 // Invoke an interceptor. Note: map checks from receiver to | |
792 // interceptor's holder has been compiled before (see a caller | |
793 // of this method.) | |
794 CompileCallLoadPropertyWithInterceptor( | |
795 masm(), receiver(), holder_reg, this->name(), holder(), | |
796 IC::kLoadPropertyWithInterceptorOnly); | |
797 | |
798 // Check if interceptor provided a value for property. If it's | |
799 // the case, return immediately. | |
800 Label interceptor_failed; | |
801 __ JumpIfRoot(x0, Heap::kNoInterceptorResultSentinelRootIndex, | |
802 &interceptor_failed); | |
803 frame_scope.GenerateLeaveFrame(); | |
804 __ Ret(); | |
805 | |
806 __ Bind(&interceptor_failed); | |
807 if (must_preserve_receiver_reg) { | |
808 __ Pop(this->name(), holder_reg, receiver()); | |
809 } else { | |
810 __ Pop(this->name(), holder_reg); | |
811 } | |
812 // Leave the internal frame. | |
813 } | |
814 | |
815 GenerateLoadPostInterceptor(it, holder_reg); | |
816 } | |
817 | |
818 | |
819 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { | |
820 // Call the runtime system to load the interceptor. | |
821 DCHECK(holder()->HasNamedInterceptor()); | |
822 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); | |
823 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), | |
824 holder()); | |
825 | |
826 ExternalReference ref = ExternalReference( | |
827 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate()); | |
828 __ TailCallExternalReference( | |
829 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1); | |
830 } | |
831 | |
832 | |
833 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( | |
834 Handle<JSObject> object, Handle<Name> name, | |
835 Handle<ExecutableAccessorInfo> callback) { | |
836 ASM_LOCATION("NamedStoreHandlerCompiler::CompileStoreCallback"); | |
837 Register holder_reg = Frontend(receiver(), name); | |
838 | |
839 // Stub never generated for non-global objects that require access checks. | |
840 DCHECK(holder()->IsJSGlobalProxy() || !holder()->IsAccessCheckNeeded()); | |
841 | |
842 // receiver() and holder_reg can alias. | |
843 DCHECK(!AreAliased(receiver(), scratch1(), scratch2(), value())); | |
844 DCHECK(!AreAliased(holder_reg, scratch1(), scratch2(), value())); | |
845 __ Mov(scratch1(), Operand(callback)); | |
846 __ Mov(scratch2(), Operand(name)); | |
847 __ Push(receiver(), holder_reg, scratch1(), scratch2(), value()); | |
848 | |
849 // Do tail-call to the runtime system. | |
850 ExternalReference store_callback_property = | |
851 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); | |
852 __ TailCallExternalReference(store_callback_property, 5, 1); | |
853 | |
854 // Return the generated code. | |
855 return GetCode(kind(), Code::FAST, name); | |
856 } | |
857 | |
858 | |
859 #undef __ | |
860 #define __ ACCESS_MASM(masm) | |
861 | |
862 | |
863 void NamedStoreHandlerCompiler::GenerateStoreViaSetter( | |
864 MacroAssembler* masm, Handle<HeapType> type, Register receiver, | |
865 Handle<JSFunction> setter) { | |
866 // ----------- S t a t e ------------- | |
867 // -- lr : return address | |
868 // ----------------------------------- | |
869 Label miss; | |
870 | |
871 { | |
872 FrameScope scope(masm, StackFrame::INTERNAL); | |
873 | |
874 // Save value register, so we can restore it later. | |
875 __ Push(value()); | |
876 | |
877 if (!setter.is_null()) { | |
878 // Call the JavaScript setter with receiver and value on the stack. | |
879 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { | |
880 // Swap in the global receiver. | |
881 __ Ldr(receiver, | |
882 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | |
883 } | |
884 __ Push(receiver, value()); | |
885 ParameterCount actual(1); | |
886 ParameterCount expected(setter); | |
887 __ InvokeFunction(setter, expected, actual, | |
888 CALL_FUNCTION, NullCallWrapper()); | |
889 } else { | |
890 // If we generate a global code snippet for deoptimization only, remember | |
891 // the place to continue after deoptimization. | |
892 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); | |
893 } | |
894 | |
895 // We have to return the passed value, not the return value of the setter. | |
896 __ Pop(x0); | |
897 | |
898 // Restore context register. | |
899 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
900 } | |
901 __ Ret(); | |
902 } | |
903 | |
904 | |
905 #undef __ | |
906 #define __ ACCESS_MASM(masm()) | |
907 | |
908 | |
909 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor( | |
910 Handle<Name> name) { | |
911 Label miss; | |
912 | |
913 ASM_LOCATION("NamedStoreHandlerCompiler::CompileStoreInterceptor"); | |
914 | |
915 __ Push(receiver(), this->name(), value()); | |
916 | |
917 // Do tail-call to the runtime system. | |
918 ExternalReference store_ic_property = ExternalReference( | |
919 IC_Utility(IC::kStorePropertyWithInterceptor), isolate()); | |
920 __ TailCallExternalReference(store_ic_property, 3, 1); | |
921 | |
922 // Return the generated code. | |
923 return GetCode(kind(), Code::FAST, name); | |
924 } | |
925 | |
926 | |
927 // TODO(all): The so-called scratch registers are significant in some cases. For | |
928 // example, PropertyAccessCompiler::keyed_store_calling_convention()[3] (x3) is | |
929 // actually | |
930 // used for KeyedStoreCompiler::transition_map(). We should verify which | |
931 // registers are actually scratch registers, and which are important. For now, | |
932 // we use the same assignments as ARM to remain on the safe side. | |
933 | |
934 Register* PropertyAccessCompiler::load_calling_convention() { | |
935 // receiver, name, scratch1, scratch2, scratch3, scratch4. | |
936 Register receiver = LoadIC::ReceiverRegister(); | |
937 Register name = LoadIC::NameRegister(); | |
938 static Register registers[] = { receiver, name, x3, x0, x4, x5 }; | |
939 return registers; | |
940 } | |
941 | |
942 | |
943 Register* PropertyAccessCompiler::store_calling_convention() { | |
944 // receiver, value, scratch1, scratch2, scratch3. | |
945 Register receiver = StoreIC::ReceiverRegister(); | |
946 Register name = StoreIC::NameRegister(); | |
947 DCHECK(x3.is(KeyedStoreIC::MapRegister())); | |
948 static Register registers[] = { receiver, name, x3, x4, x5 }; | |
949 return registers; | |
950 } | |
951 | |
952 | |
953 Register NamedStoreHandlerCompiler::value() { return StoreIC::ValueRegister(); } | |
954 | |
955 | |
956 #undef __ | |
957 #define __ ACCESS_MASM(masm) | |
958 | |
959 void NamedLoadHandlerCompiler::GenerateLoadViaGetter( | |
960 MacroAssembler* masm, Handle<HeapType> type, Register receiver, | |
961 Handle<JSFunction> getter) { | |
962 { | |
963 FrameScope scope(masm, StackFrame::INTERNAL); | |
964 | |
965 if (!getter.is_null()) { | |
966 // Call the JavaScript getter with the receiver on the stack. | |
967 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { | |
968 // Swap in the global receiver. | |
969 __ Ldr(receiver, | |
970 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); | |
971 } | |
972 __ Push(receiver); | |
973 ParameterCount actual(0); | |
974 ParameterCount expected(getter); | |
975 __ InvokeFunction(getter, expected, actual, | |
976 CALL_FUNCTION, NullCallWrapper()); | |
977 } else { | |
978 // If we generate a global code snippet for deoptimization only, remember | |
979 // the place to continue after deoptimization. | |
980 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset()); | |
981 } | |
982 | |
983 // Restore context register. | |
984 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
985 } | |
986 __ Ret(); | |
987 } | |
988 | |
989 | |
990 #undef __ | |
991 #define __ ACCESS_MASM(masm()) | |
992 | |
993 | |
994 Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal( | |
995 Handle<PropertyCell> cell, Handle<Name> name, bool is_configurable) { | |
996 Label miss; | |
997 FrontendHeader(receiver(), name, &miss); | |
998 | |
999 // Get the value from the cell. | |
1000 Register result = StoreIC::ValueRegister(); | |
1001 __ Mov(result, Operand(cell)); | |
1002 __ Ldr(result, FieldMemOperand(result, Cell::kValueOffset)); | |
1003 | |
1004 // Check for deleted property if property can actually be deleted. | |
1005 if (is_configurable) { | |
1006 __ JumpIfRoot(result, Heap::kTheHoleValueRootIndex, &miss); | |
1007 } | |
1008 | |
1009 Counters* counters = isolate()->counters(); | |
1010 __ IncrementCounter(counters->named_load_global_stub(), 1, x1, x3); | |
1011 __ Ret(); | |
1012 | |
1013 FrontendFooter(name, &miss); | |
1014 | |
1015 // Return the generated code. | |
1016 return GetCode(kind(), Code::NORMAL, name); | |
1017 } | |
1018 | |
1019 | |
1020 Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types, | |
1021 CodeHandleList* handlers, | |
1022 Handle<Name> name, | |
1023 Code::StubType type, | |
1024 IcCheckType check) { | |
1025 Label miss; | |
1026 | |
1027 if (check == PROPERTY && | |
1028 (kind() == Code::KEYED_LOAD_IC || kind() == Code::KEYED_STORE_IC)) { | |
1029 // In case we are compiling an IC for dictionary loads and stores, just | |
1030 // check whether the name is unique. | |
1031 if (name.is_identical_to(isolate()->factory()->normal_ic_symbol())) { | |
1032 __ JumpIfNotUniqueName(this->name(), &miss); | |
1033 } else { | |
1034 __ CompareAndBranch(this->name(), Operand(name), ne, &miss); | |
1035 } | |
1036 } | |
1037 | |
1038 Label number_case; | |
1039 Label* smi_target = IncludesNumberType(types) ? &number_case : &miss; | |
1040 __ JumpIfSmi(receiver(), smi_target); | |
1041 | |
1042 // Polymorphic keyed stores may use the map register | |
1043 Register map_reg = scratch1(); | |
1044 DCHECK(kind() != Code::KEYED_STORE_IC || | |
1045 map_reg.is(KeyedStoreIC::MapRegister())); | |
1046 __ Ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset)); | |
1047 int receiver_count = types->length(); | |
1048 int number_of_handled_maps = 0; | |
1049 for (int current = 0; current < receiver_count; ++current) { | |
1050 Handle<HeapType> type = types->at(current); | |
1051 Handle<Map> map = IC::TypeToMap(*type, isolate()); | |
1052 if (!map->is_deprecated()) { | |
1053 number_of_handled_maps++; | |
1054 Label try_next; | |
1055 __ Cmp(map_reg, Operand(map)); | |
1056 __ B(ne, &try_next); | |
1057 if (type->Is(HeapType::Number())) { | |
1058 DCHECK(!number_case.is_unused()); | |
1059 __ Bind(&number_case); | |
1060 } | |
1061 __ Jump(handlers->at(current), RelocInfo::CODE_TARGET); | |
1062 __ Bind(&try_next); | |
1063 } | |
1064 } | |
1065 DCHECK(number_of_handled_maps != 0); | |
1066 | |
1067 __ Bind(&miss); | |
1068 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
1069 | |
1070 // Return the generated code. | |
1071 InlineCacheState state = | |
1072 (number_of_handled_maps > 1) ? POLYMORPHIC : MONOMORPHIC; | |
1073 return GetCode(kind(), type, name, state); | |
1074 } | |
1075 | |
1076 | |
1077 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic( | |
1078 MapHandleList* receiver_maps, CodeHandleList* handler_stubs, | |
1079 MapHandleList* transitioned_maps) { | |
1080 Label miss; | |
1081 | |
1082 ASM_LOCATION("PropertyICCompiler::CompileStorePolymorphic"); | |
1083 | |
1084 __ JumpIfSmi(receiver(), &miss); | |
1085 | |
1086 int receiver_count = receiver_maps->length(); | |
1087 __ Ldr(scratch1(), FieldMemOperand(receiver(), HeapObject::kMapOffset)); | |
1088 for (int i = 0; i < receiver_count; i++) { | |
1089 __ Cmp(scratch1(), Operand(receiver_maps->at(i))); | |
1090 | |
1091 Label skip; | |
1092 __ B(&skip, ne); | |
1093 if (!transitioned_maps->at(i).is_null()) { | |
1094 // This argument is used by the handler stub. For example, see | |
1095 // ElementsTransitionGenerator::GenerateMapChangeElementsTransition. | |
1096 __ Mov(transition_map(), Operand(transitioned_maps->at(i))); | |
1097 } | |
1098 __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET); | |
1099 __ Bind(&skip); | |
1100 } | |
1101 | |
1102 __ Bind(&miss); | |
1103 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
1104 | |
1105 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); | |
1106 } | |
1107 | |
1108 | |
1109 #undef __ | |
1110 #define __ ACCESS_MASM(masm) | |
1111 | |
1112 void ElementHandlerCompiler::GenerateLoadDictionaryElement( | |
1113 MacroAssembler* masm) { | |
1114 // The return address is in lr. | |
1115 Label slow, miss; | |
1116 | |
1117 Register result = x0; | |
1118 Register key = LoadIC::NameRegister(); | |
1119 Register receiver = LoadIC::ReceiverRegister(); | |
1120 DCHECK(receiver.is(x1)); | |
1121 DCHECK(key.is(x2)); | |
1122 | |
1123 __ JumpIfNotSmi(key, &miss); | |
1124 __ Ldr(x4, FieldMemOperand(receiver, JSObject::kElementsOffset)); | |
1125 __ LoadFromNumberDictionary(&slow, x4, key, result, x7, x3, x5, x6); | |
1126 __ Ret(); | |
1127 | |
1128 __ Bind(&slow); | |
1129 __ IncrementCounter( | |
1130 masm->isolate()->counters()->keyed_load_external_array_slow(), 1, x4, x3); | |
1131 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Slow); | |
1132 | |
1133 // Miss case, call the runtime. | |
1134 __ Bind(&miss); | |
1135 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | |
1136 } | |
1137 | |
1138 | |
1139 } } // namespace v8::internal | |
1140 | |
1141 #endif // V8_TARGET_ARCH_ARM64 | |
OLD | NEW |