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.
10 #include "src/ic/ic-compiler.h"
15 #define __ ACCESS_MASM(masm)
18 void PropertyICCompiler::GenerateRuntimeSetProperty(MacroAssembler* masm,
19 StrictMode strict_mode) {
20 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
21 StoreDescriptor::ValueRegister());
23 __ mov(r0, Operand(Smi::FromInt(strict_mode)));
26 // Do tail-call to runtime routine.
27 __ TailCallRuntime(Runtime::kSetProperty, 4, 1);
32 #define __ ACCESS_MASM(masm())
35 Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types,
36 CodeHandleList* handlers,
42 if (check == PROPERTY &&
43 (kind() == Code::KEYED_LOAD_IC || kind() == Code::KEYED_STORE_IC)) {
44 // In case we are compiling an IC for dictionary loads or stores, just
45 // check whether the name is unique.
46 if (name.is_identical_to(isolate()->factory()->normal_ic_symbol())) {
47 // Keyed loads with dictionaries shouldn't be here, they go generic.
48 // The DCHECK is to protect assumptions when --vector-ics is on.
49 DCHECK(kind() != Code::KEYED_LOAD_IC);
50 Register tmp = scratch1();
51 __ JumpIfSmi(this->name(), &miss);
52 __ ldr(tmp, FieldMemOperand(this->name(), HeapObject::kMapOffset));
53 __ ldrb(tmp, FieldMemOperand(tmp, Map::kInstanceTypeOffset));
54 __ JumpIfNotUniqueNameInstanceType(tmp, &miss);
56 __ cmp(this->name(), Operand(name));
62 Label* smi_target = IncludesNumberType(types) ? &number_case : &miss;
63 __ JumpIfSmi(receiver(), smi_target);
65 // Polymorphic keyed stores may use the map register
66 Register map_reg = scratch1();
67 DCHECK(kind() != Code::KEYED_STORE_IC ||
68 map_reg.is(ElementTransitionAndStoreDescriptor::MapRegister()));
70 int receiver_count = types->length();
71 int number_of_handled_maps = 0;
72 __ ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset));
73 for (int current = 0; current < receiver_count; ++current) {
74 Handle<HeapType> type = types->at(current);
75 Handle<Map> map = IC::TypeToMap(*type, isolate());
76 if (!map->is_deprecated()) {
77 number_of_handled_maps++;
78 Handle<WeakCell> cell = Map::WeakCellForMap(map);
79 __ CmpWeakValue(map_reg, cell, scratch2());
80 if (type->Is(HeapType::Number())) {
81 DCHECK(!number_case.is_unused());
82 __ bind(&number_case);
84 __ Jump(handlers->at(current), RelocInfo::CODE_TARGET, eq);
87 DCHECK(number_of_handled_maps != 0);
90 TailCallBuiltin(masm(), MissBuiltin(kind()));
92 // Return the generated code.
93 InlineCacheState state =
94 number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC;
95 return GetCode(kind(), type, name, state);
99 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
100 MapHandleList* receiver_maps, CodeHandleList* handler_stubs,
101 MapHandleList* transitioned_maps) {
103 __ JumpIfSmi(receiver(), &miss);
105 int receiver_count = receiver_maps->length();
106 Register map_reg = scratch1();
107 __ ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset));
108 for (int i = 0; i < receiver_count; ++i) {
109 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i));
110 __ CmpWeakValue(map_reg, cell, scratch2());
111 if (transitioned_maps->at(i).is_null()) {
112 __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq);
116 Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i));
117 __ LoadWeakValue(transition_map(), cell, &miss);
118 __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, al);
124 TailCallBuiltin(masm(), MissBuiltin(kind()));
126 // Return the generated code.
127 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
133 } // namespace v8::internal
135 #endif // V8_TARGET_ARCH_ARM