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

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

Issue 1318803002: Toward precompiled snapshots. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: READ_POINTERS Created 5 years, 3 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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 friend class Object; 576 friend class Object;
577 friend class OneByteString; // StoreSmi 577 friend class OneByteString; // StoreSmi
578 friend class RawExternalTypedData; 578 friend class RawExternalTypedData;
579 friend class RawInstructions; 579 friend class RawInstructions;
580 friend class RawInstance; 580 friend class RawInstance;
581 friend class RawTypedData; 581 friend class RawTypedData;
582 friend class Scavenger; 582 friend class Scavenger;
583 friend class ScavengerVisitor; 583 friend class ScavengerVisitor;
584 friend class SizeExcludingClassVisitor; // GetClassId 584 friend class SizeExcludingClassVisitor; // GetClassId
585 friend class RetainingPathVisitor; // GetClassId 585 friend class RetainingPathVisitor; // GetClassId
586 friend class InstructionsReader; // tags_ check
586 friend class SnapshotReader; 587 friend class SnapshotReader;
587 friend class SnapshotWriter; 588 friend class SnapshotWriter;
588 friend class String; 589 friend class String;
589 friend class TypedData; 590 friend class TypedData;
590 friend class TypedDataView; 591 friend class TypedDataView;
591 friend class WeakProperty; // StorePointer 592 friend class WeakProperty; // StorePointer
592 friend class Instance; // StorePointer 593 friend class Instance; // StorePointer
593 594
594 DISALLOW_ALLOCATION(); 595 DISALLOW_ALLOCATION();
595 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); 596 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject);
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 // Else, owner_ is a regular Dart Function. 992 // Else, owner_ is a regular Dart Function.
992 RawObject* owner_; // Function, Null, or a Class. 993 RawObject* owner_; // Function, Null, or a Class.
993 RawExceptionHandlers* exception_handlers_; 994 RawExceptionHandlers* exception_handlers_;
994 RawPcDescriptors* pc_descriptors_; 995 RawPcDescriptors* pc_descriptors_;
995 RawArray* deopt_info_array_; 996 RawArray* deopt_info_array_;
996 RawArray* static_calls_target_table_; // (code-offset, function, code). 997 RawArray* static_calls_target_table_; // (code-offset, function, code).
997 RawArray* stackmaps_; 998 RawArray* stackmaps_;
998 RawLocalVarDescriptors* var_descriptors_; 999 RawLocalVarDescriptors* var_descriptors_;
999 RawArray* inlined_metadata_; 1000 RawArray* inlined_metadata_;
1000 RawArray* comments_; 1001 RawArray* comments_;
1001 // If return_address_info_ is a Smi, it is the offset to the prologue. 1002 // If return_address_info_ is a Smi, it is the offset to the prologue.
siva 2015/09/01 20:58:49 The comment here says 'If return_address_info_' wh
rmacnak 2015/09/01 23:43:47 What choice is there other than return_address_met
1002 // Else, return_address_info_ is null. 1003 // Else, return_address_info_ is null.
1003 RawObject* return_address_metadata_; 1004 RawObject* return_address_metadata_;
1004 RawObject** to() { 1005 RawObject** to() {
1005 return reinterpret_cast<RawObject**>(&ptr()->comments_); 1006 return reinterpret_cast<RawObject**>(&ptr()->return_address_metadata_);
1006 } 1007 }
1007 uword entry_point_; 1008 uword entry_point_;
1008 1009
1009 // Compilation timestamp. 1010 // Compilation timestamp.
1010 int64_t compile_timestamp_; 1011 int64_t compile_timestamp_;
1011 1012
1012 // state_bits_ is a bitfield with three fields: 1013 // state_bits_ is a bitfield with three fields:
1013 // The optimized bit, the alive bit, and a count of the number of pointer 1014 // The optimized bit, the alive bit, and a count of the number of pointer
1014 // offsets. 1015 // offsets.
1015 // Alive: If true, the embedded object pointers will be visited during GC. 1016 // Alive: If true, the embedded object pointers will be visited during GC.
(...skipping 25 matching lines...) Expand all
1041 RawObject* raw_obj_; 1042 RawObject* raw_obj_;
1042 uword raw_value_; 1043 uword raw_value_;
1043 }; 1044 };
1044 }; 1045 };
1045 Entry* data() { OPEN_ARRAY_START(Entry, Entry); } 1046 Entry* data() { OPEN_ARRAY_START(Entry, Entry); }
1046 Entry const* data() const { OPEN_ARRAY_START(Entry, Entry); } 1047 Entry const* data() const { OPEN_ARRAY_START(Entry, Entry); }
1047 1048
1048 Entry* first_entry() { return &ptr()->data()[0]; } 1049 Entry* first_entry() { return &ptr()->data()[0]; }
1049 1050
1050 friend class Object; 1051 friend class Object;
1052 friend class SnapshotReader;
1051 }; 1053 };
1052 1054
1053 1055
1054 class RawInstructions : public RawObject { 1056 class RawInstructions : public RawObject {
1055 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); 1057 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions);
1056 1058
1057 RawObject** from() { 1059 RawObject** from() {
1058 return reinterpret_cast<RawObject**>(&ptr()->code_); 1060 return reinterpret_cast<RawObject**>(&ptr()->code_);
1059 } 1061 }
1060 RawCode* code_; 1062 RawCode* code_;
(...skipping 10 matching lines...) Expand all
1071 // code which iterates over dart frames is also called during GC and 1073 // code which iterates over dart frames is also called during GC and
1072 // is not allowed to create handles. 1074 // is not allowed to create handles.
1073 static bool ContainsPC(RawObject* raw_obj, uword pc); 1075 static bool ContainsPC(RawObject* raw_obj, uword pc);
1074 1076
1075 friend class RawCode; 1077 friend class RawCode;
1076 friend class RawFunction; 1078 friend class RawFunction;
1077 friend class Code; 1079 friend class Code;
1078 friend class StackFrame; 1080 friend class StackFrame;
1079 friend class MarkingVisitor; 1081 friend class MarkingVisitor;
1080 friend class Function; 1082 friend class Function;
1083 friend class InstructionsReader;
1081 }; 1084 };
1082 1085
1083 1086
1084 class RawPcDescriptors : public RawObject { 1087 class RawPcDescriptors : public RawObject {
1085 public: 1088 public:
1086 enum Kind { 1089 enum Kind {
1087 kDeopt = 1, // Deoptimization continuation point. 1090 kDeopt = 1, // Deoptimization continuation point.
1088 kIcCall = kDeopt << 1, // IC call. 1091 kIcCall = kDeopt << 1, // IC call.
1089 kUnoptStaticCall = kIcCall << 1, // Call to a known target via stub. 1092 kUnoptStaticCall = kIcCall << 1, // Call to a known target via stub.
1090 kRuntimeCall = kUnoptStaticCall << 1, // Runtime call. 1093 kRuntimeCall = kUnoptStaticCall << 1, // Runtime call.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 private: 1131 private:
1129 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); 1132 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors);
1130 1133
1131 int32_t length_; // Number of descriptors. 1134 int32_t length_; // Number of descriptors.
1132 1135
1133 // Variable length data follows here. 1136 // Variable length data follows here.
1134 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } 1137 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); }
1135 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); } 1138 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); }
1136 1139
1137 friend class Object; 1140 friend class Object;
1141 friend class SnapshotReader;
1138 }; 1142 };
1139 1143
1140 1144
1141 // Stackmap is an immutable representation of the layout of the stack at a 1145 // Stackmap is an immutable representation of the layout of the stack at a
1142 // PC. The stack map representation consists of a bit map which marks each 1146 // PC. The stack map representation consists of a bit map which marks each
1143 // live object index starting from the base of the frame. 1147 // live object index starting from the base of the frame.
1144 // 1148 //
1145 // The Stackmap also consists of a link to the code object corresponding to 1149 // The bit map representation is optimized for dense and small bit maps, without
1146 // the frame which the stack map is describing. The bit map representation 1150 // any upper bound.
1147 // is optimized for dense and small bit maps, without any upper bound.
1148 class RawStackmap : public RawObject { 1151 class RawStackmap : public RawObject {
1149 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); 1152 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap);
1150 1153
1151 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_ 1154 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_
1152 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or 1155 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or
1153 // as large as ~33 million entries. If that is sufficient, then these two 1156 // as large as ~33 million entries. If that is sufficient, then these two
1154 // fields can be merged into a BitField. 1157 // fields can be merged into a BitField.
1155 int32_t length_; // Length of payload, in bits. 1158 int32_t length_; // Length of payload, in bits.
1156 int32_t register_bit_count_; // Live register bits, included in length_. 1159 int32_t register_bit_count_; // Live register bits, included in length_.
1157 1160
1158 // Offset from code entry point corresponding to this stack map 1161 // Offset from code entry point corresponding to this stack map
1159 // representation. 1162 // representation.
1160 uint32_t pc_offset_; 1163 uint32_t pc_offset_;
1161 1164
1162 // Variable length data follows here (bitmap of the stack layout). 1165 // Variable length data follows here (bitmap of the stack layout).
1163 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1166 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1164 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); } 1167 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); }
1168
1169 friend class SnapshotReader;
1165 }; 1170 };
1166 1171
1167 1172
1168 class RawLocalVarDescriptors : public RawObject { 1173 class RawLocalVarDescriptors : public RawObject {
1169 public: 1174 public:
1170 enum VarInfoKind { 1175 enum VarInfoKind {
1171 kStackVar = 1, 1176 kStackVar = 1,
1172 kContextVar, 1177 kContextVar,
1173 kContextLevel, 1178 kContextLevel,
1174 kSavedCurrentContext, 1179 kSavedCurrentContext,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 RawObject** to(intptr_t num_entries) { 1234 RawObject** to(intptr_t num_entries) {
1230 return reinterpret_cast<RawObject**>(nameAddrAt(num_entries - 1)); 1235 return reinterpret_cast<RawObject**>(nameAddrAt(num_entries - 1));
1231 } 1236 }
1232 1237
1233 // Variable info with [num_entries_] entries. 1238 // Variable info with [num_entries_] entries.
1234 VarInfo* data() { 1239 VarInfo* data() {
1235 return reinterpret_cast<VarInfo*>(nameAddrAt(ptr()->num_entries_)); 1240 return reinterpret_cast<VarInfo*>(nameAddrAt(ptr()->num_entries_));
1236 } 1241 }
1237 1242
1238 friend class Object; 1243 friend class Object;
1244 friend class SnapshotReader;
1239 }; 1245 };
1240 1246
1241 1247
1242 class RawExceptionHandlers : public RawObject { 1248 class RawExceptionHandlers : public RawObject {
1243 public: 1249 public:
1244 // The index into the ExceptionHandlers table corresponds to 1250 // The index into the ExceptionHandlers table corresponds to
1245 // the try_index of the handler. 1251 // the try_index of the handler.
1246 struct HandlerInfo { 1252 struct HandlerInfo {
1247 uint32_t handler_pc_offset; // PC offset value of handler. 1253 uint32_t handler_pc_offset; // PC offset value of handler.
1248 int16_t outer_try_index; // Try block index of enclosing try block. 1254 int16_t outer_try_index; // Try block index of enclosing try block.
1249 int8_t needs_stacktrace; // True if a stacktrace is needed. 1255 int8_t needs_stacktrace; // True if a stacktrace is needed.
1250 int8_t has_catch_all; // Catches all exceptions. 1256 int8_t has_catch_all; // Catches all exceptions.
1251 }; 1257 };
1252 1258
1253 private: 1259 private:
1254 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); 1260 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers);
1255 1261
1256 // Number of exception handler entries. 1262 // Number of exception handler entries.
1257 int32_t num_entries_; 1263 int32_t num_entries_;
1258 1264
1259 // Array with [num_entries_] entries. Each entry is an array of all handled 1265 // Array with [num_entries_] entries. Each entry is an array of all handled
1260 // exception types. 1266 // exception types.
1261 RawArray* handled_types_data_; 1267 RawArray* handled_types_data_;
1262 1268
1263 // Exception handler info of length [num_entries_]. 1269 // Exception handler info of length [num_entries_].
1264 const HandlerInfo* data() const { OPEN_ARRAY_START(HandlerInfo, intptr_t); } 1270 const HandlerInfo* data() const { OPEN_ARRAY_START(HandlerInfo, intptr_t); }
1265 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); } 1271 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); }
1266 1272
1267 friend class Object; 1273 friend class Object;
1274 friend class SnapshotReader;
1268 }; 1275 };
1269 1276
1270 1277
1271 class RawContext : public RawObject { 1278 class RawContext : public RawObject {
1272 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); 1279 RAW_HEAP_OBJECT_IMPLEMENTATION(Context);
1273 1280
1274 int32_t num_variables_; 1281 int32_t num_variables_;
1275 1282
1276 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } 1283 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); }
1277 RawContext* parent_; 1284 RawContext* parent_;
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2202 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2196 kTypedDataInt8ArrayViewCid + 15); 2203 kTypedDataInt8ArrayViewCid + 15);
2197 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2204 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2198 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2205 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2199 return (kNullCid - kTypedDataInt8ArrayCid); 2206 return (kNullCid - kTypedDataInt8ArrayCid);
2200 } 2207 }
2201 2208
2202 } // namespace dart 2209 } // namespace dart
2203 2210
2204 #endif // VM_RAW_OBJECT_H_ 2211 #endif // VM_RAW_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698