| 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 20 matching lines...) Expand all Loading... |
| 31 if (!*success) { | 31 if (!*success) { |
| 32 DCHECK(isolate->has_pending_exception()); | 32 DCHECK(isolate->has_pending_exception()); |
| 33 // Return an unusable dummy. | 33 // Return an unusable dummy. |
| 34 return LookupIterator(receiver, isolate->factory()->empty_string()); | 34 return LookupIterator(receiver, isolate->factory()->empty_string()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 if (name->AsArrayIndex(&index)) { | 37 if (name->AsArrayIndex(&index)) { |
| 38 LookupIterator it(isolate, receiver, index, configuration); | 38 LookupIterator it(isolate, receiver, index, configuration); |
| 39 // Here we try to avoid having to rebuild the string later | 39 // Here we try to avoid having to rebuild the string later |
| 40 // by storing it on the indexed LookupIterator. | 40 // by storing it on the indexed LookupIterator. |
| 41 it.name_ = name; | 41 it.name_ = isolate->factory()->InternalizeName(name); |
| 42 return it; | 42 return it; |
| 43 } | 43 } |
| 44 | 44 |
| 45 return LookupIterator(receiver, name, configuration); | 45 return LookupIterator(receiver, name, configuration); |
| 46 } | 46 } |
| 47 | 47 |
| 48 | 48 |
| 49 void LookupIterator::Next() { | 49 void LookupIterator::Next() { |
| 50 DCHECK_NE(JSPROXY, state_); | 50 DCHECK_NE(JSPROXY, state_); |
| 51 DCHECK_NE(TRANSITION, state_); | 51 DCHECK_NE(TRANSITION, state_); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 DCHECK_NE(INTEGER_INDEXED_EXOTIC, state_); | 232 DCHECK_NE(INTEGER_INDEXED_EXOTIC, state_); |
| 233 DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype()); | 233 DCHECK(state_ == NOT_FOUND || !HolderIsReceiverOrHiddenPrototype()); |
| 234 | 234 |
| 235 Handle<Map> map(receiver->map(), isolate_); | 235 Handle<Map> map(receiver->map(), isolate_); |
| 236 | 236 |
| 237 // Dictionary maps can always have additional data properties. | 237 // Dictionary maps can always have additional data properties. |
| 238 if (map->is_dictionary_map()) { | 238 if (map->is_dictionary_map()) { |
| 239 state_ = TRANSITION; | 239 state_ = TRANSITION; |
| 240 if (map->IsJSGlobalObjectMap()) { | 240 if (map->IsJSGlobalObjectMap()) { |
| 241 // Install a property cell. | 241 // Install a property cell. |
| 242 InternalizeName(); | |
| 243 auto cell = JSGlobalObject::EnsurePropertyCell( | 242 auto cell = JSGlobalObject::EnsurePropertyCell( |
| 244 Handle<JSGlobalObject>::cast(receiver), name()); | 243 Handle<JSGlobalObject>::cast(receiver), name()); |
| 245 DCHECK(cell->value()->IsTheHole()); | 244 DCHECK(cell->value()->IsTheHole()); |
| 246 transition_ = cell; | 245 transition_ = cell; |
| 247 } else { | 246 } else { |
| 248 transition_ = map; | 247 transition_ = map; |
| 249 } | 248 } |
| 250 return; | 249 return; |
| 251 } | 250 } |
| 252 | 251 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 NameDictionary* property_dictionary = holder->property_dictionary(); | 526 NameDictionary* property_dictionary = holder->property_dictionary(); |
| 528 property_dictionary->ValueAtPut(dictionary_entry(), *value); | 527 property_dictionary->ValueAtPut(dictionary_entry(), *value); |
| 529 } else if (property_details_.type() == v8::internal::DATA) { | 528 } else if (property_details_.type() == v8::internal::DATA) { |
| 530 JSObject::cast(*holder)->WriteToField(descriptor_number(), *value); | 529 JSObject::cast(*holder)->WriteToField(descriptor_number(), *value); |
| 531 } else { | 530 } else { |
| 532 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); | 531 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); |
| 533 } | 532 } |
| 534 } | 533 } |
| 535 | 534 |
| 536 | 535 |
| 537 void LookupIterator::InternalizeName() { | |
| 538 if (name_->IsUniqueName()) return; | |
| 539 name_ = factory()->InternalizeString(Handle<String>::cast(name_)); | |
| 540 } | |
| 541 | |
| 542 | |
| 543 bool LookupIterator::HasInterceptor(Map* map) const { | 536 bool LookupIterator::HasInterceptor(Map* map) const { |
| 544 if (IsElement()) return map->has_indexed_interceptor(); | 537 if (IsElement()) return map->has_indexed_interceptor(); |
| 545 return map->has_named_interceptor(); | 538 return map->has_named_interceptor(); |
| 546 } | 539 } |
| 547 | 540 |
| 548 | 541 |
| 549 bool LookupIterator::SkipInterceptor(JSObject* holder) { | 542 bool LookupIterator::SkipInterceptor(JSObject* holder) { |
| 550 auto info = GetInterceptor(holder); | 543 auto info = GetInterceptor(holder); |
| 551 // TODO(dcarney): check for symbol/can_intercept_symbols here as well. | 544 // TODO(dcarney): check for symbol/can_intercept_symbols here as well. |
| 552 if (info->non_masking()) { | 545 if (info->non_masking()) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // Fall through. | 674 // Fall through. |
| 682 default: | 675 default: |
| 683 return NOT_FOUND; | 676 return NOT_FOUND; |
| 684 } | 677 } |
| 685 UNREACHABLE(); | 678 UNREACHABLE(); |
| 686 return state_; | 679 return state_; |
| 687 } | 680 } |
| 688 | 681 |
| 689 } // namespace internal | 682 } // namespace internal |
| 690 } // namespace v8 | 683 } // namespace v8 |
| OLD | NEW |