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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/ic/ic.h" | 9 #include "src/ic/ic.h" |
10 #include "src/ic/ic-compiler.h" | 10 #include "src/ic/ic-compiler.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 __ bind(&miss); | 66 __ bind(&miss); |
67 | 67 |
68 TailCallBuiltin(masm(), MissBuiltin(kind())); | 68 TailCallBuiltin(masm(), MissBuiltin(kind())); |
69 | 69 |
70 // Return the generated code. | 70 // Return the generated code. |
71 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); | 71 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 Handle<Code> PropertyICCompiler::CompilePolymorphic(TypeHandleList* types, | 75 Handle<Code> PropertyICCompiler::CompilePolymorphic(MapHandleList* maps, |
76 CodeHandleList* handlers, | 76 CodeHandleList* handlers, |
77 Handle<Name> name, | 77 Handle<Name> name, |
78 Code::StubType type, | 78 Code::StubType type, |
79 IcCheckType check) { | 79 IcCheckType check) { |
80 Label miss; | 80 Label miss; |
81 | 81 |
82 if (check == PROPERTY && | 82 if (check == PROPERTY && |
83 (kind() == Code::KEYED_LOAD_IC || kind() == Code::KEYED_STORE_IC)) { | 83 (kind() == Code::KEYED_LOAD_IC || kind() == Code::KEYED_STORE_IC)) { |
84 // In case we are compiling an IC for dictionary loads or stores, just | 84 // In case we are compiling an IC for dictionary loads or stores, just |
85 // check whether the name is unique. | 85 // check whether the name is unique. |
86 if (name.is_identical_to(isolate()->factory()->normal_ic_symbol())) { | 86 if (name.is_identical_to(isolate()->factory()->normal_ic_symbol())) { |
87 // Keyed loads with dictionaries shouldn't be here, they go generic. | 87 // Keyed loads with dictionaries shouldn't be here, they go generic. |
88 // The DCHECK is to protect assumptions when --vector-ics is on. | 88 // The DCHECK is to protect assumptions when --vector-ics is on. |
89 DCHECK(kind() != Code::KEYED_LOAD_IC); | 89 DCHECK(kind() != Code::KEYED_LOAD_IC); |
90 Register tmp = scratch1(); | 90 Register tmp = scratch1(); |
91 __ JumpIfSmi(this->name(), &miss); | 91 __ JumpIfSmi(this->name(), &miss); |
92 __ movp(tmp, FieldOperand(this->name(), HeapObject::kMapOffset)); | 92 __ movp(tmp, FieldOperand(this->name(), HeapObject::kMapOffset)); |
93 __ movzxbp(tmp, FieldOperand(tmp, Map::kInstanceTypeOffset)); | 93 __ movzxbp(tmp, FieldOperand(tmp, Map::kInstanceTypeOffset)); |
94 __ JumpIfNotUniqueNameInstanceType(tmp, &miss); | 94 __ JumpIfNotUniqueNameInstanceType(tmp, &miss); |
95 } else { | 95 } else { |
96 __ Cmp(this->name(), name); | 96 __ Cmp(this->name(), name); |
97 __ j(not_equal, &miss); | 97 __ j(not_equal, &miss); |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 Label number_case; | 101 Label number_case; |
102 Label* smi_target = IncludesNumberType(types) ? &number_case : &miss; | 102 Label* smi_target = IncludesNumberMap(maps) ? &number_case : &miss; |
103 __ JumpIfSmi(receiver(), smi_target); | 103 __ JumpIfSmi(receiver(), smi_target); |
104 | 104 |
105 // Polymorphic keyed stores may use the map register | 105 // Polymorphic keyed stores may use the map register |
106 Register map_reg = scratch1(); | 106 Register map_reg = scratch1(); |
107 DCHECK(kind() != Code::KEYED_STORE_IC || | 107 DCHECK(kind() != Code::KEYED_STORE_IC || |
108 map_reg.is(ElementTransitionAndStoreDescriptor::MapRegister())); | 108 map_reg.is(ElementTransitionAndStoreDescriptor::MapRegister())); |
109 __ movp(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset)); | 109 __ movp(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset)); |
110 int receiver_count = types->length(); | 110 int receiver_count = maps->length(); |
111 int number_of_handled_maps = 0; | 111 int number_of_handled_maps = 0; |
112 for (int current = 0; current < receiver_count; ++current) { | 112 for (int current = 0; current < receiver_count; ++current) { |
113 Handle<HeapType> type = types->at(current); | 113 Handle<Map> map = maps->at(current); |
114 Handle<Map> map = IC::TypeToMap(*type, isolate()); | |
115 if (!map->is_deprecated()) { | 114 if (!map->is_deprecated()) { |
116 number_of_handled_maps++; | 115 number_of_handled_maps++; |
117 Handle<WeakCell> cell = Map::WeakCellForMap(map); | 116 Handle<WeakCell> cell = Map::WeakCellForMap(map); |
118 // Check map and tail call if there's a match | 117 // Check map and tail call if there's a match |
119 __ CmpWeakValue(map_reg, cell, scratch2()); | 118 __ CmpWeakValue(map_reg, cell, scratch2()); |
120 if (type->Is(HeapType::Number())) { | 119 if (map->instance_type() == HEAP_NUMBER_TYPE) { |
121 DCHECK(!number_case.is_unused()); | 120 DCHECK(!number_case.is_unused()); |
122 __ bind(&number_case); | 121 __ bind(&number_case); |
123 } | 122 } |
124 __ j(equal, handlers->at(current), RelocInfo::CODE_TARGET); | 123 __ j(equal, handlers->at(current), RelocInfo::CODE_TARGET); |
125 } | 124 } |
126 } | 125 } |
127 DCHECK(number_of_handled_maps > 0); | 126 DCHECK(number_of_handled_maps > 0); |
128 | 127 |
129 __ bind(&miss); | 128 __ bind(&miss); |
130 TailCallBuiltin(masm(), MissBuiltin(kind())); | 129 TailCallBuiltin(masm(), MissBuiltin(kind())); |
131 | 130 |
132 // Return the generated code. | 131 // Return the generated code. |
133 InlineCacheState state = | 132 InlineCacheState state = |
134 number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC; | 133 number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC; |
135 return GetCode(kind(), type, name, state); | 134 return GetCode(kind(), type, name, state); |
136 } | 135 } |
137 | 136 |
138 | 137 |
139 #undef __ | 138 #undef __ |
140 } | 139 } |
141 } // namespace v8::internal | 140 } // namespace v8::internal |
142 | 141 |
143 #endif // V8_TARGET_ARCH_X64 | 142 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |