| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 5772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5783 Handle<Map> map) { | 5783 Handle<Map> map) { |
| 5784 BuildCheckHeapObject(object); | 5784 BuildCheckHeapObject(object); |
| 5785 return Add<HCheckMaps>(object, map); | 5785 return Add<HCheckMaps>(object, map); |
| 5786 } | 5786 } |
| 5787 | 5787 |
| 5788 | 5788 |
| 5789 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField( | 5789 HInstruction* HOptimizedGraphBuilder::BuildLoadNamedField( |
| 5790 PropertyAccessInfo* info, | 5790 PropertyAccessInfo* info, |
| 5791 HValue* checked_object) { | 5791 HValue* checked_object) { |
| 5792 // See if this is a load for an immutable property | 5792 // See if this is a load for an immutable property |
| 5793 if (checked_object->ActualValue()->IsConstant() && info->IsCacheable() && | 5793 if (checked_object->ActualValue()->IsConstant() && info->IsReadOnly() && |
| 5794 info->IsReadOnly() && !info->IsConfigurable()) { | 5794 !info->IsConfigurable()) { |
| 5795 Handle<Object> object( | 5795 Handle<Object> object( |
| 5796 HConstant::cast(checked_object->ActualValue())->handle(isolate())); | 5796 HConstant::cast(checked_object->ActualValue())->handle(isolate())); |
| 5797 | 5797 |
| 5798 if (object->IsJSObject()) { | 5798 if (object->IsJSObject()) { |
| 5799 LookupIterator it(object, info->name(), LookupIterator::OWN_PROPERTY); | 5799 LookupIterator it(object, info->name(), LookupIterator::OWN_PROPERTY); |
| 5800 Handle<Object> value = JSObject::GetDataProperty(&it); | 5800 Handle<Object> value = JSObject::GetDataProperty(&it); |
| 5801 CHECK(it.IsFound()); | 5801 CHECK(it.IsFound()); |
| 5802 return New<HConstant>(value); | 5802 return New<HConstant>(value); |
| 5803 } | 5803 } |
| 5804 } | 5804 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5963 | 5963 |
| 5964 | 5964 |
| 5965 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupDescriptor() { | 5965 bool HOptimizedGraphBuilder::PropertyAccessInfo::LookupDescriptor() { |
| 5966 if (!type_->IsClass()) return true; | 5966 if (!type_->IsClass()) return true; |
| 5967 map()->LookupDescriptor(NULL, *name_, &lookup_); | 5967 map()->LookupDescriptor(NULL, *name_, &lookup_); |
| 5968 return LoadResult(map()); | 5968 return LoadResult(map()); |
| 5969 } | 5969 } |
| 5970 | 5970 |
| 5971 | 5971 |
| 5972 bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) { | 5972 bool HOptimizedGraphBuilder::PropertyAccessInfo::LoadResult(Handle<Map> map) { |
| 5973 if (!IsLoad() && IsProperty() && (IsReadOnly() || !IsCacheable())) { | 5973 if (!IsLoad() && IsProperty() && IsReadOnly()) { |
| 5974 return false; | 5974 return false; |
| 5975 } | 5975 } |
| 5976 | 5976 |
| 5977 if (IsField()) { | 5977 if (IsField()) { |
| 5978 // Construct the object field access. | 5978 // Construct the object field access. |
| 5979 int index = GetLocalFieldIndexFromMap(map); | 5979 int index = GetLocalFieldIndexFromMap(map); |
| 5980 access_ = HObjectAccess::ForField(map, index, representation(), name_); | 5980 access_ = HObjectAccess::ForField(map, index, representation(), name_); |
| 5981 | 5981 |
| 5982 // Load field map for heap objects. | 5982 // Load field map for heap objects. |
| 5983 LoadFieldMaps(map); | 5983 LoadFieldMaps(map); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6067 | 6067 |
| 6068 bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() { | 6068 bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() { |
| 6069 if (!CanInlinePropertyAccess(type_)) return false; | 6069 if (!CanInlinePropertyAccess(type_)) return false; |
| 6070 if (IsJSObjectFieldAccessor()) return IsLoad(); | 6070 if (IsJSObjectFieldAccessor()) return IsLoad(); |
| 6071 if (this->map()->function_with_prototype() && | 6071 if (this->map()->function_with_prototype() && |
| 6072 !this->map()->has_non_instance_prototype() && | 6072 !this->map()->has_non_instance_prototype() && |
| 6073 name_.is_identical_to(isolate()->factory()->prototype_string())) { | 6073 name_.is_identical_to(isolate()->factory()->prototype_string())) { |
| 6074 return IsLoad(); | 6074 return IsLoad(); |
| 6075 } | 6075 } |
| 6076 if (!LookupDescriptor()) return false; | 6076 if (!LookupDescriptor()) return false; |
| 6077 if (IsFound()) { | 6077 if (IsFound()) return IsLoad() || !IsReadOnly(); |
| 6078 if (IsLoad()) return true; | |
| 6079 return !IsReadOnly() && IsCacheable(); | |
| 6080 } | |
| 6081 if (!LookupInPrototypes()) return false; | 6078 if (!LookupInPrototypes()) return false; |
| 6082 if (IsLoad()) return true; | 6079 if (IsLoad()) return true; |
| 6083 | 6080 |
| 6084 if (IsAccessor()) return true; | 6081 if (IsAccessor()) return true; |
| 6085 Handle<Map> map = this->map(); | 6082 Handle<Map> map = this->map(); |
| 6086 map->LookupTransition(NULL, *name_, &lookup_); | 6083 map->LookupTransition(NULL, *name_, &lookup_); |
| 6087 if (lookup_.IsTransitionToField() && map->unused_property_fields() > 0) { | 6084 if (lookup_.IsTransitionToField() && map->unused_property_fields() > 0) { |
| 6088 // Construct the object field access. | 6085 // Construct the object field access. |
| 6089 int descriptor = transition()->LastAdded(); | 6086 int descriptor = transition()->LastAdded(); |
| 6090 int index = | 6087 int index = |
| (...skipping 6400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12491 if (ShouldProduceTraceOutput()) { | 12488 if (ShouldProduceTraceOutput()) { |
| 12492 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12489 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12493 } | 12490 } |
| 12494 | 12491 |
| 12495 #ifdef DEBUG | 12492 #ifdef DEBUG |
| 12496 graph_->Verify(false); // No full verify. | 12493 graph_->Verify(false); // No full verify. |
| 12497 #endif | 12494 #endif |
| 12498 } | 12495 } |
| 12499 | 12496 |
| 12500 } } // namespace v8::internal | 12497 } } // namespace v8::internal |
| OLD | NEW |