| OLD | NEW |
| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 return mark_bits == kMarked; | 156 return mark_bits == kMarked; |
| 157 } | 157 } |
| 158 void SetMarkBit() { | 158 void SetMarkBit() { |
| 159 ASSERT(!IsMarked()); | 159 ASSERT(!IsMarked()); |
| 160 uword header_bits = reinterpret_cast<uword>(ptr()->class_); | 160 uword header_bits = reinterpret_cast<uword>(ptr()->class_); |
| 161 ptr()->class_ = reinterpret_cast<RawClass*>(header_bits | kMarked); | 161 ptr()->class_ = reinterpret_cast<RawClass*>(header_bits | kMarked); |
| 162 } | 162 } |
| 163 void ClearMarkBit() { | 163 void ClearMarkBit() { |
| 164 ASSERT(IsMarked()); | 164 ASSERT(IsMarked()); |
| 165 uword header_bits = reinterpret_cast<uword>(ptr()->class_); | 165 uword header_bits = reinterpret_cast<uword>(ptr()->class_); |
| 166 ptr()->class_ = reinterpret_cast<RawClass*>(header_bits ^ kMarked); | 166 ptr()->class_ = reinterpret_cast<RawClass*>(header_bits ^ kMarkBit); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void Validate() const; | 169 void Validate() const; |
| 170 intptr_t Size() const; | 170 intptr_t Size() const; |
| 171 intptr_t VisitPointers(ObjectPointerVisitor* visitor); | 171 intptr_t VisitPointers(ObjectPointerVisitor* visitor); |
| 172 | 172 |
| 173 static RawObject* FromAddr(uword addr) { | 173 static RawObject* FromAddr(uword addr) { |
| 174 // We expect the untagged address here. | 174 // We expect the untagged address here. |
| 175 ASSERT((addr & kSmiTagMask) != kHeapObjectTag); | 175 ASSERT((addr & kSmiTagMask) != kHeapObjectTag); |
| 176 return reinterpret_cast<RawObject*>(addr + kHeapObjectTag); | 176 return reinterpret_cast<RawObject*>(addr + kHeapObjectTag); |
| 177 } | 177 } |
| 178 | 178 |
| 179 static uword ToAddr(RawObject* raw_obj) { | 179 static uword ToAddr(RawObject* raw_obj) { |
| 180 return reinterpret_cast<uword>(raw_obj->ptr()); | 180 return reinterpret_cast<uword>(raw_obj->ptr()); |
| 181 } | 181 } |
| 182 | 182 |
| 183 protected: | 183 protected: |
| 184 RawClass* class_; | 184 RawClass* class_; |
| 185 | 185 |
| 186 private: | 186 private: |
| 187 enum { | 187 enum { |
| 188 kMarkingMask = 3, | 188 kMarkingMask = 3, |
| 189 kNotMarked = 1, // Tagged pointer. | 189 kNotMarked = 1, // Tagged pointer. |
| 190 kMarked = 3, // Tagged pointer and forwarding bit set. | 190 kMarked = 3, // Tagged pointer and forwarding bit set. |
| 191 kMarkBit = 2, |
| 191 }; | 192 }; |
| 192 | 193 |
| 193 RawObject* ptr() const { | 194 RawObject* ptr() const { |
| 194 ASSERT(IsHeapObject()); | 195 ASSERT(IsHeapObject()); |
| 195 return reinterpret_cast<RawObject*>( | 196 return reinterpret_cast<RawObject*>( |
| 196 reinterpret_cast<uword>(this) - kHeapObjectTag); | 197 reinterpret_cast<uword>(this) - kHeapObjectTag); |
| 197 } | 198 } |
| 198 | 199 |
| 199 intptr_t tags_; // Various object tags (bits). | 200 intptr_t tags_; // Various object tags (bits). |
| 200 | 201 |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 intptr_t type_; // Uninitialized, simple or complex. | 863 intptr_t type_; // Uninitialized, simple or complex. |
| 863 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 864 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
| 864 | 865 |
| 865 // Variable length data follows here. | 866 // Variable length data follows here. |
| 866 uint8_t data_[0]; | 867 uint8_t data_[0]; |
| 867 }; | 868 }; |
| 868 | 869 |
| 869 } // namespace dart | 870 } // namespace dart |
| 870 | 871 |
| 871 #endif // VM_RAW_OBJECT_H_ | 872 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |