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

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

Powered by Google App Engine
This is Rietveld 408576698