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

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

Issue 2032153003: Use clustered serialization for full snapshots. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: round2 Created 4 years, 5 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_store.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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 #define RAW_HEAP_OBJECT_IMPLEMENTATION(object) \ 243 #define RAW_HEAP_OBJECT_IMPLEMENTATION(object) \
244 private: \ 244 private: \
245 RAW_OBJECT_IMPLEMENTATION(object); \ 245 RAW_OBJECT_IMPLEMENTATION(object); \
246 Raw##object* ptr() const { \ 246 Raw##object* ptr() const { \
247 ASSERT(IsHeapObject()); \ 247 ASSERT(IsHeapObject()); \
248 return reinterpret_cast<Raw##object*>( \ 248 return reinterpret_cast<Raw##object*>( \
249 reinterpret_cast<uword>(this) - kHeapObjectTag); \ 249 reinterpret_cast<uword>(this) - kHeapObjectTag); \
250 } \ 250 } \
251 SNAPSHOT_WRITER_SUPPORT() \ 251 SNAPSHOT_WRITER_SUPPORT() \
252 HEAP_PROFILER_SUPPORT() \ 252 HEAP_PROFILER_SUPPORT() \
253 friend class object##SerializationCluster; \
254 friend class object##DeserializationCluster; \
253 255
254 // RawObject is the base class of all raw objects, even though it carries the 256 // RawObject is the base class of all raw objects; even though it carries the
255 // class_ field not all raw objects are allocated in the heap and thus cannot 257 // tags_ field not all raw objects are allocated in the heap and thus cannot
256 // be dereferenced (e.g. RawSmi). 258 // be dereferenced (e.g. RawSmi).
257 class RawObject { 259 class RawObject {
258 public: 260 public:
259 // The tags field which is a part of the object header uses the following 261 // The tags field which is a part of the object header uses the following
260 // bit fields for storing tags. 262 // bit fields for storing tags.
261 enum TagBits { 263 enum TagBits {
262 kMarkBit = 0, 264 kMarkBit = 0,
263 kCanonicalBit = 1, 265 kCanonicalBit = 1,
264 kVMHeapObjectBit = 2, 266 kVMHeapObjectBit = 2,
265 kRememberedBit = 3, 267 kRememberedBit = 3,
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 VerifiedMemory::Write(const_cast<RawSmi**>(addr), value); 604 VerifiedMemory::Write(const_cast<RawSmi**>(addr), value);
603 } 605 }
604 606
605 #if defined(DEBUG) 607 #if defined(DEBUG)
606 static void ValidateOverwrittenPointer(RawObject* raw); 608 static void ValidateOverwrittenPointer(RawObject* raw);
607 static void ValidateOverwrittenSmi(RawSmi* raw); 609 static void ValidateOverwrittenSmi(RawSmi* raw);
608 #endif // DEBUG 610 #endif // DEBUG
609 611
610 friend class Api; 612 friend class Api;
611 friend class ApiMessageReader; // GetClassId 613 friend class ApiMessageReader; // GetClassId
614 friend class Serializer; // GetClassId
612 friend class Array; 615 friend class Array;
613 friend class Bigint; 616 friend class Bigint;
614 friend class ByteBuffer; 617 friend class ByteBuffer;
615 friend class Closure; 618 friend class Closure;
616 friend class Code; 619 friend class Code;
617 friend class Double; 620 friend class Double;
618 friend class ForwardPointersVisitor; // StorePointer 621 friend class ForwardPointersVisitor; // StorePointer
619 friend class FreeListElement; 622 friend class FreeListElement;
620 friend class Function; 623 friend class Function;
621 friend class GCMarker; 624 friend class GCMarker;
(...skipping 15 matching lines...) Expand all
637 friend class Scavenger; 640 friend class Scavenger;
638 friend class ScavengerVisitor; 641 friend class ScavengerVisitor;
639 friend class SizeExcludingClassVisitor; // GetClassId 642 friend class SizeExcludingClassVisitor; // GetClassId
640 friend class InstanceAccumulator; // GetClassId 643 friend class InstanceAccumulator; // GetClassId
641 friend class RetainingPathVisitor; // GetClassId 644 friend class RetainingPathVisitor; // GetClassId
642 friend class SkippedCodeFunctions; // StorePointer 645 friend class SkippedCodeFunctions; // StorePointer
643 friend class InstructionsReader; // tags_ check 646 friend class InstructionsReader; // tags_ check
644 friend class AssemblyInstructionsWriter; 647 friend class AssemblyInstructionsWriter;
645 friend class BlobInstructionsWriter; 648 friend class BlobInstructionsWriter;
646 friend class SnapshotReader; 649 friend class SnapshotReader;
650 friend class Deserializer;
647 friend class SnapshotWriter; 651 friend class SnapshotWriter;
648 friend class String; 652 friend class String;
649 friend class Type; // GetClassId 653 friend class Type; // GetClassId
650 friend class TypedData; 654 friend class TypedData;
651 friend class TypedDataView; 655 friend class TypedDataView;
652 friend class WeakProperty; // StorePointer 656 friend class WeakProperty; // StorePointer
653 friend class Instance; // StorePointer 657 friend class Instance; // StorePointer
654 friend class StackFrame; // GetCodeObject assertion. 658 friend class StackFrame; // GetCodeObject assertion.
655 friend class CodeLookupTableBuilder; // profiler 659 friend class CodeLookupTableBuilder; // profiler
656 friend class NativeEntry; // GetClassId 660 friend class NativeEntry; // GetClassId
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 int16_t num_own_type_arguments_; // Number of non-overlapping type arguments. 727 int16_t num_own_type_arguments_; // Number of non-overlapping type arguments.
724 uint16_t num_native_fields_; // Number of native fields in class. 728 uint16_t num_native_fields_; // Number of native fields in class.
725 uint16_t state_bits_; 729 uint16_t state_bits_;
726 730
727 friend class Instance; 731 friend class Instance;
728 friend class Isolate; 732 friend class Isolate;
729 friend class Object; 733 friend class Object;
730 friend class RawInstance; 734 friend class RawInstance;
731 friend class RawInstructions; 735 friend class RawInstructions;
732 friend class SnapshotReader; 736 friend class SnapshotReader;
737 friend class InstanceSerializationCluster;
733 }; 738 };
734 739
735 740
736 class RawUnresolvedClass : public RawObject { 741 class RawUnresolvedClass : public RawObject {
737 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); 742 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass);
738 743
739 RawObject** from() { 744 RawObject** from() {
740 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_); 745 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_);
741 } 746 }
742 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident. 747 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 kGeneratorBit = 0x2, 827 kGeneratorBit = 0x2,
823 kAsync = kAsyncBit, 828 kAsync = kAsyncBit,
824 kSyncGen = kGeneratorBit, 829 kSyncGen = kGeneratorBit,
825 kAsyncGen = kAsyncBit | kGeneratorBit, 830 kAsyncGen = kAsyncBit | kGeneratorBit,
826 }; 831 };
827 832
828 private: 833 private:
829 // So that the SkippedCodeFunctions::DetachCode can null out the code fields. 834 // So that the SkippedCodeFunctions::DetachCode can null out the code fields.
830 friend class SkippedCodeFunctions; 835 friend class SkippedCodeFunctions;
831 friend class Class; 836 friend class Class;
837
832 RAW_HEAP_OBJECT_IMPLEMENTATION(Function); 838 RAW_HEAP_OBJECT_IMPLEMENTATION(Function);
839
833 static bool ShouldVisitCode(RawCode* raw_code); 840 static bool ShouldVisitCode(RawCode* raw_code);
834 static bool CheckUsageCounter(RawFunction* raw_fun); 841 static bool CheckUsageCounter(RawFunction* raw_fun);
835 842
836 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } 843 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); }
837 RawString* name_; 844 RawString* name_;
838 RawObject* owner_; // Class or patch class or mixin class 845 RawObject* owner_; // Class or patch class or mixin class
839 // where this function is defined. 846 // where this function is defined.
840 RawAbstractType* result_type_; 847 RawAbstractType* result_type_;
841 RawArray* parameter_types_; 848 RawArray* parameter_types_;
842 RawArray* parameter_names_; 849 RawArray* parameter_names_;
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } 1161 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); }
1155 const int32_t* data() const { OPEN_ARRAY_START(int32_t, int32_t); } 1162 const int32_t* data() const { OPEN_ARRAY_START(int32_t, int32_t); }
1156 1163
1157 static bool ContainsPC(RawObject* raw_obj, uword pc); 1164 static bool ContainsPC(RawObject* raw_obj, uword pc);
1158 1165
1159 friend class Function; 1166 friend class Function;
1160 template<bool> friend class MarkingVisitorBase; 1167 template<bool> friend class MarkingVisitorBase;
1161 friend class SkippedCodeFunctions; 1168 friend class SkippedCodeFunctions;
1162 friend class StackFrame; 1169 friend class StackFrame;
1163 friend class Profiler; 1170 friend class Profiler;
1171 friend class FunctionDeserializationCluster;
1164 }; 1172 };
1165 1173
1166 1174
1167 class RawObjectPool : public RawObject { 1175 class RawObjectPool : public RawObject {
1168 RAW_HEAP_OBJECT_IMPLEMENTATION(ObjectPool); 1176 RAW_HEAP_OBJECT_IMPLEMENTATION(ObjectPool);
1169 1177
1170 intptr_t length_; 1178 intptr_t length_;
1171 RawTypedData* info_array_; 1179 RawTypedData* info_array_;
1172 1180
1173 struct Entry { 1181 struct Entry {
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 1851
1844 class RawOneByteString : public RawString { 1852 class RawOneByteString : public RawString {
1845 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); 1853 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString);
1846 1854
1847 // Variable length data follows here. 1855 // Variable length data follows here.
1848 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1856 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1849 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); } 1857 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); }
1850 1858
1851 friend class ApiMessageReader; 1859 friend class ApiMessageReader;
1852 friend class SnapshotReader; 1860 friend class SnapshotReader;
1861 friend class RODataSerializationCluster;
1853 }; 1862 };
1854 1863
1855 1864
1856 class RawTwoByteString : public RawString { 1865 class RawTwoByteString : public RawString {
1857 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); 1866 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString);
1858 1867
1859 // Variable length data follows here. 1868 // Variable length data follows here.
1860 uint16_t* data() { OPEN_ARRAY_START(uint16_t, uint16_t); } 1869 uint16_t* data() { OPEN_ARRAY_START(uint16_t, uint16_t); }
1861 const uint16_t* data() const { OPEN_ARRAY_START(uint16_t, uint16_t); } 1870 const uint16_t* data() const { OPEN_ARRAY_START(uint16_t, uint16_t); }
1862 1871
1863 friend class SnapshotReader; 1872 friend class SnapshotReader;
1873 friend class RODataSerializationCluster;
1864 }; 1874 };
1865 1875
1866 1876
1867 template<typename T> 1877 template<typename T>
1868 class ExternalStringData { 1878 class ExternalStringData {
1869 public: 1879 public:
1870 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : 1880 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) :
1871 data_(data), peer_(peer), callback_(callback) { 1881 data_(data), peer_(peer), callback_(callback) {
1872 } 1882 }
1873 ~ExternalStringData() { 1883 ~ExternalStringData() {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1929 } 1939 }
1930 RawTypeArguments* type_arguments_; 1940 RawTypeArguments* type_arguments_;
1931 RawSmi* length_; 1941 RawSmi* length_;
1932 // Variable length data follows here. 1942 // Variable length data follows here.
1933 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); } 1943 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); }
1934 RawObject* const* data() const { OPEN_ARRAY_START(RawObject*, RawObject*); } 1944 RawObject* const* data() const { OPEN_ARRAY_START(RawObject*, RawObject*); }
1935 RawObject** to(intptr_t length) { 1945 RawObject** to(intptr_t length) {
1936 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); 1946 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]);
1937 } 1947 }
1938 1948
1949 friend class LinkedHashMapSerializationCluster;
1950 friend class LinkedHashMapDeserializationCluster;
1951 friend class Deserializer;
1939 friend class RawCode; 1952 friend class RawCode;
1940 friend class RawImmutableArray; 1953 friend class RawImmutableArray;
1941 friend class SnapshotReader; 1954 friend class SnapshotReader;
1942 friend class GrowableObjectArray; 1955 friend class GrowableObjectArray;
1943 friend class LinkedHashMap; 1956 friend class LinkedHashMap;
1944 friend class RawLinkedHashMap; 1957 friend class RawLinkedHashMap;
1945 friend class Object; 1958 friend class Object;
1946 friend class ICData; // For high performance access. 1959 friend class ICData; // For high performance access.
1947 friend class SubtypeTestCache; // For high performance access. 1960 friend class SubtypeTestCache; // For high performance access.
1948 }; 1961 };
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 RawTypeArguments* type_arguments_; 1994 RawTypeArguments* type_arguments_;
1982 RawTypedData* index_; 1995 RawTypedData* index_;
1983 RawSmi* hash_mask_; 1996 RawSmi* hash_mask_;
1984 RawArray* data_; 1997 RawArray* data_;
1985 RawSmi* used_data_; 1998 RawSmi* used_data_;
1986 RawSmi* deleted_keys_; 1999 RawSmi* deleted_keys_;
1987 RawObject** to() { 2000 RawObject** to() {
1988 return reinterpret_cast<RawObject**>(&ptr()->deleted_keys_); 2001 return reinterpret_cast<RawObject**>(&ptr()->deleted_keys_);
1989 } 2002 }
1990 2003
1991
1992 friend class SnapshotReader; 2004 friend class SnapshotReader;
1993 }; 2005 };
1994 2006
1995 2007
1996 class RawFloat32x4 : public RawInstance { 2008 class RawFloat32x4 : public RawInstance {
1997 RAW_HEAP_OBJECT_IMPLEMENTATION(Float32x4); 2009 RAW_HEAP_OBJECT_IMPLEMENTATION(Float32x4);
1998 2010
1999 ALIGN8 float value_[4]; 2011 ALIGN8 float value_[4];
2000 2012
2001 friend class SnapshotReader; 2013 friend class SnapshotReader;
2014
2002 public: 2015 public:
2003 float x() const { return value_[0]; } 2016 float x() const { return value_[0]; }
2004 float y() const { return value_[1]; } 2017 float y() const { return value_[1]; }
2005 float z() const { return value_[2]; } 2018 float z() const { return value_[2]; }
2006 float w() const { return value_[3]; } 2019 float w() const { return value_[3]; }
2007 }; 2020 };
2008 COMPILE_ASSERT(sizeof(RawFloat32x4) == 24); 2021 COMPILE_ASSERT(sizeof(RawFloat32x4) == 24);
2009 2022
2010 2023
2011 class RawInt32x4 : public RawInstance { 2024 class RawInt32x4 : public RawInstance {
2012 RAW_HEAP_OBJECT_IMPLEMENTATION(Int32x4); 2025 RAW_HEAP_OBJECT_IMPLEMENTATION(Int32x4);
2013 2026
2014 ALIGN8 int32_t value_[4]; 2027 ALIGN8 int32_t value_[4];
2015 2028
2016 friend class SnapshotReader; 2029 friend class SnapshotReader;
2030
2017 public: 2031 public:
2018 int32_t x() const { return value_[0]; } 2032 int32_t x() const { return value_[0]; }
2019 int32_t y() const { return value_[1]; } 2033 int32_t y() const { return value_[1]; }
2020 int32_t z() const { return value_[2]; } 2034 int32_t z() const { return value_[2]; }
2021 int32_t w() const { return value_[3]; } 2035 int32_t w() const { return value_[3]; }
2022 }; 2036 };
2023 COMPILE_ASSERT(sizeof(RawInt32x4) == 24); 2037 COMPILE_ASSERT(sizeof(RawInt32x4) == 24);
2024 2038
2025 2039
2026 class RawFloat64x2 : public RawInstance { 2040 class RawFloat64x2 : public RawInstance {
2027 RAW_HEAP_OBJECT_IMPLEMENTATION(Float64x2); 2041 RAW_HEAP_OBJECT_IMPLEMENTATION(Float64x2);
2028 2042
2029 ALIGN8 double value_[2]; 2043 ALIGN8 double value_[2];
2030 2044
2031 friend class SnapshotReader; 2045 friend class SnapshotReader;
2046
2032 public: 2047 public:
2033 double x() const { return value_[0]; } 2048 double x() const { return value_[0]; }
2034 double y() const { return value_[1]; } 2049 double y() const { return value_[1]; }
2035 }; 2050 };
2036 COMPILE_ASSERT(sizeof(RawFloat64x2) == 24); 2051 COMPILE_ASSERT(sizeof(RawFloat64x2) == 24);
2037 2052
2038 2053
2039 // Define an aliases for intptr_t. 2054 // Define an aliases for intptr_t.
2040 #if defined(ARCH_IS_32_BIT) 2055 #if defined(ARCH_IS_32_BIT)
2041 #define kIntPtrCid kTypedDataInt32ArrayCid 2056 #define kIntPtrCid kTypedDataInt32ArrayCid
(...skipping 16 matching lines...) Expand all
2058 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 2073 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
2059 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); } 2074 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); }
2060 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 2075 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
2061 2076
2062 friend class Api; 2077 friend class Api;
2063 friend class Object; 2078 friend class Object;
2064 friend class Instance; 2079 friend class Instance;
2065 friend class SnapshotReader; 2080 friend class SnapshotReader;
2066 friend class ObjectPool; 2081 friend class ObjectPool;
2067 friend class RawObjectPool; 2082 friend class RawObjectPool;
2083 friend class ObjectPoolSerializationCluster;
2084 friend class ObjectPoolDeserializationCluster;
2068 }; 2085 };
2069 2086
2070 2087
2071 class RawExternalTypedData : public RawInstance { 2088 class RawExternalTypedData : public RawInstance {
2072 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData); 2089 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData);
2073 2090
2074 protected: 2091 protected:
2075 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 2092 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
2076 RawSmi* length_; 2093 RawSmi* length_;
2077 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 2094 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2429 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2446 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2430 kTypedDataInt8ArrayViewCid + 15); 2447 kTypedDataInt8ArrayViewCid + 15);
2431 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2448 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2432 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2449 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2433 return (kNullCid - kTypedDataInt8ArrayCid); 2450 return (kNullCid - kTypedDataInt8ArrayCid);
2434 } 2451 }
2435 2452
2436 } // namespace dart 2453 } // namespace dart
2437 2454
2438 #endif // VM_RAW_OBJECT_H_ 2455 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object_store.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698