| OLD | NEW |
| 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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 SkippedCodeFunctions; // StorePointer | 586 friend class SkippedCodeFunctions; // StorePointer |
| 587 friend class InstructionsReader; // tags_ check |
| 587 friend class SnapshotReader; | 588 friend class SnapshotReader; |
| 588 friend class SnapshotWriter; | 589 friend class SnapshotWriter; |
| 589 friend class String; | 590 friend class String; |
| 590 friend class TypedData; | 591 friend class TypedData; |
| 591 friend class TypedDataView; | 592 friend class TypedDataView; |
| 592 friend class WeakProperty; // StorePointer | 593 friend class WeakProperty; // StorePointer |
| 593 friend class Instance; // StorePointer | 594 friend class Instance; // StorePointer |
| 594 | 595 |
| 595 DISALLOW_ALLOCATION(); | 596 DISALLOW_ALLOCATION(); |
| 596 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); | 597 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 // Else, owner_ is a regular Dart Function. | 996 // Else, owner_ is a regular Dart Function. |
| 996 RawObject* owner_; // Function, Null, or a Class. | 997 RawObject* owner_; // Function, Null, or a Class. |
| 997 RawExceptionHandlers* exception_handlers_; | 998 RawExceptionHandlers* exception_handlers_; |
| 998 RawPcDescriptors* pc_descriptors_; | 999 RawPcDescriptors* pc_descriptors_; |
| 999 RawArray* deopt_info_array_; | 1000 RawArray* deopt_info_array_; |
| 1000 RawArray* static_calls_target_table_; // (code-offset, function, code). | 1001 RawArray* static_calls_target_table_; // (code-offset, function, code). |
| 1001 RawArray* stackmaps_; | 1002 RawArray* stackmaps_; |
| 1002 RawLocalVarDescriptors* var_descriptors_; | 1003 RawLocalVarDescriptors* var_descriptors_; |
| 1003 RawArray* inlined_metadata_; | 1004 RawArray* inlined_metadata_; |
| 1004 RawArray* comments_; | 1005 RawArray* comments_; |
| 1005 // If return_address_info_ is a Smi, it is the offset to the prologue. | 1006 // If return_address_metadata_ is a Smi, it is the offset to the prologue. |
| 1006 // Else, return_address_info_ is null. | 1007 // Else, return_address_metadata_ is null. |
| 1007 RawObject* return_address_metadata_; | 1008 RawObject* return_address_metadata_; |
| 1008 RawObject** to() { | 1009 RawObject** to() { |
| 1009 return reinterpret_cast<RawObject**>(&ptr()->comments_); | 1010 return reinterpret_cast<RawObject**>(&ptr()->return_address_metadata_); |
| 1010 } | 1011 } |
| 1011 uword entry_point_; | 1012 uword entry_point_; |
| 1012 | 1013 |
| 1013 // Compilation timestamp. | 1014 // Compilation timestamp. |
| 1014 int64_t compile_timestamp_; | 1015 int64_t compile_timestamp_; |
| 1015 | 1016 |
| 1016 // state_bits_ is a bitfield with three fields: | 1017 // state_bits_ is a bitfield with three fields: |
| 1017 // The optimized bit, the alive bit, and a count of the number of pointer | 1018 // The optimized bit, the alive bit, and a count of the number of pointer |
| 1018 // offsets. | 1019 // offsets. |
| 1019 // Alive: If true, the embedded object pointers will be visited during GC. | 1020 // Alive: If true, the embedded object pointers will be visited during GC. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1046 RawObject* raw_obj_; | 1047 RawObject* raw_obj_; |
| 1047 uword raw_value_; | 1048 uword raw_value_; |
| 1048 }; | 1049 }; |
| 1049 }; | 1050 }; |
| 1050 Entry* data() { OPEN_ARRAY_START(Entry, Entry); } | 1051 Entry* data() { OPEN_ARRAY_START(Entry, Entry); } |
| 1051 Entry const* data() const { OPEN_ARRAY_START(Entry, Entry); } | 1052 Entry const* data() const { OPEN_ARRAY_START(Entry, Entry); } |
| 1052 | 1053 |
| 1053 Entry* first_entry() { return &ptr()->data()[0]; } | 1054 Entry* first_entry() { return &ptr()->data()[0]; } |
| 1054 | 1055 |
| 1055 friend class Object; | 1056 friend class Object; |
| 1057 friend class SnapshotReader; |
| 1056 }; | 1058 }; |
| 1057 | 1059 |
| 1058 | 1060 |
| 1059 class RawInstructions : public RawObject { | 1061 class RawInstructions : public RawObject { |
| 1060 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); | 1062 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); |
| 1061 | 1063 |
| 1062 RawObject** from() { | 1064 RawObject** from() { |
| 1063 return reinterpret_cast<RawObject**>(&ptr()->code_); | 1065 return reinterpret_cast<RawObject**>(&ptr()->code_); |
| 1064 } | 1066 } |
| 1065 RawCode* code_; | 1067 RawCode* code_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1077 // is not allowed to create handles. | 1079 // is not allowed to create handles. |
| 1078 static bool ContainsPC(RawObject* raw_obj, uword pc); | 1080 static bool ContainsPC(RawObject* raw_obj, uword pc); |
| 1079 | 1081 |
| 1080 friend class RawCode; | 1082 friend class RawCode; |
| 1081 friend class RawFunction; | 1083 friend class RawFunction; |
| 1082 friend class Code; | 1084 friend class Code; |
| 1083 friend class StackFrame; | 1085 friend class StackFrame; |
| 1084 friend class MarkingVisitor; | 1086 friend class MarkingVisitor; |
| 1085 friend class SkippedCodeFunctions; | 1087 friend class SkippedCodeFunctions; |
| 1086 friend class Function; | 1088 friend class Function; |
| 1089 friend class InstructionsReader; |
| 1087 }; | 1090 }; |
| 1088 | 1091 |
| 1089 | 1092 |
| 1090 class RawPcDescriptors : public RawObject { | 1093 class RawPcDescriptors : public RawObject { |
| 1091 public: | 1094 public: |
| 1092 enum Kind { | 1095 enum Kind { |
| 1093 kDeopt = 1, // Deoptimization continuation point. | 1096 kDeopt = 1, // Deoptimization continuation point. |
| 1094 kIcCall = kDeopt << 1, // IC call. | 1097 kIcCall = kDeopt << 1, // IC call. |
| 1095 kUnoptStaticCall = kIcCall << 1, // Call to a known target via stub. | 1098 kUnoptStaticCall = kIcCall << 1, // Call to a known target via stub. |
| 1096 kRuntimeCall = kUnoptStaticCall << 1, // Runtime call. | 1099 kRuntimeCall = kUnoptStaticCall << 1, // Runtime call. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 private: | 1137 private: |
| 1135 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); | 1138 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); |
| 1136 | 1139 |
| 1137 int32_t length_; // Number of descriptors. | 1140 int32_t length_; // Number of descriptors. |
| 1138 | 1141 |
| 1139 // Variable length data follows here. | 1142 // Variable length data follows here. |
| 1140 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } | 1143 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } |
| 1141 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); } | 1144 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); } |
| 1142 | 1145 |
| 1143 friend class Object; | 1146 friend class Object; |
| 1147 friend class SnapshotReader; |
| 1144 }; | 1148 }; |
| 1145 | 1149 |
| 1146 | 1150 |
| 1147 // Stackmap is an immutable representation of the layout of the stack at a | 1151 // Stackmap is an immutable representation of the layout of the stack at a |
| 1148 // PC. The stack map representation consists of a bit map which marks each | 1152 // PC. The stack map representation consists of a bit map which marks each |
| 1149 // live object index starting from the base of the frame. | 1153 // live object index starting from the base of the frame. |
| 1150 // | 1154 // |
| 1151 // The Stackmap also consists of a link to the code object corresponding to | 1155 // The bit map representation is optimized for dense and small bit maps, without |
| 1152 // the frame which the stack map is describing. The bit map representation | 1156 // any upper bound. |
| 1153 // is optimized for dense and small bit maps, without any upper bound. | |
| 1154 class RawStackmap : public RawObject { | 1157 class RawStackmap : public RawObject { |
| 1155 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); | 1158 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); |
| 1156 | 1159 |
| 1157 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_ | 1160 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_ |
| 1158 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or | 1161 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or |
| 1159 // as large as ~33 million entries. If that is sufficient, then these two | 1162 // as large as ~33 million entries. If that is sufficient, then these two |
| 1160 // fields can be merged into a BitField. | 1163 // fields can be merged into a BitField. |
| 1161 int32_t length_; // Length of payload, in bits. | 1164 int32_t length_; // Length of payload, in bits. |
| 1162 int32_t register_bit_count_; // Live register bits, included in length_. | 1165 int32_t register_bit_count_; // Live register bits, included in length_. |
| 1163 | 1166 |
| 1164 // Offset from code entry point corresponding to this stack map | 1167 // Offset from code entry point corresponding to this stack map |
| 1165 // representation. | 1168 // representation. |
| 1166 uint32_t pc_offset_; | 1169 uint32_t pc_offset_; |
| 1167 | 1170 |
| 1168 // Variable length data follows here (bitmap of the stack layout). | 1171 // Variable length data follows here (bitmap of the stack layout). |
| 1169 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } | 1172 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } |
| 1170 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); } | 1173 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); } |
| 1174 |
| 1175 friend class SnapshotReader; |
| 1171 }; | 1176 }; |
| 1172 | 1177 |
| 1173 | 1178 |
| 1174 class RawLocalVarDescriptors : public RawObject { | 1179 class RawLocalVarDescriptors : public RawObject { |
| 1175 public: | 1180 public: |
| 1176 enum VarInfoKind { | 1181 enum VarInfoKind { |
| 1177 kStackVar = 1, | 1182 kStackVar = 1, |
| 1178 kContextVar, | 1183 kContextVar, |
| 1179 kContextLevel, | 1184 kContextLevel, |
| 1180 kSavedCurrentContext, | 1185 kSavedCurrentContext, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 RawObject** to(intptr_t num_entries) { | 1240 RawObject** to(intptr_t num_entries) { |
| 1236 return reinterpret_cast<RawObject**>(nameAddrAt(num_entries - 1)); | 1241 return reinterpret_cast<RawObject**>(nameAddrAt(num_entries - 1)); |
| 1237 } | 1242 } |
| 1238 | 1243 |
| 1239 // Variable info with [num_entries_] entries. | 1244 // Variable info with [num_entries_] entries. |
| 1240 VarInfo* data() { | 1245 VarInfo* data() { |
| 1241 return reinterpret_cast<VarInfo*>(nameAddrAt(ptr()->num_entries_)); | 1246 return reinterpret_cast<VarInfo*>(nameAddrAt(ptr()->num_entries_)); |
| 1242 } | 1247 } |
| 1243 | 1248 |
| 1244 friend class Object; | 1249 friend class Object; |
| 1250 friend class SnapshotReader; |
| 1245 }; | 1251 }; |
| 1246 | 1252 |
| 1247 | 1253 |
| 1248 class RawExceptionHandlers : public RawObject { | 1254 class RawExceptionHandlers : public RawObject { |
| 1249 public: | 1255 public: |
| 1250 // The index into the ExceptionHandlers table corresponds to | 1256 // The index into the ExceptionHandlers table corresponds to |
| 1251 // the try_index of the handler. | 1257 // the try_index of the handler. |
| 1252 struct HandlerInfo { | 1258 struct HandlerInfo { |
| 1253 uint32_t handler_pc_offset; // PC offset value of handler. | 1259 uint32_t handler_pc_offset; // PC offset value of handler. |
| 1254 int16_t outer_try_index; // Try block index of enclosing try block. | 1260 int16_t outer_try_index; // Try block index of enclosing try block. |
| 1255 int8_t needs_stacktrace; // True if a stacktrace is needed. | 1261 int8_t needs_stacktrace; // True if a stacktrace is needed. |
| 1256 int8_t has_catch_all; // Catches all exceptions. | 1262 int8_t has_catch_all; // Catches all exceptions. |
| 1257 }; | 1263 }; |
| 1258 | 1264 |
| 1259 private: | 1265 private: |
| 1260 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); | 1266 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); |
| 1261 | 1267 |
| 1262 // Number of exception handler entries. | 1268 // Number of exception handler entries. |
| 1263 int32_t num_entries_; | 1269 int32_t num_entries_; |
| 1264 | 1270 |
| 1265 // Array with [num_entries_] entries. Each entry is an array of all handled | 1271 // Array with [num_entries_] entries. Each entry is an array of all handled |
| 1266 // exception types. | 1272 // exception types. |
| 1267 RawArray* handled_types_data_; | 1273 RawArray* handled_types_data_; |
| 1268 | 1274 |
| 1269 // Exception handler info of length [num_entries_]. | 1275 // Exception handler info of length [num_entries_]. |
| 1270 const HandlerInfo* data() const { OPEN_ARRAY_START(HandlerInfo, intptr_t); } | 1276 const HandlerInfo* data() const { OPEN_ARRAY_START(HandlerInfo, intptr_t); } |
| 1271 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); } | 1277 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); } |
| 1272 | 1278 |
| 1273 friend class Object; | 1279 friend class Object; |
| 1280 friend class SnapshotReader; |
| 1274 }; | 1281 }; |
| 1275 | 1282 |
| 1276 | 1283 |
| 1277 class RawContext : public RawObject { | 1284 class RawContext : public RawObject { |
| 1278 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); | 1285 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); |
| 1279 | 1286 |
| 1280 int32_t num_variables_; | 1287 int32_t num_variables_; |
| 1281 | 1288 |
| 1282 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } | 1289 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } |
| 1283 RawContext* parent_; | 1290 RawContext* parent_; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 return &(reinterpret_cast<const VariableDesc*>(data())[index]); | 1335 return &(reinterpret_cast<const VariableDesc*>(data())[index]); |
| 1329 } | 1336 } |
| 1330 RawObject** to(intptr_t num_vars) { | 1337 RawObject** to(intptr_t num_vars) { |
| 1331 uword end = reinterpret_cast<uword>(ptr()->VariableDescAddr(num_vars)); | 1338 uword end = reinterpret_cast<uword>(ptr()->VariableDescAddr(num_vars)); |
| 1332 // 'end' is the address just beyond the last descriptor, so step back. | 1339 // 'end' is the address just beyond the last descriptor, so step back. |
| 1333 return reinterpret_cast<RawObject**>(end - kWordSize); | 1340 return reinterpret_cast<RawObject**>(end - kWordSize); |
| 1334 } | 1341 } |
| 1335 | 1342 |
| 1336 friend class Object; | 1343 friend class Object; |
| 1337 friend class RawClosureData; | 1344 friend class RawClosureData; |
| 1345 friend class SnapshotReader; |
| 1338 }; | 1346 }; |
| 1339 | 1347 |
| 1340 | 1348 |
| 1341 class RawICData : public RawObject { | 1349 class RawICData : public RawObject { |
| 1342 RAW_HEAP_OBJECT_IMPLEMENTATION(ICData); | 1350 RAW_HEAP_OBJECT_IMPLEMENTATION(ICData); |
| 1343 | 1351 |
| 1344 RawObject** from() { | 1352 RawObject** from() { |
| 1345 return reinterpret_cast<RawObject**>(&ptr()->owner_); | 1353 return reinterpret_cast<RawObject**>(&ptr()->owner_); |
| 1346 } | 1354 } |
| 1347 RawFunction* owner_; // Parent/calling function of this IC. | 1355 RawFunction* owner_; // Parent/calling function of this IC. |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2213 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2206 kTypedDataInt8ArrayViewCid + 15); | 2214 kTypedDataInt8ArrayViewCid + 15); |
| 2207 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2215 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2208 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2216 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2209 return (kNullCid - kTypedDataInt8ArrayCid); | 2217 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2210 } | 2218 } |
| 2211 | 2219 |
| 2212 } // namespace dart | 2220 } // namespace dart |
| 2213 | 2221 |
| 2214 #endif // VM_RAW_OBJECT_H_ | 2222 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |