Merge remote-tracking branch 'joyent/v0.12' into v0.12
[platform/upstream/nodejs.git] / deps / v8 / src / ic / arm / handler-compiler-arm.cc
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
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #if V8_TARGET_ARCH_ARM
8
9 #include "src/ic/call-optimization.h"
10 #include "src/ic/handler-compiler.h"
11 #include "src/ic/ic.h"
12
13 namespace v8 {
14 namespace internal {
15
16 #define __ ACCESS_MASM(masm)
17
18
19 void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
20     MacroAssembler* masm, Handle<HeapType> type, Register receiver,
21     Handle<JSFunction> getter) {
22   // ----------- S t a t e -------------
23   //  -- r0    : receiver
24   //  -- r2    : name
25   //  -- lr    : return address
26   // -----------------------------------
27   {
28     FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
29
30     if (!getter.is_null()) {
31       // Call the JavaScript getter with the receiver on the stack.
32       if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
33         // Swap in the global receiver.
34         __ ldr(receiver,
35                FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
36       }
37       __ push(receiver);
38       ParameterCount actual(0);
39       ParameterCount expected(getter);
40       __ InvokeFunction(getter, expected, actual, CALL_FUNCTION,
41                         NullCallWrapper());
42     } else {
43       // If we generate a global code snippet for deoptimization only, remember
44       // the place to continue after deoptimization.
45       masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset());
46     }
47
48     // Restore context register.
49     __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
50   }
51   __ Ret();
52 }
53
54
55 void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
56     MacroAssembler* masm, Handle<HeapType> type, Register receiver,
57     Handle<JSFunction> setter) {
58   // ----------- S t a t e -------------
59   //  -- lr    : return address
60   // -----------------------------------
61   {
62     FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
63
64     // Save value register, so we can restore it later.
65     __ push(value());
66
67     if (!setter.is_null()) {
68       // Call the JavaScript setter with receiver and value on the stack.
69       if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
70         // Swap in the global receiver.
71         __ ldr(receiver,
72                FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
73       }
74       __ Push(receiver, value());
75       ParameterCount actual(1);
76       ParameterCount expected(setter);
77       __ InvokeFunction(setter, expected, actual, CALL_FUNCTION,
78                         NullCallWrapper());
79     } else {
80       // If we generate a global code snippet for deoptimization only, remember
81       // the place to continue after deoptimization.
82       masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset());
83     }
84
85     // We have to return the passed value, not the return value of the setter.
86     __ pop(r0);
87
88     // Restore context register.
89     __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
90   }
91   __ Ret();
92 }
93
94
95 void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup(
96     MacroAssembler* masm, Label* miss_label, Register receiver,
97     Handle<Name> name, Register scratch0, Register scratch1) {
98   DCHECK(name->IsUniqueName());
99   DCHECK(!receiver.is(scratch0));
100   Counters* counters = masm->isolate()->counters();
101   __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1);
102   __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1);
103
104   Label done;
105
106   const int kInterceptorOrAccessCheckNeededMask =
107       (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded);
108
109   // Bail out if the receiver has a named interceptor or requires access checks.
110   Register map = scratch1;
111   __ ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
112   __ ldrb(scratch0, FieldMemOperand(map, Map::kBitFieldOffset));
113   __ tst(scratch0, Operand(kInterceptorOrAccessCheckNeededMask));
114   __ b(ne, miss_label);
115
116   // Check that receiver is a JSObject.
117   __ ldrb(scratch0, FieldMemOperand(map, Map::kInstanceTypeOffset));
118   __ cmp(scratch0, Operand(FIRST_SPEC_OBJECT_TYPE));
119   __ b(lt, miss_label);
120
121   // Load properties array.
122   Register properties = scratch0;
123   __ ldr(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
124   // Check that the properties array is a dictionary.
125   __ ldr(map, FieldMemOperand(properties, HeapObject::kMapOffset));
126   Register tmp = properties;
127   __ LoadRoot(tmp, Heap::kHashTableMapRootIndex);
128   __ cmp(map, tmp);
129   __ b(ne, miss_label);
130
131   // Restore the temporarily used register.
132   __ ldr(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
133
134
135   NameDictionaryLookupStub::GenerateNegativeLookup(
136       masm, miss_label, &done, receiver, properties, name, scratch1);
137   __ bind(&done);
138   __ DecrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1);
139 }
140
141
142 void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype(
143     MacroAssembler* masm, int index, Register prototype, Label* miss) {
144   Isolate* isolate = masm->isolate();
145   // Get the global function with the given index.
146   Handle<JSFunction> function(
147       JSFunction::cast(isolate->native_context()->get(index)));
148
149   // Check we're still in the same context.
150   Register scratch = prototype;
151   const int offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX);
152   __ ldr(scratch, MemOperand(cp, offset));
153   __ ldr(scratch, FieldMemOperand(scratch, GlobalObject::kNativeContextOffset));
154   __ ldr(scratch, MemOperand(scratch, Context::SlotOffset(index)));
155   __ Move(ip, function);
156   __ cmp(ip, scratch);
157   __ b(ne, miss);
158
159   // Load its initial map. The global functions all have initial maps.
160   __ Move(prototype, Handle<Map>(function->initial_map()));
161   // Load the prototype from the initial map.
162   __ ldr(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset));
163 }
164
165
166 void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(
167     MacroAssembler* masm, Register receiver, Register scratch1,
168     Register scratch2, Label* miss_label) {
169   __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label);
170   __ mov(r0, scratch1);
171   __ Ret();
172 }
173
174
175 // Generate code to check that a global property cell is empty. Create
176 // the property cell at compilation time if no cell exists for the
177 // property.
178 void PropertyHandlerCompiler::GenerateCheckPropertyCell(
179     MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name,
180     Register scratch, Label* miss) {
181   Handle<Cell> cell = JSGlobalObject::EnsurePropertyCell(global, name);
182   DCHECK(cell->value()->IsTheHole());
183   __ mov(scratch, Operand(cell));
184   __ ldr(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
185   __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
186   __ cmp(scratch, ip);
187   __ b(ne, miss);
188 }
189
190
191 static void PushInterceptorArguments(MacroAssembler* masm, Register receiver,
192                                      Register holder, Register name,
193                                      Handle<JSObject> holder_obj) {
194   STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
195   STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex == 1);
196   STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 2);
197   STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 3);
198   STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 4);
199   __ push(name);
200   Handle<InterceptorInfo> interceptor(holder_obj->GetNamedInterceptor());
201   DCHECK(!masm->isolate()->heap()->InNewSpace(*interceptor));
202   Register scratch = name;
203   __ mov(scratch, Operand(interceptor));
204   __ push(scratch);
205   __ push(receiver);
206   __ push(holder);
207 }
208
209
210 static void CompileCallLoadPropertyWithInterceptor(
211     MacroAssembler* masm, Register receiver, Register holder, Register name,
212     Handle<JSObject> holder_obj, IC::UtilityId id) {
213   PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
214   __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
215                            NamedLoadHandlerCompiler::kInterceptorArgsLength);
216 }
217
218
219 // Generate call to api function.
220 void PropertyHandlerCompiler::GenerateFastApiCall(
221     MacroAssembler* masm, const CallOptimization& optimization,
222     Handle<Map> receiver_map, Register receiver, Register scratch_in,
223     bool is_store, int argc, Register* values) {
224   DCHECK(!receiver.is(scratch_in));
225   __ push(receiver);
226   // Write the arguments to stack frame.
227   for (int i = 0; i < argc; i++) {
228     Register arg = values[argc - 1 - i];
229     DCHECK(!receiver.is(arg));
230     DCHECK(!scratch_in.is(arg));
231     __ push(arg);
232   }
233   DCHECK(optimization.is_simple_api_call());
234
235   // Abi for CallApiFunctionStub.
236   Register callee = r0;
237   Register call_data = r4;
238   Register holder = r2;
239   Register api_function_address = r1;
240
241   // Put holder in place.
242   CallOptimization::HolderLookup holder_lookup;
243   Handle<JSObject> api_holder =
244       optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup);
245   switch (holder_lookup) {
246     case CallOptimization::kHolderIsReceiver:
247       __ Move(holder, receiver);
248       break;
249     case CallOptimization::kHolderFound:
250       __ Move(holder, api_holder);
251       break;
252     case CallOptimization::kHolderNotFound:
253       UNREACHABLE();
254       break;
255   }
256
257   Isolate* isolate = masm->isolate();
258   Handle<JSFunction> function = optimization.constant_function();
259   Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
260   Handle<Object> call_data_obj(api_call_info->data(), isolate);
261
262   // Put callee in place.
263   __ Move(callee, function);
264
265   bool call_data_undefined = false;
266   // Put call_data in place.
267   if (isolate->heap()->InNewSpace(*call_data_obj)) {
268     __ Move(call_data, api_call_info);
269     __ ldr(call_data, FieldMemOperand(call_data, CallHandlerInfo::kDataOffset));
270   } else if (call_data_obj->IsUndefined()) {
271     call_data_undefined = true;
272     __ LoadRoot(call_data, Heap::kUndefinedValueRootIndex);
273   } else {
274     __ Move(call_data, call_data_obj);
275   }
276
277   // Put api_function_address in place.
278   Address function_address = v8::ToCData<Address>(api_call_info->callback());
279   ApiFunction fun(function_address);
280   ExternalReference::Type type = ExternalReference::DIRECT_API_CALL;
281   ExternalReference ref = ExternalReference(&fun, type, masm->isolate());
282   __ mov(api_function_address, Operand(ref));
283
284   // Jump to stub.
285   CallApiFunctionStub stub(isolate, is_store, call_data_undefined, argc);
286   __ TailCallStub(&stub);
287 }
288
289
290 void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) {
291   // Push receiver, key and value for runtime call.
292   __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
293           StoreDescriptor::ValueRegister());
294
295   // The slow case calls into the runtime to complete the store without causing
296   // an IC miss that would otherwise cause a transition to the generic stub.
297   ExternalReference ref =
298       ExternalReference(IC_Utility(IC::kStoreIC_Slow), masm->isolate());
299   __ TailCallExternalReference(ref, 3, 1);
300 }
301
302
303 void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) {
304   // Push receiver, key and value for runtime call.
305   __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
306           StoreDescriptor::ValueRegister());
307
308   // The slow case calls into the runtime to complete the store without causing
309   // an IC miss that would otherwise cause a transition to the generic stub.
310   ExternalReference ref =
311       ExternalReference(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate());
312   __ TailCallExternalReference(ref, 3, 1);
313 }
314
315
316 #undef __
317 #define __ ACCESS_MASM(masm())
318
319
320 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label,
321                                                     Handle<Name> name) {
322   if (!label->is_unused()) {
323     __ bind(label);
324     __ mov(this->name(), Operand(name));
325   }
326 }
327
328
329 void NamedStoreHandlerCompiler::GenerateRestoreNameAndMap(
330     Handle<Name> name, Handle<Map> transition) {
331   __ mov(this->name(), Operand(name));
332   __ mov(StoreTransitionDescriptor::MapRegister(), Operand(transition));
333 }
334
335
336 void NamedStoreHandlerCompiler::GenerateConstantCheck(Object* constant,
337                                                       Register value_reg,
338                                                       Label* miss_label) {
339   __ Move(scratch1(), handle(constant, isolate()));
340   __ cmp(value_reg, scratch1());
341   __ b(ne, miss_label);
342 }
343
344
345 void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(HeapType* field_type,
346                                                         Register value_reg,
347                                                         Label* miss_label) {
348   __ JumpIfSmi(value_reg, miss_label);
349   HeapType::Iterator<Map> it = field_type->Classes();
350   if (!it.Done()) {
351     __ ldr(scratch1(), FieldMemOperand(value_reg, HeapObject::kMapOffset));
352     Label do_store;
353     while (true) {
354       __ CompareMap(scratch1(), it.Current(), &do_store);
355       it.Advance();
356       if (it.Done()) {
357         __ b(ne, miss_label);
358         break;
359       }
360       __ b(eq, &do_store);
361     }
362     __ bind(&do_store);
363   }
364 }
365
366
367 Register PropertyHandlerCompiler::CheckPrototypes(
368     Register object_reg, Register holder_reg, Register scratch1,
369     Register scratch2, Handle<Name> name, Label* miss,
370     PrototypeCheckType check) {
371   Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate()));
372
373   // Make sure there's no overlap between holder and object registers.
374   DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
375   DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) &&
376          !scratch2.is(scratch1));
377
378   // Keep track of the current object in register reg.
379   Register reg = object_reg;
380   int depth = 0;
381
382   Handle<JSObject> current = Handle<JSObject>::null();
383   if (type()->IsConstant()) {
384     current = Handle<JSObject>::cast(type()->AsConstant()->Value());
385   }
386   Handle<JSObject> prototype = Handle<JSObject>::null();
387   Handle<Map> current_map = receiver_map;
388   Handle<Map> holder_map(holder()->map());
389   // Traverse the prototype chain and check the maps in the prototype chain for
390   // fast and global objects or do negative lookup for normal objects.
391   while (!current_map.is_identical_to(holder_map)) {
392     ++depth;
393
394     // Only global objects and objects that do not require access
395     // checks are allowed in stubs.
396     DCHECK(current_map->IsJSGlobalProxyMap() ||
397            !current_map->is_access_check_needed());
398
399     prototype = handle(JSObject::cast(current_map->prototype()));
400     if (current_map->is_dictionary_map() &&
401         !current_map->IsJSGlobalObjectMap()) {
402       DCHECK(!current_map->IsJSGlobalProxyMap());  // Proxy maps are fast.
403       if (!name->IsUniqueName()) {
404         DCHECK(name->IsString());
405         name = factory()->InternalizeString(Handle<String>::cast(name));
406       }
407       DCHECK(current.is_null() ||
408              current->property_dictionary()->FindEntry(name) ==
409                  NameDictionary::kNotFound);
410
411       GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1,
412                                        scratch2);
413
414       __ ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
415       reg = holder_reg;  // From now on the object will be in holder_reg.
416       __ ldr(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset));
417     } else {
418       Register map_reg = scratch1;
419       if (depth != 1 || check == CHECK_ALL_MAPS) {
420         // CheckMap implicitly loads the map of |reg| into |map_reg|.
421         __ CheckMap(reg, map_reg, current_map, miss, DONT_DO_SMI_CHECK);
422       } else {
423         __ ldr(map_reg, FieldMemOperand(reg, HeapObject::kMapOffset));
424       }
425
426       // Check access rights to the global object.  This has to happen after
427       // the map check so that we know that the object is actually a global
428       // object.
429       // This allows us to install generated handlers for accesses to the
430       // global proxy (as opposed to using slow ICs). See corresponding code
431       // in LookupForRead().
432       if (current_map->IsJSGlobalProxyMap()) {
433         __ CheckAccessGlobalProxy(reg, scratch2, miss);
434       } else if (current_map->IsJSGlobalObjectMap()) {
435         GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current),
436                                   name, scratch2, miss);
437       }
438
439       reg = holder_reg;  // From now on the object will be in holder_reg.
440
441       // Two possible reasons for loading the prototype from the map:
442       // (1) Can't store references to new space in code.
443       // (2) Handler is shared for all receivers with the same prototype
444       //     map (but not necessarily the same prototype instance).
445       bool load_prototype_from_map =
446           heap()->InNewSpace(*prototype) || depth == 1;
447       if (load_prototype_from_map) {
448         __ ldr(reg, FieldMemOperand(map_reg, Map::kPrototypeOffset));
449       } else {
450         __ mov(reg, Operand(prototype));
451       }
452     }
453
454     // Go to the next object in the prototype chain.
455     current = prototype;
456     current_map = handle(current->map());
457   }
458
459   // Log the check depth.
460   LOG(isolate(), IntEvent("check-maps-depth", depth + 1));
461
462   if (depth != 0 || check == CHECK_ALL_MAPS) {
463     // Check the holder map.
464     __ CheckMap(reg, scratch1, current_map, miss, DONT_DO_SMI_CHECK);
465   }
466
467   // Perform security check for access to the global object.
468   DCHECK(current_map->IsJSGlobalProxyMap() ||
469          !current_map->is_access_check_needed());
470   if (current_map->IsJSGlobalProxyMap()) {
471     __ CheckAccessGlobalProxy(reg, scratch1, miss);
472   }
473
474   // Return the register containing the holder.
475   return reg;
476 }
477
478
479 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
480   if (!miss->is_unused()) {
481     Label success;
482     __ b(&success);
483     __ bind(miss);
484     TailCallBuiltin(masm(), MissBuiltin(kind()));
485     __ bind(&success);
486   }
487 }
488
489
490 void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
491   if (!miss->is_unused()) {
492     Label success;
493     __ b(&success);
494     GenerateRestoreName(miss, name);
495     TailCallBuiltin(masm(), MissBuiltin(kind()));
496     __ bind(&success);
497   }
498 }
499
500
501 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
502   // Return the constant value.
503   __ Move(r0, value);
504   __ Ret();
505 }
506
507
508 void NamedLoadHandlerCompiler::GenerateLoadCallback(
509     Register reg, Handle<ExecutableAccessorInfo> callback) {
510   // Build AccessorInfo::args_ list on the stack and push property name below
511   // the exit frame to make GC aware of them and store pointers to them.
512   STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
513   STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1);
514   STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2);
515   STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3);
516   STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4);
517   STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5);
518   STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6);
519   DCHECK(!scratch2().is(reg));
520   DCHECK(!scratch3().is(reg));
521   DCHECK(!scratch4().is(reg));
522   __ push(receiver());
523   if (heap()->InNewSpace(callback->data())) {
524     __ Move(scratch3(), callback);
525     __ ldr(scratch3(),
526            FieldMemOperand(scratch3(), ExecutableAccessorInfo::kDataOffset));
527   } else {
528     __ Move(scratch3(), Handle<Object>(callback->data(), isolate()));
529   }
530   __ push(scratch3());
531   __ LoadRoot(scratch3(), Heap::kUndefinedValueRootIndex);
532   __ mov(scratch4(), scratch3());
533   __ Push(scratch3(), scratch4());
534   __ mov(scratch4(), Operand(ExternalReference::isolate_address(isolate())));
535   __ Push(scratch4(), reg);
536   __ mov(scratch2(), sp);  // scratch2 = PropertyAccessorInfo::args_
537   __ push(name());
538
539   // Abi for CallApiGetter
540   Register getter_address_reg = ApiGetterDescriptor::function_address();
541
542   Address getter_address = v8::ToCData<Address>(callback->getter());
543   ApiFunction fun(getter_address);
544   ExternalReference::Type type = ExternalReference::DIRECT_GETTER_CALL;
545   ExternalReference ref = ExternalReference(&fun, type, isolate());
546   __ mov(getter_address_reg, Operand(ref));
547
548   CallApiGetterStub stub(isolate());
549   __ TailCallStub(&stub);
550 }
551
552
553 void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup(
554     LookupIterator* it, Register holder_reg) {
555   DCHECK(holder()->HasNamedInterceptor());
556   DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined());
557
558   // Compile the interceptor call, followed by inline code to load the
559   // property from further up the prototype chain if the call fails.
560   // Check that the maps haven't changed.
561   DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1()));
562
563   // Preserve the receiver register explicitly whenever it is different from the
564   // holder and it is needed should the interceptor return without any result.
565   // The ACCESSOR case needs the receiver to be passed into C++ code, the FIELD
566   // case might cause a miss during the prototype check.
567   bool must_perform_prototype_check =
568       !holder().is_identical_to(it->GetHolder<JSObject>());
569   bool must_preserve_receiver_reg =
570       !receiver().is(holder_reg) &&
571       (it->state() == LookupIterator::ACCESSOR || must_perform_prototype_check);
572
573   // Save necessary data before invoking an interceptor.
574   // Requires a frame to make GC aware of pushed pointers.
575   {
576     FrameAndConstantPoolScope frame_scope(masm(), StackFrame::INTERNAL);
577     if (must_preserve_receiver_reg) {
578       __ Push(receiver(), holder_reg, this->name());
579     } else {
580       __ Push(holder_reg, this->name());
581     }
582     // Invoke an interceptor.  Note: map checks from receiver to
583     // interceptor's holder has been compiled before (see a caller
584     // of this method.)
585     CompileCallLoadPropertyWithInterceptor(
586         masm(), receiver(), holder_reg, this->name(), holder(),
587         IC::kLoadPropertyWithInterceptorOnly);
588
589     // Check if interceptor provided a value for property.  If it's
590     // the case, return immediately.
591     Label interceptor_failed;
592     __ LoadRoot(scratch1(), Heap::kNoInterceptorResultSentinelRootIndex);
593     __ cmp(r0, scratch1());
594     __ b(eq, &interceptor_failed);
595     frame_scope.GenerateLeaveFrame();
596     __ Ret();
597
598     __ bind(&interceptor_failed);
599     __ pop(this->name());
600     __ pop(holder_reg);
601     if (must_preserve_receiver_reg) {
602       __ pop(receiver());
603     }
604     // Leave the internal frame.
605   }
606
607   GenerateLoadPostInterceptor(it, holder_reg);
608 }
609
610
611 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
612   // Call the runtime system to load the interceptor.
613   DCHECK(holder()->HasNamedInterceptor());
614   DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined());
615   PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(),
616                            holder());
617
618   ExternalReference ref = ExternalReference(
619       IC_Utility(IC::kLoadPropertyWithInterceptor), isolate());
620   __ TailCallExternalReference(
621       ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
622 }
623
624
625 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
626     Handle<JSObject> object, Handle<Name> name,
627     Handle<ExecutableAccessorInfo> callback) {
628   Register holder_reg = Frontend(receiver(), name);
629
630   __ push(receiver());  // receiver
631   __ push(holder_reg);
632   __ mov(ip, Operand(callback));  // callback info
633   __ push(ip);
634   __ mov(ip, Operand(name));
635   __ Push(ip, value());
636
637   // Do tail-call to the runtime system.
638   ExternalReference store_callback_property =
639       ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate());
640   __ TailCallExternalReference(store_callback_property, 5, 1);
641
642   // Return the generated code.
643   return GetCode(kind(), Code::FAST, name);
644 }
645
646
647 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor(
648     Handle<Name> name) {
649   __ Push(receiver(), this->name(), value());
650
651   // Do tail-call to the runtime system.
652   ExternalReference store_ic_property = ExternalReference(
653       IC_Utility(IC::kStorePropertyWithInterceptor), isolate());
654   __ TailCallExternalReference(store_ic_property, 3, 1);
655
656   // Return the generated code.
657   return GetCode(kind(), Code::FAST, name);
658 }
659
660
661 Register NamedStoreHandlerCompiler::value() {
662   return StoreDescriptor::ValueRegister();
663 }
664
665
666 Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal(
667     Handle<PropertyCell> cell, Handle<Name> name, bool is_configurable) {
668   Label miss;
669   FrontendHeader(receiver(), name, &miss);
670
671   // Get the value from the cell.
672   Register result = StoreDescriptor::ValueRegister();
673   __ mov(result, Operand(cell));
674   __ ldr(result, FieldMemOperand(result, Cell::kValueOffset));
675
676   // Check for deleted property if property can actually be deleted.
677   if (is_configurable) {
678     __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
679     __ cmp(result, ip);
680     __ b(eq, &miss);
681   }
682
683   Counters* counters = isolate()->counters();
684   __ IncrementCounter(counters->named_load_global_stub(), 1, r1, r3);
685   __ Ret();
686
687   FrontendFooter(name, &miss);
688
689   // Return the generated code.
690   return GetCode(kind(), Code::NORMAL, name);
691 }
692
693
694 #undef __
695 }
696 }  // namespace v8::internal
697
698 #endif  // V8_TARGET_ARCH_ARM