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

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

Issue 343803002: Finishes removing intptr_t from raw object fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.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/globals.h" 9 #include "vm/globals.h"
10 #include "vm/token.h" 10 #include "vm/token.h"
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 RawArray* static_calls_target_table_; // (code-offset, function, code). 858 RawArray* static_calls_target_table_; // (code-offset, function, code).
859 RawArray* stackmaps_; 859 RawArray* stackmaps_;
860 RawLocalVarDescriptors* var_descriptors_; 860 RawLocalVarDescriptors* var_descriptors_;
861 RawArray* comments_; 861 RawArray* comments_;
862 RawObject** to() { 862 RawObject** to() {
863 return reinterpret_cast<RawObject**>(&ptr()->comments_); 863 return reinterpret_cast<RawObject**>(&ptr()->comments_);
864 } 864 }
865 865
866 // Compilation timestamp. 866 // Compilation timestamp.
867 int64_t compile_timestamp_; 867 int64_t compile_timestamp_;
868 intptr_t pointer_offsets_length_; 868
869 // state_bits_ is a bitfield with three fields:
870 // The optimized bit, the alive bit, and a count of the number of pointer
871 // offsets.
869 // Alive: If true, the embedded object pointers will be visited during GC. 872 // Alive: If true, the embedded object pointers will be visited during GC.
870 // This field cannot be shorter because of alignment issues on x64 873 int32_t state_bits_;
871 // architectures.
872 intptr_t state_bits_; // state, is_optimized, is_alive.
873 874
874 // PC offsets for code patching. 875 // PC offsets for code patching.
875 intptr_t entry_patch_pc_offset_; 876 int32_t entry_patch_pc_offset_;
876 intptr_t patch_code_pc_offset_; 877 int32_t patch_code_pc_offset_;
877 intptr_t lazy_deopt_pc_offset_; 878 int32_t lazy_deopt_pc_offset_;
878 879
879 // Variable length data follows here. 880 // Variable length data follows here.
880 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } 881 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); }
881 882
882 friend class StackFrame; 883 friend class StackFrame;
883 friend class MarkingVisitor; 884 friend class MarkingVisitor;
884 friend class Function; 885 friend class Function;
885 }; 886 };
886 887
887 888
888 class RawInstructions : public RawObject { 889 class RawInstructions : public RawObject {
889 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); 890 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions);
890 891
891 RawObject** from() { 892 RawObject** from() {
892 return reinterpret_cast<RawObject**>(&ptr()->code_); 893 return reinterpret_cast<RawObject**>(&ptr()->code_);
893 } 894 }
894 RawCode* code_; 895 RawCode* code_;
895 RawArray* object_pool_; 896 RawArray* object_pool_;
896 RawObject** to() { 897 RawObject** to() {
897 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); 898 return reinterpret_cast<RawObject**>(&ptr()->object_pool_);
898 } 899 }
899 intptr_t size_; 900 int32_t size_;
900 901
901 // Variable length data follows here. 902 // Variable length data follows here.
902 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 903 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
903 904
904 // Private helper function used while visiting stack frames. The 905 // Private helper function used while visiting stack frames. The
905 // code which iterates over dart frames is also called during GC and 906 // code which iterates over dart frames is also called during GC and
906 // is not allowed to create handles. 907 // is not allowed to create handles.
907 static bool ContainsPC(RawObject* raw_obj, uword pc); 908 static bool ContainsPC(RawObject* raw_obj, uword pc);
908 909
909 friend class RawCode; 910 friend class RawCode;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 }; 982 };
982 983
983 static intptr_t RecordSize(bool has_try_index); 984 static intptr_t RecordSize(bool has_try_index);
984 985
985 private: 986 private:
986 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); 987 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors);
987 988
988 static const intptr_t kFullRecSize; 989 static const intptr_t kFullRecSize;
989 static const intptr_t kCompressedRecSize; 990 static const intptr_t kCompressedRecSize;
990 991
991 intptr_t record_size_in_bytes_; 992 int32_t record_size_in_bytes_;
992 intptr_t length_; // Number of descriptors. 993 int32_t length_; // Number of descriptors.
993 994
994 // Variable length data follows here. 995 // Variable length data follows here.
995 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } 996 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); }
996 997
997 friend class Object; 998 friend class Object;
998 }; 999 };
999 1000
1000 1001
1001 // Stackmap is an immutable representation of the layout of the stack at a 1002 // Stackmap is an immutable representation of the layout of the stack at a
1002 // PC. The stack map representation consists of a bit map which marks each 1003 // PC. The stack map representation consists of a bit map which marks each
1003 // live object index starting from the base of the frame. 1004 // live object index starting from the base of the frame.
1004 // 1005 //
1005 // The Stackmap also consists of a link to the code object corresponding to 1006 // The Stackmap also consists of a link to the code object corresponding to
1006 // the frame which the stack map is describing. The bit map representation 1007 // the frame which the stack map is describing. The bit map representation
1007 // is optimized for dense and small bit maps, without any upper bound. 1008 // is optimized for dense and small bit maps, without any upper bound.
1008 class RawStackmap : public RawObject { 1009 class RawStackmap : public RawObject {
1009 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); 1010 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap);
1010 1011
1011 // TODO(kmillikin): We need a small number of bits to encode the register 1012 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_
1012 // count. Consider packing them in with the length. 1013 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or
1013 intptr_t length_; // Length of payload, in bits. 1014 // as large as ~33 million entries. If that is sufficient, then these two
1014 intptr_t register_bit_count_; // Live register bits, included in length_. 1015 // fields can be merged into a BitField.
1016 int32_t length_; // Length of payload, in bits.
1017 int32_t register_bit_count_; // Live register bits, included in length_.
1015 1018
1016 uword pc_; // PC corresponding to this stack map representation. 1019 // Offset from code entry point corresponding to this stack map
1020 // representation.
1021 uint32_t pc_offset_;
1017 1022
1018 // Variable length data follows here (bitmap of the stack layout). 1023 // Variable length data follows here (bitmap of the stack layout).
1019 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1024 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1020 }; 1025 };
1021 1026
1022 1027
1023 class RawLocalVarDescriptors : public RawObject { 1028 class RawLocalVarDescriptors : public RawObject {
1024 public: 1029 public:
1025 enum VarInfoKind { 1030 enum VarInfoKind {
1026 kStackVar = 1, 1031 kStackVar = 1,
1027 kContextVar, 1032 kContextVar,
1028 kContextLevel, 1033 kContextLevel,
1029 kSavedEntryContext, 1034 kSavedEntryContext,
1030 kSavedCurrentContext 1035 kSavedCurrentContext
1031 }; 1036 };
1032 1037
1038 enum {
1039 kKindPos = 0,
1040 kKindSize = 8,
1041 kIndexPos = 9,
Florian Schneider 2014/09/03 09:29:53 This is off by one since 9+24=33. kIndexPos = kK
zra 2014/09/03 19:26:45 Thanks for catching this!
1042 // Since there are 24 bits for the stack slot index, Functions can have
1043 // only ~16.7 million stack slots.
1044 kIndexSize = 24,
1045 kMaxIndex = (1 << (kIndexSize - 1)) - 1,
1046 };
1047
1048 // The index can be < 0.
Florian Schneider 2014/09/03 09:29:53 Ideally, BitField would take the signedness of the
zra 2014/09/03 19:26:45 The first template parameter of BitField is freque
1049 class IndexBits {
1050 public:
1051 static bool is_valid(int32_t val) {
1052 return Utils::IsInt(24, val);
1053 }
1054 static int32_t update(int32_t val, int32_t orig) {
1055 ASSERT(is_valid(val));
1056 const int32_t v = val & ((1 << kIndexSize) - 1);
1057 return Bits::update(v, orig);
1058 }
1059 static int32_t decode(int32_t val) {
1060 const int32_t v = Bits::decode(val);
1061 return (v << kIndexPos) >> kIndexPos; // Sign-extend.
1062 }
1063 private:
1064 class Bits : public BitField<int32_t, kIndexPos, kIndexSize> {};
1065 };
1066
1067 class KindBits : public BitField<int8_t, kKindPos, kKindSize>{};
1068
1033 struct VarInfo { 1069 struct VarInfo {
1034 intptr_t index; // Slot index on stack or in context. 1070 int32_t index_kind; // Bitfield for slot index on stack or in context,
1035 intptr_t begin_pos; // Token position of scope start. 1071 // and Entry kind of type VarInfoKind.
1036 intptr_t end_pos; // Token position of scope end. 1072 int32_t begin_pos; // Token position of scope start.
1037 int16_t scope_id; // Scope to which the variable belongs. 1073 int32_t end_pos; // Token position of scope end.
1038 int8_t kind; // Entry kind of type VarInfoKind. 1074 int16_t scope_id; // Scope to which the variable belongs.
1075
1076 VarInfoKind kind() const {
1077 return static_cast<VarInfoKind>(KindBits::decode(index_kind));
1078 }
1079 void set_kind(VarInfoKind kind) {
1080 index_kind = KindBits::update(kind, index_kind);
1081 }
1082 int32_t index() const {
1083 return IndexBits::decode(index_kind);
1084 }
1085 void set_index(int32_t index) {
1086 index_kind = IndexBits::update(index, index_kind);
1087 }
1039 }; 1088 };
1040 1089
1041 private: 1090 private:
1042 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); 1091 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors);
1043 intptr_t length_; // Number of descriptors.
1044 RawArray* names_; // Array of [length_] variable names. 1092 RawArray* names_; // Array of [length_] variable names.
1093 int32_t length_; // Number of descriptors.
1045 1094
1046 // Variable info with [length_] entries. 1095 // Variable info with [length_] entries.
1047 VarInfo* data() { OPEN_ARRAY_START(VarInfo, intptr_t); } 1096 VarInfo* data() { OPEN_ARRAY_START(VarInfo, int32_t); }
1048 }; 1097 };
1049 1098
1050 1099
1051 class RawExceptionHandlers : public RawObject { 1100 class RawExceptionHandlers : public RawObject {
1052 public: 1101 public:
1053 // The index into the ExceptionHandlers table corresponds to 1102 // The index into the ExceptionHandlers table corresponds to
1054 // the try_index of the handler. 1103 // the try_index of the handler.
1055 struct HandlerInfo { 1104 struct HandlerInfo {
1056 intptr_t handler_pc; // PC value of handler. 1105 intptr_t handler_pc; // PC value of handler.
1057 int16_t outer_try_index; // Try block index of enclosing try block. 1106 int16_t outer_try_index; // Try block index of enclosing try block.
1058 int8_t needs_stacktrace; // True if a stacktrace is needed. 1107 int8_t needs_stacktrace; // True if a stacktrace is needed.
1059 int8_t has_catch_all; // Catches all exceptions. 1108 int8_t has_catch_all; // Catches all exceptions.
1060 }; 1109 };
1061 1110
1062 private: 1111 private:
1063 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); 1112 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers);
1064 1113
1065 // Number of exception handler entries. 1114 // Number of exception handler entries.
1066 intptr_t length_; 1115 int32_t length_;
1067 1116
1068 // Array with [length_] entries. Each entry is an array of all handled 1117 // Array with [length_] entries. Each entry is an array of all handled
1069 // exception types. 1118 // exception types.
1070 RawArray* handled_types_data_; 1119 RawArray* handled_types_data_;
1071 1120
1072 // Exception handler info of length [length_]. 1121 // Exception handler info of length [length_].
1073 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); } 1122 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); }
1074 }; 1123 };
1075 1124
1076 1125
1077 // Contains an array of deoptimization commands, e.g., move a specific register 1126 // Contains an array of deoptimization commands, e.g., move a specific register
1078 // into a specific slot of unoptimized frame. 1127 // into a specific slot of unoptimized frame.
1079 class RawDeoptInfo : public RawObject { 1128 class RawDeoptInfo : public RawObject {
1080 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo); 1129 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo);
1081 1130
1082 RawSmi* length_; // Number of deoptimization commands 1131 RawSmi* length_; // Number of deoptimization commands
1083 1132
1084 // Variable length data follows here. 1133 // Variable length data follows here.
1085 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); } 1134 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); }
1086 }; 1135 };
1087 1136
1088 1137
1089 class RawContext : public RawObject { 1138 class RawContext : public RawObject {
1090 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); 1139 RAW_HEAP_OBJECT_IMPLEMENTATION(Context);
1091 1140
1092 intptr_t num_variables_; 1141 int32_t num_variables_;
1093 Isolate* isolate_; 1142 Isolate* isolate_;
1094 1143
1095 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } 1144 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); }
1096 RawContext* parent_; 1145 RawContext* parent_;
1097 1146
1098 // Variable length data follows here. 1147 // Variable length data follows here.
1099 RawInstance** data() { OPEN_ARRAY_START(RawInstance*, RawInstance*); } 1148 RawInstance** data() { OPEN_ARRAY_START(RawInstance*, RawInstance*); }
1100 RawObject** to(intptr_t num_vars) { 1149 RawObject** to(intptr_t num_vars) {
1101 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]); 1150 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]);
1102 } 1151 }
1103 1152
1104 friend class SnapshotReader; 1153 friend class SnapshotReader;
1105 }; 1154 };
1106 1155
1107 1156
1108 class RawContextScope : public RawObject { 1157 class RawContextScope : public RawObject {
1109 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); 1158 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope);
1110 1159
1111 // TODO(iposva): Switch to convential enum offset based structure to avoid 1160 // TODO(iposva): Switch to conventional enum offset based structure to avoid
1112 // alignment mishaps. 1161 // alignment mishaps.
1113 struct VariableDesc { 1162 struct VariableDesc {
1114 RawSmi* token_pos; 1163 RawSmi* token_pos;
1115 RawString* name; 1164 RawString* name;
1116 RawBool* is_final; 1165 RawBool* is_final;
1117 RawBool* is_const; 1166 RawBool* is_const;
1118 union { 1167 union {
1119 RawAbstractType* type; 1168 RawAbstractType* type;
1120 RawInstance* value; // iff is_const is true 1169 RawInstance* value; // iff is_const is true
1121 }; 1170 };
1122 RawSmi* context_index; 1171 RawSmi* context_index;
1123 RawSmi* context_level; 1172 RawSmi* context_level;
1124 }; 1173 };
1125 1174
1126 intptr_t num_variables_; 1175 int32_t num_variables_;
1127 1176
1128 RawObject** from() { 1177 RawObject** from() {
1129 return reinterpret_cast<RawObject**>(&ptr()->data()[0]); 1178 return reinterpret_cast<RawObject**>(&ptr()->data()[0]);
1130 } 1179 }
1131 // Variable length data follows here. 1180 // Variable length data follows here.
1132 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); } 1181 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); }
1133 RawObject** to(intptr_t num_vars) { 1182 RawObject** to(intptr_t num_vars) {
1134 const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize); 1183 const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize);
1135 return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]); 1184 return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]);
1136 } 1185 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 friend class SnapshotReader; 1434 friend class SnapshotReader;
1386 }; 1435 };
1387 1436
1388 1437
1389 class RawBigint : public RawInteger { 1438 class RawBigint : public RawInteger {
1390 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint); 1439 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint);
1391 1440
1392 // Actual length in chunks at the time of allocation (later we may 1441 // Actual length in chunks at the time of allocation (later we may
1393 // clamp the operational length but we need to maintain a consistent 1442 // clamp the operational length but we need to maintain a consistent
1394 // object length so that the object can be traversed during GC). 1443 // object length so that the object can be traversed during GC).
1395 intptr_t allocated_length_; 1444 int32_t allocated_length_;
1396 1445
1397 // Operational length in chunks of the bigint object, clamping can 1446 // Operational length in chunks of the bigint object, clamping can
1398 // cause this length to be reduced. If the signed_length_ is 1447 // cause this length to be reduced. If the signed_length_ is
1399 // negative then the number is negative. 1448 // negative then the number is negative.
1400 intptr_t signed_length_; 1449 int32_t signed_length_;
1401 1450
1402 // A sequence of Chunks (typedef in Bignum) representing bignum digits. 1451 // A sequence of Chunks (typedef in Bignum) representing bignum digits.
1403 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)]; 1452 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)];
1404 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1453 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1405 1454
1406 friend class SnapshotReader; 1455 friend class SnapshotReader;
1407 }; 1456 };
1408 1457
1409 1458
1410 class RawDouble : public RawNumber { 1459 class RawDouble : public RawNumber {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 RawObject** from() { 1752 RawObject** from() {
1704 return reinterpret_cast<RawObject**>(&ptr()->data_length_); 1753 return reinterpret_cast<RawObject**>(&ptr()->data_length_);
1705 } 1754 }
1706 RawSmi* data_length_; 1755 RawSmi* data_length_;
1707 RawSmi* num_bracket_expressions_; 1756 RawSmi* num_bracket_expressions_;
1708 RawString* pattern_; // Pattern to be used for matching. 1757 RawString* pattern_; // Pattern to be used for matching.
1709 RawObject** to() { 1758 RawObject** to() {
1710 return reinterpret_cast<RawObject**>(&ptr()->pattern_); 1759 return reinterpret_cast<RawObject**>(&ptr()->pattern_);
1711 } 1760 }
1712 1761
1713 intptr_t type_; // Uninitialized, simple or complex. 1762 // A bitfield with two fields:
1714 intptr_t flags_; // Represents global/local, case insensitive, multiline. 1763 // type: Uninitialized, simple or complex.
1764 // flags: Represents global/local, case insensitive, multiline.
1765 int8_t type_flags_;
1715 1766
1716 // Variable length data follows here. 1767 // Variable length data follows here.
1717 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1768 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1718 }; 1769 };
1719 1770
1720 1771
1721 class RawWeakProperty : public RawInstance { 1772 class RawWeakProperty : public RawInstance {
1722 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty); 1773 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty);
1723 1774
1724 RawObject** from() { 1775 RawObject** from() {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2037 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
1987 kTypedDataInt8ArrayViewCid + 15); 2038 kTypedDataInt8ArrayViewCid + 15);
1988 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2039 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
1989 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2040 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
1990 return (kNullCid - kTypedDataInt8ArrayCid); 2041 return (kNullCid - kTypedDataInt8ArrayCid);
1991 } 2042 }
1992 2043
1993 } // namespace dart 2044 } // namespace dart
1994 2045
1995 #endif // VM_RAW_OBJECT_H_ 2046 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698