OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <ostream> | 5 #include <ostream> |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/compilation-dependencies.h" | 8 #include "src/compilation-dependencies.h" |
9 #include "src/compiler/access-info.h" | 9 #include "src/compiler/access-info.h" |
10 #include "src/compiler/type-cache.h" | 10 #include "src/compiler/type-cache.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 receiver_maps); | 87 receiver_maps); |
88 } | 88 } |
89 | 89 |
90 // static | 90 // static |
91 PropertyAccessInfo PropertyAccessInfo::AccessorConstant( | 91 PropertyAccessInfo PropertyAccessInfo::AccessorConstant( |
92 MapList const& receiver_maps, Handle<Object> constant, | 92 MapList const& receiver_maps, Handle<Object> constant, |
93 MaybeHandle<JSObject> holder) { | 93 MaybeHandle<JSObject> holder) { |
94 return PropertyAccessInfo(kAccessorConstant, holder, constant, receiver_maps); | 94 return PropertyAccessInfo(kAccessorConstant, holder, constant, receiver_maps); |
95 } | 95 } |
96 | 96 |
| 97 // static |
| 98 PropertyAccessInfo PropertyAccessInfo::Generic(MapList const& receiver_maps) { |
| 99 return PropertyAccessInfo(kGeneric, MaybeHandle<JSObject>(), Handle<Object>(), |
| 100 receiver_maps); |
| 101 } |
| 102 |
97 PropertyAccessInfo::PropertyAccessInfo() | 103 PropertyAccessInfo::PropertyAccessInfo() |
98 : kind_(kInvalid), | 104 : kind_(kInvalid), |
99 field_representation_(MachineRepresentation::kNone), | 105 field_representation_(MachineRepresentation::kNone), |
100 field_type_(Type::None()) {} | 106 field_type_(Type::None()) {} |
101 | 107 |
102 PropertyAccessInfo::PropertyAccessInfo(MaybeHandle<JSObject> holder, | 108 PropertyAccessInfo::PropertyAccessInfo(MaybeHandle<JSObject> holder, |
103 MapList const& receiver_maps) | 109 MapList const& receiver_maps) |
104 : kind_(kNotFound), | 110 : kind_(kNotFound), |
105 receiver_maps_(receiver_maps), | 111 receiver_maps_(receiver_maps), |
106 holder_(holder), | 112 holder_(holder), |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 case kAccessorConstant: { | 166 case kAccessorConstant: { |
161 // Check if we actually access the same constant. | 167 // Check if we actually access the same constant. |
162 if (this->constant_.address() == that->constant_.address()) { | 168 if (this->constant_.address() == that->constant_.address()) { |
163 this->receiver_maps_.insert(this->receiver_maps_.end(), | 169 this->receiver_maps_.insert(this->receiver_maps_.end(), |
164 that->receiver_maps_.begin(), | 170 that->receiver_maps_.begin(), |
165 that->receiver_maps_.end()); | 171 that->receiver_maps_.end()); |
166 return true; | 172 return true; |
167 } | 173 } |
168 return false; | 174 return false; |
169 } | 175 } |
| 176 case kGeneric: { |
| 177 this->receiver_maps_.insert(this->receiver_maps_.end(), |
| 178 that->receiver_maps_.begin(), |
| 179 that->receiver_maps_.end()); |
| 180 return true; |
| 181 } |
170 } | 182 } |
171 | 183 |
172 UNREACHABLE(); | 184 UNREACHABLE(); |
173 return false; | 185 return false; |
174 } | 186 } |
175 | 187 |
176 AccessInfoFactory::AccessInfoFactory(CompilationDependencies* dependencies, | 188 AccessInfoFactory::AccessInfoFactory(CompilationDependencies* dependencies, |
177 Handle<Context> native_context, Zone* zone) | 189 Handle<Context> native_context, Zone* zone) |
178 : dependencies_(dependencies), | 190 : dependencies_(dependencies), |
179 native_context_(native_context), | 191 native_context_(native_context), |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 return true; | 483 return true; |
472 } | 484 } |
473 return false; | 485 return false; |
474 } | 486 } |
475 | 487 |
476 | 488 |
477 bool AccessInfoFactory::LookupTransition(Handle<Map> map, Handle<Name> name, | 489 bool AccessInfoFactory::LookupTransition(Handle<Map> map, Handle<Name> name, |
478 MaybeHandle<JSObject> holder, | 490 MaybeHandle<JSObject> holder, |
479 PropertyAccessInfo* access_info) { | 491 PropertyAccessInfo* access_info) { |
480 // Check if the {map} has a data transition with the given {name}. | 492 // Check if the {map} has a data transition with the given {name}. |
481 if (map->unused_property_fields() == 0) return false; | 493 if (map->unused_property_fields() == 0) { |
| 494 *access_info = PropertyAccessInfo::Generic(MapList{map}); |
| 495 return true; |
| 496 } |
482 Handle<Map> transition_map; | 497 Handle<Map> transition_map; |
483 if (TransitionArray::SearchTransition(map, kData, name, NONE) | 498 if (TransitionArray::SearchTransition(map, kData, name, NONE) |
484 .ToHandle(&transition_map)) { | 499 .ToHandle(&transition_map)) { |
485 int const number = transition_map->LastAdded(); | 500 int const number = transition_map->LastAdded(); |
486 PropertyDetails const details = | 501 PropertyDetails const details = |
487 transition_map->instance_descriptors()->GetDetails(number); | 502 transition_map->instance_descriptors()->GetDetails(number); |
488 // Don't bother optimizing stores to read-only properties. | 503 // Don't bother optimizing stores to read-only properties. |
489 if (details.IsReadOnly()) return false; | 504 if (details.IsReadOnly()) return false; |
490 // TODO(bmeurer): Handle transition to data constant? | 505 // TODO(bmeurer): Handle transition to data constant? |
491 if (details.type() != DATA) return false; | 506 if (details.type() != DATA) return false; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 } | 546 } |
532 return false; | 547 return false; |
533 } | 548 } |
534 | 549 |
535 | 550 |
536 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } | 551 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } |
537 | 552 |
538 } // namespace compiler | 553 } // namespace compiler |
539 } // namespace internal | 554 } // namespace internal |
540 } // namespace v8 | 555 } // namespace v8 |
OLD | NEW |