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

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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object_snapshot.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_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 uint16_t id_; // Class Id, also index in the class table.
rmacnak 2015/06/02 21:04:11 Limited by object header
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 RawGrowableObjectArray* metadata_; // Metadata on classes, methods etc. 908 RawGrowableObjectArray* metadata_; // Metadata on classes, methods etc.
909 RawArray* anonymous_classes_; // Classes containing top-level elements. 909 RawArray* anonymous_classes_; // Classes containing top-level elements.
910 RawArray* imports_; // List of Namespaces imported without prefix. 910 RawArray* imports_; // List of Namespaces imported without prefix.
911 RawArray* exports_; // List of re-exported Namespaces. 911 RawArray* exports_; // List of re-exported Namespaces.
912 RawArray* loaded_scripts_; // Array of scripts loaded in this library. 912 RawArray* loaded_scripts_; // Array of scripts loaded in this library.
913 RawInstance* load_error_; // Error iff load_state_ == kLoadError. 913 RawInstance* load_error_; // Error iff load_state_ == kLoadError.
914 RawObject** to() { 914 RawObject** to() {
915 return reinterpret_cast<RawObject**>(&ptr()->load_error_); 915 return reinterpret_cast<RawObject**>(&ptr()->load_error_);
916 } 916 }
917 917
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. 918 Dart_NativeEntryResolver native_entry_resolver_; // Resolves natives.
922 Dart_NativeEntrySymbol native_entry_symbol_resolver_; 919 Dart_NativeEntrySymbol native_entry_symbol_resolver_;
920 uint16_t index_; // Library id number.
rmacnak 2015/06/02 21:04:11 Limited by number of classes
921 uint16_t num_imports_; // Number of entries in imports_.
922 uint16_t num_anonymous_; // Number of entries in anonymous_classes_.
923 int8_t load_state_; // Of type LibraryState.
923 bool corelib_imported_; 924 bool corelib_imported_;
924 bool is_dart_scheme_; 925 bool is_dart_scheme_;
925 bool debuggable_; // True if debugger can stop in library. 926 bool debuggable_; // True if debugger can stop in library.
926 int8_t load_state_; // Of type LibraryState.
927 927
928 friend class Isolate; 928 friend class Isolate;
929 }; 929 };
930 930
931 931
932 class RawNamespace : public RawObject { 932 class RawNamespace : public RawObject {
933 RAW_HEAP_OBJECT_IMPLEMENTATION(Namespace); 933 RAW_HEAP_OBJECT_IMPLEMENTATION(Namespace);
934 934
935 RawObject** from() { 935 RawObject** from() {
936 return reinterpret_cast<RawObject**>(&ptr()->library_); 936 return reinterpret_cast<RawObject**>(&ptr()->library_);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 1392
1393 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } 1393 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); }
1394 RawString* name_; // Library prefix name. 1394 RawString* name_; // Library prefix name.
1395 RawArray* imports_; // Libraries imported with this prefix. 1395 RawArray* imports_; // Libraries imported with this prefix.
1396 RawLibrary* importer_; // Library which declares this prefix. 1396 RawLibrary* importer_; // Library which declares this prefix.
1397 RawArray* dependent_code_; // Code that refers to deferred, unloaded 1397 RawArray* dependent_code_; // Code that refers to deferred, unloaded
1398 // library prefix. 1398 // library prefix.
1399 RawObject** to() { 1399 RawObject** to() {
1400 return reinterpret_cast<RawObject**>(&ptr()->dependent_code_); 1400 return reinterpret_cast<RawObject**>(&ptr()->dependent_code_);
1401 } 1401 }
1402 int32_t num_imports_; // Number of library entries in libraries_. 1402 int16_t num_imports_; // Number of library entries in libraries_.
1403 bool is_deferred_load_; 1403 bool is_deferred_load_;
1404 bool is_loaded_; 1404 bool is_loaded_;
1405 }; 1405 };
1406 1406
1407 1407
1408 class RawAbstractType : public RawInstance { 1408 class RawAbstractType : public RawInstance {
1409 protected: 1409 protected:
1410 enum TypeState { 1410 enum TypeState {
1411 kAllocated, // Initial state. 1411 kAllocated, // Initial state.
1412 kResolved, // Type class and type arguments resolved. 1412 kResolved, // Type class and type arguments resolved.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 private: 1458 private:
1459 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter); 1459 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter);
1460 1460
1461 RawObject** from() { 1461 RawObject** from() {
1462 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_); 1462 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_);
1463 } 1463 }
1464 RawClass* parameterized_class_; 1464 RawClass* parameterized_class_;
1465 RawString* name_; 1465 RawString* name_;
1466 RawAbstractType* bound_; // ObjectType if no explicit bound specified. 1466 RawAbstractType* bound_; // ObjectType if no explicit bound specified.
1467 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); } 1467 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); }
1468 int32_t index_;
1469 int32_t token_pos_; 1468 int32_t token_pos_;
1469 int16_t index_;
rmacnak 2015/06/02 21:04:11 Limited by num_type_arguments_ in RawClass
1470 int8_t type_state_; 1470 int8_t type_state_;
1471 }; 1471 };
1472 1472
1473 1473
1474 class RawBoundedType : public RawAbstractType { 1474 class RawBoundedType : public RawAbstractType {
1475 private: 1475 private:
1476 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType); 1476 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType);
1477 1477
1478 RawObject** from() { 1478 RawObject** from() {
1479 return reinterpret_cast<RawObject**>(&ptr()->type_); 1479 return reinterpret_cast<RawObject**>(&ptr()->type_);
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2136 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2137 kTypedDataInt8ArrayViewCid + 15); 2137 kTypedDataInt8ArrayViewCid + 15);
2138 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2138 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2139 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2139 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2140 return (kNullCid - kTypedDataInt8ArrayCid); 2140 return (kNullCid - kTypedDataInt8ArrayCid);
2141 } 2141 }
2142 2142
2143 } // namespace dart 2143 } // namespace dart
2144 2144
2145 #endif // VM_RAW_OBJECT_H_ 2145 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698