| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   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 |   97 // static | 
|   98 PropertyAccessInfo PropertyAccessInfo::FunctionPrototype( |  | 
|   99     MapList const& receiver_maps) { |  | 
|  100   return PropertyAccessInfo(kFunctionPrototype, MaybeHandle<JSObject>(), |  | 
|  101                             Handle<Object>(), receiver_maps); |  | 
|  102 } |  | 
|  103  |  | 
|  104 // static |  | 
|  105 PropertyAccessInfo PropertyAccessInfo::Generic(MapList const& receiver_maps) { |   98 PropertyAccessInfo PropertyAccessInfo::Generic(MapList const& receiver_maps) { | 
|  106   return PropertyAccessInfo(kGeneric, MaybeHandle<JSObject>(), Handle<Object>(), |   99   return PropertyAccessInfo(kGeneric, MaybeHandle<JSObject>(), Handle<Object>(), | 
|  107                             receiver_maps); |  100                             receiver_maps); | 
|  108 } |  101 } | 
|  109  |  102  | 
|  110 PropertyAccessInfo::PropertyAccessInfo() |  103 PropertyAccessInfo::PropertyAccessInfo() | 
|  111     : kind_(kInvalid), |  104     : kind_(kInvalid), | 
|  112       field_representation_(MachineRepresentation::kNone), |  105       field_representation_(MachineRepresentation::kNone), | 
|  113       field_type_(Type::None()) {} |  106       field_type_(Type::None()) {} | 
|  114  |  107  | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
|  144       field_map_(field_map) {} |  137       field_map_(field_map) {} | 
|  145  |  138  | 
|  146 bool PropertyAccessInfo::Merge(PropertyAccessInfo const* that) { |  139 bool PropertyAccessInfo::Merge(PropertyAccessInfo const* that) { | 
|  147   if (this->kind_ != that->kind_) return false; |  140   if (this->kind_ != that->kind_) return false; | 
|  148   if (this->holder_.address() != that->holder_.address()) return false; |  141   if (this->holder_.address() != that->holder_.address()) return false; | 
|  149  |  142  | 
|  150   switch (this->kind_) { |  143   switch (this->kind_) { | 
|  151     case kInvalid: |  144     case kInvalid: | 
|  152       break; |  145       break; | 
|  153  |  146  | 
 |  147     case kNotFound: | 
 |  148       return true; | 
 |  149  | 
|  154     case kDataField: { |  150     case kDataField: { | 
|  155       // Check if we actually access the same field. |  151       // Check if we actually access the same field. | 
|  156       if (this->transition_map_.address() == that->transition_map_.address() && |  152       if (this->transition_map_.address() == that->transition_map_.address() && | 
|  157           this->field_index_ == that->field_index_ && |  153           this->field_index_ == that->field_index_ && | 
|  158           this->field_type_->Is(that->field_type_) && |  154           this->field_type_->Is(that->field_type_) && | 
|  159           that->field_type_->Is(this->field_type_) && |  155           that->field_type_->Is(this->field_type_) && | 
|  160           this->field_representation_ == that->field_representation_) { |  156           this->field_representation_ == that->field_representation_) { | 
|  161         this->receiver_maps_.insert(this->receiver_maps_.end(), |  157         this->receiver_maps_.insert(this->receiver_maps_.end(), | 
|  162                                     that->receiver_maps_.begin(), |  158                                     that->receiver_maps_.begin(), | 
|  163                                     that->receiver_maps_.end()); |  159                                     that->receiver_maps_.end()); | 
|  164         return true; |  160         return true; | 
|  165       } |  161       } | 
|  166       return false; |  162       return false; | 
|  167     } |  163     } | 
|  168  |  164  | 
|  169     case kDataConstant: |  165     case kDataConstant: | 
|  170     case kAccessorConstant: { |  166     case kAccessorConstant: { | 
|  171       // Check if we actually access the same constant. |  167       // Check if we actually access the same constant. | 
|  172       if (this->constant_.address() == that->constant_.address()) { |  168       if (this->constant_.address() == that->constant_.address()) { | 
|  173         this->receiver_maps_.insert(this->receiver_maps_.end(), |  169         this->receiver_maps_.insert(this->receiver_maps_.end(), | 
|  174                                     that->receiver_maps_.begin(), |  170                                     that->receiver_maps_.begin(), | 
|  175                                     that->receiver_maps_.end()); |  171                                     that->receiver_maps_.end()); | 
|  176         return true; |  172         return true; | 
|  177       } |  173       } | 
|  178       return false; |  174       return false; | 
|  179     } |  175     } | 
|  180  |  | 
|  181     case kNotFound: |  | 
|  182     case kFunctionPrototype: |  | 
|  183     case kGeneric: { |  176     case kGeneric: { | 
|  184       this->receiver_maps_.insert(this->receiver_maps_.end(), |  177       this->receiver_maps_.insert(this->receiver_maps_.end(), | 
|  185                                   that->receiver_maps_.begin(), |  178                                   that->receiver_maps_.begin(), | 
|  186                                   that->receiver_maps_.end()); |  179                                   that->receiver_maps_.end()); | 
|  187       return true; |  180       return true; | 
|  188     } |  181     } | 
|  189   } |  182   } | 
|  190  |  183  | 
|  191   UNREACHABLE(); |  184   UNREACHABLE(); | 
|  192   return false; |  185   return false; | 
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  449       } |  442       } | 
|  450       if (!merged) access_infos->push_back(access_info); |  443       if (!merged) access_infos->push_back(access_info); | 
|  451     } |  444     } | 
|  452   } |  445   } | 
|  453   return true; |  446   return true; | 
|  454 } |  447 } | 
|  455  |  448  | 
|  456  |  449  | 
|  457 bool AccessInfoFactory::LookupSpecialFieldAccessor( |  450 bool AccessInfoFactory::LookupSpecialFieldAccessor( | 
|  458     Handle<Map> map, Handle<Name> name, PropertyAccessInfo* access_info) { |  451     Handle<Map> map, Handle<Name> name, PropertyAccessInfo* access_info) { | 
|  459   // Check for Function::prototype accessor. |  | 
|  460   if (map->IsJSFunctionMap() && map->is_constructor() && |  | 
|  461       name.is_identical_to(factory()->prototype_string())) { |  | 
|  462     DCHECK(!map->has_non_instance_prototype()); |  | 
|  463     *access_info = PropertyAccessInfo::FunctionPrototype(MapList{map}); |  | 
|  464     return true; |  | 
|  465   } |  | 
|  466   // Check for special JSObject field accessors. |  452   // Check for special JSObject field accessors. | 
|  467   int offset; |  453   int offset; | 
|  468   if (Accessors::IsJSObjectFieldAccessor(map, name, &offset)) { |  454   if (Accessors::IsJSObjectFieldAccessor(map, name, &offset)) { | 
|  469     FieldIndex field_index = FieldIndex::ForInObjectOffset(offset); |  455     FieldIndex field_index = FieldIndex::ForInObjectOffset(offset); | 
|  470     Type* field_type = Type::NonInternal(); |  456     Type* field_type = Type::NonInternal(); | 
|  471     MachineRepresentation field_representation = MachineRepresentation::kTagged; |  457     MachineRepresentation field_representation = MachineRepresentation::kTagged; | 
|  472     if (map->IsStringMap()) { |  458     if (map->IsStringMap()) { | 
|  473       DCHECK(Name::Equals(factory()->length_string(), name)); |  459       DCHECK(Name::Equals(factory()->length_string(), name)); | 
|  474       // The String::length property is always a smi in the range |  460       // The String::length property is always a smi in the range | 
|  475       // [0, String::kMaxLength]. |  461       // [0, String::kMaxLength]. | 
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  560   } |  546   } | 
|  561   return false; |  547   return false; | 
|  562 } |  548 } | 
|  563  |  549  | 
|  564  |  550  | 
|  565 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } |  551 Factory* AccessInfoFactory::factory() const { return isolate()->factory(); } | 
|  566  |  552  | 
|  567 }  // namespace compiler |  553 }  // namespace compiler | 
|  568 }  // namespace internal |  554 }  // namespace internal | 
|  569 }  // namespace v8 |  555 }  // namespace v8 | 
| OLD | NEW |