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

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/atomic.h" 9 #include "vm/atomic.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 RawArray* static_calls_target_table_; // (code-offset, function, code). 882 RawArray* static_calls_target_table_; // (code-offset, function, code).
883 RawArray* stackmaps_; 883 RawArray* stackmaps_;
884 RawLocalVarDescriptors* var_descriptors_; 884 RawLocalVarDescriptors* var_descriptors_;
885 RawArray* comments_; 885 RawArray* comments_;
886 RawObject** to() { 886 RawObject** to() {
887 return reinterpret_cast<RawObject**>(&ptr()->comments_); 887 return reinterpret_cast<RawObject**>(&ptr()->comments_);
888 } 888 }
889 889
890 // Compilation timestamp. 890 // Compilation timestamp.
891 int64_t compile_timestamp_; 891 int64_t compile_timestamp_;
892 intptr_t pointer_offsets_length_; 892
893 // state_bits_ is a bitfield with three fields:
894 // The optimized bit, the alive bit, and a count of the number of pointer
895 // offsets.
893 // Alive: If true, the embedded object pointers will be visited during GC. 896 // Alive: If true, the embedded object pointers will be visited during GC.
894 // This field cannot be shorter because of alignment issues on x64 897 int32_t state_bits_;
895 // architectures.
896 intptr_t state_bits_; // state, is_optimized, is_alive.
897 898
898 // PC offsets for code patching. 899 // PC offsets for code patching.
899 intptr_t entry_patch_pc_offset_; 900 int32_t entry_patch_pc_offset_;
900 intptr_t patch_code_pc_offset_; 901 int32_t patch_code_pc_offset_;
901 intptr_t lazy_deopt_pc_offset_; 902 int32_t lazy_deopt_pc_offset_;
902 903
903 // Variable length data follows here. 904 // Variable length data follows here.
904 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } 905 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); }
905 906
906 friend class StackFrame; 907 friend class StackFrame;
907 friend class MarkingVisitor; 908 friend class MarkingVisitor;
908 friend class Function; 909 friend class Function;
909 }; 910 };
910 911
911 912
912 class RawInstructions : public RawObject { 913 class RawInstructions : public RawObject {
913 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); 914 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions);
914 915
915 RawObject** from() { 916 RawObject** from() {
916 return reinterpret_cast<RawObject**>(&ptr()->code_); 917 return reinterpret_cast<RawObject**>(&ptr()->code_);
917 } 918 }
918 RawCode* code_; 919 RawCode* code_;
919 RawArray* object_pool_; 920 RawArray* object_pool_;
920 RawObject** to() { 921 RawObject** to() {
921 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); 922 return reinterpret_cast<RawObject**>(&ptr()->object_pool_);
922 } 923 }
923 intptr_t size_; 924 int32_t size_;
924 925
925 // Variable length data follows here. 926 // Variable length data follows here.
926 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 927 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
927 928
928 // Private helper function used while visiting stack frames. The 929 // Private helper function used while visiting stack frames. The
929 // code which iterates over dart frames is also called during GC and 930 // code which iterates over dart frames is also called during GC and
930 // is not allowed to create handles. 931 // is not allowed to create handles.
931 static bool ContainsPC(RawObject* raw_obj, uword pc); 932 static bool ContainsPC(RawObject* raw_obj, uword pc);
932 933
933 friend class RawCode; 934 friend class RawCode;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 }; 1006 };
1006 1007
1007 static intptr_t RecordSize(bool has_try_index); 1008 static intptr_t RecordSize(bool has_try_index);
1008 1009
1009 private: 1010 private:
1010 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); 1011 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors);
1011 1012
1012 static const intptr_t kFullRecSize; 1013 static const intptr_t kFullRecSize;
1013 static const intptr_t kCompressedRecSize; 1014 static const intptr_t kCompressedRecSize;
1014 1015
1015 intptr_t record_size_in_bytes_; 1016 int32_t record_size_in_bytes_;
1016 intptr_t length_; // Number of descriptors. 1017 int32_t length_; // Number of descriptors.
1017 1018
1018 // Variable length data follows here. 1019 // Variable length data follows here.
1019 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } 1020 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); }
1020 1021
1021 friend class Object; 1022 friend class Object;
1022 }; 1023 };
1023 1024
1024 1025
1025 // 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
1026 // 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
1027 // live object index starting from the base of the frame. 1028 // live object index starting from the base of the frame.
1028 // 1029 //
1029 // 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
1030 // 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
1031 // 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.
1032 class RawStackmap : public RawObject { 1033 class RawStackmap : public RawObject {
1033 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); 1034 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap);
1034 1035
1035 // TODO(kmillikin): We need a small number of bits to encode the register 1036 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_
1036 // count. Consider packing them in with the length. 1037 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or
1037 intptr_t length_; // Length of payload, in bits. 1038 // as large as ~33 million entries. If that is sufficient, then these two
1038 intptr_t register_bit_count_; // Live register bits, included in length_. 1039 // fields can be merged into a BitField.
1040 int32_t length_; // Length of payload, in bits.
1041 int32_t register_bit_count_; // Live register bits, included in length_.
1039 1042
1040 uword pc_; // PC corresponding to this stack map representation. 1043 // Offset from code entry point corresponding to this stack map
1044 // representation.
1045 uint32_t pc_offset_;
1041 1046
1042 // Variable length data follows here (bitmap of the stack layout). 1047 // Variable length data follows here (bitmap of the stack layout).
1043 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1048 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1044 }; 1049 };
1045 1050
1046 1051
1047 class RawLocalVarDescriptors : public RawObject { 1052 class RawLocalVarDescriptors : public RawObject {
1048 public: 1053 public:
1049 enum VarInfoKind { 1054 enum VarInfoKind {
1050 kStackVar = 1, 1055 kStackVar = 1,
1051 kContextVar, 1056 kContextVar,
1052 kContextLevel, 1057 kContextLevel,
1053 kSavedEntryContext, 1058 kSavedEntryContext,
1054 kSavedCurrentContext 1059 kSavedCurrentContext
1055 }; 1060 };
1056 1061
1062 enum {
1063 kKindPos = 0,
1064 kKindSize = 8,
1065 kIndexPos = kKindPos + kKindSize,
1066 // Since there are 24 bits for the stack slot index, Functions can have
1067 // only ~16.7 million stack slots.
1068 kPayloadSize = sizeof(int32_t) * kBitsPerByte,
1069 kIndexSize = kPayloadSize - kIndexPos,
1070 kIndexBias = 1 << (kIndexSize - 1),
1071 kMaxIndex = (1 << (kIndexSize - 1)) - 1,
1072 };
1073
1074 class IndexBits : public BitField<int32_t, kIndexPos, kIndexSize> {};
1075 class KindBits : public BitField<int8_t, kKindPos, kKindSize>{};
1076
1057 struct VarInfo { 1077 struct VarInfo {
1058 intptr_t index; // Slot index on stack or in context. 1078 int32_t index_kind; // Bitfield for slot index on stack or in context,
1059 intptr_t begin_pos; // Token position of scope start. 1079 // and Entry kind of type VarInfoKind.
1060 intptr_t end_pos; // Token position of scope end. 1080 int32_t begin_pos; // Token position of scope start.
1061 int16_t scope_id; // Scope to which the variable belongs. 1081 int32_t end_pos; // Token position of scope end.
1062 int8_t kind; // Entry kind of type VarInfoKind. 1082 int16_t scope_id; // Scope to which the variable belongs.
1083
1084 VarInfoKind kind() const {
1085 return static_cast<VarInfoKind>(KindBits::decode(index_kind));
1086 }
1087 void set_kind(VarInfoKind kind) {
1088 index_kind = KindBits::update(kind, index_kind);
1089 }
1090 int32_t index() const {
1091 return IndexBits::decode(index_kind) - kIndexBias;
1092 }
1093 void set_index(int32_t index) {
1094 index_kind = IndexBits::update(index + kIndexBias, index_kind);
1095 }
1063 }; 1096 };
1064 1097
1065 private: 1098 private:
1066 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); 1099 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors);
1067 intptr_t length_; // Number of descriptors.
1068 RawArray* names_; // Array of [length_] variable names. 1100 RawArray* names_; // Array of [length_] variable names.
1101 int32_t length_; // Number of descriptors.
1069 1102
1070 // Variable info with [length_] entries. 1103 // Variable info with [length_] entries.
1071 VarInfo* data() { OPEN_ARRAY_START(VarInfo, intptr_t); } 1104 VarInfo* data() { OPEN_ARRAY_START(VarInfo, int32_t); }
1072 }; 1105 };
1073 1106
1074 1107
1075 class RawExceptionHandlers : public RawObject { 1108 class RawExceptionHandlers : public RawObject {
1076 public: 1109 public:
1077 // The index into the ExceptionHandlers table corresponds to 1110 // The index into the ExceptionHandlers table corresponds to
1078 // the try_index of the handler. 1111 // the try_index of the handler.
1079 struct HandlerInfo { 1112 struct HandlerInfo {
1080 intptr_t handler_pc; // PC value of handler. 1113 intptr_t handler_pc; // PC value of handler.
1081 int16_t outer_try_index; // Try block index of enclosing try block. 1114 int16_t outer_try_index; // Try block index of enclosing try block.
1082 int8_t needs_stacktrace; // True if a stacktrace is needed. 1115 int8_t needs_stacktrace; // True if a stacktrace is needed.
1083 int8_t has_catch_all; // Catches all exceptions. 1116 int8_t has_catch_all; // Catches all exceptions.
1084 }; 1117 };
1085 1118
1086 private: 1119 private:
1087 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); 1120 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers);
1088 1121
1089 // Number of exception handler entries. 1122 // Number of exception handler entries.
1090 intptr_t length_; 1123 int32_t length_;
1091 1124
1092 // Array with [length_] entries. Each entry is an array of all handled 1125 // Array with [length_] entries. Each entry is an array of all handled
1093 // exception types. 1126 // exception types.
1094 RawArray* handled_types_data_; 1127 RawArray* handled_types_data_;
1095 1128
1096 // Exception handler info of length [length_]. 1129 // Exception handler info of length [length_].
1097 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); } 1130 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); }
1098 }; 1131 };
1099 1132
1100 1133
1101 // Contains an array of deoptimization commands, e.g., move a specific register 1134 // Contains an array of deoptimization commands, e.g., move a specific register
1102 // into a specific slot of unoptimized frame. 1135 // into a specific slot of unoptimized frame.
1103 class RawDeoptInfo : public RawObject { 1136 class RawDeoptInfo : public RawObject {
1104 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo); 1137 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo);
1105 1138
1106 RawSmi* length_; // Number of deoptimization commands 1139 RawSmi* length_; // Number of deoptimization commands
1107 1140
1108 // Variable length data follows here. 1141 // Variable length data follows here.
1109 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); } 1142 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); }
1110 }; 1143 };
1111 1144
1112 1145
1113 class RawContext : public RawObject { 1146 class RawContext : public RawObject {
1114 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); 1147 RAW_HEAP_OBJECT_IMPLEMENTATION(Context);
1115 1148
1116 intptr_t num_variables_; 1149 int32_t num_variables_;
1117 Isolate* isolate_; 1150 Isolate* isolate_;
1118 1151
1119 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } 1152 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); }
1120 RawContext* parent_; 1153 RawContext* parent_;
1121 1154
1122 // Variable length data follows here. 1155 // Variable length data follows here.
1123 RawInstance** data() { OPEN_ARRAY_START(RawInstance*, RawInstance*); } 1156 RawInstance** data() { OPEN_ARRAY_START(RawInstance*, RawInstance*); }
1124 RawObject** to(intptr_t num_vars) { 1157 RawObject** to(intptr_t num_vars) {
1125 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]); 1158 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]);
1126 } 1159 }
1127 1160
1128 friend class SnapshotReader; 1161 friend class SnapshotReader;
1129 }; 1162 };
1130 1163
1131 1164
1132 class RawContextScope : public RawObject { 1165 class RawContextScope : public RawObject {
1133 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); 1166 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope);
1134 1167
1135 // TODO(iposva): Switch to convential enum offset based structure to avoid 1168 // TODO(iposva): Switch to conventional enum offset based structure to avoid
1136 // alignment mishaps. 1169 // alignment mishaps.
1137 struct VariableDesc { 1170 struct VariableDesc {
1138 RawSmi* token_pos; 1171 RawSmi* token_pos;
1139 RawString* name; 1172 RawString* name;
1140 RawBool* is_final; 1173 RawBool* is_final;
1141 RawBool* is_const; 1174 RawBool* is_const;
1142 union { 1175 union {
1143 RawAbstractType* type; 1176 RawAbstractType* type;
1144 RawInstance* value; // iff is_const is true 1177 RawInstance* value; // iff is_const is true
1145 }; 1178 };
1146 RawSmi* context_index; 1179 RawSmi* context_index;
1147 RawSmi* context_level; 1180 RawSmi* context_level;
1148 }; 1181 };
1149 1182
1150 intptr_t num_variables_; 1183 int32_t num_variables_;
1151 1184
1152 RawObject** from() { 1185 RawObject** from() {
1153 return reinterpret_cast<RawObject**>(&ptr()->data()[0]); 1186 return reinterpret_cast<RawObject**>(&ptr()->data()[0]);
1154 } 1187 }
1155 // Variable length data follows here. 1188 // Variable length data follows here.
1156 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); } 1189 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); }
1157 RawObject** to(intptr_t num_vars) { 1190 RawObject** to(intptr_t num_vars) {
1158 const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize); 1191 const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize);
1159 return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]); 1192 return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]);
1160 } 1193 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 friend class SnapshotReader; 1442 friend class SnapshotReader;
1410 }; 1443 };
1411 1444
1412 1445
1413 class RawBigint : public RawInteger { 1446 class RawBigint : public RawInteger {
1414 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint); 1447 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint);
1415 1448
1416 // Actual length in chunks at the time of allocation (later we may 1449 // Actual length in chunks at the time of allocation (later we may
1417 // clamp the operational length but we need to maintain a consistent 1450 // clamp the operational length but we need to maintain a consistent
1418 // object length so that the object can be traversed during GC). 1451 // object length so that the object can be traversed during GC).
1419 intptr_t allocated_length_; 1452 int32_t allocated_length_;
1420 1453
1421 // Operational length in chunks of the bigint object, clamping can 1454 // Operational length in chunks of the bigint object, clamping can
1422 // cause this length to be reduced. If the signed_length_ is 1455 // cause this length to be reduced. If the signed_length_ is
1423 // negative then the number is negative. 1456 // negative then the number is negative.
1424 intptr_t signed_length_; 1457 int32_t signed_length_;
1425 1458
1426 // A sequence of Chunks (typedef in Bignum) representing bignum digits. 1459 // A sequence of Chunks (typedef in Bignum) representing bignum digits.
1427 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)]; 1460 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)];
1428 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1461 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1429 1462
1430 friend class SnapshotReader; 1463 friend class SnapshotReader;
1431 }; 1464 };
1432 1465
1433 1466
1434 class RawDouble : public RawNumber { 1467 class RawDouble : public RawNumber {
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 RawObject** from() { 1760 RawObject** from() {
1728 return reinterpret_cast<RawObject**>(&ptr()->data_length_); 1761 return reinterpret_cast<RawObject**>(&ptr()->data_length_);
1729 } 1762 }
1730 RawSmi* data_length_; 1763 RawSmi* data_length_;
1731 RawSmi* num_bracket_expressions_; 1764 RawSmi* num_bracket_expressions_;
1732 RawString* pattern_; // Pattern to be used for matching. 1765 RawString* pattern_; // Pattern to be used for matching.
1733 RawObject** to() { 1766 RawObject** to() {
1734 return reinterpret_cast<RawObject**>(&ptr()->pattern_); 1767 return reinterpret_cast<RawObject**>(&ptr()->pattern_);
1735 } 1768 }
1736 1769
1737 intptr_t type_; // Uninitialized, simple or complex. 1770 // A bitfield with two fields:
1738 intptr_t flags_; // Represents global/local, case insensitive, multiline. 1771 // type: Uninitialized, simple or complex.
1772 // flags: Represents global/local, case insensitive, multiline.
1773 int8_t type_flags_;
1739 1774
1740 // Variable length data follows here. 1775 // Variable length data follows here.
1741 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1776 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1742 }; 1777 };
1743 1778
1744 1779
1745 class RawWeakProperty : public RawInstance { 1780 class RawWeakProperty : public RawInstance {
1746 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty); 1781 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty);
1747 1782
1748 RawObject** from() { 1783 RawObject** from() {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2045 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2011 kTypedDataInt8ArrayViewCid + 15); 2046 kTypedDataInt8ArrayViewCid + 15);
2012 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2047 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2013 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2048 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2014 return (kNullCid - kTypedDataInt8ArrayCid); 2049 return (kNullCid - kTypedDataInt8ArrayCid);
2015 } 2050 }
2016 2051
2017 } // namespace dart 2052 } // namespace dart
2018 2053
2019 #endif // VM_RAW_OBJECT_H_ 2054 #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