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_X64 | 5 #if V8_TARGET_ARCH_X64 |
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 { |
(...skipping 15 matching lines...) Expand all Loading... |
26 __ Push(StoreDescriptor::ValueRegister()); | 26 __ Push(StoreDescriptor::ValueRegister()); |
27 __ Push(Smi::FromInt(language_mode)); | 27 __ Push(Smi::FromInt(language_mode)); |
28 __ PushReturnAddressFrom(rbx); | 28 __ PushReturnAddressFrom(rbx); |
29 | 29 |
30 // Do tail-call to runtime routine. | 30 // Do tail-call to runtime routine. |
31 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); | 31 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 #undef __ | 35 #undef __ |
36 #define __ ACCESS_MASM(masm()) | |
37 | |
38 | |
39 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic( | |
40 MapHandleList* receiver_maps, CodeHandleList* handler_stubs, | |
41 MapHandleList* transitioned_maps) { | |
42 Label miss; | |
43 __ JumpIfSmi(receiver(), &miss); | |
44 | |
45 Register map_reg = scratch1(); | |
46 __ movp(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset)); | |
47 int receiver_count = receiver_maps->length(); | |
48 for (int i = 0; i < receiver_count; ++i) { | |
49 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i)); | |
50 // Check map and tail call if there's a match | |
51 __ CmpWeakValue(map_reg, cell, scratch2()); | |
52 if (transitioned_maps->at(i).is_null()) { | |
53 __ j(equal, handler_stubs->at(i), RelocInfo::CODE_TARGET); | |
54 } else { | |
55 Label next_map; | |
56 __ j(not_equal, &next_map, Label::kNear); | |
57 Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i)); | |
58 Register transition_map = scratch1(); | |
59 DCHECK(!FLAG_vector_stores && | |
60 transition_map.is(StoreTransitionDescriptor::MapRegister())); | |
61 __ LoadWeakValue(transition_map, cell, &miss); | |
62 __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET); | |
63 __ bind(&next_map); | |
64 } | |
65 } | |
66 | |
67 __ bind(&miss); | |
68 | |
69 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
70 | |
71 // Return the generated code. | |
72 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); | |
73 } | |
74 | |
75 | |
76 Handle<Code> PropertyICCompiler::CompilePolymorphic(MapHandleList* maps, | |
77 CodeHandleList* handlers, | |
78 Handle<Name> name, | |
79 Code::StubType type, | |
80 IcCheckType check) { | |
81 Label miss; | |
82 | |
83 if (check == PROPERTY && | |
84 (kind() == Code::KEYED_LOAD_IC || kind() == Code::KEYED_STORE_IC)) { | |
85 // In case we are compiling an IC for dictionary loads or stores, just | |
86 // check whether the name is unique. | |
87 if (name.is_identical_to(isolate()->factory()->normal_ic_symbol())) { | |
88 // Keyed loads with dictionaries shouldn't be here, they go generic. | |
89 // The DCHECK is to protect assumptions when --vector-ics is on. | |
90 DCHECK(kind() != Code::KEYED_LOAD_IC); | |
91 Register tmp = scratch1(); | |
92 __ JumpIfSmi(this->name(), &miss); | |
93 __ movp(tmp, FieldOperand(this->name(), HeapObject::kMapOffset)); | |
94 __ movzxbp(tmp, FieldOperand(tmp, Map::kInstanceTypeOffset)); | |
95 __ JumpIfNotUniqueNameInstanceType(tmp, &miss); | |
96 } else { | |
97 __ Cmp(this->name(), name); | |
98 __ j(not_equal, &miss); | |
99 } | |
100 } | |
101 | |
102 Label number_case; | |
103 Label* smi_target = IncludesNumberMap(maps) ? &number_case : &miss; | |
104 __ JumpIfSmi(receiver(), smi_target); | |
105 | |
106 // Polymorphic keyed stores may use the map register | |
107 Register map_reg = scratch1(); | |
108 DCHECK(kind() != Code::KEYED_STORE_IC || | |
109 map_reg.is(StoreTransitionDescriptor::MapRegister())); | |
110 __ movp(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset)); | |
111 int receiver_count = maps->length(); | |
112 int number_of_handled_maps = 0; | |
113 for (int current = 0; current < receiver_count; ++current) { | |
114 Handle<Map> map = maps->at(current); | |
115 if (!map->is_deprecated()) { | |
116 number_of_handled_maps++; | |
117 Handle<WeakCell> cell = Map::WeakCellForMap(map); | |
118 // Check map and tail call if there's a match | |
119 __ CmpWeakValue(map_reg, cell, scratch2()); | |
120 if (map->instance_type() == HEAP_NUMBER_TYPE) { | |
121 DCHECK(!number_case.is_unused()); | |
122 __ bind(&number_case); | |
123 } | |
124 __ j(equal, handlers->at(current), RelocInfo::CODE_TARGET); | |
125 } | |
126 } | |
127 DCHECK(number_of_handled_maps > 0); | |
128 | |
129 __ bind(&miss); | |
130 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
131 | |
132 // Return the generated code. | |
133 InlineCacheState state = | |
134 number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC; | |
135 return GetCode(kind(), type, name, state); | |
136 } | |
137 | |
138 | |
139 #undef __ | |
140 } // namespace internal | 36 } // namespace internal |
141 } // namespace v8 | 37 } // namespace v8 |
142 | 38 |
143 #endif // V8_TARGET_ARCH_X64 | 39 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |