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

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

Issue 1149943009: Shrink some fields and add some bounds checks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 (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_RAW_OBJECT_H_ 5 #ifndef VM_RAW_OBJECT_H_
6 #define VM_RAW_OBJECT_H_ 6 #define VM_RAW_OBJECT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/atomic.h" 9 #include "vm/atomic.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 RawObject* canonical_types_; // An array of canonicalized types of this class 606 RawObject* canonical_types_; // An array of canonicalized types of this class
607 // or the canonical type. 607 // or the canonical type.
608 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions. 608 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions.
609 RawArray* cha_codes_; // CHA optimized codes. 609 RawArray* cha_codes_; // CHA optimized codes.
610 RawCode* allocation_stub_; // Stub code for allocation of instances. 610 RawCode* allocation_stub_; // Stub code for allocation of instances.
611 RawObject** to() { 611 RawObject** to() {
612 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); 612 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_);
613 } 613 }
614 614
615 cpp_vtable handle_vtable_; 615 cpp_vtable handle_vtable_;
616 int32_t id_; // Class Id, also index in the class table.
617 int32_t token_pos_; 616 int32_t token_pos_;
618 int32_t instance_size_in_words_; // Size if fixed len or 0 if variable len. 617 int32_t instance_size_in_words_; // Size if fixed len or 0 if variable len.
619 int32_t type_arguments_field_offset_in_words_; // Offset of type args fld. 618 int32_t type_arguments_field_offset_in_words_; // Offset of type args fld.
620 int32_t next_field_offset_in_words_; // Offset of the next instance field. 619 int32_t next_field_offset_in_words_; // Offset of the next instance field.
620 classid_t id_; // Class Id, also index in the class table.
621 int16_t num_type_arguments_; // Number of type arguments in flatten vector. 621 int16_t num_type_arguments_; // Number of type arguments in flatten vector.
622 int16_t num_own_type_arguments_; // Number of non-overlapping type arguments. 622 int16_t num_own_type_arguments_; // Number of non-overlapping type arguments.
623 uint16_t num_native_fields_; // Number of native fields in class. 623 uint16_t num_native_fields_; // Number of native fields in class.
624 uint16_t state_bits_; 624 uint16_t state_bits_;
625 625
626 friend class Instance; 626 friend class Instance;
627 friend class Object; 627 friend class Object;
628 friend class RawInstance; 628 friend class RawInstance;
629 friend class RawInstructions; 629 friend class RawInstructions;
630 friend class SnapshotReader; 630 friend class SnapshotReader;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 RawObject** to() { 749 RawObject** to() {
750 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); 750 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_);
751 } 751 }
752 752
753 int32_t token_pos_; 753 int32_t token_pos_;
754 int32_t end_token_pos_; 754 int32_t end_token_pos_;
755 int32_t usage_counter_; // Incremented while function is running. 755 int32_t usage_counter_; // Incremented while function is running.
756 int16_t num_fixed_parameters_; 756 int16_t num_fixed_parameters_;
757 int16_t num_optional_parameters_; // > 0: positional; < 0: named. 757 int16_t num_optional_parameters_; // > 0: positional; < 0: named.
758 int16_t deoptimization_counter_; 758 int16_t deoptimization_counter_;
759 int16_t regexp_cid_; 759 classid_t regexp_cid_;
760 uint32_t kind_tag_; // See Function::KindTagBits. 760 uint32_t kind_tag_; // See Function::KindTagBits.
761 uint16_t optimized_instruction_count_; 761 uint16_t optimized_instruction_count_;
762 uint16_t optimized_call_site_count_; 762 uint16_t optimized_call_site_count_;
763 }; 763 };
764 764
765 765
766 class RawClosureData : public RawObject { 766 class RawClosureData : public RawObject {
767 private: 767 private:
768 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData); 768 RAW_HEAP_OBJECT_IMPLEMENTATION(ClosureData);
769 769
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 RawObject* owner_; // Class or patch class or mixin class 806 RawObject* owner_; // Class or patch class or mixin class
807 // where this field is defined. 807 // where this field is defined.
808 RawAbstractType* type_; 808 RawAbstractType* type_;
809 RawInstance* value_; // Offset in words for instance and value for static. 809 RawInstance* value_; // Offset in words for instance and value for static.
810 RawArray* dependent_code_; 810 RawArray* dependent_code_;
811 RawSmi* guarded_list_length_; 811 RawSmi* guarded_list_length_;
812 RawObject** to() { 812 RawObject** to() {
813 return reinterpret_cast<RawObject**>(&ptr()->guarded_list_length_); 813 return reinterpret_cast<RawObject**>(&ptr()->guarded_list_length_);
814 } 814 }
815 815
816 // TODO(rmacnak): Make guarded_cid and is_nullable be cid_t.
816 int32_t token_pos_; 817 int32_t token_pos_;
817 int32_t guarded_cid_; 818 int32_t guarded_cid_;
818 int32_t is_nullable_; // kNullCid if field can contain null value and 819 int32_t is_nullable_; // kNullCid if field can contain null value and
819 // any other value otherwise. 820 // any other value otherwise.
820 // Offset to the guarded length field inside an instance of class matching 821 // Offset to the guarded length field inside an instance of class matching
821 // guarded_cid_. Stored corrected by -kHeapObjectTag to simplify code 822 // guarded_cid_. Stored corrected by -kHeapObjectTag to simplify code
822 // generated on platforms with weak addressing modes (ARM, MIPS). 823 // generated on platforms with weak addressing modes (ARM, MIPS).
823 int8_t guarded_list_length_in_object_offset_; 824 int8_t guarded_list_length_in_object_offset_;
824 825
825 uint8_t kind_bits_; // static, final, const, has initializer. 826 uint8_t kind_bits_; // static, final, const, has initializer.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 RawGrowableObjectArray* metadata_; // Metadata on classes, methods etc. 909 RawGrowableObjectArray* metadata_; // Metadata on classes, methods etc.
909 RawArray* anonymous_classes_; // Classes containing top-level elements. 910 RawArray* anonymous_classes_; // Classes containing top-level elements.
910 RawArray* imports_; // List of Namespaces imported without prefix. 911 RawArray* imports_; // List of Namespaces imported without prefix.
911 RawArray* exports_; // List of re-exported Namespaces. 912 RawArray* exports_; // List of re-exported Namespaces.
912 RawArray* loaded_scripts_; // Array of scripts loaded in this library. 913 RawArray* loaded_scripts_; // Array of scripts loaded in this library.
913 RawInstance* load_error_; // Error iff load_state_ == kLoadError. 914 RawInstance* load_error_; // Error iff load_state_ == kLoadError.
914 RawObject** to() { 915 RawObject** to() {
915 return reinterpret_cast<RawObject**>(&ptr()->load_error_); 916 return reinterpret_cast<RawObject**>(&ptr()->load_error_);
916 } 917 }
917 918
918 int32_t index_; // Library id number.
919 int32_t num_imports_; // Number of entries in imports_.
920 int32_t num_anonymous_; // Number of entries in anonymous_classes_.
921 Dart_NativeEntryResolver native_entry_resolver_; // Resolves natives. 919 Dart_NativeEntryResolver native_entry_resolver_; // Resolves natives.
922 Dart_NativeEntrySymbol native_entry_symbol_resolver_; 920 Dart_NativeEntrySymbol native_entry_symbol_resolver_;
921 classid_t index_; // Library id number.
922 classid_t num_anonymous_; // Number of entries in anonymous_classes_.
923 uint16_t num_imports_; // Number of entries in imports_.
924 int8_t load_state_; // Of type LibraryState.
923 bool corelib_imported_; 925 bool corelib_imported_;
924 bool is_dart_scheme_; 926 bool is_dart_scheme_;
925 bool debuggable_; // True if debugger can stop in library. 927 bool debuggable_; // True if debugger can stop in library.
926 int8_t load_state_; // Of type LibraryState.
927 928
928 friend class Isolate; 929 friend class Isolate;
929 }; 930 };
930 931
931 932
932 class RawNamespace : public RawObject { 933 class RawNamespace : public RawObject {
933 RAW_HEAP_OBJECT_IMPLEMENTATION(Namespace); 934 RAW_HEAP_OBJECT_IMPLEMENTATION(Namespace);
934 935
935 RawObject** from() { 936 RawObject** from() {
936 return reinterpret_cast<RawObject**>(&ptr()->library_); 937 return reinterpret_cast<RawObject**>(&ptr()->library_);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 1393
1393 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } 1394 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); }
1394 RawString* name_; // Library prefix name. 1395 RawString* name_; // Library prefix name.
1395 RawArray* imports_; // Libraries imported with this prefix. 1396 RawArray* imports_; // Libraries imported with this prefix.
1396 RawLibrary* importer_; // Library which declares this prefix. 1397 RawLibrary* importer_; // Library which declares this prefix.
1397 RawArray* dependent_code_; // Code that refers to deferred, unloaded 1398 RawArray* dependent_code_; // Code that refers to deferred, unloaded
1398 // library prefix. 1399 // library prefix.
1399 RawObject** to() { 1400 RawObject** to() {
1400 return reinterpret_cast<RawObject**>(&ptr()->dependent_code_); 1401 return reinterpret_cast<RawObject**>(&ptr()->dependent_code_);
1401 } 1402 }
1402 int32_t num_imports_; // Number of library entries in libraries_. 1403 uint16_t num_imports_; // Number of library entries in libraries_.
1403 bool is_deferred_load_; 1404 bool is_deferred_load_;
1404 bool is_loaded_; 1405 bool is_loaded_;
1405 }; 1406 };
1406 1407
1407 1408
1408 class RawAbstractType : public RawInstance { 1409 class RawAbstractType : public RawInstance {
1409 protected: 1410 protected:
1410 enum TypeState { 1411 enum TypeState {
1411 kAllocated, // Initial state. 1412 kAllocated, // Initial state.
1412 kResolved, // Type class and type arguments resolved. 1413 kResolved, // Type class and type arguments resolved.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 private: 1459 private:
1459 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter); 1460 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter);
1460 1461
1461 RawObject** from() { 1462 RawObject** from() {
1462 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_); 1463 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_);
1463 } 1464 }
1464 RawClass* parameterized_class_; 1465 RawClass* parameterized_class_;
1465 RawString* name_; 1466 RawString* name_;
1466 RawAbstractType* bound_; // ObjectType if no explicit bound specified. 1467 RawAbstractType* bound_; // ObjectType if no explicit bound specified.
1467 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); } 1468 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); }
1468 int32_t index_;
1469 int32_t token_pos_; 1469 int32_t token_pos_;
1470 int16_t index_;
1470 int8_t type_state_; 1471 int8_t type_state_;
1471 }; 1472 };
1472 1473
1473 1474
1474 class RawBoundedType : public RawAbstractType { 1475 class RawBoundedType : public RawAbstractType {
1475 private: 1476 private:
1476 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType); 1477 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType);
1477 1478
1478 RawObject** from() { 1479 RawObject** from() {
1479 return reinterpret_cast<RawObject**>(&ptr()->type_); 1480 return reinterpret_cast<RawObject**>(&ptr()->type_);
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2138 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2138 kTypedDataInt8ArrayViewCid + 15); 2139 kTypedDataInt8ArrayViewCid + 15);
2139 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2140 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2140 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2141 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2141 return (kNullCid - kTypedDataInt8ArrayCid); 2142 return (kNullCid - kTypedDataInt8ArrayCid);
2142 } 2143 }
2143 2144
2144 } // namespace dart 2145 } // namespace dart
2145 2146
2146 #endif // VM_RAW_OBJECT_H_ 2147 #endif // VM_RAW_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698