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

Side by Side Diff: vm/raw_object.h

Issue 9965042: - Add a class index to the classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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/globals.h" 9 #include "vm/globals.h"
10 #include "vm/token.h" 10 #include "vm/token.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 // Forward declarations. 79 // Forward declarations.
80 class Isolate; 80 class Isolate;
81 #define DEFINE_FORWARD_DECLARATION(clazz) \ 81 #define DEFINE_FORWARD_DECLARATION(clazz) \
82 class Raw##clazz; 82 class Raw##clazz;
83 CLASS_LIST(DEFINE_FORWARD_DECLARATION) 83 CLASS_LIST(DEFINE_FORWARD_DECLARATION)
84 #undef DEFINE_FORWARD_DECLARATION 84 #undef DEFINE_FORWARD_DECLARATION
85 85
86 86
87 enum ObjectKind { 87 enum ObjectKind {
88 kIllegalObjectKind = 0,
88 #define DEFINE_OBJECT_KIND(clazz) \ 89 #define DEFINE_OBJECT_KIND(clazz) \
89 k##clazz, 90 k##clazz,
90 CLASS_LIST(DEFINE_OBJECT_KIND) 91 CLASS_LIST(DEFINE_OBJECT_KIND)
91 #undef DEFINE_OBJECT_KIND 92 #undef DEFINE_OBJECT_KIND
92 // The following entry does not describe a real object, but instead it 93 // The following entry does not describe a real object, but instead it
93 // identifies free list elements in the heap. 94 // identifies free list elements in the heap.
94 kFreeListElement, 95 kFreeListElement,
95 kNumOfObjectKinds = kFreeListElement 96 // The following entries do not describe a real object, but instead are used
97 // to allocate class indexes for pre-allocated instance classes such as the
98 // Null, Void, Dynamic and other similar classes.
99 kNullClassIndex,
100 kSentinelClassIndex,
101 kDynamicClassIndex,
102 kVoidClassIndex,
103 kNumPredefinedKinds = 100
96 }; 104 };
97 105
98 enum ObjectAlignment { 106 enum ObjectAlignment {
99 // Alignment offsets are used to determine object age. 107 // Alignment offsets are used to determine object age.
100 kNewObjectAlignmentOffset = kWordSize, 108 kNewObjectAlignmentOffset = kWordSize,
101 kOldObjectAlignmentOffset = 0, 109 kOldObjectAlignmentOffset = 0,
102 // Object sizes are aligned to kObjectAlignment. 110 // Object sizes are aligned to kObjectAlignment.
103 kObjectAlignment = 2 * kWordSize, 111 kObjectAlignment = 2 * kWordSize,
104 kObjectAlignmentLog2 = kWordSizeLog2 + 1, 112 kObjectAlignmentLog2 = kWordSizeLog2 + 1,
105 kObjectAlignmentMask = kObjectAlignment - 1, 113 kObjectAlignmentMask = kObjectAlignment - 1,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 kFreeBit = 0, 160 kFreeBit = 0,
153 kMarkBit = 1, 161 kMarkBit = 1,
154 kCanonicalBit = 2, 162 kCanonicalBit = 2,
155 kFromSnapshotBit = 3, 163 kFromSnapshotBit = 3,
156 kReservedBit10K = 4, 164 kReservedBit10K = 4,
157 kReservedBit100K = 5, 165 kReservedBit100K = 5,
158 kReservedBit1M = 6, 166 kReservedBit1M = 6,
159 kReservedBit10M = 7, 167 kReservedBit10M = 7,
160 kSizeTagBit = 8, 168 kSizeTagBit = 8,
161 kSizeTagSize = 8, 169 kSizeTagSize = 8,
170 kClassTagBit = kSizeTagBit + kSizeTagSize,
171 kClassTagSize = 16
162 }; 172 };
163 173
164 // Encodes the object size in the tag in units of object alignment. 174 // Encodes the object size in the tag in units of object alignment.
165 class SizeTag { 175 class SizeTag {
166 public: 176 public:
167 static const intptr_t kMaxSizeTag = 177 static const intptr_t kMaxSizeTag =
168 ((1 << RawObject::kSizeTagSize) - 1) << kObjectAlignmentLog2; 178 ((1 << RawObject::kSizeTagSize) - 1) << kObjectAlignmentLog2;
169 179
170 static uword encode(intptr_t size) { 180 static uword encode(intptr_t size) {
171 return SizeBits::encode(SizeToTagValue(size)); 181 return SizeBits::encode(SizeToTagValue(size));
(...skipping 13 matching lines...) Expand all
185 195
186 static intptr_t SizeToTagValue(intptr_t size) { 196 static intptr_t SizeToTagValue(intptr_t size) {
187 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 197 ASSERT(Utils::IsAligned(size, kObjectAlignment));
188 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2); 198 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2);
189 } 199 }
190 static intptr_t TagValueToSize(intptr_t value) { 200 static intptr_t TagValueToSize(intptr_t value) {
191 return value << kObjectAlignmentLog2; 201 return value << kObjectAlignmentLog2;
192 } 202 }
193 }; 203 };
194 204
205 class ClassTag : public BitField<intptr_t, kClassTagBit, kClassTagSize> {};
206
195 bool IsHeapObject() const { 207 bool IsHeapObject() const {
196 uword value = reinterpret_cast<uword>(this); 208 uword value = reinterpret_cast<uword>(this);
197 return (value & kSmiTagMask) == kHeapObjectTag; 209 return (value & kSmiTagMask) == kHeapObjectTag;
198 } 210 }
199 211
200 bool IsNewObject() const { 212 bool IsNewObject() const {
201 uword addr = reinterpret_cast<uword>(this); 213 uword addr = reinterpret_cast<uword>(this);
202 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset; 214 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset;
203 } 215 }
204 bool IsOldObject() const { 216 bool IsOldObject() const {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 RawArray* constants_; // Canonicalized values of this class. 342 RawArray* constants_; // Canonicalized values of this class.
331 RawArray* canonical_types_; // Canonicalized types of this class. 343 RawArray* canonical_types_; // Canonicalized types of this class.
332 RawCode* allocation_stub_; // Stub code for allocation of instances. 344 RawCode* allocation_stub_; // Stub code for allocation of instances.
333 RawObject** to() { 345 RawObject** to() {
334 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); 346 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_);
335 } 347 }
336 348
337 cpp_vtable handle_vtable_; 349 cpp_vtable handle_vtable_;
338 intptr_t instance_size_; 350 intptr_t instance_size_;
339 ObjectKind instance_kind_; 351 ObjectKind instance_kind_;
352 intptr_t index_; // Index in the class table.
340 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments. 353 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments.
341 intptr_t next_field_offset_; // Offset of then next instance field. 354 intptr_t next_field_offset_; // Offset of then next instance field.
342 intptr_t num_native_fields_; // Number of native fields in class. 355 intptr_t num_native_fields_; // Number of native fields in class.
343 intptr_t token_index_; 356 intptr_t token_index_;
344 int8_t class_state_; // Of type ClassState. 357 int8_t class_state_; // Of type ClassState.
345 bool is_const_; 358 bool is_const_;
346 bool is_interface_; 359 bool is_interface_;
347 360
348 friend class Object; 361 friend class Object;
349 friend class RawInstance; 362 friend class RawInstance;
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 intptr_t type_; // Uninitialized, simple or complex. 1177 intptr_t type_; // Uninitialized, simple or complex.
1165 intptr_t flags_; // Represents global/local, case insensitive, multiline. 1178 intptr_t flags_; // Represents global/local, case insensitive, multiline.
1166 1179
1167 // Variable length data follows here. 1180 // Variable length data follows here.
1168 uint8_t data_[0]; 1181 uint8_t data_[0];
1169 }; 1182 };
1170 1183
1171 } // namespace dart 1184 } // namespace dart
1172 1185
1173 #endif // VM_RAW_OBJECT_H_ 1186 #endif // VM_RAW_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698