OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/lookup.h" | 5 #include "src/lookup.h" |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
9 #include "src/elements.h" | 9 #include "src/elements.h" |
10 #include "src/field-type.h" | 10 #include "src/field-type.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 return LookupIterator(receiver, name, configuration); | 45 return LookupIterator(receiver, name, configuration); |
46 } | 46 } |
47 | 47 |
48 template <bool is_element> | 48 template <bool is_element> |
49 void LookupIterator::Start() { | 49 void LookupIterator::Start() { |
50 DisallowHeapAllocation no_gc; | 50 DisallowHeapAllocation no_gc; |
51 | 51 |
52 has_property_ = false; | 52 has_property_ = false; |
53 state_ = NOT_FOUND; | 53 state_ = NOT_FOUND; |
54 number_ = DescriptorArray::kNotFound; | |
55 holder_ = initial_holder_; | 54 holder_ = initial_holder_; |
56 | 55 |
57 JSReceiver* holder = *holder_; | 56 JSReceiver* holder = *holder_; |
58 Map* map = holder->map(); | 57 Map* map = holder->map(); |
59 | 58 |
60 state_ = LookupInHolder<is_element>(map, holder); | 59 state_ = LookupInHolder<is_element>(map, holder); |
61 if (IsFound()) return; | 60 if (IsFound()) return; |
62 | 61 |
63 NextInternal<is_element>(map, holder); | 62 NextInternal<is_element>(map, holder); |
64 } | 63 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 state_ = LookupInHolder<is_element>(map, holder); | 102 state_ = LookupInHolder<is_element>(map, holder); |
104 } while (!IsFound()); | 103 } while (!IsFound()); |
105 | 104 |
106 holder_ = handle(holder, isolate_); | 105 holder_ = handle(holder, isolate_); |
107 } | 106 } |
108 | 107 |
109 template <bool is_element> | 108 template <bool is_element> |
110 void LookupIterator::RestartInternal(InterceptorState interceptor_state) { | 109 void LookupIterator::RestartInternal(InterceptorState interceptor_state) { |
111 interceptor_state_ = interceptor_state; | 110 interceptor_state_ = interceptor_state; |
112 property_details_ = PropertyDetails::Empty(); | 111 property_details_ = PropertyDetails::Empty(); |
| 112 number_ = DescriptorArray::kNotFound; |
113 Start<is_element>(); | 113 Start<is_element>(); |
114 } | 114 } |
115 | 115 |
116 template void LookupIterator::RestartInternal<true>(InterceptorState); | 116 template void LookupIterator::RestartInternal<true>(InterceptorState); |
117 template void LookupIterator::RestartInternal<false>(InterceptorState); | 117 template void LookupIterator::RestartInternal<false>(InterceptorState); |
118 | 118 |
119 // static | 119 // static |
120 Handle<JSReceiver> LookupIterator::GetRootForNonJSReceiver( | 120 Handle<JSReceiver> LookupIterator::GetRootForNonJSReceiver( |
121 Isolate* isolate, Handle<Object> receiver, uint32_t index) { | 121 Isolate* isolate, Handle<Object> receiver, uint32_t index) { |
122 // Strings are the only objects with properties (only elements) directly on | 122 // Strings are the only objects with properties (only elements) directly on |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 Handle<GlobalDictionary> property_dictionary = | 610 Handle<GlobalDictionary> property_dictionary = |
611 handle(JSObject::cast(*holder)->global_dictionary()); | 611 handle(JSObject::cast(*holder)->global_dictionary()); |
612 PropertyCell::UpdateCell(property_dictionary, dictionary_entry(), value, | 612 PropertyCell::UpdateCell(property_dictionary, dictionary_entry(), value, |
613 property_details_); | 613 property_details_); |
614 } else { | 614 } else { |
615 NameDictionary* property_dictionary = holder->property_dictionary(); | 615 NameDictionary* property_dictionary = holder->property_dictionary(); |
616 property_dictionary->ValueAtPut(dictionary_entry(), *value); | 616 property_dictionary->ValueAtPut(dictionary_entry(), *value); |
617 } | 617 } |
618 } | 618 } |
619 | 619 |
620 | 620 template <bool is_element> |
621 bool LookupIterator::SkipInterceptor(JSObject* holder) { | 621 bool LookupIterator::SkipInterceptor(JSObject* holder) { |
622 auto info = GetInterceptor(holder); | 622 auto info = GetInterceptor<is_element>(holder); |
623 // TODO(dcarney): check for symbol/can_intercept_symbols here as well. | 623 // TODO(dcarney): check for symbol/can_intercept_symbols here as well. |
624 if (info->non_masking()) { | 624 if (info->non_masking()) { |
625 switch (interceptor_state_) { | 625 switch (interceptor_state_) { |
626 case InterceptorState::kUninitialized: | 626 case InterceptorState::kUninitialized: |
627 interceptor_state_ = InterceptorState::kSkipNonMasking; | 627 interceptor_state_ = InterceptorState::kSkipNonMasking; |
628 // Fall through. | 628 // Fall through. |
629 case InterceptorState::kSkipNonMasking: | 629 case InterceptorState::kSkipNonMasking: |
630 return true; | 630 return true; |
631 case InterceptorState::kProcessNonMasking: | 631 case InterceptorState::kProcessNonMasking: |
632 return false; | 632 return false; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 case NOT_FOUND: | 682 case NOT_FOUND: |
683 if (map->IsJSProxyMap()) { | 683 if (map->IsJSProxyMap()) { |
684 if (is_element || !name_->IsPrivate()) return JSPROXY; | 684 if (is_element || !name_->IsPrivate()) return JSPROXY; |
685 } | 685 } |
686 if (map->is_access_check_needed()) { | 686 if (map->is_access_check_needed()) { |
687 if (is_element || !name_->IsPrivate()) return ACCESS_CHECK; | 687 if (is_element || !name_->IsPrivate()) return ACCESS_CHECK; |
688 } | 688 } |
689 // Fall through. | 689 // Fall through. |
690 case ACCESS_CHECK: | 690 case ACCESS_CHECK: |
691 if (check_interceptor() && HasInterceptor<is_element>(map) && | 691 if (check_interceptor() && HasInterceptor<is_element>(map) && |
692 !SkipInterceptor(JSObject::cast(holder))) { | 692 !SkipInterceptor<is_element>(JSObject::cast(holder))) { |
693 if (is_element || !name_->IsPrivate()) return INTERCEPTOR; | 693 if (is_element || !name_->IsPrivate()) return INTERCEPTOR; |
694 } | 694 } |
695 // Fall through. | 695 // Fall through. |
696 case INTERCEPTOR: | 696 case INTERCEPTOR: |
697 if (!is_element && map->IsJSGlobalObjectMap()) { | 697 if (!is_element && map->IsJSGlobalObjectMap()) { |
698 GlobalDictionary* dict = JSObject::cast(holder)->global_dictionary(); | 698 GlobalDictionary* dict = JSObject::cast(holder)->global_dictionary(); |
699 int number = dict->FindEntry(name_); | 699 int number = dict->FindEntry(name_); |
700 if (number == GlobalDictionary::kNotFound) return NOT_FOUND; | 700 if (number == GlobalDictionary::kNotFound) return NOT_FOUND; |
701 number_ = static_cast<uint32_t>(number); | 701 number_ = static_cast<uint32_t>(number); |
702 DCHECK(dict->ValueAt(number_)->IsPropertyCell()); | 702 DCHECK(dict->ValueAt(number_)->IsPropertyCell()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 case v8::internal::kAccessor: | 761 case v8::internal::kAccessor: |
762 return ACCESSOR; | 762 return ACCESSOR; |
763 } | 763 } |
764 | 764 |
765 UNREACHABLE(); | 765 UNREACHABLE(); |
766 return state_; | 766 return state_; |
767 } | 767 } |
768 | 768 |
769 } // namespace internal | 769 } // namespace internal |
770 } // namespace v8 | 770 } // namespace v8 |
OLD | NEW |