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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 static bool IsIntegerClassId(intptr_t index); | 396 static bool IsIntegerClassId(intptr_t index); |
397 static bool IsStringClassId(intptr_t index); | 397 static bool IsStringClassId(intptr_t index); |
398 static bool IsOneByteStringClassId(intptr_t index); | 398 static bool IsOneByteStringClassId(intptr_t index); |
399 static bool IsTwoByteStringClassId(intptr_t index); | 399 static bool IsTwoByteStringClassId(intptr_t index); |
400 static bool IsExternalStringClassId(intptr_t index); | 400 static bool IsExternalStringClassId(intptr_t index); |
401 static bool IsBuiltinListClassId(intptr_t index); | 401 static bool IsBuiltinListClassId(intptr_t index); |
402 static bool IsTypedDataClassId(intptr_t index); | 402 static bool IsTypedDataClassId(intptr_t index); |
403 static bool IsTypedDataViewClassId(intptr_t index); | 403 static bool IsTypedDataViewClassId(intptr_t index); |
404 static bool IsExternalTypedDataClassId(intptr_t index); | 404 static bool IsExternalTypedDataClassId(intptr_t index); |
405 static bool IsInternalVMdefinedClassId(intptr_t index); | 405 static bool IsInternalVMdefinedClassId(intptr_t index); |
| 406 static bool IsVariableSizeClassId(intptr_t index); |
406 | 407 |
407 static intptr_t NumberOfTypedDataClasses(); | 408 static intptr_t NumberOfTypedDataClasses(); |
408 | 409 |
409 private: | 410 private: |
410 uword tags_; // Various object tags (bits). | 411 uword tags_; // Various object tags (bits). |
411 | 412 |
412 class WatchedBit : public BitField<bool, kWatchedBit, 1> {}; | 413 class WatchedBit : public BitField<bool, kWatchedBit, 1> {}; |
413 | 414 |
414 class MarkBit : public BitField<bool, kMarkBit, 1> {}; | 415 class MarkBit : public BitField<bool, kMarkBit, 1> {}; |
415 | 416 |
(...skipping 19 matching lines...) Expand all Loading... |
435 uword tags = ptr()->tags_; | 436 uword tags = ptr()->tags_; |
436 return ClassIdTag::decode(tags); | 437 return ClassIdTag::decode(tags); |
437 } | 438 } |
438 | 439 |
439 friend class Api; | 440 friend class Api; |
440 friend class Array; | 441 friend class Array; |
441 friend class FreeListElement; | 442 friend class FreeListElement; |
442 friend class GCMarker; | 443 friend class GCMarker; |
443 friend class ExternalTypedData; | 444 friend class ExternalTypedData; |
444 friend class Heap; | 445 friend class Heap; |
| 446 friend class ClassStatsVisitor; |
445 friend class MarkingVisitor; | 447 friend class MarkingVisitor; |
446 friend class Object; | 448 friend class Object; |
447 friend class ObjectHistogram; | 449 friend class ObjectHistogram; |
448 friend class RawExternalTypedData; | 450 friend class RawExternalTypedData; |
449 friend class RawInstructions; | 451 friend class RawInstructions; |
450 friend class RawInstance; | 452 friend class RawInstance; |
451 friend class RawTypedData; | 453 friend class RawTypedData; |
452 friend class Scavenger; | 454 friend class Scavenger; |
| 455 friend class ScavengerVisitor; |
453 friend class SnapshotReader; | 456 friend class SnapshotReader; |
454 friend class SnapshotWriter; | 457 friend class SnapshotWriter; |
455 friend class String; | 458 friend class String; |
456 friend class TypedData; | 459 friend class TypedData; |
457 friend class TypedDataView; | 460 friend class TypedDataView; |
458 | 461 |
459 DISALLOW_ALLOCATION(); | 462 DISALLOW_ALLOCATION(); |
460 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); | 463 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); |
461 }; | 464 }; |
462 | 465 |
463 | 466 |
464 class RawClass : public RawObject { | 467 class RawClass : public RawObject { |
465 public: | 468 public: |
466 enum ClassFinalizedState { | 469 enum ClassFinalizedState { |
467 kAllocated = 0, // Initial state. | 470 kAllocated = 0, // Initial state. |
468 kPreFinalized, // VM classes: size precomputed, but no checks done. | 471 kPreFinalized, // VM classes: size precomputed, but no checks done. |
469 kFinalized, // Class parsed, finalized and ready for use. | 472 kFinalized, // Class parsed, finalized and ready for use. |
470 }; | 473 }; |
471 | 474 |
472 private: | 475 private: |
473 RAW_HEAP_OBJECT_IMPLEMENTATION(Class); | 476 RAW_HEAP_OBJECT_IMPLEMENTATION(Class); |
474 | 477 |
475 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } | 478 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); } |
476 RawString* name_; | 479 RawString* name_; |
| 480 RawString* user_name_; |
477 RawArray* functions_; | 481 RawArray* functions_; |
478 RawArray* fields_; | 482 RawArray* fields_; |
479 RawArray* offset_in_words_to_field_; | 483 RawArray* offset_in_words_to_field_; |
480 RawGrowableObjectArray* closure_functions_; // Local functions and literals. | 484 RawGrowableObjectArray* closure_functions_; // Local functions and literals. |
481 RawArray* interfaces_; // Array of AbstractType. | 485 RawArray* interfaces_; // Array of AbstractType. |
482 RawGrowableObjectArray* direct_subclasses_; // Array of Class. | 486 RawGrowableObjectArray* direct_subclasses_; // Array of Class. |
483 RawScript* script_; | 487 RawScript* script_; |
484 RawLibrary* library_; | 488 RawLibrary* library_; |
485 RawTypeArguments* type_parameters_; // Array of TypeParameter. | 489 RawTypeArguments* type_parameters_; // Array of TypeParameter. |
486 RawAbstractType* super_type_; | 490 RawAbstractType* super_type_; |
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 index <= kExternalTypedDataInt32x4ArrayCid); | 1735 index <= kExternalTypedDataInt32x4ArrayCid); |
1732 } | 1736 } |
1733 | 1737 |
1734 | 1738 |
1735 inline bool RawObject::IsInternalVMdefinedClassId(intptr_t index) { | 1739 inline bool RawObject::IsInternalVMdefinedClassId(intptr_t index) { |
1736 return ((index < kNumPredefinedCids) && | 1740 return ((index < kNumPredefinedCids) && |
1737 !RawObject::IsTypedDataViewClassId(index)); | 1741 !RawObject::IsTypedDataViewClassId(index)); |
1738 } | 1742 } |
1739 | 1743 |
1740 | 1744 |
| 1745 |
| 1746 inline bool RawObject::IsVariableSizeClassId(intptr_t index) { |
| 1747 return (index == kArrayCid) || |
| 1748 (index == kImmutableArrayCid) || |
| 1749 RawObject::IsOneByteStringClassId(index) || |
| 1750 RawObject::IsTwoByteStringClassId(index) || |
| 1751 RawObject::IsTypedDataClassId(index) || |
| 1752 (index == kContextCid) || |
| 1753 (index == kTypeArgumentsCid) || |
| 1754 (index == kInstructionsCid) || |
| 1755 (index == kPcDescriptorsCid) || |
| 1756 (index == kStackmapCid) || |
| 1757 (index == kLocalVarDescriptorsCid) || |
| 1758 (index == kExceptionHandlersCid) || |
| 1759 (index == kDeoptInfoCid) || |
| 1760 (index == kCodeCid) || |
| 1761 (index == kContextScopeCid) || |
| 1762 (index == kInstanceCid) || |
| 1763 (index == kBigintCid) || |
| 1764 (index == kJSRegExpCid); |
| 1765 } |
| 1766 |
| 1767 |
1741 inline intptr_t RawObject::NumberOfTypedDataClasses() { | 1768 inline intptr_t RawObject::NumberOfTypedDataClasses() { |
1742 // Make sure this is updated when new TypedData types are added. | 1769 // Make sure this is updated when new TypedData types are added. |
1743 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 13); | 1770 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 13); |
1744 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 14); | 1771 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 14); |
1745 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 13); | 1772 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 13); |
1746 return (kNullCid - kTypedDataInt8ArrayCid); | 1773 return (kNullCid - kTypedDataInt8ArrayCid); |
1747 } | 1774 } |
1748 | 1775 |
1749 } // namespace dart | 1776 } // namespace dart |
1750 | 1777 |
1751 #endif // VM_RAW_OBJECT_H_ | 1778 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |