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/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 { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 | 94 |
95 bool LookupIterator::IsBootstrapping() const { | 95 bool LookupIterator::IsBootstrapping() const { |
96 return isolate_->bootstrapper()->IsActive(); | 96 return isolate_->bootstrapper()->IsActive(); |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 bool LookupIterator::HasAccess(v8::AccessType access_type) const { | 100 bool LookupIterator::HasAccess(v8::AccessType access_type) const { |
101 ASSERT_EQ(ACCESS_CHECK, state_); | 101 ASSERT_EQ(ACCESS_CHECK, state_); |
102 ASSERT(is_guaranteed_to_have_holder()); | 102 ASSERT(is_guaranteed_to_have_holder()); |
103 return isolate_->MayNamedAccess(GetHolder(), name_, access_type); | 103 return isolate_->MayNamedAccess(GetNonJSProxyHolder(), name_, access_type); |
104 } | 104 } |
105 | 105 |
106 | 106 |
107 bool LookupIterator::HasProperty() { | 107 bool LookupIterator::HasProperty() { |
108 ASSERT_EQ(PROPERTY, state_); | 108 ASSERT_EQ(PROPERTY, state_); |
109 ASSERT(is_guaranteed_to_have_holder()); | 109 ASSERT(is_guaranteed_to_have_holder()); |
110 | 110 |
111 if (property_encoding_ == DICTIONARY) { | 111 if (property_encoding_ == DICTIONARY) { |
112 Handle<JSObject> holder = GetHolder(); | 112 Handle<JSObject> holder = GetNonJSProxyHolder(); |
113 number_ = holder->property_dictionary()->FindEntry(name_); | 113 number_ = holder->property_dictionary()->FindEntry(name_); |
114 if (number_ == NameDictionary::kNotFound) return false; | 114 if (number_ == NameDictionary::kNotFound) return false; |
115 | 115 |
116 property_details_ = GetHolder()->property_dictionary()->DetailsAt(number_); | 116 property_details_ = holder->property_dictionary()->DetailsAt(number_); |
117 // Holes in dictionary cells are absent values. | 117 // Holes in dictionary cells are absent values. |
118 if (holder->IsGlobalObject() && | 118 if (holder->IsGlobalObject() && |
119 (property_details_.IsDeleted() || FetchValue()->IsTheHole())) { | 119 (property_details_.IsDeleted() || FetchValue()->IsTheHole())) { |
120 return false; | 120 return false; |
121 } | 121 } |
122 } else { | 122 } else { |
123 property_details_ = holder_map_->instance_descriptors()->GetDetails( | 123 property_details_ = holder_map_->instance_descriptors()->GetDetails( |
124 number_); | 124 number_); |
125 } | 125 } |
126 | 126 |
(...skipping 15 matching lines...) Expand all Loading... |
142 has_property_ = true; | 142 has_property_ = true; |
143 return true; | 143 return true; |
144 } | 144 } |
145 | 145 |
146 | 146 |
147 void LookupIterator::PrepareForDataProperty(Handle<Object> value) { | 147 void LookupIterator::PrepareForDataProperty(Handle<Object> value) { |
148 ASSERT(has_property_); | 148 ASSERT(has_property_); |
149 ASSERT(HolderIsReceiver()); | 149 ASSERT(HolderIsReceiver()); |
150 if (property_encoding_ == DICTIONARY) return; | 150 if (property_encoding_ == DICTIONARY) return; |
151 holder_map_ = Map::PrepareForDataProperty(holder_map_, number_, value); | 151 holder_map_ = Map::PrepareForDataProperty(holder_map_, number_, value); |
152 JSObject::MigrateToMap(GetHolder(), holder_map_); | 152 JSObject::MigrateToMap(GetNonJSProxyHolder(), holder_map_); |
153 // Reload property information. | 153 // Reload property information. |
154 if (holder_map_->is_dictionary_map()) { | 154 if (holder_map_->is_dictionary_map()) { |
155 property_encoding_ = DICTIONARY; | 155 property_encoding_ = DICTIONARY; |
156 } else { | 156 } else { |
157 property_encoding_ = DESCRIPTOR; | 157 property_encoding_ = DESCRIPTOR; |
158 } | 158 } |
159 CHECK(HasProperty()); | 159 CHECK(HasProperty()); |
160 } | 160 } |
161 | 161 |
162 | 162 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 if (JSReceiver::cast(iter.GetCurrent()) == holder) return true; | 211 if (JSReceiver::cast(iter.GetCurrent()) == holder) return true; |
212 ASSERT(!current->IsJSProxy()); | 212 ASSERT(!current->IsJSProxy()); |
213 iter.Advance(); | 213 iter.Advance(); |
214 } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)); | 214 } while (!iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)); |
215 return false; | 215 return false; |
216 } | 216 } |
217 | 217 |
218 | 218 |
219 Handle<Object> LookupIterator::FetchValue() const { | 219 Handle<Object> LookupIterator::FetchValue() const { |
220 Object* result = NULL; | 220 Object* result = NULL; |
| 221 Handle<JSObject> holder = GetNonJSProxyHolder(); |
221 switch (property_encoding_) { | 222 switch (property_encoding_) { |
222 case DICTIONARY: | 223 case DICTIONARY: |
223 result = GetHolder()->property_dictionary()->ValueAt(number_); | 224 result = holder->property_dictionary()->ValueAt(number_); |
224 if (GetHolder()->IsGlobalObject()) { | 225 if (holder->IsGlobalObject()) { |
225 result = PropertyCell::cast(result)->value(); | 226 result = PropertyCell::cast(result)->value(); |
226 } | 227 } |
227 break; | 228 break; |
228 case DESCRIPTOR: | 229 case DESCRIPTOR: |
229 if (property_details_.type() == v8::internal::FIELD) { | 230 if (property_details_.type() == v8::internal::FIELD) { |
230 FieldIndex field_index = FieldIndex::ForDescriptor( | 231 FieldIndex field_index = FieldIndex::ForDescriptor( |
231 *holder_map_, number_); | 232 *holder_map_, number_); |
232 return JSObject::FastPropertyAt( | 233 return JSObject::FastPropertyAt( |
233 GetHolder(), property_details_.representation(), field_index); | 234 holder, property_details_.representation(), field_index); |
234 } | 235 } |
235 result = holder_map_->instance_descriptors()->GetValue(number_); | 236 result = holder_map_->instance_descriptors()->GetValue(number_); |
236 } | 237 } |
237 return handle(result, isolate_); | 238 return handle(result, isolate_); |
238 } | 239 } |
239 | 240 |
240 | 241 |
241 Handle<Object> LookupIterator::GetAccessors() const { | 242 Handle<Object> LookupIterator::GetAccessors() const { |
242 ASSERT(has_property_); | 243 ASSERT(has_property_); |
243 ASSERT_EQ(ACCESSOR, property_kind_); | 244 ASSERT_EQ(ACCESSOR, property_kind_); |
244 return FetchValue(); | 245 return FetchValue(); |
245 } | 246 } |
246 | 247 |
247 | 248 |
248 Handle<Object> LookupIterator::GetDataValue() const { | 249 Handle<Object> LookupIterator::GetDataValue() const { |
249 ASSERT(has_property_); | 250 ASSERT(has_property_); |
250 ASSERT_EQ(DATA, property_kind_); | 251 ASSERT_EQ(DATA, property_kind_); |
251 Handle<Object> value = FetchValue(); | 252 Handle<Object> value = FetchValue(); |
252 return value; | 253 return value; |
253 } | 254 } |
254 | 255 |
255 | 256 |
256 void LookupIterator::WriteDataValue(Handle<Object> value) { | 257 void LookupIterator::WriteDataValue(Handle<Object> value) { |
257 ASSERT(is_guaranteed_to_have_holder()); | 258 ASSERT(is_guaranteed_to_have_holder()); |
258 ASSERT(has_property_); | 259 ASSERT(has_property_); |
| 260 Handle<JSObject> holder = GetNonJSProxyHolder(); |
259 if (property_encoding_ == DICTIONARY) { | 261 if (property_encoding_ == DICTIONARY) { |
260 Handle<JSObject> holder = GetHolder(); | |
261 NameDictionary* property_dictionary = holder->property_dictionary(); | 262 NameDictionary* property_dictionary = holder->property_dictionary(); |
262 if (holder->IsGlobalObject()) { | 263 if (holder->IsGlobalObject()) { |
263 Handle<PropertyCell> cell( | 264 Handle<PropertyCell> cell( |
264 PropertyCell::cast(property_dictionary->ValueAt(number_))); | 265 PropertyCell::cast(property_dictionary->ValueAt(number_))); |
265 PropertyCell::SetValueInferType(cell, value); | 266 PropertyCell::SetValueInferType(cell, value); |
266 } else { | 267 } else { |
267 property_dictionary->ValueAtPut(number_, *value); | 268 property_dictionary->ValueAtPut(number_, *value); |
268 } | 269 } |
269 } else if (property_details_.type() == v8::internal::FIELD) { | 270 } else if (property_details_.type() == v8::internal::FIELD) { |
270 GetHolder()->WriteToField(number_, *value); | 271 holder->WriteToField(number_, *value); |
271 } else { | 272 } else { |
272 ASSERT_EQ(v8::internal::CONSTANT, property_details_.type()); | 273 ASSERT_EQ(v8::internal::CONSTANT, property_details_.type()); |
273 } | 274 } |
274 } | 275 } |
275 | 276 |
276 | 277 |
277 void LookupIterator::InternalizeName() { | 278 void LookupIterator::InternalizeName() { |
278 if (name_->IsUniqueName()) return; | 279 if (name_->IsUniqueName()) return; |
279 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); | 280 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); |
280 } | 281 } |
281 } } // namespace v8::internal | 282 } } // namespace v8::internal |
OLD | NEW |