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

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, 7 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 kDynamicClassIndex,
101 kVoidClassIndex,
102 kNumPredefinedKinds = 100
96 }; 103 };
97 104
98 enum ObjectAlignment { 105 enum ObjectAlignment {
99 // Alignment offsets are used to determine object age. 106 // Alignment offsets are used to determine object age.
100 kNewObjectAlignmentOffset = kWordSize, 107 kNewObjectAlignmentOffset = kWordSize,
101 kOldObjectAlignmentOffset = 0, 108 kOldObjectAlignmentOffset = 0,
102 // Object sizes are aligned to kObjectAlignment. 109 // Object sizes are aligned to kObjectAlignment.
103 kObjectAlignment = 2 * kWordSize, 110 kObjectAlignment = 2 * kWordSize,
104 kObjectAlignmentLog2 = kWordSizeLog2 + 1, 111 kObjectAlignmentLog2 = kWordSizeLog2 + 1,
105 kObjectAlignmentMask = kObjectAlignment - 1, 112 kObjectAlignmentMask = kObjectAlignment - 1,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 kFreeBit = 0, 160 kFreeBit = 0,
154 kMarkBit = 1, 161 kMarkBit = 1,
155 kCanonicalBit = 2, 162 kCanonicalBit = 2,
156 kFromSnapshotBit = 3, 163 kFromSnapshotBit = 3,
157 kReservedBit10K = 4, 164 kReservedBit10K = 4,
158 kReservedBit100K = 5, 165 kReservedBit100K = 5,
159 kReservedBit1M = 6, 166 kReservedBit1M = 6,
160 kReservedBit10M = 7, 167 kReservedBit10M = 7,
161 kSizeTagBit = 8, 168 kSizeTagBit = 8,
162 kSizeTagSize = 8, 169 kSizeTagSize = 8,
170 kClassTagBit = kSizeTagBit + kSizeTagSize,
171 kClassTagSize = 16
163 }; 172 };
164 173
165 // 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.
166 class SizeTag { 175 class SizeTag {
167 public: 176 public:
168 static const intptr_t kMaxSizeTag = 177 static const intptr_t kMaxSizeTag =
169 ((1 << RawObject::kSizeTagSize) - 1) << kObjectAlignmentLog2; 178 ((1 << RawObject::kSizeTagSize) - 1) << kObjectAlignmentLog2;
170 179
171 static uword encode(intptr_t size) { 180 static uword encode(intptr_t size) {
172 return SizeBits::encode(SizeToTagValue(size)); 181 return SizeBits::encode(SizeToTagValue(size));
(...skipping 13 matching lines...) Expand all
186 195
187 static intptr_t SizeToTagValue(intptr_t size) { 196 static intptr_t SizeToTagValue(intptr_t size) {
188 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 197 ASSERT(Utils::IsAligned(size, kObjectAlignment));
189 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2); 198 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2);
190 } 199 }
191 static intptr_t TagValueToSize(intptr_t value) { 200 static intptr_t TagValueToSize(intptr_t value) {
192 return value << kObjectAlignmentLog2; 201 return value << kObjectAlignmentLog2;
193 } 202 }
194 }; 203 };
195 204
205 class ClassTag : public BitField<intptr_t, kClassTagBit, kClassTagSize> {};
206
196 bool IsHeapObject() const { 207 bool IsHeapObject() const {
197 uword value = reinterpret_cast<uword>(this); 208 uword value = reinterpret_cast<uword>(this);
198 return (value & kSmiTagMask) == kHeapObjectTag; 209 return (value & kSmiTagMask) == kHeapObjectTag;
199 } 210 }
200 211
201 bool IsNewObject() const { 212 bool IsNewObject() const {
202 uword addr = reinterpret_cast<uword>(this); 213 uword addr = reinterpret_cast<uword>(this);
203 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset; 214 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset;
204 } 215 }
205 bool IsOldObject() const { 216 bool IsOldObject() const {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 RawArray* constants_; // Canonicalized values of this class. 345 RawArray* constants_; // Canonicalized values of this class.
335 RawArray* canonical_types_; // Canonicalized types of this class. 346 RawArray* canonical_types_; // Canonicalized types of this class.
336 RawCode* allocation_stub_; // Stub code for allocation of instances. 347 RawCode* allocation_stub_; // Stub code for allocation of instances.
337 RawObject** to() { 348 RawObject** to() {
338 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); 349 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_);
339 } 350 }
340 351
341 cpp_vtable handle_vtable_; 352 cpp_vtable handle_vtable_;
342 intptr_t instance_size_; 353 intptr_t instance_size_;
343 ObjectKind instance_kind_; 354 ObjectKind instance_kind_;
355 intptr_t index_; // Index in the class table.
344 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments. 356 intptr_t type_arguments_instance_field_offset_; // May be kNoTypeArguments.
345 intptr_t next_field_offset_; // Offset of then next instance field. 357 intptr_t next_field_offset_; // Offset of then next instance field.
346 intptr_t num_native_fields_; // Number of native fields in class. 358 intptr_t num_native_fields_; // Number of native fields in class.
347 intptr_t token_index_; 359 intptr_t token_index_;
348 int8_t class_state_; // Of type ClassState. 360 int8_t class_state_; // Of type ClassState.
349 bool is_const_; 361 bool is_const_;
350 bool is_interface_; 362 bool is_interface_;
351 363
352 friend class Object; 364 friend class Object;
353 friend class RawInstance; 365 friend class RawInstance;
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 intptr_t type_; // Uninitialized, simple or complex. 1199 intptr_t type_; // Uninitialized, simple or complex.
1188 intptr_t flags_; // Represents global/local, case insensitive, multiline. 1200 intptr_t flags_; // Represents global/local, case insensitive, multiline.
1189 1201
1190 // Variable length data follows here. 1202 // Variable length data follows here.
1191 uint8_t data_[0]; 1203 uint8_t data_[0];
1192 }; 1204 };
1193 1205
1194 } // namespace dart 1206 } // namespace dart
1195 1207
1196 #endif // VM_RAW_OBJECT_H_ 1208 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « vm/object_store.h ('k') | vm/raw_object.cc » ('j') | vm/raw_object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698