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

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

Issue 612133004: Write barrier audit: const raw_ptr() (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.cc ('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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 #define RAW_OBJECT_IMPLEMENTATION(object) \ 210 #define RAW_OBJECT_IMPLEMENTATION(object) \
211 private: /* NOLINT */ \ 211 private: /* NOLINT */ \
212 VISITOR_SUPPORT(object) \ 212 VISITOR_SUPPORT(object) \
213 friend class object; \ 213 friend class object; \
214 friend class RawObject; \ 214 friend class RawObject; \
215 friend class Heap; \ 215 friend class Heap; \
216 DISALLOW_ALLOCATION(); \ 216 DISALLOW_ALLOCATION(); \
217 DISALLOW_IMPLICIT_CONSTRUCTORS(Raw##object) 217 DISALLOW_IMPLICIT_CONSTRUCTORS(Raw##object)
218 218
219 // TODO(koda): Make ptr() return const*, like Object::raw_ptr().
219 #define RAW_HEAP_OBJECT_IMPLEMENTATION(object) \ 220 #define RAW_HEAP_OBJECT_IMPLEMENTATION(object) \
220 private: \ 221 private: \
221 RAW_OBJECT_IMPLEMENTATION(object); \ 222 RAW_OBJECT_IMPLEMENTATION(object); \
222 Raw##object* ptr() const { \ 223 Raw##object* ptr() const { \
223 ASSERT(IsHeapObject()); \ 224 ASSERT(IsHeapObject()); \
224 return reinterpret_cast<Raw##object*>( \ 225 return reinterpret_cast<Raw##object*>( \
225 reinterpret_cast<uword>(this) - kHeapObjectTag); \ 226 reinterpret_cast<uword>(this) - kHeapObjectTag); \
226 } \ 227 } \
227 SNAPSHOT_WRITER_SUPPORT() \ 228 SNAPSHOT_WRITER_SUPPORT() \
228 HEAP_PROFILER_SUPPORT() \ 229 HEAP_PROFILER_SUPPORT() \
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 452
452 class RememberedBit : public BitField<bool, kRememberedBit, 1> {}; 453 class RememberedBit : public BitField<bool, kRememberedBit, 1> {};
453 454
454 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {}; 455 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {};
455 456
456 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {}; 457 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {};
457 458
458 class ReservedBits : public 459 class ReservedBits : public
459 BitField<intptr_t, kReservedTagPos, kReservedTagSize> {}; // NOLINT 460 BitField<intptr_t, kReservedTagPos, kReservedTagSize> {}; // NOLINT
460 461
462 // TODO(koda): Return const*, like Object::raw_ptr().
461 RawObject* ptr() const { 463 RawObject* ptr() const {
462 ASSERT(IsHeapObject()); 464 ASSERT(IsHeapObject());
463 return reinterpret_cast<RawObject*>( 465 return reinterpret_cast<RawObject*>(
464 reinterpret_cast<uword>(this) - kHeapObjectTag); 466 reinterpret_cast<uword>(this) - kHeapObjectTag);
465 } 467 }
466 468
467 intptr_t SizeFromClass() const; 469 intptr_t SizeFromClass() const;
468 470
469 intptr_t GetClassId() const { 471 intptr_t GetClassId() const {
470 uword tags = ptr()->tags_; 472 uword tags = ptr()->tags_;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 return reinterpret_cast<RawObject**>(&ptr()->instantiations_); 584 return reinterpret_cast<RawObject**>(&ptr()->instantiations_);
583 } 585 }
584 // The instantiations_ array remains empty for instantiated type arguments. 586 // The instantiations_ array remains empty for instantiated type arguments.
585 RawArray* instantiations_; // Array of paired canonical vectors: 587 RawArray* instantiations_; // Array of paired canonical vectors:
586 // Even index: instantiator. 588 // Even index: instantiator.
587 // Odd index: instantiated (without bound error). 589 // Odd index: instantiated (without bound error).
588 // Instantiations leading to bound errors do not get cached. 590 // Instantiations leading to bound errors do not get cached.
589 RawSmi* length_; 591 RawSmi* length_;
590 592
591 // Variable length data follows here. 593 // Variable length data follows here.
594 RawAbstractType* const* types() const {
595 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*);
596 }
592 RawAbstractType** types() { 597 RawAbstractType** types() {
593 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*); 598 OPEN_ARRAY_START(RawAbstractType*, RawAbstractType*);
594 } 599 }
595 RawObject** to(intptr_t length) { 600 RawObject** to(intptr_t length) {
596 return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]); 601 return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]);
597 } 602 }
598 603
599 friend class SnapshotReader; 604 friend class SnapshotReader;
600 }; 605 };
601 606
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 // Alive: If true, the embedded object pointers will be visited during GC. 894 // Alive: If true, the embedded object pointers will be visited during GC.
890 int32_t state_bits_; 895 int32_t state_bits_;
891 896
892 // PC offsets for code patching. 897 // PC offsets for code patching.
893 int32_t entry_patch_pc_offset_; 898 int32_t entry_patch_pc_offset_;
894 int32_t patch_code_pc_offset_; 899 int32_t patch_code_pc_offset_;
895 int32_t lazy_deopt_pc_offset_; 900 int32_t lazy_deopt_pc_offset_;
896 901
897 // Variable length data follows here. 902 // Variable length data follows here.
898 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } 903 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); }
904 const int32_t* data() const { OPEN_ARRAY_START(int32_t, int32_t); }
899 905
900 friend class StackFrame; 906 friend class StackFrame;
901 friend class MarkingVisitor; 907 friend class MarkingVisitor;
902 friend class Function; 908 friend class Function;
903 }; 909 };
904 910
905 911
906 class RawInstructions : public RawObject { 912 class RawInstructions : public RawObject {
907 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); 913 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions);
908 914
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); 1010 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors);
1005 1011
1006 static const intptr_t kFullRecSize; 1012 static const intptr_t kFullRecSize;
1007 static const intptr_t kCompressedRecSize; 1013 static const intptr_t kCompressedRecSize;
1008 1014
1009 int32_t record_size_in_bytes_; 1015 int32_t record_size_in_bytes_;
1010 int32_t length_; // Number of descriptors. 1016 int32_t length_; // Number of descriptors.
1011 1017
1012 // Variable length data follows here. 1018 // Variable length data follows here.
1013 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } 1019 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); }
1020 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); }
1014 1021
1015 friend class Object; 1022 friend class Object;
1016 }; 1023 };
1017 1024
1018 1025
1019 // Stackmap is an immutable representation of the layout of the stack at a 1026 // Stackmap is an immutable representation of the layout of the stack at a
1020 // PC. The stack map representation consists of a bit map which marks each 1027 // PC. The stack map representation consists of a bit map which marks each
1021 // live object index starting from the base of the frame. 1028 // live object index starting from the base of the frame.
1022 // 1029 //
1023 // The Stackmap also consists of a link to the code object corresponding to 1030 // The Stackmap also consists of a link to the code object corresponding to
1024 // the frame which the stack map is describing. The bit map representation 1031 // the frame which the stack map is describing. The bit map representation
1025 // is optimized for dense and small bit maps, without any upper bound. 1032 // is optimized for dense and small bit maps, without any upper bound.
1026 class RawStackmap : public RawObject { 1033 class RawStackmap : public RawObject {
1027 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); 1034 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap);
1028 1035
1029 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_ 1036 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_
1030 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or 1037 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or
1031 // as large as ~33 million entries. If that is sufficient, then these two 1038 // as large as ~33 million entries. If that is sufficient, then these two
1032 // fields can be merged into a BitField. 1039 // fields can be merged into a BitField.
1033 int32_t length_; // Length of payload, in bits. 1040 int32_t length_; // Length of payload, in bits.
1034 int32_t register_bit_count_; // Live register bits, included in length_. 1041 int32_t register_bit_count_; // Live register bits, included in length_.
1035 1042
1036 // Offset from code entry point corresponding to this stack map 1043 // Offset from code entry point corresponding to this stack map
1037 // representation. 1044 // representation.
1038 uint32_t pc_offset_; 1045 uint32_t pc_offset_;
1039 1046
1040 // Variable length data follows here (bitmap of the stack layout). 1047 // Variable length data follows here (bitmap of the stack layout).
1041 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1048 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1049 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); }
1042 }; 1050 };
1043 1051
1044 1052
1045 class RawLocalVarDescriptors : public RawObject { 1053 class RawLocalVarDescriptors : public RawObject {
1046 public: 1054 public:
1047 enum VarInfoKind { 1055 enum VarInfoKind {
1048 kStackVar = 1, 1056 kStackVar = 1,
1049 kContextVar, 1057 kContextVar,
1050 kContextLevel, 1058 kContextLevel,
1051 kSavedEntryContext, 1059 kSavedEntryContext,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); 1139 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers);
1132 1140
1133 // Number of exception handler entries. 1141 // Number of exception handler entries.
1134 int32_t num_entries_; 1142 int32_t num_entries_;
1135 1143
1136 // Array with [num_entries_] entries. Each entry is an array of all handled 1144 // Array with [num_entries_] entries. Each entry is an array of all handled
1137 // exception types. 1145 // exception types.
1138 RawArray* handled_types_data_; 1146 RawArray* handled_types_data_;
1139 1147
1140 // Exception handler info of length [num_entries_]. 1148 // Exception handler info of length [num_entries_].
1149 const HandlerInfo* data() const { OPEN_ARRAY_START(HandlerInfo, intptr_t); }
1141 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); } 1150 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); }
1142 1151
1143 friend class Object; 1152 friend class Object;
1144 }; 1153 };
1145 1154
1146 1155
1147 // Contains an array of deoptimization commands, e.g., move a specific register 1156 // Contains an array of deoptimization commands, e.g., move a specific register
1148 // into a specific slot of unoptimized frame. 1157 // into a specific slot of unoptimized frame.
1149 class RawDeoptInfo : public RawObject { 1158 class RawDeoptInfo : public RawObject {
1150 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo); 1159 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo);
1151 1160
1152 RawSmi* length_; // Number of deoptimization commands 1161 RawSmi* length_; // Number of deoptimization commands
1153 1162
1154 // Variable length data follows here. 1163 // Variable length data follows here.
1155 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); } 1164 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); }
1165 const intptr_t* data() const { OPEN_ARRAY_START(intptr_t, intptr_t); }
1156 }; 1166 };
1157 1167
1158 1168
1159 class RawContext : public RawObject { 1169 class RawContext : public RawObject {
1160 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); 1170 RAW_HEAP_OBJECT_IMPLEMENTATION(Context);
1161 1171
1162 int32_t num_variables_; 1172 int32_t num_variables_;
1163 Isolate* isolate_; 1173 Isolate* isolate_;
1164 1174
1165 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } 1175 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); }
1166 RawContext* parent_; 1176 RawContext* parent_;
1167 1177
1168 // Variable length data follows here. 1178 // Variable length data follows here.
1169 RawInstance** data() { OPEN_ARRAY_START(RawInstance*, RawInstance*); } 1179 RawInstance** data() { OPEN_ARRAY_START(RawInstance*, RawInstance*); }
1180 RawInstance* const* data() const {
1181 OPEN_ARRAY_START(RawInstance*, RawInstance*);
1182 }
1170 RawObject** to(intptr_t num_vars) { 1183 RawObject** to(intptr_t num_vars) {
1171 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]); 1184 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]);
1172 } 1185 }
1173 1186
1174 friend class SnapshotReader; 1187 friend class SnapshotReader;
1175 }; 1188 };
1176 1189
1177 1190
1178 class RawContextScope : public RawObject { 1191 class RawContextScope : public RawObject {
1179 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); 1192 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 1501
1489 friend class Library; 1502 friend class Library;
1490 }; 1503 };
1491 1504
1492 1505
1493 class RawOneByteString : public RawString { 1506 class RawOneByteString : public RawString {
1494 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); 1507 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString);
1495 1508
1496 // Variable length data follows here. 1509 // Variable length data follows here.
1497 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1510 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1511 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); }
1498 1512
1499 friend class ApiMessageReader; 1513 friend class ApiMessageReader;
1500 friend class SnapshotReader; 1514 friend class SnapshotReader;
1501 }; 1515 };
1502 1516
1503 1517
1504 class RawTwoByteString : public RawString { 1518 class RawTwoByteString : public RawString {
1505 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); 1519 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString);
1506 1520
1507 // Variable length data follows here. 1521 // Variable length data follows here.
1508 uint16_t* data() { OPEN_ARRAY_START(uint16_t, uint16_t); } 1522 uint16_t* data() { OPEN_ARRAY_START(uint16_t, uint16_t); }
1523 const uint16_t* data() const { OPEN_ARRAY_START(uint16_t, uint16_t); }
1509 1524
1510 friend class SnapshotReader; 1525 friend class SnapshotReader;
1511 }; 1526 };
1512 1527
1513 1528
1514 template<typename T> 1529 template<typename T>
1515 class ExternalStringData { 1530 class ExternalStringData {
1516 public: 1531 public:
1517 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : 1532 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) :
1518 data_(data), peer_(peer), callback_(callback) { 1533 data_(data), peer_(peer), callback_(callback) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 class RawArray : public RawInstance { 1576 class RawArray : public RawInstance {
1562 RAW_HEAP_OBJECT_IMPLEMENTATION(Array); 1577 RAW_HEAP_OBJECT_IMPLEMENTATION(Array);
1563 1578
1564 RawObject** from() { 1579 RawObject** from() {
1565 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); 1580 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_);
1566 } 1581 }
1567 RawTypeArguments* type_arguments_; 1582 RawTypeArguments* type_arguments_;
1568 RawSmi* length_; 1583 RawSmi* length_;
1569 // Variable length data follows here. 1584 // Variable length data follows here.
1570 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); } 1585 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); }
1586 RawObject* const* data() const { OPEN_ARRAY_START(RawObject*, RawObject*); }
1571 RawObject** to(intptr_t length) { 1587 RawObject** to(intptr_t length) {
1572 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]); 1588 return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]);
1573 } 1589 }
1574 1590
1575 friend class RawCode; 1591 friend class RawCode;
1576 friend class RawImmutableArray; 1592 friend class RawImmutableArray;
1577 friend class SnapshotReader; 1593 friend class SnapshotReader;
1578 friend class GrowableObjectArray; 1594 friend class GrowableObjectArray;
1579 friend class LinkedHashMap; 1595 friend class LinkedHashMap;
1580 friend class Object; 1596 friend class Object;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 1693
1678 1694
1679 class RawTypedData : public RawInstance { 1695 class RawTypedData : public RawInstance {
1680 RAW_HEAP_OBJECT_IMPLEMENTATION(TypedData); 1696 RAW_HEAP_OBJECT_IMPLEMENTATION(TypedData);
1681 1697
1682 protected: 1698 protected:
1683 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 1699 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1684 RawSmi* length_; 1700 RawSmi* length_;
1685 // Variable length data follows here. 1701 // Variable length data follows here.
1686 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1702 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1703 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); }
1687 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 1704 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1688 1705
1689 friend class Api; 1706 friend class Api;
1690 friend class Object; 1707 friend class Object;
1691 friend class Instance; 1708 friend class Instance;
1692 friend class SnapshotReader; 1709 friend class SnapshotReader;
1693 }; 1710 };
1694 1711
1695 1712
1696 class RawExternalTypedData : public RawInstance { 1713 class RawExternalTypedData : public RawInstance {
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2066 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2050 kTypedDataInt8ArrayViewCid + 15); 2067 kTypedDataInt8ArrayViewCid + 15);
2051 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2068 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2052 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2069 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2053 return (kNullCid - kTypedDataInt8ArrayCid); 2070 return (kNullCid - kTypedDataInt8ArrayCid);
2054 } 2071 }
2055 2072
2056 } // namespace dart 2073 } // namespace dart
2057 2074
2058 #endif // VM_RAW_OBJECT_H_ 2075 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698