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

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
« no previous file with comments | « runtime/vm/intrinsifier.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 RawClass* patch_class() const {
695 return raw_ptr()->patch_class_;
696 }
697 void set_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_synthesized_class() const {
828 return SynthesizedClassBit::decode(raw_ptr()->state_bits_);
829 }
830 void set_is_synthesized_class() const;
831
811 bool is_finalized() const { 832 bool is_finalized() const {
812 return StateBits::decode(raw_ptr()->state_bits_) == RawClass::kFinalized; 833 return StateBits::decode(raw_ptr()->state_bits_) == RawClass::kFinalized;
813 } 834 }
814 void set_is_finalized() const; 835 void set_is_finalized() const;
815 836
816 bool is_prefinalized() const { 837 bool is_prefinalized() const {
817 return StateBits::decode(raw_ptr()->state_bits_) == RawClass::kPreFinalized; 838 return StateBits::decode(raw_ptr()->state_bits_) == RawClass::kPreFinalized;
818 } 839 }
819 840
820 void set_is_prefinalized() const; 841 void set_is_prefinalized() const;
821 842
843 bool is_marked_for_parsing() const {
844 return MarkedForParsingBit::decode(raw_ptr()->state_bits_);
845 }
846 void set_is_marked_for_parsing() const;
847 void reset_is_marked_for_parsing() const;
848
822 bool is_const() const { return ConstBit::decode(raw_ptr()->state_bits_); } 849 bool is_const() const { return ConstBit::decode(raw_ptr()->state_bits_); }
823 void set_is_const() const; 850 void set_is_const() const;
824 851
825 int num_native_fields() const { 852 int num_native_fields() const {
826 return raw_ptr()->num_native_fields_; 853 return raw_ptr()->num_native_fields_;
827 } 854 }
828 void set_num_native_fields(int value) const { 855 void set_num_native_fields(int value) const {
829 raw_ptr()->num_native_fields_ = value; 856 raw_ptr()->num_native_fields_ = value;
830 } 857 }
831 static intptr_t num_native_fields_offset() { 858 static intptr_t num_native_fields_offset() {
832 return OFFSET_OF(RawClass, num_native_fields_); 859 return OFFSET_OF(RawClass, num_native_fields_);
833 } 860 }
834 861
835 RawCode* allocation_stub() const { 862 RawCode* allocation_stub() const {
836 return raw_ptr()->allocation_stub_; 863 return raw_ptr()->allocation_stub_;
837 } 864 }
838 void set_allocation_stub(const Code& value) const; 865 void set_allocation_stub(const Code& value) const;
839 866
840 RawArray* constants() const; 867 RawArray* constants() const;
841 868
842 void Finalize() const; 869 void Finalize() const;
843 870
844 const char* ApplyPatch(const Class& patch) const; 871 const char* ApplyPatch(const Class& patch) const;
845 872
873 RawError* EnsureIsFinalized(Isolate* isolate) const;
874
846 // Allocate a class used for VM internal objects. 875 // Allocate a class used for VM internal objects.
847 template <class FakeObject> static RawClass* New(); 876 template <class FakeObject> static RawClass* New();
848 877
849 // Allocate instance classes. 878 // Allocate instance classes.
850 static RawClass* New(const String& name, 879 static RawClass* New(const String& name,
851 const Script& script, 880 const Script& script,
852 intptr_t token_pos); 881 intptr_t token_pos);
853 static RawClass* NewNativeWrapper(const Library& library, 882 static RawClass* NewNativeWrapper(const Library& library,
854 const String& name, 883 const String& name,
855 int num_fields); 884 int num_fields);
(...skipping 25 matching lines...) Expand all
881 // Patch the signature function of a signature class allocated without it. 910 // Patch the signature function of a signature class allocated without it.
882 void PatchSignatureFunction(const Function& signature_function) const; 911 void PatchSignatureFunction(const Function& signature_function) const;
883 912
884 // Return a class object corresponding to the specified kind. If 913 // Return a class object corresponding to the specified kind. If
885 // a canonicalized version of it exists then that object is returned 914 // a canonicalized version of it exists then that object is returned
886 // otherwise a new object is allocated and returned. 915 // otherwise a new object is allocated and returned.
887 static RawClass* GetClass(intptr_t class_id, bool is_signature_class); 916 static RawClass* GetClass(intptr_t class_id, bool is_signature_class);
888 917
889 private: 918 private:
890 enum { 919 enum {
891 kConstBit = 1, 920 kConstBit = 0,
892 kImplementedBit = 2, 921 kImplementedBit = 1,
893 kAbstractBit = 3, 922 kAbstractBit = 2,
894 kStateTagBit = 4, 923 kPatchBit = 3,
924 kSynthesizedClassBit = 4,
925 kTypeFinalizedBit = 5,
926 kStateTagBit = 6,
895 kStateTagSize = 2, 927 kStateTagSize = 2,
928 kMarkedForParsingBit = 8,
896 }; 929 };
897 class ConstBit : public BitField<bool, kConstBit, 1> {}; 930 class ConstBit : public BitField<bool, kConstBit, 1> {};
898 class ImplementedBit : public BitField<bool, kImplementedBit, 1> {}; 931 class ImplementedBit : public BitField<bool, kImplementedBit, 1> {};
899 class AbstractBit : public BitField<bool, kAbstractBit, 1> {}; 932 class AbstractBit : public BitField<bool, kAbstractBit, 1> {};
933 class PatchBit : public BitField<bool, kPatchBit, 1> {};
934 class SynthesizedClassBit : public BitField<bool, kSynthesizedClassBit, 1> {};
935 class TypeFinalizedBit : public BitField<bool, kTypeFinalizedBit, 1> {};
900 class StateBits : public BitField<RawClass::ClassState, 936 class StateBits : public BitField<RawClass::ClassState,
901 kStateTagBit, kStateTagSize> {}; // NOLINT 937 kStateTagBit, kStateTagSize> {}; // NOLINT
938 class MarkedForParsingBit : public BitField<bool, kMarkedForParsingBit, 1> {};
902 939
903 void set_name(const String& value) const; 940 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; 941 void set_signature_function(const Function& value) const;
906 void set_signature_type(const AbstractType& value) const; 942 void set_signature_type(const AbstractType& value) const;
907 void set_class_state(RawClass::ClassState state) const; 943 void set_class_state(RawClass::ClassState state) const;
908 void set_state_bits(intptr_t bits) const; 944 void set_state_bits(intptr_t bits) const;
909 945
910 void set_constants(const Array& value) const; 946 void set_constants(const Array& value) const;
911 947
912 void set_canonical_types(const Array& value) const; 948 void set_canonical_types(const Array& value) const;
913 RawArray* canonical_types() const; 949 RawArray* canonical_types() const;
914 950
(...skipping 4851 matching lines...) Expand 10 before | Expand all | Expand 10 after
5766 5802
5767 5803
5768 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 5804 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
5769 intptr_t index) { 5805 intptr_t index) {
5770 return array.At((index * kEntryLength) + kTargetFunctionIndex); 5806 return array.At((index * kEntryLength) + kTargetFunctionIndex);
5771 } 5807 }
5772 5808
5773 } // namespace dart 5809 } // namespace dart
5774 5810
5775 #endif // VM_OBJECT_H_ 5811 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698