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

Side by Side Diff: runtime/vm/raw_object.h

Issue 2281263002: AOT: Reassign class ids so class hierarchies have contiguous ranges. (Closed)
Patch Set: . Created 4 years, 3 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
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/atomic.h" 9 #include "vm/atomic.h"
10 #include "vm/globals.h" 10 #include "vm/globals.h"
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 reinterpret_cast<uword>(this) - kHeapObjectTag); 532 reinterpret_cast<uword>(this) - kHeapObjectTag);
533 } 533 }
534 534
535 intptr_t SizeFromClass() const; 535 intptr_t SizeFromClass() const;
536 536
537 intptr_t GetClassId() const { 537 intptr_t GetClassId() const {
538 uword tags = ptr()->tags_; 538 uword tags = ptr()->tags_;
539 return ClassIdTag::decode(tags); 539 return ClassIdTag::decode(tags);
540 } 540 }
541 541
542 void SetClassId(intptr_t new_cid) {
543 uword tags = ptr()->tags_;
544 ptr()->tags_ = ClassIdTag::update(new_cid, tags);
545 }
546
542 template<class TagBitField> 547 template<class TagBitField>
543 void UpdateTagBit(bool value) { 548 void UpdateTagBit(bool value) {
544 uword tags = ptr()->tags_; 549 uword tags = ptr()->tags_;
545 uword old_tags; 550 uword old_tags;
546 do { 551 do {
547 old_tags = tags; 552 old_tags = tags;
548 uword new_tags = TagBitField::update(value, old_tags); 553 uword new_tags = TagBitField::update(value, old_tags);
549 tags = AtomicOperations::CompareAndSwapWord( 554 tags = AtomicOperations::CompareAndSwapWord(
550 &ptr()->tags_, old_tags, new_tags); 555 &ptr()->tags_, old_tags, new_tags);
551 } while (tags != old_tags); 556 } while (tags != old_tags);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 *const_cast<RawSmi**>(addr) = value; 594 *const_cast<RawSmi**>(addr) = value;
590 } 595 }
591 596
592 friend class Api; 597 friend class Api;
593 friend class ApiMessageReader; // GetClassId 598 friend class ApiMessageReader; // GetClassId
594 friend class Serializer; // GetClassId 599 friend class Serializer; // GetClassId
595 friend class Array; 600 friend class Array;
596 friend class Become; // GetClassId 601 friend class Become; // GetClassId
597 friend class Bigint; 602 friend class Bigint;
598 friend class ByteBuffer; 603 friend class ByteBuffer;
604 friend class CidRewriteVisitor;
599 friend class Closure; 605 friend class Closure;
600 friend class Code; 606 friend class Code;
601 friend class Double; 607 friend class Double;
602 friend class ForwardPointersVisitor; // StorePointer 608 friend class ForwardPointersVisitor; // StorePointer
603 friend class FreeListElement; 609 friend class FreeListElement;
604 friend class Function; 610 friend class Function;
605 friend class GCMarker; 611 friend class GCMarker;
606 friend class ExternalTypedData; 612 friend class ExternalTypedData;
607 friend class ForwardList; 613 friend class ForwardList;
608 friend class GrowableObjectArray; // StorePointer 614 friend class GrowableObjectArray; // StorePointer
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 uint16_t num_native_fields_; // Number of native fields in class. 718 uint16_t num_native_fields_; // Number of native fields in class.
713 uint16_t state_bits_; 719 uint16_t state_bits_;
714 720
715 friend class Instance; 721 friend class Instance;
716 friend class Isolate; 722 friend class Isolate;
717 friend class Object; 723 friend class Object;
718 friend class RawInstance; 724 friend class RawInstance;
719 friend class RawInstructions; 725 friend class RawInstructions;
720 friend class SnapshotReader; 726 friend class SnapshotReader;
721 friend class InstanceSerializationCluster; 727 friend class InstanceSerializationCluster;
728 friend class CidRewriteVisitor;
722 }; 729 };
723 730
724 731
725 class RawUnresolvedClass : public RawObject { 732 class RawUnresolvedClass : public RawObject {
726 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); 733 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass);
727 734
728 RawObject** from() { 735 RawObject** from() {
729 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_); 736 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_);
730 } 737 }
731 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident. 738 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 TokenPosition token_pos_; 947 TokenPosition token_pos_;
941 classid_t guarded_cid_; 948 classid_t guarded_cid_;
942 classid_t is_nullable_; // kNullCid if field can contain null value and 949 classid_t is_nullable_; // kNullCid if field can contain null value and
943 // any other value otherwise. 950 // any other value otherwise.
944 // Offset to the guarded length field inside an instance of class matching 951 // Offset to the guarded length field inside an instance of class matching
945 // guarded_cid_. Stored corrected by -kHeapObjectTag to simplify code 952 // guarded_cid_. Stored corrected by -kHeapObjectTag to simplify code
946 // generated on platforms with weak addressing modes (ARM, MIPS). 953 // generated on platforms with weak addressing modes (ARM, MIPS).
947 int8_t guarded_list_length_in_object_offset_; 954 int8_t guarded_list_length_in_object_offset_;
948 955
949 uint8_t kind_bits_; // static, final, const, has initializer.... 956 uint8_t kind_bits_; // static, final, const, has initializer....
957
958 friend class CidRewriteVisitor;
950 }; 959 };
951 960
952 961
953 class RawLiteralToken : public RawObject { 962 class RawLiteralToken : public RawObject {
954 RAW_HEAP_OBJECT_IMPLEMENTATION(LiteralToken); 963 RAW_HEAP_OBJECT_IMPLEMENTATION(LiteralToken);
955 964
956 RawObject** from() { 965 RawObject** from() {
957 return reinterpret_cast<RawObject**>(&ptr()->literal_); 966 return reinterpret_cast<RawObject**>(&ptr()->literal_);
958 } 967 }
959 RawString* literal_; // Literal characters as they appear in source text. 968 RawString* literal_; // Literal characters as they appear in source text.
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 // can describe the issue without needing the signature. 1683 // can describe the issue without needing the signature.
1675 union { 1684 union {
1676 RawFunction* signature_; // If not null, this type is a function type. 1685 RawFunction* signature_; // If not null, this type is a function type.
1677 RawLanguageError* error_; // If not null, type is malformed or malbounded. 1686 RawLanguageError* error_; // If not null, type is malformed or malbounded.
1678 } sig_or_err_; 1687 } sig_or_err_;
1679 RawObject** to() { 1688 RawObject** to() {
1680 return reinterpret_cast<RawObject**>(&ptr()->sig_or_err_.error_); 1689 return reinterpret_cast<RawObject**>(&ptr()->sig_or_err_.error_);
1681 } 1690 }
1682 TokenPosition token_pos_; 1691 TokenPosition token_pos_;
1683 int8_t type_state_; 1692 int8_t type_state_;
1693
1694 friend class CidRewriteVisitor;
1684 }; 1695 };
1685 1696
1686 1697
1687 class RawTypeRef : public RawAbstractType { 1698 class RawTypeRef : public RawAbstractType {
1688 private: 1699 private:
1689 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef); 1700 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef);
1690 1701
1691 RawObject** from() { 1702 RawObject** from() {
1692 return reinterpret_cast<RawObject**>(&ptr()->type_); 1703 return reinterpret_cast<RawObject**>(&ptr()->type_);
1693 } 1704 }
(...skipping 12 matching lines...) Expand all
1706 return reinterpret_cast<RawObject**>(&ptr()->name_); 1717 return reinterpret_cast<RawObject**>(&ptr()->name_);
1707 } 1718 }
1708 RawString* name_; 1719 RawString* name_;
1709 RawSmi* hash_; 1720 RawSmi* hash_;
1710 RawAbstractType* bound_; // ObjectType if no explicit bound specified. 1721 RawAbstractType* bound_; // ObjectType if no explicit bound specified.
1711 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); } 1722 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); }
1712 classid_t parameterized_class_id_; 1723 classid_t parameterized_class_id_;
1713 TokenPosition token_pos_; 1724 TokenPosition token_pos_;
1714 int16_t index_; 1725 int16_t index_;
1715 int8_t type_state_; 1726 int8_t type_state_;
1727
1728 friend class CidRewriteVisitor;
1716 }; 1729 };
1717 1730
1718 1731
1719 class RawBoundedType : public RawAbstractType { 1732 class RawBoundedType : public RawAbstractType {
1720 private: 1733 private:
1721 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType); 1734 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType);
1722 1735
1723 RawObject** from() { 1736 RawObject** from() {
1724 return reinterpret_cast<RawObject**>(&ptr()->type_); 1737 return reinterpret_cast<RawObject**>(&ptr()->type_);
1725 } 1738 }
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2438 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2426 kTypedDataInt8ArrayViewCid + 15); 2439 kTypedDataInt8ArrayViewCid + 15);
2427 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2440 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2428 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2441 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2429 return (kNullCid - kTypedDataInt8ArrayCid); 2442 return (kNullCid - kTypedDataInt8ArrayCid);
2430 } 2443 }
2431 2444
2432 } // namespace dart 2445 } // namespace dart
2433 2446
2434 #endif // VM_RAW_OBJECT_H_ 2447 #endif // VM_RAW_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698