OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/ic/ic.h" | 7 #include "src/ic/ic.h" |
8 #include "src/ic/ic-compiler.h" | 8 #include "src/ic/ic-compiler.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 #define __ ACCESS_MASM(masm) | 13 #define __ ACCESS_MASM(masm) |
14 | 14 |
15 void PropertyICCompiler::GenerateRuntimeSetProperty( | 15 void PropertyICCompiler::GenerateRuntimeSetProperty( |
16 MacroAssembler* masm, LanguageMode language_mode) { | 16 MacroAssembler* masm, LanguageMode language_mode) { |
17 ASM_LOCATION("PropertyICCompiler::GenerateRuntimeSetProperty"); | 17 ASM_LOCATION("PropertyICCompiler::GenerateRuntimeSetProperty"); |
18 | 18 |
19 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(), | 19 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(), |
20 StoreDescriptor::ValueRegister()); | 20 StoreDescriptor::ValueRegister()); |
21 | 21 |
22 __ Mov(x10, Smi::FromInt(language_mode)); | 22 __ Mov(x10, Smi::FromInt(language_mode)); |
23 __ Push(x10); | 23 __ Push(x10); |
24 | 24 |
25 // Do tail-call to runtime routine. | 25 // Do tail-call to runtime routine. |
26 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); | 26 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); |
27 } | 27 } |
28 | 28 |
29 | |
30 #undef __ | |
31 #define __ ACCESS_MASM(masm()) | |
32 | |
33 | |
34 Handle<Code> PropertyICCompiler::CompilePolymorphic(MapHandleList* maps, | |
35 CodeHandleList* handlers, | |
36 Handle<Name> name, | |
37 Code::StubType type, | |
38 IcCheckType check) { | |
39 Label miss; | |
40 | |
41 if (check == PROPERTY && | |
42 (kind() == Code::KEYED_LOAD_IC || kind() == Code::KEYED_STORE_IC)) { | |
43 // In case we are compiling an IC for dictionary loads or stores, just | |
44 // check whether the name is unique. | |
45 if (name.is_identical_to(isolate()->factory()->normal_ic_symbol())) { | |
46 // Keyed loads with dictionaries shouldn't be here, they go generic. | |
47 // The DCHECK is to protect assumptions when --vector-ics is on. | |
48 DCHECK(kind() != Code::KEYED_LOAD_IC); | |
49 Register tmp = scratch1(); | |
50 __ JumpIfSmi(this->name(), &miss); | |
51 __ Ldr(tmp, FieldMemOperand(this->name(), HeapObject::kMapOffset)); | |
52 __ Ldrb(tmp, FieldMemOperand(tmp, Map::kInstanceTypeOffset)); | |
53 __ JumpIfNotUniqueNameInstanceType(tmp, &miss); | |
54 } else { | |
55 __ CompareAndBranch(this->name(), Operand(name), ne, &miss); | |
56 } | |
57 } | |
58 | |
59 Label number_case; | |
60 Label* smi_target = IncludesNumberMap(maps) ? &number_case : &miss; | |
61 __ JumpIfSmi(receiver(), smi_target); | |
62 | |
63 // Polymorphic keyed stores may use the map register | |
64 Register map_reg = scratch1(); | |
65 DCHECK(kind() != Code::KEYED_STORE_IC || | |
66 map_reg.is(StoreTransitionDescriptor::MapRegister())); | |
67 __ Ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset)); | |
68 int receiver_count = maps->length(); | |
69 int number_of_handled_maps = 0; | |
70 for (int current = 0; current < receiver_count; ++current) { | |
71 Handle<Map> map = maps->at(current); | |
72 if (!map->is_deprecated()) { | |
73 number_of_handled_maps++; | |
74 Handle<WeakCell> cell = Map::WeakCellForMap(map); | |
75 __ CmpWeakValue(map_reg, cell, scratch2()); | |
76 Label try_next; | |
77 __ B(ne, &try_next); | |
78 if (map->instance_type() == HEAP_NUMBER_TYPE) { | |
79 DCHECK(!number_case.is_unused()); | |
80 __ Bind(&number_case); | |
81 } | |
82 __ Jump(handlers->at(current), RelocInfo::CODE_TARGET); | |
83 __ Bind(&try_next); | |
84 } | |
85 } | |
86 DCHECK(number_of_handled_maps != 0); | |
87 | |
88 __ Bind(&miss); | |
89 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
90 | |
91 // Return the generated code. | |
92 InlineCacheState state = | |
93 (number_of_handled_maps > 1) ? POLYMORPHIC : MONOMORPHIC; | |
94 return GetCode(kind(), type, name, state); | |
95 } | |
96 | |
97 | |
98 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic( | |
99 MapHandleList* receiver_maps, CodeHandleList* handler_stubs, | |
100 MapHandleList* transitioned_maps) { | |
101 Label miss; | |
102 | |
103 ASM_LOCATION("PropertyICCompiler::CompileStorePolymorphic"); | |
104 | |
105 __ JumpIfSmi(receiver(), &miss); | |
106 | |
107 int receiver_count = receiver_maps->length(); | |
108 Register map_reg = scratch1(); | |
109 __ Ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset)); | |
110 for (int i = 0; i < receiver_count; i++) { | |
111 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i)); | |
112 __ CmpWeakValue(map_reg, cell, scratch2()); | |
113 Label skip; | |
114 __ B(&skip, ne); | |
115 if (!transitioned_maps->at(i).is_null()) { | |
116 // This argument is used by the handler stub. For example, see | |
117 // ElementsTransitionGenerator::GenerateMapChangeElementsTransition. | |
118 Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i)); | |
119 Register transition_map = scratch1(); | |
120 DCHECK(!FLAG_vector_stores && | |
121 transition_map.is(StoreTransitionDescriptor::MapRegister())); | |
122 __ LoadWeakValue(transition_map, cell, &miss); | |
123 } | |
124 __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET); | |
125 __ Bind(&skip); | |
126 } | |
127 | |
128 __ Bind(&miss); | |
129 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
130 | |
131 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); | |
132 } | |
133 | |
134 | |
135 #undef __ | 29 #undef __ |
136 } // namespace internal | 30 } // namespace internal |
137 } // namespace v8 | 31 } // namespace v8 |
138 | 32 |
139 #endif // V8_TARGET_ARCH_ARM64 | 33 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |