Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 | 229 |
| 230 bool IsNewObject() const { | 230 bool IsNewObject() const { |
| 231 uword addr = reinterpret_cast<uword>(this); | 231 uword addr = reinterpret_cast<uword>(this); |
| 232 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset; | 232 return (addr & kNewObjectAlignmentOffset) == kNewObjectAlignmentOffset; |
| 233 } | 233 } |
| 234 bool IsOldObject() const { | 234 bool IsOldObject() const { |
| 235 uword addr = reinterpret_cast<uword>(this); | 235 uword addr = reinterpret_cast<uword>(this); |
| 236 return (addr & kNewObjectAlignmentOffset) == kOldObjectAlignmentOffset; | 236 return (addr & kNewObjectAlignmentOffset) == kOldObjectAlignmentOffset; |
| 237 } | 237 } |
| 238 | 238 |
| 239 bool IsFree() const { | |
| 240 return FreeBit::decode(ptr()->tags_); | |
| 241 } | |
| 242 | |
| 239 // Support for GC marking bit. | 243 // Support for GC marking bit. |
| 240 bool IsMarked() const { | 244 bool IsMarked() const { |
| 241 return MarkBit::decode(ptr()->tags_); | 245 return MarkBit::decode(ptr()->tags_); |
| 242 } | 246 } |
| 243 void SetMarkBit() { | 247 void SetMarkBit() { |
| 244 ASSERT(!IsMarked()); | 248 ASSERT(!IsMarked()); |
| 245 uword tags = ptr()->tags_; | 249 uword tags = ptr()->tags_; |
| 246 ptr()->tags_ = MarkBit::update(true, tags); | 250 ptr()->tags_ = MarkBit::update(true, tags); |
| 247 } | 251 } |
| 248 void ClearMarkBit() { | 252 void ClearMarkBit() { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 static bool IsErrorClassIndex(intptr_t index); | 309 static bool IsErrorClassIndex(intptr_t index); |
| 306 static bool IsNumberClassIndex(intptr_t index); | 310 static bool IsNumberClassIndex(intptr_t index); |
| 307 static bool IsIntegerClassIndex(intptr_t index); | 311 static bool IsIntegerClassIndex(intptr_t index); |
| 308 static bool IsStringClassIndex(intptr_t index); | 312 static bool IsStringClassIndex(intptr_t index); |
| 309 static bool IsOneByteStringClassIndex(intptr_t index); | 313 static bool IsOneByteStringClassIndex(intptr_t index); |
| 310 static bool IsTwoByteStringClassIndex(intptr_t index); | 314 static bool IsTwoByteStringClassIndex(intptr_t index); |
| 311 static bool IsExternalStringClassIndex(intptr_t index); | 315 static bool IsExternalStringClassIndex(intptr_t index); |
| 312 static bool IsBuiltinListClassIndex(intptr_t index); | 316 static bool IsBuiltinListClassIndex(intptr_t index); |
| 313 static bool IsByteArrayClassIndex(intptr_t index); | 317 static bool IsByteArrayClassIndex(intptr_t index); |
| 314 | 318 |
| 319 RawClass* GetClass() const { | |
| 320 return GetClass(ptr()->tags_); | |
|
Ivan Posva
2012/05/26 04:34:46
If anything then all we should have here is GetCla
Vyacheslav Egorov (Google)
2012/05/26 16:48:22
Will do.
| |
| 321 } | |
| 322 | |
| 323 static RawClass* GetClass(uword tags); | |
|
Ivan Posva
2012/05/26 04:34:46
Does not belong here. Please move to Object, or Cl
Vyacheslav Egorov (Google)
2012/05/26 16:48:22
Will do.
| |
| 324 | |
| 325 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {}; | |
| 326 | |
| 315 protected: | 327 protected: |
| 316 RawClass* class_; | |
| 317 uword tags_; // Various object tags (bits). | 328 uword tags_; // Various object tags (bits). |
| 318 | 329 |
| 319 private: | 330 private: |
| 320 class FreeBit : public BitField<bool, kFreeBit, 1> {}; | 331 class FreeBit : public BitField<bool, kFreeBit, 1> {}; |
| 321 | 332 |
| 322 class MarkBit : public BitField<bool, kMarkBit, 1> {}; | 333 class MarkBit : public BitField<bool, kMarkBit, 1> {}; |
| 323 | 334 |
| 324 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {}; | 335 class CanonicalObjectTag : public BitField<bool, kCanonicalBit, 1> {}; |
| 325 | 336 |
| 326 class CreatedFromSnapshotTag : public BitField<bool, kFromSnapshotBit, 1> {}; | |
| 327 | 337 |
| 328 RawObject* ptr() const { | 338 RawObject* ptr() const { |
| 329 ASSERT(IsHeapObject()); | 339 ASSERT(IsHeapObject()); |
| 330 return reinterpret_cast<RawObject*>( | 340 return reinterpret_cast<RawObject*>( |
| 331 reinterpret_cast<uword>(this) - kHeapObjectTag); | 341 reinterpret_cast<uword>(this) - kHeapObjectTag); |
| 332 } | 342 } |
| 333 | 343 |
| 334 intptr_t SizeFromClass() const; | 344 intptr_t SizeFromClass() const; |
| 335 | 345 |
| 336 intptr_t GetClassIndex() const { | 346 intptr_t GetClassIndex() const { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 intptr_t token_index_; | 404 intptr_t token_index_; |
| 395 int8_t class_state_; // Of type ClassState. | 405 int8_t class_state_; // Of type ClassState. |
| 396 bool is_const_; | 406 bool is_const_; |
| 397 bool is_interface_; | 407 bool is_interface_; |
| 398 | 408 |
| 399 friend class Object; | 409 friend class Object; |
| 400 friend class RawInstance; | 410 friend class RawInstance; |
| 401 friend class RawInstructions; | 411 friend class RawInstructions; |
| 402 friend RawClass* AllocateFakeClass(); | 412 friend RawClass* AllocateFakeClass(); |
| 403 friend class SnapshotReader; | 413 friend class SnapshotReader; |
| 414 friend class ClassTable; | |
| 404 }; | 415 }; |
| 405 | 416 |
| 406 | 417 |
| 407 class RawUnresolvedClass : public RawObject { | 418 class RawUnresolvedClass : public RawObject { |
| 408 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); | 419 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); |
| 409 | 420 |
| 410 RawObject** from() { | 421 RawObject** from() { |
| 411 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_); | 422 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_); |
| 412 } | 423 } |
| 413 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident. | 424 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident. |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1496 kExternalUint64Array == kByteArray + 18 && | 1507 kExternalUint64Array == kByteArray + 18 && |
| 1497 kExternalFloat32Array == kByteArray + 19 && | 1508 kExternalFloat32Array == kByteArray + 19 && |
| 1498 kExternalFloat64Array == kByteArray + 20 && | 1509 kExternalFloat64Array == kByteArray + 20 && |
| 1499 kClosure == kByteArray + 21); | 1510 kClosure == kByteArray + 21); |
| 1500 return (index >= kByteArray && index <= kClosure); | 1511 return (index >= kByteArray && index <= kClosure); |
| 1501 } | 1512 } |
| 1502 | 1513 |
| 1503 } // namespace dart | 1514 } // namespace dart |
| 1504 | 1515 |
| 1505 #endif // VM_RAW_OBJECT_H_ | 1516 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |