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<HeapType> type, Register receiver,
21 Register holder, int accessor_index, int expected_arguments,
23 // ----------- S t a t e -------------
26 // -- lr : return address
27 // -----------------------------------
29 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
31 if (accessor_index >= 0) {
32 DCHECK(!holder.is(scratch));
33 DCHECK(!receiver.is(scratch));
34 // Call the JavaScript getter with the receiver on the stack.
35 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
36 // Swap in the global receiver.
38 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
42 ParameterCount actual(0);
43 ParameterCount expected(expected_arguments);
44 __ LoadAccessor(r4, holder, accessor_index, ACCESSOR_GETTER);
45 __ InvokeFunction(r4, expected, actual, CALL_FUNCTION, NullCallWrapper());
47 // If we generate a global code snippet for deoptimization only, remember
48 // the place to continue after deoptimization.
49 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset());
52 // Restore context register.
53 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
59 void NamedStoreHandlerCompiler::GenerateStoreViaSetter(
60 MacroAssembler* masm, Handle<HeapType> type, Register receiver,
61 Register holder, int accessor_index, int expected_arguments,
63 // ----------- S t a t e -------------
64 // -- lr : return address
65 // -----------------------------------
67 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
69 // Save value register, so we can restore it later.
72 if (accessor_index >= 0) {
73 DCHECK(!holder.is(scratch));
74 DCHECK(!receiver.is(scratch));
75 DCHECK(!value().is(scratch));
76 // Call the JavaScript setter with receiver and value on the stack.
77 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) {
78 // Swap in the global receiver.
80 FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset));
83 __ Push(receiver, value());
84 ParameterCount actual(1);
85 ParameterCount expected(expected_arguments);
86 __ LoadAccessor(r4, holder, accessor_index, ACCESSOR_SETTER);
87 __ InvokeFunction(r4, expected, actual, CALL_FUNCTION, NullCallWrapper());
89 // If we generate a global code snippet for deoptimization only, remember
90 // the place to continue after deoptimization.
91 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset());
94 // We have to return the passed value, not the return value of the setter.
97 // Restore context register.
98 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
104 void PropertyHandlerCompiler::PushVectorAndSlot(Register vector,
106 MacroAssembler* masm = this->masm();
107 __ Push(vector, slot);
111 void PropertyHandlerCompiler::PopVectorAndSlot(Register vector, Register slot) {
112 MacroAssembler* masm = this->masm();
113 __ Pop(vector, slot);
117 void PropertyHandlerCompiler::DiscardVectorAndSlot() {
118 MacroAssembler* masm = this->masm();
119 // Remove vector and slot.
120 __ addi(sp, sp, Operand(2 * kPointerSize));
124 void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup(
125 MacroAssembler* masm, Label* miss_label, Register receiver,
126 Handle<Name> name, Register scratch0, Register scratch1) {
127 DCHECK(name->IsUniqueName());
128 DCHECK(!receiver.is(scratch0));
129 Counters* counters = masm->isolate()->counters();
130 __ IncrementCounter(counters->negative_lookups(), 1, scratch0, scratch1);
131 __ IncrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1);
135 const int kInterceptorOrAccessCheckNeededMask =
136 (1 << Map::kHasNamedInterceptor) | (1 << Map::kIsAccessCheckNeeded);
138 // Bail out if the receiver has a named interceptor or requires access checks.
139 Register map = scratch1;
140 __ LoadP(map, FieldMemOperand(receiver, HeapObject::kMapOffset));
141 __ lbz(scratch0, FieldMemOperand(map, Map::kBitFieldOffset));
142 __ andi(r0, scratch0, Operand(kInterceptorOrAccessCheckNeededMask));
143 __ bne(miss_label, cr0);
145 // Check that receiver is a JSObject.
146 __ lbz(scratch0, FieldMemOperand(map, Map::kInstanceTypeOffset));
147 __ cmpi(scratch0, Operand(FIRST_SPEC_OBJECT_TYPE));
150 // Load properties array.
151 Register properties = scratch0;
152 __ LoadP(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
153 // Check that the properties array is a dictionary.
154 __ LoadP(map, FieldMemOperand(properties, HeapObject::kMapOffset));
155 Register tmp = properties;
156 __ LoadRoot(tmp, Heap::kHashTableMapRootIndex);
160 // Restore the temporarily used register.
161 __ LoadP(properties, FieldMemOperand(receiver, JSObject::kPropertiesOffset));
164 NameDictionaryLookupStub::GenerateNegativeLookup(
165 masm, miss_label, &done, receiver, properties, name, scratch1);
167 __ DecrementCounter(counters->negative_lookups_miss(), 1, scratch0, scratch1);
171 void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype(
172 MacroAssembler* masm, int index, Register result, Label* miss) {
173 const int offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX);
174 __ LoadP(result, MemOperand(cp, offset));
175 __ LoadP(result, FieldMemOperand(result, GlobalObject::kNativeContextOffset));
176 __ LoadP(result, MemOperand(result, Context::SlotOffset(index)));
177 // Load its initial map. The global functions all have initial maps.
179 FieldMemOperand(result, JSFunction::kPrototypeOrInitialMapOffset));
180 // Load the prototype from the initial map.
181 __ LoadP(result, FieldMemOperand(result, Map::kPrototypeOffset));
185 void NamedLoadHandlerCompiler::GenerateLoadFunctionPrototype(
186 MacroAssembler* masm, Register receiver, Register scratch1,
187 Register scratch2, Label* miss_label) {
188 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label);
194 // Generate code to check that a global property cell is empty. Create
195 // the property cell at compilation time if no cell exists for the
197 void PropertyHandlerCompiler::GenerateCheckPropertyCell(
198 MacroAssembler* masm, Handle<JSGlobalObject> global, Handle<Name> name,
199 Register scratch, Label* miss) {
200 Handle<Cell> cell = JSGlobalObject::EnsurePropertyCell(global, name);
201 DCHECK(cell->value()->IsTheHole());
202 Handle<WeakCell> weak_cell = masm->isolate()->factory()->NewWeakCell(cell);
203 __ LoadWeakValue(scratch, weak_cell, miss);
204 __ LoadP(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
205 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
211 static void PushInterceptorArguments(MacroAssembler* masm, Register receiver,
212 Register holder, Register name,
213 Handle<JSObject> holder_obj) {
214 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex == 0);
215 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex == 1);
216 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 2);
217 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 3);
224 static void CompileCallLoadPropertyWithInterceptor(
225 MacroAssembler* masm, Register receiver, Register holder, Register name,
226 Handle<JSObject> holder_obj, IC::UtilityId id) {
227 PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
228 __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()),
229 NamedLoadHandlerCompiler::kInterceptorArgsLength);
233 // Generate call to api function.
234 void PropertyHandlerCompiler::GenerateApiAccessorCall(
235 MacroAssembler* masm, const CallOptimization& optimization,
236 Handle<Map> receiver_map, Register receiver, Register scratch_in,
237 bool is_store, Register store_parameter, Register accessor_holder,
238 int accessor_index) {
239 DCHECK(!accessor_holder.is(scratch_in));
240 DCHECK(!receiver.is(scratch_in));
242 // Write the arguments to stack frame.
244 DCHECK(!receiver.is(store_parameter));
245 DCHECK(!scratch_in.is(store_parameter));
246 __ push(store_parameter);
248 DCHECK(optimization.is_simple_api_call());
250 // Abi for CallApiFunctionStub.
251 Register callee = r3;
253 Register holder = r5;
254 Register api_function_address = r4;
256 // Put callee in place.
257 __ LoadAccessor(callee, accessor_holder, accessor_index,
258 is_store ? ACCESSOR_SETTER : ACCESSOR_GETTER);
260 // Put holder in place.
261 CallOptimization::HolderLookup holder_lookup;
262 int holder_depth = 0;
263 optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup,
265 switch (holder_lookup) {
266 case CallOptimization::kHolderIsReceiver:
267 __ Move(holder, receiver);
269 case CallOptimization::kHolderFound:
270 __ LoadP(holder, FieldMemOperand(receiver, HeapObject::kMapOffset));
271 __ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
272 for (int i = 1; i < holder_depth; i++) {
273 __ LoadP(holder, FieldMemOperand(holder, HeapObject::kMapOffset));
274 __ LoadP(holder, FieldMemOperand(holder, Map::kPrototypeOffset));
277 case CallOptimization::kHolderNotFound:
282 Isolate* isolate = masm->isolate();
283 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
284 bool call_data_undefined = false;
285 // Put call data in place.
286 if (api_call_info->data()->IsUndefined()) {
287 call_data_undefined = true;
288 __ LoadRoot(data, Heap::kUndefinedValueRootIndex);
291 FieldMemOperand(callee, JSFunction::kSharedFunctionInfoOffset));
293 FieldMemOperand(data, SharedFunctionInfo::kFunctionDataOffset));
295 FieldMemOperand(data, FunctionTemplateInfo::kCallCodeOffset));
296 __ LoadP(data, FieldMemOperand(data, CallHandlerInfo::kDataOffset));
299 // Put api_function_address in place.
300 Address function_address = v8::ToCData<Address>(api_call_info->callback());
301 ApiFunction fun(function_address);
302 ExternalReference::Type type = ExternalReference::DIRECT_API_CALL;
303 ExternalReference ref = ExternalReference(&fun, type, masm->isolate());
304 __ mov(api_function_address, Operand(ref));
307 CallApiAccessorStub stub(isolate, is_store, call_data_undefined);
308 __ TailCallStub(&stub);
312 void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) {
313 // Push receiver, key and value for runtime call.
314 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
315 StoreDescriptor::ValueRegister());
317 // The slow case calls into the runtime to complete the store without causing
318 // an IC miss that would otherwise cause a transition to the generic stub.
319 ExternalReference ref =
320 ExternalReference(IC_Utility(IC::kStoreIC_Slow), masm->isolate());
321 __ TailCallExternalReference(ref, 3, 1);
325 void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) {
326 // Push receiver, key and value for runtime call.
327 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
328 StoreDescriptor::ValueRegister());
330 // The slow case calls into the runtime to complete the store without causing
331 // an IC miss that would otherwise cause a transition to the generic stub.
332 ExternalReference ref =
333 ExternalReference(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate());
334 __ TailCallExternalReference(ref, 3, 1);
339 #define __ ACCESS_MASM(masm())
342 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label,
344 if (!label->is_unused()) {
346 __ mov(this->name(), Operand(name));
351 void NamedStoreHandlerCompiler::GenerateRestoreName(Handle<Name> name) {
352 __ mov(this->name(), Operand(name));
356 void NamedStoreHandlerCompiler::GenerateRestoreMap(Handle<Map> transition,
359 Handle<WeakCell> cell = Map::WeakCellForMap(transition);
360 Register map_reg = StoreTransitionDescriptor::MapRegister();
361 DCHECK(!map_reg.is(scratch));
362 __ LoadWeakValue(map_reg, cell, miss);
363 if (transition->CanBeDeprecated()) {
364 __ lwz(scratch, FieldMemOperand(map_reg, Map::kBitField3Offset));
365 __ DecodeField<Map::Deprecated>(r0, scratch, SetRC);
371 void NamedStoreHandlerCompiler::GenerateConstantCheck(Register map_reg,
376 DCHECK(!map_reg.is(scratch));
377 DCHECK(!map_reg.is(value_reg));
378 DCHECK(!value_reg.is(scratch));
379 __ LoadInstanceDescriptors(map_reg, scratch);
380 __ LoadP(scratch, FieldMemOperand(
381 scratch, DescriptorArray::GetValueOffset(descriptor)));
382 __ cmp(value_reg, scratch);
387 void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(HeapType* field_type,
390 Register map_reg = scratch1();
391 Register scratch = scratch2();
392 DCHECK(!value_reg.is(map_reg));
393 DCHECK(!value_reg.is(scratch));
394 __ JumpIfSmi(value_reg, miss_label);
395 HeapType::Iterator<Map> it = field_type->Classes();
397 __ LoadP(map_reg, FieldMemOperand(value_reg, HeapObject::kMapOffset));
400 __ CmpWeakValue(map_reg, Map::WeakCellForMap(it.Current()), scratch);
413 Register PropertyHandlerCompiler::CheckPrototypes(
414 Register object_reg, Register holder_reg, Register scratch1,
415 Register scratch2, Handle<Name> name, Label* miss,
416 PrototypeCheckType check) {
417 Handle<Map> receiver_map(IC::TypeToMap(*type(), isolate()));
419 // Make sure there's no overlap between holder and object registers.
420 DCHECK(!scratch1.is(object_reg) && !scratch1.is(holder_reg));
421 DCHECK(!scratch2.is(object_reg) && !scratch2.is(holder_reg) &&
422 !scratch2.is(scratch1));
424 // Keep track of the current object in register reg.
425 Register reg = object_reg;
428 Handle<JSObject> current = Handle<JSObject>::null();
429 if (type()->IsConstant()) {
430 current = Handle<JSObject>::cast(type()->AsConstant()->Value());
432 Handle<JSObject> prototype = Handle<JSObject>::null();
433 Handle<Map> current_map = receiver_map;
434 Handle<Map> holder_map(holder()->map());
435 // Traverse the prototype chain and check the maps in the prototype chain for
436 // fast and global objects or do negative lookup for normal objects.
437 while (!current_map.is_identical_to(holder_map)) {
440 // Only global objects and objects that do not require access
441 // checks are allowed in stubs.
442 DCHECK(current_map->IsJSGlobalProxyMap() ||
443 !current_map->is_access_check_needed());
445 prototype = handle(JSObject::cast(current_map->prototype()));
446 if (current_map->is_dictionary_map() &&
447 !current_map->IsJSGlobalObjectMap()) {
448 DCHECK(!current_map->IsJSGlobalProxyMap()); // Proxy maps are fast.
449 if (!name->IsUniqueName()) {
450 DCHECK(name->IsString());
451 name = factory()->InternalizeString(Handle<String>::cast(name));
453 DCHECK(current.is_null() ||
454 current->property_dictionary()->FindEntry(name) ==
455 NameDictionary::kNotFound);
457 GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1,
460 __ LoadP(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
461 reg = holder_reg; // From now on the object will be in holder_reg.
462 __ LoadP(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset));
464 Register map_reg = scratch1;
465 __ LoadP(map_reg, FieldMemOperand(reg, HeapObject::kMapOffset));
466 if (depth != 1 || check == CHECK_ALL_MAPS) {
467 Handle<WeakCell> cell = Map::WeakCellForMap(current_map);
468 __ CmpWeakValue(map_reg, cell, scratch2);
472 // Check access rights to the global object. This has to happen after
473 // the map check so that we know that the object is actually a global
475 // This allows us to install generated handlers for accesses to the
476 // global proxy (as opposed to using slow ICs). See corresponding code
477 // in LookupForRead().
478 if (current_map->IsJSGlobalProxyMap()) {
479 __ CheckAccessGlobalProxy(reg, scratch2, miss);
480 } else if (current_map->IsJSGlobalObjectMap()) {
481 GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current),
482 name, scratch2, miss);
485 reg = holder_reg; // From now on the object will be in holder_reg.
487 __ LoadP(reg, FieldMemOperand(map_reg, Map::kPrototypeOffset));
490 // Go to the next object in the prototype chain.
492 current_map = handle(current->map());
495 // Log the check depth.
496 LOG(isolate(), IntEvent("check-maps-depth", depth + 1));
498 if (depth != 0 || check == CHECK_ALL_MAPS) {
499 // Check the holder map.
500 __ LoadP(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset));
501 Handle<WeakCell> cell = Map::WeakCellForMap(current_map);
502 __ CmpWeakValue(scratch1, cell, scratch2);
506 // Perform security check for access to the global object.
507 DCHECK(current_map->IsJSGlobalProxyMap() ||
508 !current_map->is_access_check_needed());
509 if (current_map->IsJSGlobalProxyMap()) {
510 __ CheckAccessGlobalProxy(reg, scratch1, miss);
513 // Return the register containing the holder.
518 void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
519 if (!miss->is_unused()) {
523 if (IC::ICUseVector(kind())) {
524 DCHECK(kind() == Code::LOAD_IC);
527 TailCallBuiltin(masm(), MissBuiltin(kind()));
533 void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
534 if (!miss->is_unused()) {
537 GenerateRestoreName(miss, name);
538 TailCallBuiltin(masm(), MissBuiltin(kind()));
544 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
545 // Return the constant value.
551 void NamedLoadHandlerCompiler::GenerateLoadCallback(
552 Register reg, Handle<ExecutableAccessorInfo> callback) {
553 // Build AccessorInfo::args_ list on the stack and push property name below
554 // the exit frame to make GC aware of them and store pointers to them.
555 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0);
556 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1);
557 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2);
558 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3);
559 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4);
560 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5);
561 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6);
562 DCHECK(!scratch2().is(reg));
563 DCHECK(!scratch3().is(reg));
564 DCHECK(!scratch4().is(reg));
566 // Push data from ExecutableAccessorInfo.
567 Handle<Object> data(callback->data(), isolate());
568 if (data->IsUndefined() || data->IsSmi()) {
569 __ Move(scratch3(), data);
571 Handle<WeakCell> cell =
572 isolate()->factory()->NewWeakCell(Handle<HeapObject>::cast(data));
573 // The callback is alive if this instruction is executed,
574 // so the weak cell is not cleared and points to data.
575 __ GetWeakValue(scratch3(), cell);
578 __ LoadRoot(scratch3(), Heap::kUndefinedValueRootIndex);
579 __ mr(scratch4(), scratch3());
580 __ Push(scratch3(), scratch4());
581 __ mov(scratch4(), Operand(ExternalReference::isolate_address(isolate())));
582 __ Push(scratch4(), reg);
585 // Abi for CallApiGetter
586 Register getter_address_reg = ApiGetterDescriptor::function_address();
588 Address getter_address = v8::ToCData<Address>(callback->getter());
589 ApiFunction fun(getter_address);
590 ExternalReference::Type type = ExternalReference::DIRECT_GETTER_CALL;
591 ExternalReference ref = ExternalReference(&fun, type, isolate());
592 __ mov(getter_address_reg, Operand(ref));
594 CallApiGetterStub stub(isolate());
595 __ TailCallStub(&stub);
599 void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup(
600 LookupIterator* it, Register holder_reg) {
601 DCHECK(holder()->HasNamedInterceptor());
602 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined());
604 // Compile the interceptor call, followed by inline code to load the
605 // property from further up the prototype chain if the call fails.
606 // Check that the maps haven't changed.
607 DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1()));
609 // Preserve the receiver register explicitly whenever it is different from the
610 // holder and it is needed should the interceptor return without any result.
611 // The ACCESSOR case needs the receiver to be passed into C++ code, the FIELD
612 // case might cause a miss during the prototype check.
613 bool must_perform_prototype_check =
614 !holder().is_identical_to(it->GetHolder<JSObject>());
615 bool must_preserve_receiver_reg =
616 !receiver().is(holder_reg) &&
617 (it->state() == LookupIterator::ACCESSOR || must_perform_prototype_check);
619 // Save necessary data before invoking an interceptor.
620 // Requires a frame to make GC aware of pushed pointers.
622 FrameAndConstantPoolScope frame_scope(masm(), StackFrame::INTERNAL);
623 if (must_preserve_receiver_reg) {
624 __ Push(receiver(), holder_reg, this->name());
626 __ Push(holder_reg, this->name());
628 InterceptorVectorSlotPush(holder_reg);
629 // Invoke an interceptor. Note: map checks from receiver to
630 // interceptor's holder has been compiled before (see a caller
632 CompileCallLoadPropertyWithInterceptor(
633 masm(), receiver(), holder_reg, this->name(), holder(),
634 IC::kLoadPropertyWithInterceptorOnly);
636 // Check if interceptor provided a value for property. If it's
637 // the case, return immediately.
638 Label interceptor_failed;
639 __ LoadRoot(scratch1(), Heap::kNoInterceptorResultSentinelRootIndex);
640 __ cmp(r3, scratch1());
641 __ beq(&interceptor_failed);
642 frame_scope.GenerateLeaveFrame();
645 __ bind(&interceptor_failed);
646 InterceptorVectorSlotPop(holder_reg);
647 __ pop(this->name());
649 if (must_preserve_receiver_reg) {
652 // Leave the internal frame.
655 GenerateLoadPostInterceptor(it, holder_reg);
659 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
660 // Call the runtime system to load the interceptor.
661 DCHECK(holder()->HasNamedInterceptor());
662 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined());
663 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(),
666 ExternalReference ref = ExternalReference(
667 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate());
668 __ TailCallExternalReference(
669 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
673 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
674 Handle<JSObject> object, Handle<Name> name, int accessor_index) {
675 Register holder_reg = Frontend(name);
677 __ Push(receiver(), holder_reg); // receiver
678 __ LoadSmiLiteral(ip, Smi::FromInt(accessor_index));
680 __ mov(ip, Operand(name));
681 __ Push(ip, value());
683 // Do tail-call to the runtime system.
684 ExternalReference store_callback_property =
685 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate());
686 __ TailCallExternalReference(store_callback_property, 5, 1);
688 // Return the generated code.
689 return GetCode(kind(), Code::FAST, name);
693 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor(
695 __ Push(receiver(), this->name(), value());
697 // Do tail-call to the runtime system.
698 ExternalReference store_ic_property = ExternalReference(
699 IC_Utility(IC::kStorePropertyWithInterceptor), isolate());
700 __ TailCallExternalReference(store_ic_property, 3, 1);
702 // Return the generated code.
703 return GetCode(kind(), Code::FAST, name);
707 Register NamedStoreHandlerCompiler::value() {
708 return StoreDescriptor::ValueRegister();
712 Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal(
713 Handle<PropertyCell> cell, Handle<Name> name, bool is_configurable) {
715 if (IC::ICUseVector(kind())) {
718 FrontendHeader(receiver(), name, &miss);
720 // Get the value from the cell.
721 Register result = StoreDescriptor::ValueRegister();
722 Handle<WeakCell> weak_cell = factory()->NewWeakCell(cell);
723 __ LoadWeakValue(result, weak_cell, &miss);
724 __ LoadP(result, FieldMemOperand(result, Cell::kValueOffset));
726 // Check for deleted property if property can actually be deleted.
727 if (is_configurable) {
728 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
733 Counters* counters = isolate()->counters();
734 __ IncrementCounter(counters->named_load_global_stub(), 1, r4, r6);
735 if (IC::ICUseVector(kind())) {
736 DiscardVectorAndSlot();
740 FrontendFooter(name, &miss);
742 // Return the generated code.
743 return GetCode(kind(), Code::NORMAL, name);
749 } // namespace v8::internal
751 #endif // V8_TARGET_ARCH_ARM