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

Side by Side Diff: runtime/vm/object.h

Issue 14820028: Delay Class parsing until the class is actually used. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 598
599 RawString* Name() const; 599 RawString* Name() const;
600 RawString* UserVisibleName() const; 600 RawString* UserVisibleName() const;
601 601
602 virtual RawString* DictionaryName() const { return Name(); } 602 virtual RawString* DictionaryName() const { return Name(); }
603 603
604 RawScript* script() const { return raw_ptr()->script_; } 604 RawScript* script() const { return raw_ptr()->script_; }
605 void set_script(const Script& value) const; 605 void set_script(const Script& value) const;
606 606
607 intptr_t token_pos() const { return raw_ptr()->token_pos_; } 607 intptr_t token_pos() const { return raw_ptr()->token_pos_; }
608 void set_token_pos(intptr_t value) const;
608 609
609 // This class represents the signature class of a closure function if 610 // This class represents the signature class of a closure function if
610 // signature_function() is not null. 611 // signature_function() is not null.
611 // The associated function may be a closure function (with code) or a 612 // The associated function may be a closure function (with code) or a
612 // signature function (without code) solely describing the result type and 613 // signature function (without code) solely describing the result type and
613 // parameter types of the signature. 614 // parameter types of the signature.
614 RawFunction* signature_function() const { 615 RawFunction* signature_function() const {
615 return raw_ptr()->signature_function_; 616 return raw_ptr()->signature_function_;
616 } 617 }
617 static intptr_t signature_function_offset() { 618 static intptr_t signature_function_offset() {
(...skipping 27 matching lines...) Expand all
645 intptr_t token_pos) const; 646 intptr_t token_pos) const;
646 647
647 // The type argument vector is flattened and includes the type arguments of 648 // The type argument vector is flattened and includes the type arguments of
648 // the super class. 649 // the super class.
649 bool HasTypeArguments() const; 650 bool HasTypeArguments() const;
650 intptr_t NumTypeArguments() const; 651 intptr_t NumTypeArguments() const;
651 652
652 // If this class is parameterized, each instance has a type_arguments field. 653 // If this class is parameterized, each instance has a type_arguments field.
653 static const intptr_t kNoTypeArguments = -1; 654 static const intptr_t kNoTypeArguments = -1;
654 intptr_t type_arguments_field_offset() const { 655 intptr_t type_arguments_field_offset() const {
655 ASSERT(is_finalized() || is_prefinalized()); 656 ASSERT(is_type_finalized() || is_prefinalized());
656 if (raw_ptr()->type_arguments_field_offset_in_words_ == kNoTypeArguments) { 657 if (raw_ptr()->type_arguments_field_offset_in_words_ == kNoTypeArguments) {
657 return kNoTypeArguments; 658 return kNoTypeArguments;
658 } 659 }
659 return raw_ptr()->type_arguments_field_offset_in_words_ * kWordSize; 660 return raw_ptr()->type_arguments_field_offset_in_words_ * kWordSize;
660 } 661 }
661 void set_type_arguments_field_offset(intptr_t value_in_bytes) const { 662 void set_type_arguments_field_offset(intptr_t value_in_bytes) const {
662 intptr_t value; 663 intptr_t value;
663 if (value_in_bytes == kNoTypeArguments) { 664 if (value_in_bytes == kNoTypeArguments) {
664 value = kNoTypeArguments; 665 value = kNoTypeArguments;
665 } else { 666 } else {
(...skipping 17 matching lines...) Expand all
683 static intptr_t super_type_offset() { 684 static intptr_t super_type_offset() {
684 return OFFSET_OF(RawClass, super_type_); 685 return OFFSET_OF(RawClass, super_type_);
685 } 686 }
686 687
687 // Asserts that the class of the super type has been resolved. 688 // Asserts that the class of the super type has been resolved.
688 RawClass* SuperClass() const; 689 RawClass* SuperClass() const;
689 690
690 RawType* mixin() const { return raw_ptr()->mixin_; } 691 RawType* mixin() const { return raw_ptr()->mixin_; }
691 void set_mixin(const Type& value) const; 692 void set_mixin(const Type& value) const;
692 693
694 RawGrowableObjectArray* patch_classes() const {
695 return raw_ptr()->patch_classes_;
696 }
697 void add_patch_class(const Class& patch_class) const;
698
693 // Interfaces is an array of Types. 699 // Interfaces is an array of Types.
694 RawArray* interfaces() const { return raw_ptr()->interfaces_; } 700 RawArray* interfaces() const { return raw_ptr()->interfaces_; }
695 void set_interfaces(const Array& value) const; 701 void set_interfaces(const Array& value) const;
696 static intptr_t interfaces_offset() { 702 static intptr_t interfaces_offset() {
697 return OFFSET_OF(RawClass, interfaces_); 703 return OFFSET_OF(RawClass, interfaces_);
698 } 704 }
699 705
700 // Returns the list of classes having this class as direct superclass. 706 // Returns the list of classes having this class as direct superclass.
701 RawGrowableObjectArray* direct_subclasses() const { 707 RawGrowableObjectArray* direct_subclasses() const {
702 return raw_ptr()->direct_subclasses_; 708 return raw_ptr()->direct_subclasses_;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 bool is_implemented() const { 807 bool is_implemented() const {
802 return ImplementedBit::decode(raw_ptr()->state_bits_); 808 return ImplementedBit::decode(raw_ptr()->state_bits_);
803 } 809 }
804 void set_is_implemented() const; 810 void set_is_implemented() const;
805 811
806 bool is_abstract() const { 812 bool is_abstract() const {
807 return AbstractBit::decode(raw_ptr()->state_bits_); 813 return AbstractBit::decode(raw_ptr()->state_bits_);
808 } 814 }
809 void set_is_abstract() const; 815 void set_is_abstract() const;
810 816
817 bool is_type_finalized() const {
818 return TypeFinalizedBit::decode(raw_ptr()->state_bits_);
819 }
820 void set_is_type_finalized() const;
821
822 bool is_patch() const {
823 return PatchBit::decode(raw_ptr()->state_bits_);
824 }
825 void set_is_patch() const;
826
827 bool is_parsed() const {
828 return ParsedBit::decode(raw_ptr()->state_bits_);
829 }
830 void set_is_parsed() const;
831
832 bool is_synthesized_class() const {
833 return SynthesizedClassBit::decode(raw_ptr()->state_bits_);
834 }
835 void set_is_synthesized_class() const;
836
811 bool is_finalized() const { 837 bool is_finalized() const {
812 return StateBits::decode(raw_ptr()->state_bits_) == RawClass::kFinalized; 838 return StateBits::decode(raw_ptr()->state_bits_) == RawClass::kFinalized;
813 } 839 }
814 void set_is_finalized() const; 840 void set_is_finalized() const;
815 841
816 bool is_prefinalized() const { 842 bool is_prefinalized() const {
817 return StateBits::decode(raw_ptr()->state_bits_) == RawClass::kPreFinalized; 843 return StateBits::decode(raw_ptr()->state_bits_) == RawClass::kPreFinalized;
818 } 844 }
819 845
820 void set_is_prefinalized() const; 846 void set_is_prefinalized() const;
(...skipping 15 matching lines...) Expand all
836 return raw_ptr()->allocation_stub_; 862 return raw_ptr()->allocation_stub_;
837 } 863 }
838 void set_allocation_stub(const Code& value) const; 864 void set_allocation_stub(const Code& value) const;
839 865
840 RawArray* constants() const; 866 RawArray* constants() const;
841 867
842 void Finalize() const; 868 void Finalize() const;
843 869
844 const char* ApplyPatch(const Class& patch) const; 870 const char* ApplyPatch(const Class& patch) const;
845 871
872 RawError* EnsureIsParsed(Isolate* isolate) const;
873
846 // Allocate a class used for VM internal objects. 874 // Allocate a class used for VM internal objects.
847 template <class FakeObject> static RawClass* New(); 875 template <class FakeObject> static RawClass* New();
848 876
849 // Allocate instance classes. 877 // Allocate instance classes.
850 static RawClass* New(const String& name, 878 static RawClass* New(const String& name,
851 const Script& script, 879 const Script& script,
852 intptr_t token_pos); 880 intptr_t token_pos);
853 static RawClass* NewNativeWrapper(const Library& library, 881 static RawClass* NewNativeWrapper(const Library& library,
854 const String& name, 882 const String& name,
855 int num_fields); 883 int num_fields);
(...skipping 25 matching lines...) Expand all
881 // Patch the signature function of a signature class allocated without it. 909 // Patch the signature function of a signature class allocated without it.
882 void PatchSignatureFunction(const Function& signature_function) const; 910 void PatchSignatureFunction(const Function& signature_function) const;
883 911
884 // Return a class object corresponding to the specified kind. If 912 // Return a class object corresponding to the specified kind. If
885 // a canonicalized version of it exists then that object is returned 913 // a canonicalized version of it exists then that object is returned
886 // otherwise a new object is allocated and returned. 914 // otherwise a new object is allocated and returned.
887 static RawClass* GetClass(intptr_t class_id, bool is_signature_class); 915 static RawClass* GetClass(intptr_t class_id, bool is_signature_class);
888 916
889 private: 917 private:
890 enum { 918 enum {
891 kConstBit = 1, 919 kConstBit = 0,
892 kImplementedBit = 2, 920 kImplementedBit = 1,
893 kAbstractBit = 3, 921 kAbstractBit = 2,
894 kStateTagBit = 4, 922 kPatchBit = 3,
923 kSynthesizedClassBit = 4,
924 kTypeFinalizedBit = 5,
925 kStateTagBit = 6,
895 kStateTagSize = 2, 926 kStateTagSize = 2,
927 kParsedBit = 8,
896 }; 928 };
897 class ConstBit : public BitField<bool, kConstBit, 1> {}; 929 class ConstBit : public BitField<bool, kConstBit, 1> {};
898 class ImplementedBit : public BitField<bool, kImplementedBit, 1> {}; 930 class ImplementedBit : public BitField<bool, kImplementedBit, 1> {};
899 class AbstractBit : public BitField<bool, kAbstractBit, 1> {}; 931 class AbstractBit : public BitField<bool, kAbstractBit, 1> {};
932 class TypeFinalizedBit : public BitField<bool, kTypeFinalizedBit, 1> {};
933 class PatchBit : public BitField<bool, kPatchBit, 1> {};
934 class ParsedBit : public BitField<bool, kParsedBit, 1> {};
900 class StateBits : public BitField<RawClass::ClassState, 935 class StateBits : public BitField<RawClass::ClassState,
901 kStateTagBit, kStateTagSize> {}; // NOLINT 936 kStateTagBit, kStateTagSize> {}; // NOLINT
937 class SynthesizedClassBit : public BitField<bool, kSynthesizedClassBit, 1> {};
902 938
903 void set_name(const String& value) const; 939 void set_name(const String& value) const;
904 void set_token_pos(intptr_t value) const;
905 void set_signature_function(const Function& value) const; 940 void set_signature_function(const Function& value) const;
906 void set_signature_type(const AbstractType& value) const; 941 void set_signature_type(const AbstractType& value) const;
907 void set_class_state(RawClass::ClassState state) const; 942 void set_class_state(RawClass::ClassState state) const;
908 void set_state_bits(intptr_t bits) const; 943 void set_state_bits(intptr_t bits) const;
909 944
910 void set_constants(const Array& value) const; 945 void set_constants(const Array& value) const;
911 946
912 void set_canonical_types(const Array& value) const; 947 void set_canonical_types(const Array& value) const;
913 RawArray* canonical_types() const; 948 RawArray* canonical_types() const;
914 949
(...skipping 4853 matching lines...) Expand 10 before | Expand all | Expand 10 after
5768 5803
5769 5804
5770 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 5805 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
5771 intptr_t index) { 5806 intptr_t index) {
5772 return array.At((index * kEntryLength) + kTargetFunctionIndex); 5807 return array.At((index * kEntryLength) + kTargetFunctionIndex);
5773 } 5808 }
5774 5809
5775 } // namespace dart 5810 } // namespace dart
5776 5811
5777 #endif // VM_OBJECT_H_ 5812 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698