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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
(...skipping 6541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6552 bool HOptimizedGraphBuilder::PropertyAccessInfo::IsIntegerIndexedExotic() { | 6552 bool HOptimizedGraphBuilder::PropertyAccessInfo::IsIntegerIndexedExotic() { |
6553 InstanceType instance_type = map_->instance_type(); | 6553 InstanceType instance_type = map_->instance_type(); |
6554 return instance_type == JS_TYPED_ARRAY_TYPE && name_->IsString() && | 6554 return instance_type == JS_TYPED_ARRAY_TYPE && name_->IsString() && |
6555 IsSpecialIndex(isolate()->unicode_cache(), String::cast(*name_)); | 6555 IsSpecialIndex(isolate()->unicode_cache(), String::cast(*name_)); |
6556 } | 6556 } |
6557 | 6557 |
6558 | 6558 |
6559 bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() { | 6559 bool HOptimizedGraphBuilder::PropertyAccessInfo::CanAccessMonomorphic() { |
6560 if (!CanInlinePropertyAccess(map_)) return false; | 6560 if (!CanInlinePropertyAccess(map_)) return false; |
6561 if (IsJSObjectFieldAccessor()) return IsLoad(); | 6561 if (IsJSObjectFieldAccessor()) return IsLoad(); |
6562 if (IsJSArrayBufferViewFieldAccessor()) return IsLoad(); | |
6563 if (map_->IsJSFunctionMap() && map_->is_constructor() && | 6562 if (map_->IsJSFunctionMap() && map_->is_constructor() && |
6564 !map_->has_non_instance_prototype() && | 6563 !map_->has_non_instance_prototype() && |
6565 name_.is_identical_to(isolate()->factory()->prototype_string())) { | 6564 name_.is_identical_to(isolate()->factory()->prototype_string())) { |
6566 return IsLoad(); | 6565 return IsLoad(); |
6567 } | 6566 } |
6568 if (!LookupDescriptor()) return false; | 6567 if (!LookupDescriptor()) return false; |
6569 if (IsFound()) return IsLoad() || !IsReadOnly(); | 6568 if (IsFound()) return IsLoad() || !IsReadOnly(); |
6570 if (IsIntegerIndexedExotic()) return false; | 6569 if (IsIntegerIndexedExotic()) return false; |
6571 if (!LookupInPrototypes()) return false; | 6570 if (!LookupInPrototypes()) return false; |
6572 if (IsLoad()) return true; | 6571 if (IsLoad()) return true; |
(...skipping 27 matching lines...) Expand all Loading... |
6600 HObjectAccess access = HObjectAccess::ForMap(); // bogus default | 6599 HObjectAccess access = HObjectAccess::ForMap(); // bogus default |
6601 if (GetJSObjectFieldAccess(&access)) { | 6600 if (GetJSObjectFieldAccess(&access)) { |
6602 for (int i = 1; i < maps->length(); ++i) { | 6601 for (int i = 1; i < maps->length(); ++i) { |
6603 PropertyAccessInfo test_info(builder_, access_type_, maps->at(i), name_); | 6602 PropertyAccessInfo test_info(builder_, access_type_, maps->at(i), name_); |
6604 HObjectAccess test_access = HObjectAccess::ForMap(); // bogus default | 6603 HObjectAccess test_access = HObjectAccess::ForMap(); // bogus default |
6605 if (!test_info.GetJSObjectFieldAccess(&test_access)) return false; | 6604 if (!test_info.GetJSObjectFieldAccess(&test_access)) return false; |
6606 if (!access.Equals(test_access)) return false; | 6605 if (!access.Equals(test_access)) return false; |
6607 } | 6606 } |
6608 return true; | 6607 return true; |
6609 } | 6608 } |
6610 if (GetJSArrayBufferViewFieldAccess(&access)) { | |
6611 for (int i = 1; i < maps->length(); ++i) { | |
6612 PropertyAccessInfo test_info(builder_, access_type_, maps->at(i), name_); | |
6613 HObjectAccess test_access = HObjectAccess::ForMap(); // bogus default | |
6614 if (!test_info.GetJSArrayBufferViewFieldAccess(&test_access)) { | |
6615 return false; | |
6616 } | |
6617 if (!access.Equals(test_access)) return false; | |
6618 } | |
6619 return true; | |
6620 } | |
6621 | 6609 |
6622 // Currently only handle numbers as a polymorphic case. | 6610 // Currently only handle numbers as a polymorphic case. |
6623 // TODO(verwaest): Support monomorphic handling of numbers with a HCheckNumber | 6611 // TODO(verwaest): Support monomorphic handling of numbers with a HCheckNumber |
6624 // instruction. | 6612 // instruction. |
6625 if (IsNumberType()) return false; | 6613 if (IsNumberType()) return false; |
6626 | 6614 |
6627 // Multiple maps cannot transition to the same target map. | 6615 // Multiple maps cannot transition to the same target map. |
6628 DCHECK(!IsLoad() || !IsTransition()); | 6616 DCHECK(!IsLoad() || !IsTransition()); |
6629 if (IsTransition() && maps->length() > 1) return false; | 6617 if (IsTransition() && maps->length() > 1) return false; |
6630 | 6618 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6664 HValue* HOptimizedGraphBuilder::BuildMonomorphicAccess( | 6652 HValue* HOptimizedGraphBuilder::BuildMonomorphicAccess( |
6665 PropertyAccessInfo* info, HValue* object, HValue* checked_object, | 6653 PropertyAccessInfo* info, HValue* object, HValue* checked_object, |
6666 HValue* value, BailoutId ast_id, BailoutId return_id, | 6654 HValue* value, BailoutId ast_id, BailoutId return_id, |
6667 bool can_inline_accessor) { | 6655 bool can_inline_accessor) { |
6668 HObjectAccess access = HObjectAccess::ForMap(); // bogus default | 6656 HObjectAccess access = HObjectAccess::ForMap(); // bogus default |
6669 if (info->GetJSObjectFieldAccess(&access)) { | 6657 if (info->GetJSObjectFieldAccess(&access)) { |
6670 DCHECK(info->IsLoad()); | 6658 DCHECK(info->IsLoad()); |
6671 return New<HLoadNamedField>(object, checked_object, access); | 6659 return New<HLoadNamedField>(object, checked_object, access); |
6672 } | 6660 } |
6673 | 6661 |
6674 if (info->GetJSArrayBufferViewFieldAccess(&access)) { | |
6675 DCHECK(info->IsLoad()); | |
6676 checked_object = Add<HCheckArrayBufferNotNeutered>(checked_object); | |
6677 return New<HLoadNamedField>(object, checked_object, access); | |
6678 } | |
6679 | |
6680 if (info->name().is_identical_to(isolate()->factory()->prototype_string()) && | 6662 if (info->name().is_identical_to(isolate()->factory()->prototype_string()) && |
6681 info->map()->IsJSFunctionMap() && info->map()->is_constructor()) { | 6663 info->map()->IsJSFunctionMap() && info->map()->is_constructor()) { |
6682 DCHECK(!info->map()->has_non_instance_prototype()); | 6664 DCHECK(!info->map()->has_non_instance_prototype()); |
6683 return New<HLoadFunctionPrototype>(checked_object); | 6665 return New<HLoadFunctionPrototype>(checked_object); |
6684 } | 6666 } |
6685 | 6667 |
6686 HValue* checked_holder = checked_object; | 6668 HValue* checked_holder = checked_object; |
6687 if (info->has_holder()) { | 6669 if (info->has_holder()) { |
6688 Handle<JSObject> prototype(JSObject::cast(info->map()->prototype())); | 6670 Handle<JSObject> prototype(JSObject::cast(info->map()->prototype())); |
6689 checked_holder = BuildCheckPrototypeMaps(prototype, info->holder()); | 6671 checked_holder = BuildCheckPrototypeMaps(prototype, info->holder()); |
(...skipping 7053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13743 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13725 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13744 } | 13726 } |
13745 | 13727 |
13746 #ifdef DEBUG | 13728 #ifdef DEBUG |
13747 graph_->Verify(false); // No full verify. | 13729 graph_->Verify(false); // No full verify. |
13748 #endif | 13730 #endif |
13749 } | 13731 } |
13750 | 13732 |
13751 } // namespace internal | 13733 } // namespace internal |
13752 } // namespace v8 | 13734 } // namespace v8 |
OLD | NEW |