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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 Handle<JSObject> holder = GetHolder<JSObject>(); | 586 Handle<JSObject> holder = GetHolder<JSObject>(); |
587 ElementsAccessor* accessor = holder->GetElementsAccessor(); | 587 ElementsAccessor* accessor = holder->GetElementsAccessor(); |
588 return accessor->Get(holder, number_); | 588 return accessor->Get(holder, number_); |
589 } else if (holder_->IsJSGlobalObject()) { | 589 } else if (holder_->IsJSGlobalObject()) { |
590 Handle<JSObject> holder = GetHolder<JSObject>(); | 590 Handle<JSObject> holder = GetHolder<JSObject>(); |
591 result = holder->global_dictionary()->ValueAt(number_); | 591 result = holder->global_dictionary()->ValueAt(number_); |
592 DCHECK(result->IsPropertyCell()); | 592 DCHECK(result->IsPropertyCell()); |
593 result = PropertyCell::cast(result)->value(); | 593 result = PropertyCell::cast(result)->value(); |
594 } else if (!holder_->HasFastProperties()) { | 594 } else if (!holder_->HasFastProperties()) { |
595 result = holder_->property_dictionary()->ValueAt(number_); | 595 result = holder_->property_dictionary()->ValueAt(number_); |
596 } else if (property_details_.type() == v8::internal::DATA) { | 596 } else if (property_details_.location() == kField) { |
| 597 DCHECK_EQ(kData, property_details_.kind()); |
597 Handle<JSObject> holder = GetHolder<JSObject>(); | 598 Handle<JSObject> holder = GetHolder<JSObject>(); |
598 FieldIndex field_index = FieldIndex::ForDescriptor(holder->map(), number_); | 599 FieldIndex field_index = FieldIndex::ForDescriptor(holder->map(), number_); |
599 return JSObject::FastPropertyAt(holder, property_details_.representation(), | 600 return JSObject::FastPropertyAt(holder, property_details_.representation(), |
600 field_index); | 601 field_index); |
601 } else { | 602 } else { |
602 result = holder_->map()->instance_descriptors()->GetValue(number_); | 603 result = holder_->map()->instance_descriptors()->GetValue(number_); |
603 } | 604 } |
604 return handle(result, isolate_); | 605 return handle(result, isolate_); |
605 } | 606 } |
606 | 607 |
607 int LookupIterator::GetFieldDescriptorIndex() const { | 608 int LookupIterator::GetFieldDescriptorIndex() const { |
608 DCHECK(has_property_); | 609 DCHECK(has_property_); |
609 DCHECK(holder_->HasFastProperties()); | 610 DCHECK(holder_->HasFastProperties()); |
610 DCHECK_EQ(v8::internal::DATA, property_details_.type()); | 611 DCHECK_EQ(kField, property_details_.location()); |
| 612 DCHECK_EQ(kData, property_details_.kind()); |
611 return descriptor_number(); | 613 return descriptor_number(); |
612 } | 614 } |
613 | 615 |
614 int LookupIterator::GetAccessorIndex() const { | 616 int LookupIterator::GetAccessorIndex() const { |
615 DCHECK(has_property_); | 617 DCHECK(has_property_); |
616 DCHECK(holder_->HasFastProperties()); | 618 DCHECK(holder_->HasFastProperties()); |
617 DCHECK_EQ(v8::internal::ACCESSOR_CONSTANT, property_details_.type()); | 619 DCHECK_EQ(kDescriptor, property_details_.location()); |
| 620 DCHECK_EQ(kAccessor, property_details_.kind()); |
618 return descriptor_number(); | 621 return descriptor_number(); |
619 } | 622 } |
620 | 623 |
621 | 624 |
622 int LookupIterator::GetConstantIndex() const { | 625 int LookupIterator::GetConstantIndex() const { |
623 DCHECK(has_property_); | 626 DCHECK(has_property_); |
624 DCHECK(holder_->HasFastProperties()); | 627 DCHECK(holder_->HasFastProperties()); |
625 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); | 628 DCHECK_EQ(kDescriptor, property_details_.location()); |
| 629 DCHECK_EQ(kData, property_details_.kind()); |
626 DCHECK(!IsElement()); | 630 DCHECK(!IsElement()); |
627 return descriptor_number(); | 631 return descriptor_number(); |
628 } | 632 } |
629 | 633 |
630 | 634 |
631 FieldIndex LookupIterator::GetFieldIndex() const { | 635 FieldIndex LookupIterator::GetFieldIndex() const { |
632 DCHECK(has_property_); | 636 DCHECK(has_property_); |
633 DCHECK(holder_->HasFastProperties()); | 637 DCHECK(holder_->HasFastProperties()); |
634 DCHECK_EQ(v8::internal::DATA, property_details_.type()); | 638 DCHECK_EQ(kField, property_details_.location()); |
635 DCHECK(!IsElement()); | 639 DCHECK(!IsElement()); |
636 Map* holder_map = holder_->map(); | 640 Map* holder_map = holder_->map(); |
637 int index = | 641 int index = |
638 holder_map->instance_descriptors()->GetFieldIndex(descriptor_number()); | 642 holder_map->instance_descriptors()->GetFieldIndex(descriptor_number()); |
639 bool is_double = representation().IsDouble(); | 643 bool is_double = representation().IsDouble(); |
640 return FieldIndex::ForPropertyIndex(holder_map, index, is_double); | 644 return FieldIndex::ForPropertyIndex(holder_map, index, is_double); |
641 } | 645 } |
642 | 646 |
643 Handle<FieldType> LookupIterator::GetFieldType() const { | 647 Handle<FieldType> LookupIterator::GetFieldType() const { |
644 DCHECK(has_property_); | 648 DCHECK(has_property_); |
645 DCHECK(holder_->HasFastProperties()); | 649 DCHECK(holder_->HasFastProperties()); |
646 DCHECK_EQ(v8::internal::DATA, property_details_.type()); | 650 DCHECK_EQ(kField, property_details_.location()); |
647 return handle( | 651 return handle( |
648 holder_->map()->instance_descriptors()->GetFieldType(descriptor_number()), | 652 holder_->map()->instance_descriptors()->GetFieldType(descriptor_number()), |
649 isolate_); | 653 isolate_); |
650 } | 654 } |
651 | 655 |
652 | 656 |
653 Handle<PropertyCell> LookupIterator::GetPropertyCell() const { | 657 Handle<PropertyCell> LookupIterator::GetPropertyCell() const { |
654 DCHECK(!IsElement()); | 658 DCHECK(!IsElement()); |
655 Handle<JSGlobalObject> holder = GetHolder<JSGlobalObject>(); | 659 Handle<JSGlobalObject> holder = GetHolder<JSGlobalObject>(); |
656 Object* value = holder->global_dictionary()->ValueAt(dictionary_entry()); | 660 Object* value = holder->global_dictionary()->ValueAt(dictionary_entry()); |
(...skipping 16 matching lines...) Expand all Loading... |
673 | 677 |
674 | 678 |
675 void LookupIterator::WriteDataValue(Handle<Object> value) { | 679 void LookupIterator::WriteDataValue(Handle<Object> value) { |
676 DCHECK_EQ(DATA, state_); | 680 DCHECK_EQ(DATA, state_); |
677 Handle<JSReceiver> holder = GetHolder<JSReceiver>(); | 681 Handle<JSReceiver> holder = GetHolder<JSReceiver>(); |
678 if (IsElement()) { | 682 if (IsElement()) { |
679 Handle<JSObject> object = Handle<JSObject>::cast(holder); | 683 Handle<JSObject> object = Handle<JSObject>::cast(holder); |
680 ElementsAccessor* accessor = object->GetElementsAccessor(); | 684 ElementsAccessor* accessor = object->GetElementsAccessor(); |
681 accessor->Set(object, number_, *value); | 685 accessor->Set(object, number_, *value); |
682 } else if (holder->HasFastProperties()) { | 686 } else if (holder->HasFastProperties()) { |
683 if (property_details_.type() == v8::internal::DATA) { | 687 if (property_details_.location() == kField) { |
684 JSObject::cast(*holder)->WriteToField(descriptor_number(), | 688 JSObject::cast(*holder)->WriteToField(descriptor_number(), |
685 property_details_, *value); | 689 property_details_, *value); |
686 } else { | 690 } else { |
687 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); | 691 DCHECK_EQ(kDescriptor, property_details_.location()); |
688 } | 692 } |
689 } else if (holder->IsJSGlobalObject()) { | 693 } else if (holder->IsJSGlobalObject()) { |
690 GlobalDictionary* dictionary = JSObject::cast(*holder)->global_dictionary(); | 694 GlobalDictionary* dictionary = JSObject::cast(*holder)->global_dictionary(); |
691 Object* cell = dictionary->ValueAt(dictionary_entry()); | 695 Object* cell = dictionary->ValueAt(dictionary_entry()); |
692 DCHECK(cell->IsPropertyCell()); | 696 DCHECK(cell->IsPropertyCell()); |
693 PropertyCell::cast(cell)->set_value(*value); | 697 PropertyCell::cast(cell)->set_value(*value); |
694 } else { | 698 } else { |
695 NameDictionary* dictionary = holder->property_dictionary(); | 699 NameDictionary* dictionary = holder->property_dictionary(); |
696 dictionary->ValueAtPut(dictionary_entry(), *value); | 700 dictionary->ValueAtPut(dictionary_entry(), *value); |
697 } | 701 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 | 874 |
871 // We have found a cached property! Modify the iterator accordingly. | 875 // We have found a cached property! Modify the iterator accordingly. |
872 name_ = maybe_name.ToHandleChecked(); | 876 name_ = maybe_name.ToHandleChecked(); |
873 Restart(); | 877 Restart(); |
874 CHECK_EQ(state(), LookupIterator::DATA); | 878 CHECK_EQ(state(), LookupIterator::DATA); |
875 return true; | 879 return true; |
876 } | 880 } |
877 | 881 |
878 } // namespace internal | 882 } // namespace internal |
879 } // namespace v8 | 883 } // namespace v8 |
OLD | NEW |