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

Side by Side Diff: vm/raw_object.h

Issue 9027017: - Promote objects from new gen to old space if they survived a scavenge. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 8 years, 12 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 | « vm/pages.cc ('k') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/snapshot.h" 10 #include "vm/snapshot.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 uword addr = reinterpret_cast<uword>(this); 153 uword addr = reinterpret_cast<uword>(this);
154 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset; 154 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset;
155 } 155 }
156 bool IsOldObject() const { 156 bool IsOldObject() const {
157 uword addr = reinterpret_cast<uword>(this); 157 uword addr = reinterpret_cast<uword>(this);
158 return (addr & kNewObjectAlignmentOffset) == kOldObjectAlignmentOffset; 158 return (addr & kNewObjectAlignmentOffset) == kOldObjectAlignmentOffset;
159 } 159 }
160 160
161 // Support for GC marking bit. 161 // Support for GC marking bit.
162 bool IsMarked() const { 162 bool IsMarked() const {
163 uword header_bits = reinterpret_cast<uword>(ptr()->class_); 163 return MarkBit::decode(ptr()->tags_);
164 uword mark_bits = header_bits & kMarkingMask;
165 ASSERT((mark_bits == kNotMarked) || (mark_bits == kMarked));
166 return mark_bits == kMarked;
167 } 164 }
168 void SetMarkBit() { 165 void SetMarkBit() {
169 ASSERT(!IsMarked()); 166 ASSERT(!IsMarked());
170 uword header_bits = reinterpret_cast<uword>(ptr()->class_); 167 intptr_t tags = ptr()->tags_;
171 ptr()->class_ = reinterpret_cast<RawClass*>(header_bits | kMarked); 168 ptr()->tags_ = MarkBit::update(true, tags);
172 } 169 }
173 void ClearMarkBit() { 170 void ClearMarkBit() {
174 ASSERT(IsMarked()); 171 ASSERT(IsMarked());
175 uword header_bits = reinterpret_cast<uword>(ptr()->class_); 172 intptr_t tags = ptr()->tags_;
176 ptr()->class_ = reinterpret_cast<RawClass*>(header_bits ^ kMarkBit); 173 ptr()->tags_ = MarkBit::update(false, tags);
177 } 174 }
178 175
179 // Support for object tags. 176 // Support for object tags.
180 bool IsCanonical() const { 177 bool IsCanonical() const {
181 return CanonicalObjectTag::decode(ptr()->tags_); 178 return CanonicalObjectTag::decode(ptr()->tags_);
182 } 179 }
183 void SetCanonical() { 180 void SetCanonical() {
184 intptr_t tags = ptr()->tags_; 181 intptr_t tags = ptr()->tags_;
185 ptr()->tags_ = CanonicalObjectTag::update(true, tags); 182 ptr()->tags_ = CanonicalObjectTag::update(true, tags);
186 } 183 }
(...skipping 26 matching lines...) Expand all
213 static bool IsCanonical(intptr_t value) { 210 static bool IsCanonical(intptr_t value) {
214 return CanonicalObjectTag::decode(value); 211 return CanonicalObjectTag::decode(value);
215 } 212 }
216 213
217 protected: 214 protected:
218 RawClass* class_; 215 RawClass* class_;
219 intptr_t tags_; // Various object tags (bits). 216 intptr_t tags_; // Various object tags (bits).
220 217
221 private: 218 private:
222 enum { 219 enum {
223 kMarkingMask = 3, 220 kMarkBit = 1,
224 kNotMarked = 1, // Tagged pointer. 221 kCanonicalBit = 2,
225 kMarked = 3, // Tagged pointer and forwarding bit set. 222 kFromSnapshotBit = 3,
226 kMarkBit = 2,
227 }; 223 };
228 224
229 class CanonicalObjectTag : public BitField<bool, 2, 1> { 225 class MarkBit : public BitField<bool, kMarkBit, 1> {};
230 };
231 226
232 class CreatedFromSnapshotTag : public BitField<bool, 3, 1> { 227 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {};
233 }; 228
229 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {};
234 230
235 RawObject* ptr() const { 231 RawObject* ptr() const {
236 ASSERT(IsHeapObject()); 232 ASSERT(IsHeapObject());
237 return reinterpret_cast<RawObject*>( 233 return reinterpret_cast<RawObject*>(
238 reinterpret_cast<uword>(this) - kHeapObjectTag); 234 reinterpret_cast<uword>(this) - kHeapObjectTag);
239 } 235 }
240 236
241 friend class Object; 237 friend class Object;
242 friend class Array; 238 friend class Array;
243 friend class SnapshotWriter; 239 friend class SnapshotWriter;
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 intptr_t type_; // Uninitialized, simple or complex. 914 intptr_t type_; // Uninitialized, simple or complex.
919 intptr_t flags_; // Represents global/local, case insensitive, multiline. 915 intptr_t flags_; // Represents global/local, case insensitive, multiline.
920 916
921 // Variable length data follows here. 917 // Variable length data follows here.
922 uint8_t data_[0]; 918 uint8_t data_[0];
923 }; 919 };
924 920
925 } // namespace dart 921 } // namespace dart
926 922
927 #endif // VM_RAW_OBJECT_H_ 923 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « vm/pages.cc ('k') | vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698