Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1239)

Side by Side Diff: src/lookup.cc

Issue 324383005: Rossberg's suggested changes to the LookupIterator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed ishell's extra comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/lookup.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/lookup.h" 8 #include "src/lookup.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 13
14 void LookupIterator::Next() { 14 void LookupIterator::Next() {
15 has_property_ = false; 15 has_property_ = false;
16 do { 16 do {
17 LookupInHolder(); 17 state_ = LookupInHolder();
18 } while (!IsFound() && NextHolder()); 18 } while (!IsFound() && NextHolder());
19 } 19 }
20 20
21 21
22 Handle<JSReceiver> LookupIterator::GetOrigin() const { 22 Handle<JSReceiver> LookupIterator::GetRoot() const {
23 Handle<Object> receiver = GetReceiver(); 23 Handle<Object> receiver = GetReceiver();
24 if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver); 24 if (receiver->IsJSReceiver()) return Handle<JSReceiver>::cast(receiver);
25 Context* native_context = isolate_->context()->native_context(); 25 Context* native_context = isolate_->context()->native_context();
26 JSFunction* function; 26 JSFunction* function;
27 if (receiver->IsNumber()) { 27 if (receiver->IsNumber()) {
28 function = native_context->number_function(); 28 function = native_context->number_function();
29 } else if (receiver->IsString()) { 29 } else if (receiver->IsString()) {
30 function = native_context->string_function(); 30 function = native_context->string_function();
31 } else if (receiver->IsSymbol()) { 31 } else if (receiver->IsSymbol()) {
32 function = native_context->symbol_function(); 32 function = native_context->symbol_function();
(...skipping 27 matching lines...) Expand all
60 !next->map()->is_hidden_prototype()) { 60 !next->map()->is_hidden_prototype()) {
61 return false; 61 return false;
62 } 62 }
63 63
64 holder_map_ = handle(next->map()); 64 holder_map_ = handle(next->map());
65 maybe_holder_ = next; 65 maybe_holder_ = next;
66 return true; 66 return true;
67 } 67 }
68 68
69 69
70 void LookupIterator::LookupInHolder() { 70 LookupIterator::State LookupIterator::LookupInHolder() {
71 State old_state = state_; 71 switch (state_) {
72 state_ = NOT_FOUND;
73 switch (old_state) {
74 case NOT_FOUND: 72 case NOT_FOUND:
75 if (holder_map_->IsJSProxyMap()) { 73 if (holder_map_->IsJSProxyMap()) {
76 state_ = JSPROXY; 74 return JSPROXY;
77 return;
78 } 75 }
79 if (check_access_check() && holder_map_->is_access_check_needed()) { 76 if (check_access_check() && holder_map_->is_access_check_needed()) {
80 state_ = ACCESS_CHECK; 77 return ACCESS_CHECK;
81 return;
82 } 78 }
79 // Fall through.
83 case ACCESS_CHECK: 80 case ACCESS_CHECK:
84 if (check_interceptor() && holder_map_->has_named_interceptor()) { 81 if (check_interceptor() && holder_map_->has_named_interceptor()) {
85 state_ = INTERCEPTOR; 82 return INTERCEPTOR;
86 return;
87 } 83 }
84 // Fall through.
88 case INTERCEPTOR: 85 case INTERCEPTOR:
89 if (holder_map_->is_dictionary_map()) { 86 if (holder_map_->is_dictionary_map()) {
90 property_encoding_ = DICTIONARY; 87 property_encoding_ = DICTIONARY;
91 } else { 88 } else {
92 DescriptorArray* descriptors = holder_map_->instance_descriptors(); 89 DescriptorArray* descriptors = holder_map_->instance_descriptors();
93 number_ = descriptors->SearchWithCache(*name_, *holder_map_); 90 number_ = descriptors->SearchWithCache(*name_, *holder_map_);
94 if (number_ == DescriptorArray::kNotFound) return; 91 if (number_ == DescriptorArray::kNotFound) return NOT_FOUND;
95 property_encoding_ = DESCRIPTOR; 92 property_encoding_ = DESCRIPTOR;
96 } 93 }
97 state_ = PROPERTY; 94 return PROPERTY;
98 case PROPERTY: 95 case PROPERTY:
99 return; 96 return NOT_FOUND;
100 case JSPROXY: 97 case JSPROXY:
101 UNREACHABLE(); 98 UNREACHABLE();
102 } 99 }
100 UNREACHABLE();
101 return state_;
103 } 102 }
104 103
105 104
106 bool LookupIterator::IsBootstrapping() const { 105 bool LookupIterator::IsBootstrapping() const {
107 return isolate_->bootstrapper()->IsActive(); 106 return isolate_->bootstrapper()->IsActive();
108 } 107 }
109 108
110 109
111 bool LookupIterator::HasAccess(v8::AccessType access_type) const { 110 bool LookupIterator::HasAccess(v8::AccessType access_type) const {
112 ASSERT_EQ(ACCESS_CHECK, state_); 111 ASSERT_EQ(ACCESS_CHECK, state_);
(...skipping 20 matching lines...) Expand all
133 } 132 }
134 } else { 133 } else {
135 property_details_ = holder_map_->instance_descriptors()->GetDetails( 134 property_details_ = holder_map_->instance_descriptors()->GetDetails(
136 number_); 135 number_);
137 } 136 }
138 137
139 switch (property_details_.type()) { 138 switch (property_details_.type()) {
140 case v8::internal::FIELD: 139 case v8::internal::FIELD:
141 case v8::internal::NORMAL: 140 case v8::internal::NORMAL:
142 case v8::internal::CONSTANT: 141 case v8::internal::CONSTANT:
143 property_type_ = DATA; 142 property_kind_ = DATA;
144 break; 143 break;
145 case v8::internal::CALLBACKS: 144 case v8::internal::CALLBACKS:
146 property_type_ = ACCESSORS; 145 property_kind_ = ACCESSOR;
147 break; 146 break;
148 case v8::internal::HANDLER: 147 case v8::internal::HANDLER:
149 case v8::internal::NONEXISTENT: 148 case v8::internal::NONEXISTENT:
150 case v8::internal::INTERCEPTOR: 149 case v8::internal::INTERCEPTOR:
151 UNREACHABLE(); 150 UNREACHABLE();
152 } 151 }
153 152
154 has_property_ = true; 153 has_property_ = true;
155 return true; 154 return true;
156 } 155 }
(...skipping 16 matching lines...) Expand all
173 GetHolder(), property_details_.representation(), field_index); 172 GetHolder(), property_details_.representation(), field_index);
174 } 173 }
175 result = holder_map_->instance_descriptors()->GetValue(number_); 174 result = holder_map_->instance_descriptors()->GetValue(number_);
176 } 175 }
177 return handle(result, isolate_); 176 return handle(result, isolate_);
178 } 177 }
179 178
180 179
181 Handle<Object> LookupIterator::GetAccessors() const { 180 Handle<Object> LookupIterator::GetAccessors() const {
182 ASSERT(has_property_); 181 ASSERT(has_property_);
183 ASSERT_EQ(ACCESSORS, property_type_); 182 ASSERT_EQ(ACCESSOR, property_kind_);
184 return FetchValue(); 183 return FetchValue();
185 } 184 }
186 185
187 186
188 Handle<Object> LookupIterator::GetDataValue() const { 187 Handle<Object> LookupIterator::GetDataValue() const {
189 ASSERT(has_property_); 188 ASSERT(has_property_);
190 ASSERT_EQ(DATA, property_type_); 189 ASSERT_EQ(DATA, property_kind_);
191 Handle<Object> value = FetchValue(); 190 Handle<Object> value = FetchValue();
192 if (value->IsTheHole()) { 191 if (value->IsTheHole()) {
193 ASSERT_EQ(DICTIONARY, property_encoding_); 192 ASSERT_EQ(DICTIONARY, property_encoding_);
194 ASSERT(GetHolder()->IsGlobalObject()); 193 ASSERT(GetHolder()->IsGlobalObject());
195 ASSERT(property_details_.IsReadOnly()); 194 ASSERT(property_details_.IsReadOnly());
196 return factory()->undefined_value(); 195 return factory()->undefined_value();
197 } 196 }
198 return value; 197 return value;
199 } 198 }
200 199
201 200
202 } } // namespace v8::internal 201 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lookup.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698