OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 5952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5963 } | 5963 } |
5964 } | 5964 } |
5965 info->GeneralizeRepresentation(r); | 5965 info->GeneralizeRepresentation(r); |
5966 info->field_type_ = info->field_type_.Combine(field_type_); | 5966 info->field_type_ = info->field_type_.Combine(field_type_); |
5967 return true; | 5967 return true; |
5968 } | 5968 } |
5969 | 5969 |
5970 | 5970 |
5971 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupDescriptor() { | 5971 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupDescriptor() { |
5972 if (!map_->IsJSObjectMap()) return true; | 5972 if (!map_->IsJSObjectMap()) return true; |
5973 lookup_.LookupDescriptor(*map_, *name_); | 5973 LookupDescriptor(*map_, *name_); |
5974 return LoadResult(map_); | 5974 return LoadResult(map_); |
5975 } | 5975 } |
5976 | 5976 |
5977 | 5977 |
5978 bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) { | 5978 bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) { |
5979 if (!IsLoad() && IsProperty() && IsReadOnly()) { | 5979 if (!IsLoad() && IsProperty() && IsReadOnly()) { |
5980 return false; | 5980 return false; |
5981 } | 5981 } |
5982 | 5982 |
5983 if (IsData()) { | 5983 if (IsData()) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6052 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupInPrototypes() { | 6052 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupInPrototypes() { |
6053 Handle<Map> map = this->map(); | 6053 Handle<Map> map = this->map(); |
6054 | 6054 |
6055 while (map->prototype()->IsJSObject()) { | 6055 while (map->prototype()->IsJSObject()) { |
6056 holder_ = handle(JSObject::cast(map->prototype())); | 6056 holder_ = handle(JSObject::cast(map->prototype())); |
6057 if (holder_->map()->is_deprecated()) { | 6057 if (holder_->map()->is_deprecated()) { |
6058 JSObject::TryMigrateInstance(holder_); | 6058 JSObject::TryMigrateInstance(holder_); |
6059 } | 6059 } |
6060 map = Handle<Map>(holder_->map()); | 6060 map = Handle<Map>(holder_->map()); |
6061 if (!CanInlinePropertyAccess(map)) { | 6061 if (!CanInlinePropertyAccess(map)) { |
6062 lookup_.NotFound(); | 6062 NotFound(); |
6063 return false; | 6063 return false; |
6064 } | 6064 } |
6065 lookup_.LookupDescriptor(*map, *name_); | 6065 LookupDescriptor(*map, *name_); |
6066 if (IsFound()) return LoadResult(map); | 6066 if (IsFound()) return LoadResult(map); |
6067 } | 6067 } |
6068 lookup_.NotFound(); | 6068 NotFound(); |
6069 return true; | 6069 return true; |
6070 } | 6070 } |
6071 | 6071 |
6072 | 6072 |
6073 bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() { | 6073 bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() { |
6074 if (!CanInlinePropertyAccess(map_)) return false; | 6074 if (!CanInlinePropertyAccess(map_)) return false; |
6075 if (IsJSObjectFieldAccessor()) return IsLoad(); | 6075 if (IsJSObjectFieldAccessor()) return IsLoad(); |
6076 if (map_->function_with_prototype() && !map_->has_non_instance_prototype() && | 6076 if (map_->function_with_prototype() && !map_->has_non_instance_prototype() && |
6077 name_.is_identical_to(isolate()->factory()->prototype_string())) { | 6077 name_.is_identical_to(isolate()->factory()->prototype_string())) { |
6078 return IsLoad(); | 6078 return IsLoad(); |
6079 } | 6079 } |
6080 if (!LookupDescriptor()) return false; | 6080 if (!LookupDescriptor()) return false; |
6081 if (IsFound()) return IsLoad() || !IsReadOnly(); | 6081 if (IsFound()) return IsLoad() || !IsReadOnly(); |
6082 if (!LookupInPrototypes()) return false; | 6082 if (!LookupInPrototypes()) return false; |
6083 if (IsLoad()) return true; | 6083 if (IsLoad()) return true; |
6084 | 6084 |
6085 if (IsAccessorConstant()) return true; | 6085 if (IsAccessorConstant()) return true; |
6086 lookup_.LookupTransition(*map_, *name_, NONE); | 6086 LookupTransition(*map_, *name_, NONE); |
6087 if (lookup_.IsTransitionToData() && map_->unused_property_fields() > 0) { | 6087 if (IsTransitionToData() && map_->unused_property_fields() > 0) { |
6088 // Construct the object field access. | 6088 // Construct the object field access. |
6089 int descriptor = transition()->LastAdded(); | 6089 int descriptor = transition()->LastAdded(); |
6090 int index = | 6090 int index = |
6091 transition()->instance_descriptors()->GetFieldIndex(descriptor) - | 6091 transition()->instance_descriptors()->GetFieldIndex(descriptor) - |
6092 map_->inobject_properties(); | 6092 map_->inobject_properties(); |
6093 PropertyDetails details = | 6093 PropertyDetails details = |
6094 transition()->instance_descriptors()->GetDetails(descriptor); | 6094 transition()->instance_descriptors()->GetDetails(descriptor); |
6095 Representation representation = details.representation(); | 6095 Representation representation = details.representation(); |
6096 access_ = HObjectAccess::ForField(map_, index, representation, name_); | 6096 access_ = HObjectAccess::ForField(map_, index, representation, name_); |
6097 | 6097 |
(...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8167 break; | 8167 break; |
8168 } | 8168 } |
8169 return false; | 8169 return false; |
8170 } | 8170 } |
8171 | 8171 |
8172 | 8172 |
8173 // static | 8173 // static |
8174 bool HOptimizedGraphBuilder::IsReadOnlyLengthDescriptor( | 8174 bool HOptimizedGraphBuilder::IsReadOnlyLengthDescriptor( |
8175 Handle<Map> jsarray_map) { | 8175 Handle<Map> jsarray_map) { |
8176 DCHECK(!jsarray_map->is_dictionary_map()); | 8176 DCHECK(!jsarray_map->is_dictionary_map()); |
8177 LookupResult lookup; | |
8178 Isolate* isolate = jsarray_map->GetIsolate(); | 8177 Isolate* isolate = jsarray_map->GetIsolate(); |
8179 Handle<Name> length_string = isolate->factory()->length_string(); | 8178 Handle<Name> length_string = isolate->factory()->length_string(); |
8180 lookup.LookupDescriptor(*jsarray_map, *length_string); | 8179 DescriptorArray* descriptors = jsarray_map->instance_descriptors(); |
8181 return lookup.IsReadOnly(); | 8180 int number = descriptors->SearchWithCache(*length_string, *jsarray_map); |
| 8181 DCHECK_NE(DescriptorArray::kNotFound, number); |
| 8182 return descriptors->GetDetails(number).IsReadOnly(); |
8182 } | 8183 } |
8183 | 8184 |
8184 | 8185 |
8185 // static | 8186 // static |
8186 bool HOptimizedGraphBuilder::CanInlineArrayResizeOperation( | 8187 bool HOptimizedGraphBuilder::CanInlineArrayResizeOperation( |
8187 Handle<Map> receiver_map) { | 8188 Handle<Map> receiver_map) { |
8188 return !receiver_map.is_null() && | 8189 return !receiver_map.is_null() && |
8189 receiver_map->instance_type() == JS_ARRAY_TYPE && | 8190 receiver_map->instance_type() == JS_ARRAY_TYPE && |
8190 IsFastElementsKind(receiver_map->elements_kind()) && | 8191 IsFastElementsKind(receiver_map->elements_kind()) && |
8191 !receiver_map->is_dictionary_map() && | 8192 !receiver_map->is_dictionary_map() && |
(...skipping 5242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13434 if (ShouldProduceTraceOutput()) { | 13435 if (ShouldProduceTraceOutput()) { |
13435 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13436 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13436 } | 13437 } |
13437 | 13438 |
13438 #ifdef DEBUG | 13439 #ifdef DEBUG |
13439 graph_->Verify(false); // No full verify. | 13440 graph_->Verify(false); // No full verify. |
13440 #endif | 13441 #endif |
13441 } | 13442 } |
13442 | 13443 |
13443 } } // namespace v8::internal | 13444 } } // namespace v8::internal |
OLD | NEW |