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

Side by Side Diff: src/lookup.cc

Issue 2624903003: [runtime] Use PropertyKind/PropertyLocation instead of PropertyType. (Closed)
Patch Set: Created 3 years, 11 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
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/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
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) {
Jakob Kummerow 2017/01/12 15:40:30 DCHECK_EQ(kData, details.kind());
Igor Sheludko 2017/01/12 15:52:31 Done.
597 Handle<JSObject> holder = GetHolder<JSObject>(); 597 Handle<JSObject> holder = GetHolder<JSObject>();
598 FieldIndex field_index = FieldIndex::ForDescriptor(holder->map(), number_); 598 FieldIndex field_index = FieldIndex::ForDescriptor(holder->map(), number_);
599 return JSObject::FastPropertyAt(holder, property_details_.representation(), 599 return JSObject::FastPropertyAt(holder, property_details_.representation(),
600 field_index); 600 field_index);
601 } else { 601 } else {
602 result = holder_->map()->instance_descriptors()->GetValue(number_); 602 result = holder_->map()->instance_descriptors()->GetValue(number_);
603 } 603 }
604 return handle(result, isolate_); 604 return handle(result, isolate_);
605 } 605 }
606 606
607 int LookupIterator::GetFieldDescriptorIndex() const { 607 int LookupIterator::GetFieldDescriptorIndex() const {
608 DCHECK(has_property_); 608 DCHECK(has_property_);
609 DCHECK(holder_->HasFastProperties()); 609 DCHECK(holder_->HasFastProperties());
610 DCHECK_EQ(v8::internal::DATA, property_details_.type()); 610 DCHECK_EQ(kField, property_details_.location());
611 DCHECK_EQ(kData, property_details_.kind());
611 return descriptor_number(); 612 return descriptor_number();
612 } 613 }
613 614
614 int LookupIterator::GetAccessorIndex() const { 615 int LookupIterator::GetAccessorIndex() const {
615 DCHECK(has_property_); 616 DCHECK(has_property_);
616 DCHECK(holder_->HasFastProperties()); 617 DCHECK(holder_->HasFastProperties());
617 DCHECK_EQ(v8::internal::ACCESSOR_CONSTANT, property_details_.type()); 618 DCHECK_EQ(kDescriptor, property_details_.location());
619 DCHECK_EQ(kAccessor, property_details_.kind());
618 return descriptor_number(); 620 return descriptor_number();
619 } 621 }
620 622
621 623
622 int LookupIterator::GetConstantIndex() const { 624 int LookupIterator::GetConstantIndex() const {
623 DCHECK(has_property_); 625 DCHECK(has_property_);
624 DCHECK(holder_->HasFastProperties()); 626 DCHECK(holder_->HasFastProperties());
625 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); 627 DCHECK_EQ(kDescriptor, property_details_.location());
628 DCHECK_EQ(kData, property_details_.kind());
626 DCHECK(!IsElement()); 629 DCHECK(!IsElement());
627 return descriptor_number(); 630 return descriptor_number();
628 } 631 }
629 632
630 633
631 FieldIndex LookupIterator::GetFieldIndex() const { 634 FieldIndex LookupIterator::GetFieldIndex() const {
632 DCHECK(has_property_); 635 DCHECK(has_property_);
633 DCHECK(holder_->HasFastProperties()); 636 DCHECK(holder_->HasFastProperties());
634 DCHECK_EQ(v8::internal::DATA, property_details_.type()); 637 DCHECK_EQ(kField, property_details_.location());
635 DCHECK(!IsElement()); 638 DCHECK(!IsElement());
636 Map* holder_map = holder_->map(); 639 Map* holder_map = holder_->map();
637 int index = 640 int index =
638 holder_map->instance_descriptors()->GetFieldIndex(descriptor_number()); 641 holder_map->instance_descriptors()->GetFieldIndex(descriptor_number());
639 bool is_double = representation().IsDouble(); 642 bool is_double = representation().IsDouble();
640 return FieldIndex::ForPropertyIndex(holder_map, index, is_double); 643 return FieldIndex::ForPropertyIndex(holder_map, index, is_double);
641 } 644 }
642 645
643 Handle<FieldType> LookupIterator::GetFieldType() const { 646 Handle<FieldType> LookupIterator::GetFieldType() const {
644 DCHECK(has_property_); 647 DCHECK(has_property_);
645 DCHECK(holder_->HasFastProperties()); 648 DCHECK(holder_->HasFastProperties());
646 DCHECK_EQ(v8::internal::DATA, property_details_.type()); 649 DCHECK_EQ(kField, property_details_.location());
647 return handle( 650 return handle(
648 holder_->map()->instance_descriptors()->GetFieldType(descriptor_number()), 651 holder_->map()->instance_descriptors()->GetFieldType(descriptor_number()),
649 isolate_); 652 isolate_);
650 } 653 }
651 654
652 655
653 Handle<PropertyCell> LookupIterator::GetPropertyCell() const { 656 Handle<PropertyCell> LookupIterator::GetPropertyCell() const {
654 DCHECK(!IsElement()); 657 DCHECK(!IsElement());
655 Handle<JSGlobalObject> holder = GetHolder<JSGlobalObject>(); 658 Handle<JSGlobalObject> holder = GetHolder<JSGlobalObject>();
656 Object* value = holder->global_dictionary()->ValueAt(dictionary_entry()); 659 Object* value = holder->global_dictionary()->ValueAt(dictionary_entry());
(...skipping 16 matching lines...) Expand all
673 676
674 677
675 void LookupIterator::WriteDataValue(Handle<Object> value) { 678 void LookupIterator::WriteDataValue(Handle<Object> value) {
676 DCHECK_EQ(DATA, state_); 679 DCHECK_EQ(DATA, state_);
677 Handle<JSReceiver> holder = GetHolder<JSReceiver>(); 680 Handle<JSReceiver> holder = GetHolder<JSReceiver>();
678 if (IsElement()) { 681 if (IsElement()) {
679 Handle<JSObject> object = Handle<JSObject>::cast(holder); 682 Handle<JSObject> object = Handle<JSObject>::cast(holder);
680 ElementsAccessor* accessor = object->GetElementsAccessor(); 683 ElementsAccessor* accessor = object->GetElementsAccessor();
681 accessor->Set(object, number_, *value); 684 accessor->Set(object, number_, *value);
682 } else if (holder->HasFastProperties()) { 685 } else if (holder->HasFastProperties()) {
683 if (property_details_.type() == v8::internal::DATA) { 686 if (property_details_.location() == kField) {
684 JSObject::cast(*holder)->WriteToField(descriptor_number(), 687 JSObject::cast(*holder)->WriteToField(descriptor_number(),
685 property_details_, *value); 688 property_details_, *value);
686 } else { 689 } else {
687 DCHECK_EQ(v8::internal::DATA_CONSTANT, property_details_.type()); 690 DCHECK_EQ(kDescriptor, property_details_.location());
688 } 691 }
689 } else if (holder->IsJSGlobalObject()) { 692 } else if (holder->IsJSGlobalObject()) {
690 GlobalDictionary* dictionary = JSObject::cast(*holder)->global_dictionary(); 693 GlobalDictionary* dictionary = JSObject::cast(*holder)->global_dictionary();
691 Object* cell = dictionary->ValueAt(dictionary_entry()); 694 Object* cell = dictionary->ValueAt(dictionary_entry());
692 DCHECK(cell->IsPropertyCell()); 695 DCHECK(cell->IsPropertyCell());
693 PropertyCell::cast(cell)->set_value(*value); 696 PropertyCell::cast(cell)->set_value(*value);
694 } else { 697 } else {
695 NameDictionary* dictionary = holder->property_dictionary(); 698 NameDictionary* dictionary = holder->property_dictionary();
696 dictionary->ValueAtPut(dictionary_entry(), *value); 699 dictionary->ValueAtPut(dictionary_entry(), *value);
697 } 700 }
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 873
871 // We have found a cached property! Modify the iterator accordingly. 874 // We have found a cached property! Modify the iterator accordingly.
872 name_ = maybe_name.ToHandleChecked(); 875 name_ = maybe_name.ToHandleChecked();
873 Restart(); 876 Restart();
874 CHECK_EQ(state(), LookupIterator::DATA); 877 CHECK_EQ(state(), LookupIterator::DATA);
875 return true; 878 return true;
876 } 879 }
877 880
878 } // namespace internal 881 } // namespace internal
879 } // namespace v8 882 } // namespace v8
OLDNEW
« src/json-stringifier.cc ('K') | « src/layout-descriptor-inl.h ('k') | src/map-updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698