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.
9 #include "src/ic/call-optimization.h"
10 #include "src/ic/handler-compiler.h"
11 #include "src/ic/ic.h"
16 #define __ ACCESS_MASM(masm)
19 void NamedLoadHandlerCompiler::GenerateLoadViaGetter(
20 MacroAssembler* masm, Handle<Map> map, Register receiver, Register holder,
21 int accessor_index, int expected_arguments, Register scratch) {
22 // ----------- S t a t e -------------
25 // -- lr : return address
26 // -----------------------------------
28 FrameScope scope(masm, StackFrame::INTERNAL);
30 if (accessor_index >= 0) {
31 DCHECK(!holder.is(scratch));
32 DCHECK(!receiver.is(scratch));
33 // Call the JavaScript getter with the receiver on the stack.
34 if (map->IsJSGlobalObjectMap()) {
35 // Swap in the global receiver.
37 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
41 ParameterCount actual(0);
42 ParameterCount expected(expected_arguments);
43 __ LoadAccessor(r4, holder, accessor_index, ACCESSOR_GETTER);
44 __ InvokeFunction(r4, expected, actual, CALL_FUNCTION, NullCallWrapper());
46 // If we generate a global code snippet for deoptimization only, remember
47 // the place to continue after deoptimization.
48 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset());
51 // Restore context register.
52 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
58 void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
59 MacroAssembler* masm, Handle<Map> map, Register receiver, Register holder,
60 int accessor_index, int expected_arguments, Register scratch) {
61 // ----------- S t a t e -------------
62 // -- lr : return address
63 // -----------------------------------
65 FrameScope scope(masm, StackFrame::INTERNAL);
67 // Save value register, so we can restore it later.
70 if (accessor_index >= 0) {
71 DCHECK(!holder.is(scratch));
72 DCHECK(!receiver.is(scratch));
73 DCHECK(!value().is(scratch));
74 // Call the JavaScript setter with receiver and value on the stack.
75 if (map->IsJSGlobalObjectMap()) {
76 // Swap in the global receiver.
78 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
81 __ Push(receiver, value());
82 ParameterCount actual(1);
83 ParameterCount expected(expected_arguments);
84 __ LoadAccessor(r4, holder, accessor_index, ACCESSOR_SETTER);
85 __ InvokeFunction(r4, expected, actual, CALL_FUNCTION, NullCallWrapper());
87 // If we generate a global code snippet for deoptimization only, remember
88 // the place to continue after deoptimization.
89 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset());
92 // We have to return the passed value, not the return value of the setter.
95 // Restore context register.
96 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
102 void PropertyHandlerCompiler::PushVectorAndSlot(Register vector,
104 MacroAssembler* masm = this->masm();
105 __ Push(vector, slot);
109 void PropertyHandlerCompiler::PopVectorAndSlot(Register vector, Register slot) {
110 MacroAssembler* masm = this->masm();
111 __ Pop(vector, slot);
115 void PropertyHandlerCompiler::DiscardVectorAndSlot() {
116 MacroAssembler* masm = this->masm();
117 // Remove vector and slot.
118 __ addi(sp, sp, Operand(2 * kPointerSize));
122 void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup(
123 MacroAssembler* masm, Label* miss_label, Register receiver,
124 Handle<Name> name, Register scratch0, Register scratch1) {
125 DCHECK(name->IsUniqueName());
126 DCHECK(!receiver.is(scratch0));
127 Counters* counters = masm->isolate()->counters();
128 __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1);
129 __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1);
133 const int kInterceptorOrAccessCheckNeededMask =
134 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded);
136 // Bail out if the receiver has a named interceptor or requires access checks.
137 Register map = scratch1;
138 __ LoadP(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
139 __ lbz(scratch0, FieldMemOperand(map, Map::kBitFieldOffset));
140 __ andi(r0, scratch0, Operand(kInterceptorOrAccessCheckNeededMask));
141 __ bne(miss_label, cr0);
143 // Check that receiver is a JSObject.
144 __ lbz(scratch0, FieldMemOperand(map, Map::kInstanceTypeOffset));
145 __ cmpi(scratch0, Operand(FIRST_SPEC_OBJECT_TYPE));
148 // Load properties array.
149 Register properties = scratch0;
150 __ LoadP(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
151 // Check that the properties array is a dictionary.
152 __ LoadP(map, FieldMemOperand(properties, HeapObject::kMapOffset));
153 Register tmp = properties;
154 __ LoadRoot(tmp, Heap::kHashTableMapRootIndex);
158 // Restore the temporarily used register.
159 __ LoadP(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
162 NameDictionaryLookupStub::GenerateNegativeLookup(
163 masm, miss_label, &done, receiver, properties, name, scratch1);
165 __ DecrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1);
169 void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype(
170 MacroAssembler* masm, int index, Register result, Label* miss) {
171 const int offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX);
172 __ LoadP(result, MemOperand(cp, offset));
173 __ LoadP(result, FieldMemOperand(result, GlobalObject::kNativeContextOffset));
174 __ LoadP(result, MemOperand(result, Context::SlotOffset(index)));
175 // Load its initial map. The global functions all have initial maps.
177 FieldMemOperand(result, JSFunction::kPrototypeOrInitialMapOffset));
178 // Load the prototype from the initial map.
179 __ LoadP(result, FieldMemOperand(result, Map::kPrototypeOffset));
183 void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(
184 MacroAssembler* masm, Register receiver, Register scratch1,
185 Register scratch2, Label* miss_label) {
186 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label);
192 // Generate code to check that a global property cell is empty. Create
193 // the property cell at compilation time if no cell exists for the
195 void PropertyHandlerCompiler::GenerateCheckPropertyCell(
196 MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name,
197 Register scratch, Label* miss) {
198 Handle<PropertyCell> cell = JSGlobalObject::EnsurePropertyCell(global, name);
199 DCHECK(cell->value()->IsTheHole());
200 Handle<WeakCell> weak_cell = masm->isolate()->factory()->NewWeakCell(cell);
201 __ LoadWeakValue(scratch, weak_cell, miss);
202 __ LoadP(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
203 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
209 static void PushInterceptorArguments(MacroAssembler* masm, Register receiver,
210 Register holder, Register name,
211 Handle<JSObject> holder_obj) {
212 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
213 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 1);
214 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 2);
215 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 3);
222 static void CompileCallLoadPropertyWithInterceptor(
223 MacroAssembler* masm, Register receiver, Register holder, Register name,
224 Handle<JSObject> holder_obj, IC::UtilityId id) {
225 PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
226 __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
227 NamedLoadHandlerCompiler::kInterceptorArgsLength);
231 // Generate call to api function.
232 void PropertyHandlerCompiler::GenerateApiAccessorCall(
233 MacroAssembler* masm, const CallOptimization& optimization,
234 Handle<Map> receiver_map, Register receiver, Register scratch_in,
235 bool is_store, Register store_parameter, Register accessor_holder,
236 int accessor_index) {
237 DCHECK(!accessor_holder.is(scratch_in));
238 DCHECK(!receiver.is(scratch_in));
240 // Write the arguments to stack frame.
242 DCHECK(!receiver.is(store_parameter));
243 DCHECK(!scratch_in.is(store_parameter));
244 __ push(store_parameter);
246 DCHECK(optimization.is_simple_api_call());
248 // Abi for CallApiFunctionStub.
249 Register callee = r3;
251 Register holder = r5;
252 Register api_function_address = r4;
254 // Put callee in place.
255 __ LoadAccessor(callee, accessor_holder, accessor_index,
256 is_store ? ACCESSOR_SETTER : ACCESSOR_GETTER);
258 // Put holder in place.
259 CallOptimization::HolderLookup holder_lookup;
260 int holder_depth = 0;
261 optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
263 switch (holder_lookup) {
264 case CallOptimization::kHolderIsReceiver:
265 __ Move(holder, receiver);
267 case CallOptimization::kHolderFound:
268 __ LoadP(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
269 __ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
270 for (int i = 1; i < holder_depth; i++) {
271 __ LoadP(holder, FieldMemOperand(holder, HeapObject::kMapOffset));
272 __ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
275 case CallOptimization::kHolderNotFound:
280 Isolate* isolate = masm->isolate();
281 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
282 bool call_data_undefined = false;
283 // Put call data in place.
284 if (api_call_info->data()->IsUndefined()) {
285 call_data_undefined = true;
286 __ LoadRoot(data, Heap::kUndefinedValueRootIndex);
289 FieldMemOperand(callee, JSFunction::kSharedFunctionInfoOffset));
291 FieldMemOperand(data, SharedFunctionInfo::kFunctionDataOffset));
293 FieldMemOperand(data, FunctionTemplateInfo::kCallCodeOffset));
294 __ LoadP(data, FieldMemOperand(data, CallHandlerInfo::kDataOffset));
297 // Put api_function_address in place.
298 Address function_address = v8::ToCData<Address>(api_call_info->callback());
299 ApiFunction fun(function_address);
300 ExternalReference::Type type = ExternalReference::DIRECT_API_CALL;
301 ExternalReference ref = ExternalReference(&fun, type, masm->isolate());
302 __ mov(api_function_address, Operand(ref));
305 CallApiAccessorStub stub(isolate, is_store, call_data_undefined);
306 __ TailCallStub(&stub);
310 void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) {
311 // Push receiver, key and value for runtime call.
312 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
313 StoreDescriptor::ValueRegister());
315 // The slow case calls into the runtime to complete the store without causing
316 // an IC miss that would otherwise cause a transition to the generic stub.
317 ExternalReference ref =
318 ExternalReference(IC_Utility(IC::kStoreIC_Slow), masm->isolate());
319 __ TailCallExternalReference(ref, 3, 1);
323 void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) {
324 // Push receiver, key and value for runtime call.
325 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
326 StoreDescriptor::ValueRegister());
328 // The slow case calls into the runtime to complete the store without causing
329 // an IC miss that would otherwise cause a transition to the generic stub.
330 ExternalReference ref =
331 ExternalReference(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate());
332 __ TailCallExternalReference(ref, 3, 1);
337 #define __ ACCESS_MASM(masm())
340 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label,
342 if (!label->is_unused()) {
344 __ mov(this->name(), Operand(name));
349 void NamedStoreHandlerCompiler::GenerateRestoreName(Handle<Name> name) {
350 __ mov(this->name(), Operand(name));
354 void NamedStoreHandlerCompiler::GenerateRestoreMap(Handle<Map> transition,
357 Handle<WeakCell> cell = Map::WeakCellForMap(transition);
358 Register map_reg = StoreTransitionDescriptor::MapRegister();
359 DCHECK(!map_reg.is(scratch));
360 __ LoadWeakValue(map_reg, cell, miss);
361 if (transition->CanBeDeprecated()) {
362 __ lwz(scratch, FieldMemOperand(map_reg, Map::kBitField3Offset));
363 __ DecodeField<Map::Deprecated>(r0, scratch, SetRC);
369 void NamedStoreHandlerCompiler::GenerateConstantCheck(Register map_reg,
374 DCHECK(!map_reg.is(scratch));
375 DCHECK(!map_reg.is(value_reg));
376 DCHECK(!value_reg.is(scratch));
377 __ LoadInstanceDescriptors(map_reg, scratch);
378 __ LoadP(scratch, FieldMemOperand(
379 scratch, DescriptorArray::GetValueOffset(descriptor)));
380 __ cmp(value_reg, scratch);
385 void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(HeapType* field_type,
388 Register map_reg = scratch1();
389 Register scratch = scratch2();
390 DCHECK(!value_reg.is(map_reg));
391 DCHECK(!value_reg.is(scratch));
392 __ JumpIfSmi(value_reg, miss_label);
393 HeapType::Iterator<Map> it = field_type->Classes();
395 __ LoadP(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset));
398 __ CmpWeakValue(map_reg, Map::WeakCellForMap(it.Current()), scratch);
411 Register PropertyHandlerCompiler::CheckPrototypes(
412 Register object_reg, Register holder_reg, Register scratch1,
413 Register scratch2, Handle<Name> name, Label* miss,
414 PrototypeCheckType check) {
415 Handle<Map> receiver_map = map();
417 // Make sure there's no overlap between holder and object registers.
418 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
419 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) &&
420 !scratch2.is(scratch1));
422 // Keep track of the current object in register reg.
423 Register reg = object_reg;
426 Handle<JSObject> current = Handle<JSObject>::null();
427 if (receiver_map->IsJSGlobalObjectMap()) {
428 current = isolate()->global_object();
430 // Check access rights to the global object. This has to happen after
431 // the map check so that we know that the object is actually a global
433 // This allows us to install generated handlers for accesses to the
434 // global proxy (as opposed to using slow ICs). See corresponding code
435 // in LookupForRead().
436 if (receiver_map->IsJSGlobalProxyMap()) {
437 __ CheckAccessGlobalProxy(reg, scratch2, miss);
440 Handle<JSObject> prototype = Handle<JSObject>::null();
441 Handle<Map> current_map = receiver_map;
442 Handle<Map> holder_map(holder()->map());
443 // Traverse the prototype chain and check the maps in the prototype chain for
444 // fast and global objects or do negative lookup for normal objects.
445 while (!current_map.is_identical_to(holder_map)) {
448 // Only global objects and objects that do not require access
449 // checks are allowed in stubs.
450 DCHECK(current_map->IsJSGlobalProxyMap() ||
451 !current_map->is_access_check_needed());
453 prototype = handle(JSObject::cast(current_map->prototype()));
454 if (current_map->is_dictionary_map() &&
455 !current_map->IsJSGlobalObjectMap()) {
456 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast.
457 if (!name->IsUniqueName()) {
458 DCHECK(name->IsString());
459 name = factory()->InternalizeString(Handle<String>::cast(name));
461 DCHECK(current.is_null() ||
462 current->property_dictionary()->FindEntry(name) ==
463 NameDictionary::kNotFound);
465 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1,
468 __ LoadP(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
469 reg = holder_reg; // From now on the object will be in holder_reg.
470 __ LoadP(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset));
472 Register map_reg = scratch1;
473 __ LoadP(map_reg, FieldMemOperand(reg, HeapObject::kMapOffset));
475 if (current_map->IsJSGlobalObjectMap()) {
476 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current),
477 name, scratch2, miss);
478 } else if (depth != 1 || check == CHECK_ALL_MAPS) {
479 Handle<WeakCell> cell = Map::WeakCellForMap(current_map);
480 __ CmpWeakValue(map_reg, cell, scratch2);
484 reg = holder_reg; // From now on the object will be in holder_reg.
486 __ LoadP(reg, FieldMemOperand(map_reg, Map::kPrototypeOffset));
489 // Go to the next object in the prototype chain.
491 current_map = handle(current->map());
494 // Log the check depth.
495 LOG(isolate(), IntEvent("check-maps-depth", depth + 1));
497 if (depth != 0 || check == CHECK_ALL_MAPS) {
498 // Check the holder map.
499 __ LoadP(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
500 Handle<WeakCell> cell = Map::WeakCellForMap(current_map);
501 __ CmpWeakValue(scratch1, cell, scratch2);
505 // Return the register containing the holder.
510 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
511 if (!miss->is_unused()) {
515 if (IC::ICUseVector(kind())) {
516 DCHECK(kind() == Code::LOAD_IC);
519 TailCallBuiltin(masm(), MissBuiltin(kind()));
525 void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
526 if (!miss->is_unused()) {
529 GenerateRestoreName(miss, name);
530 TailCallBuiltin(masm(), MissBuiltin(kind()));
536 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
537 // Return the constant value.
543 void NamedLoadHandlerCompiler::GenerateLoadCallback(
544 Register reg, Handle<ExecutableAccessorInfo> callback) {
545 // Build AccessorInfo::args_ list on the stack and push property name below
546 // the exit frame to make GC aware of them and store pointers to them.
547 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
548 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1);
549 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2);
550 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3);
551 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4);
552 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5);
553 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6);
554 DCHECK(!scratch2().is(reg));
555 DCHECK(!scratch3().is(reg));
556 DCHECK(!scratch4().is(reg));
558 // Push data from ExecutableAccessorInfo.
559 Handle<Object> data(callback->data(), isolate());
560 if (data->IsUndefined() || data->IsSmi()) {
561 __ Move(scratch3(), data);
563 Handle<WeakCell> cell =
564 isolate()->factory()->NewWeakCell(Handle<HeapObject>::cast(data));
565 // The callback is alive if this instruction is executed,
566 // so the weak cell is not cleared and points to data.
567 __ GetWeakValue(scratch3(), cell);
570 __ LoadRoot(scratch3(), Heap::kUndefinedValueRootIndex);
571 __ mr(scratch4(), scratch3());
572 __ Push(scratch3(), scratch4());
573 __ mov(scratch4(), Operand(ExternalReference::isolate_address(isolate())));
574 __ Push(scratch4(), reg);
577 // Abi for CallApiGetter
578 Register getter_address_reg = ApiGetterDescriptor::function_address();
580 Address getter_address = v8::ToCData<Address>(callback->getter());
581 ApiFunction fun(getter_address);
582 ExternalReference::Type type = ExternalReference::DIRECT_GETTER_CALL;
583 ExternalReference ref = ExternalReference(&fun, type, isolate());
584 __ mov(getter_address_reg, Operand(ref));
586 CallApiGetterStub stub(isolate());
587 __ TailCallStub(&stub);
591 void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup(
592 LookupIterator* it, Register holder_reg) {
593 DCHECK(holder()->HasNamedInterceptor());
594 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined());
596 // Compile the interceptor call, followed by inline code to load the
597 // property from further up the prototype chain if the call fails.
598 // Check that the maps haven't changed.
599 DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1()));
601 // Preserve the receiver register explicitly whenever it is different from the
602 // holder and it is needed should the interceptor return without any result.
603 // The ACCESSOR case needs the receiver to be passed into C++ code, the FIELD
604 // case might cause a miss during the prototype check.
605 bool must_perform_prototype_check =
606 !holder().is_identical_to(it->GetHolder<JSObject>());
607 bool must_preserve_receiver_reg =
608 !receiver().is(holder_reg) &&
609 (it->state() == LookupIterator::ACCESSOR || must_perform_prototype_check);
611 // Save necessary data before invoking an interceptor.
612 // Requires a frame to make GC aware of pushed pointers.
614 FrameScope frame_scope(masm(), StackFrame::INTERNAL);
615 if (must_preserve_receiver_reg) {
616 __ Push(receiver(), holder_reg, this->name());
618 __ Push(holder_reg, this->name());
620 InterceptorVectorSlotPush(holder_reg);
621 // Invoke an interceptor. Note: map checks from receiver to
622 // interceptor's holder has been compiled before (see a caller
624 CompileCallLoadPropertyWithInterceptor(
625 masm(), receiver(), holder_reg, this->name(), holder(),
626 IC::kLoadPropertyWithInterceptorOnly);
628 // Check if interceptor provided a value for property. If it's
629 // the case, return immediately.
630 Label interceptor_failed;
631 __ LoadRoot(scratch1(), Heap::kNoInterceptorResultSentinelRootIndex);
632 __ cmp(r3, scratch1());
633 __ beq(&interceptor_failed);
634 frame_scope.GenerateLeaveFrame();
637 __ bind(&interceptor_failed);
638 InterceptorVectorSlotPop(holder_reg);
639 __ pop(this->name());
641 if (must_preserve_receiver_reg) {
644 // Leave the internal frame.
647 GenerateLoadPostInterceptor(it, holder_reg);
651 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
652 // Call the runtime system to load the interceptor.
653 DCHECK(holder()->HasNamedInterceptor());
654 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined());
655 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(),
658 ExternalReference ref = ExternalReference(
659 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate());
660 __ TailCallExternalReference(
661 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
665 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
666 Handle<JSObject> object, Handle<Name> name,
667 Handle<ExecutableAccessorInfo> callback) {
668 Register holder_reg = Frontend(name);
670 __ Push(receiver(), holder_reg); // receiver
672 // If the callback cannot leak, then push the callback directly,
673 // otherwise wrap it in a weak cell.
674 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) {
675 __ mov(ip, Operand(callback));
677 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback);
678 __ mov(ip, Operand(cell));
681 __ mov(ip, Operand(name));
682 __ Push(ip, value());
684 // Do tail-call to the runtime system.
685 ExternalReference store_callback_property =
686 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate());
687 __ TailCallExternalReference(store_callback_property, 5, 1);
689 // Return the generated code.
690 return GetCode(kind(), Code::FAST, name);
694 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor(
696 __ Push(receiver(), this->name(), value());
698 // Do tail-call to the runtime system.
699 ExternalReference store_ic_property = ExternalReference(
700 IC_Utility(IC::kStorePropertyWithInterceptor), isolate());
701 __ TailCallExternalReference(store_ic_property, 3, 1);
703 // Return the generated code.
704 return GetCode(kind(), Code::FAST, name);
708 Register NamedStoreHandlerCompiler::value() {
709 return StoreDescriptor::ValueRegister();
713 Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal(
714 Handle<PropertyCell> cell, Handle<Name> name, bool is_configurable) {
716 if (IC::ICUseVector(kind())) {
719 FrontendHeader(receiver(), name, &miss);
721 // Get the value from the cell.
722 Register result = StoreDescriptor::ValueRegister();
723 Handle<WeakCell> weak_cell = factory()->NewWeakCell(cell);
724 __ LoadWeakValue(result, weak_cell, &miss);
725 __ LoadP(result, FieldMemOperand(result, PropertyCell::kValueOffset));
727 // Check for deleted property if property can actually be deleted.
728 if (is_configurable) {
729 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
734 Counters* counters = isolate()->counters();
735 __ IncrementCounter(counters->named_load_global_stub(), 1, r4, r6);
736 if (IC::ICUseVector(kind())) {
737 DiscardVectorAndSlot();
741 FrontendFooter(name, &miss);
743 // Return the generated code.
744 return GetCode(kind(), Code::NORMAL, name);
750 } // namespace v8::internal
752 #endif // V8_TARGET_ARCH_ARM