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

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

Issue 1644793002: Replace intptr_t with TokenDescriptor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « runtime/vm/precompiler.cc ('k') | runtime/vm/raw_object_snapshot.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) 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"
11 #include "vm/snapshot.h" 11 #include "vm/snapshot.h"
12 #include "vm/token.h" 12 #include "vm/token.h"
13 #include "vm/token_position.h"
13 #include "vm/verified_memory.h" 14 #include "vm/verified_memory.h"
14 15
15 namespace dart { 16 namespace dart {
16 17
17 // Macrobatics to define the Object hierarchy of VM implementation classes. 18 // Macrobatics to define the Object hierarchy of VM implementation classes.
18 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \ 19 #define CLASS_LIST_NO_OBJECT_NOR_STRING_NOR_ARRAY(V) \
19 V(Class) \ 20 V(Class) \
20 V(UnresolvedClass) \ 21 V(UnresolvedClass) \
21 V(TypeArguments) \ 22 V(TypeArguments) \
22 V(PatchClass) \ 23 V(PatchClass) \
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 RawObject* canonical_types_; // An array of canonicalized types of this class 672 RawObject* canonical_types_; // An array of canonicalized types of this class
672 // or the canonical type. 673 // or the canonical type.
673 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions. 674 RawArray* invocation_dispatcher_cache_; // Cache for dispatcher functions.
674 RawArray* cha_codes_; // CHA optimized codes. 675 RawArray* cha_codes_; // CHA optimized codes.
675 RawCode* allocation_stub_; // Stub code for allocation of instances. 676 RawCode* allocation_stub_; // Stub code for allocation of instances.
676 RawObject** to() { 677 RawObject** to() {
677 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_); 678 return reinterpret_cast<RawObject**>(&ptr()->allocation_stub_);
678 } 679 }
679 680
680 cpp_vtable handle_vtable_; 681 cpp_vtable handle_vtable_;
681 int32_t token_pos_; 682 TokenPosition token_pos_;
682 int32_t instance_size_in_words_; // Size if fixed len or 0 if variable len. 683 int32_t instance_size_in_words_; // Size if fixed len or 0 if variable len.
683 int32_t type_arguments_field_offset_in_words_; // Offset of type args fld. 684 int32_t type_arguments_field_offset_in_words_; // Offset of type args fld.
684 int32_t next_field_offset_in_words_; // Offset of the next instance field. 685 int32_t next_field_offset_in_words_; // Offset of the next instance field.
685 classid_t id_; // Class Id, also index in the class table. 686 classid_t id_; // Class Id, also index in the class table.
686 int16_t num_type_arguments_; // Number of type arguments in flattened vector. 687 int16_t num_type_arguments_; // Number of type arguments in flattened vector.
687 int16_t num_own_type_arguments_; // Number of non-overlapping type arguments. 688 int16_t num_own_type_arguments_; // Number of non-overlapping type arguments.
688 uint16_t num_native_fields_; // Number of native fields in class. 689 uint16_t num_native_fields_; // Number of native fields in class.
689 uint16_t state_bits_; 690 uint16_t state_bits_;
690 691
691 friend class Instance; 692 friend class Instance;
692 friend class Object; 693 friend class Object;
693 friend class RawInstance; 694 friend class RawInstance;
694 friend class RawInstructions; 695 friend class RawInstructions;
695 friend class SnapshotReader; 696 friend class SnapshotReader;
696 }; 697 };
697 698
698 699
699 class RawUnresolvedClass : public RawObject { 700 class RawUnresolvedClass : public RawObject {
700 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass); 701 RAW_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass);
701 702
702 RawObject** from() { 703 RawObject** from() {
703 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_); 704 return reinterpret_cast<RawObject**>(&ptr()->library_prefix_);
704 } 705 }
705 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident. 706 RawLibraryPrefix* library_prefix_; // Library prefix qualifier for the ident.
706 RawString* ident_; // Name of the unresolved identifier. 707 RawString* ident_; // Name of the unresolved identifier.
707 RawObject** to() { 708 RawObject** to() {
708 return reinterpret_cast<RawObject**>(&ptr()->ident_); 709 return reinterpret_cast<RawObject**>(&ptr()->ident_);
709 } 710 }
710 int32_t token_pos_; 711 TokenPosition token_pos_;
711 }; 712 };
712 713
713 714
714 class RawTypeArguments : public RawObject { 715 class RawTypeArguments : public RawObject {
715 private: 716 private:
716 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments); 717 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeArguments);
717 718
718 RawObject** from() { 719 RawObject** from() {
719 return reinterpret_cast<RawObject**>(&ptr()->instantiations_); 720 return reinterpret_cast<RawObject**>(&ptr()->instantiations_);
720 } 721 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 RawObject** to_no_code() { 810 RawObject** to_no_code() {
810 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); 811 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_);
811 } 812 }
812 RawCode* code_; // Currently active code. 813 RawCode* code_; // Currently active code.
813 RawCode* unoptimized_code_; // Unoptimized code, keep it after optimization. 814 RawCode* unoptimized_code_; // Unoptimized code, keep it after optimization.
814 RawObject** to() { 815 RawObject** to() {
815 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); 816 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_);
816 } 817 }
817 uword entry_point_; 818 uword entry_point_;
818 819
819 int32_t token_pos_; 820 TokenPosition token_pos_;
820 int32_t end_token_pos_; 821 TokenPosition end_token_pos_;
821 int32_t usage_counter_; // Incremented while function is running. 822 int32_t usage_counter_; // Incremented while function is running.
822 int16_t num_fixed_parameters_; 823 int16_t num_fixed_parameters_;
823 int16_t num_optional_parameters_; // > 0: positional; < 0: named. 824 int16_t num_optional_parameters_; // > 0: positional; < 0: named.
824 int16_t deoptimization_counter_; 825 int16_t deoptimization_counter_;
825 uint32_t kind_tag_; // See Function::KindTagBits. 826 uint32_t kind_tag_; // See Function::KindTagBits.
826 uint16_t optimized_instruction_count_; 827 uint16_t optimized_instruction_count_;
827 uint16_t optimized_call_site_count_; 828 uint16_t optimized_call_site_count_;
828 }; 829 };
829 830
830 831
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 } initializer_; 887 } initializer_;
887 RawObject** to_precompiled_snapshot() { 888 RawObject** to_precompiled_snapshot() {
888 return reinterpret_cast<RawObject**>(&ptr()->initializer_); 889 return reinterpret_cast<RawObject**>(&ptr()->initializer_);
889 } 890 }
890 RawArray* dependent_code_; 891 RawArray* dependent_code_;
891 RawSmi* guarded_list_length_; 892 RawSmi* guarded_list_length_;
892 RawObject** to() { 893 RawObject** to() {
893 return reinterpret_cast<RawObject**>(&ptr()->guarded_list_length_); 894 return reinterpret_cast<RawObject**>(&ptr()->guarded_list_length_);
894 } 895 }
895 896
896 int32_t token_pos_; 897 TokenPosition token_pos_;
897 classid_t guarded_cid_; 898 classid_t guarded_cid_;
898 classid_t is_nullable_; // kNullCid if field can contain null value and 899 classid_t is_nullable_; // kNullCid if field can contain null value and
899 // any other value otherwise. 900 // any other value otherwise.
900 // Offset to the guarded length field inside an instance of class matching 901 // Offset to the guarded length field inside an instance of class matching
901 // guarded_cid_. Stored corrected by -kHeapObjectTag to simplify code 902 // guarded_cid_. Stored corrected by -kHeapObjectTag to simplify code
902 // generated on platforms with weak addressing modes (ARM, MIPS). 903 // generated on platforms with weak addressing modes (ARM, MIPS).
903 int8_t guarded_list_length_in_object_offset_; 904 int8_t guarded_list_length_in_object_offset_;
904 905
905 uint8_t kind_bits_; // static, final, const, has initializer.... 906 uint8_t kind_bits_; // static, final, const, has initializer....
906 }; 907 };
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 kIndexBias = 1 << (kIndexSize - 1), 1273 kIndexBias = 1 << (kIndexSize - 1),
1273 kMaxIndex = (1 << (kIndexSize - 1)) - 1, 1274 kMaxIndex = (1 << (kIndexSize - 1)) - 1,
1274 }; 1275 };
1275 1276
1276 class IndexBits : public BitField<int32_t, kIndexPos, kIndexSize> {}; 1277 class IndexBits : public BitField<int32_t, kIndexPos, kIndexSize> {};
1277 class KindBits : public BitField<int8_t, kKindPos, kKindSize>{}; 1278 class KindBits : public BitField<int8_t, kKindPos, kKindSize>{};
1278 1279
1279 struct VarInfo { 1280 struct VarInfo {
1280 int32_t index_kind; // Bitfield for slot index on stack or in context, 1281 int32_t index_kind; // Bitfield for slot index on stack or in context,
1281 // and Entry kind of type VarInfoKind. 1282 // and Entry kind of type VarInfoKind.
1282 int32_t begin_pos; // Token position of scope start. 1283 TokenPosition begin_pos; // Token position of scope start.
1283 int32_t end_pos; // Token position of scope end. 1284 TokenPosition end_pos; // Token position of scope end.
1284 int16_t scope_id; // Scope to which the variable belongs. 1285 int16_t scope_id; // Scope to which the variable belongs.
1285 1286
1286 VarInfoKind kind() const { 1287 VarInfoKind kind() const {
1287 return static_cast<VarInfoKind>(KindBits::decode(index_kind)); 1288 return static_cast<VarInfoKind>(KindBits::decode(index_kind));
1288 } 1289 }
1289 void set_kind(VarInfoKind kind) { 1290 void set_kind(VarInfoKind kind) {
1290 index_kind = KindBits::update(kind, index_kind); 1291 index_kind = KindBits::update(kind, index_kind);
1291 } 1292 }
1292 int32_t index() const { 1293 int32_t index() const {
1293 return IndexBits::decode(index_kind) - kIndexBias; 1294 return IndexBits::decode(index_kind) - kIndexBias;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 RawObject** from() { 1489 RawObject** from() {
1489 return reinterpret_cast<RawObject**>(&ptr()->previous_error_); 1490 return reinterpret_cast<RawObject**>(&ptr()->previous_error_);
1490 } 1491 }
1491 RawError* previous_error_; // May be null. 1492 RawError* previous_error_; // May be null.
1492 RawScript* script_; 1493 RawScript* script_;
1493 RawString* message_; 1494 RawString* message_;
1494 RawString* formatted_message_; // Incl. previous error's formatted message. 1495 RawString* formatted_message_; // Incl. previous error's formatted message.
1495 RawObject** to() { 1496 RawObject** to() {
1496 return reinterpret_cast<RawObject**>(&ptr()->formatted_message_); 1497 return reinterpret_cast<RawObject**>(&ptr()->formatted_message_);
1497 } 1498 }
1498 int32_t token_pos_; // Source position in script_. 1499 TokenPosition token_pos_; // Source position in script_.
1499 bool report_after_token_; // Report message at or after the token. 1500 bool report_after_token_; // Report message at or after the token.
1500 int8_t kind_; // Of type LanguageError::Kind. 1501 int8_t kind_; // Of type LanguageError::Kind.
1501 }; 1502 };
1502 1503
1503 1504
1504 class RawUnhandledException : public RawError { 1505 class RawUnhandledException : public RawError {
1505 RAW_HEAP_OBJECT_IMPLEMENTATION(UnhandledException); 1506 RAW_HEAP_OBJECT_IMPLEMENTATION(UnhandledException);
1506 1507
1507 RawObject** from() { 1508 RawObject** from() {
1508 return reinterpret_cast<RawObject**>(&ptr()->exception_); 1509 return reinterpret_cast<RawObject**>(&ptr()->exception_);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 1577
1577 RawObject** from() { 1578 RawObject** from() {
1578 return reinterpret_cast<RawObject**>(&ptr()->type_class_); 1579 return reinterpret_cast<RawObject**>(&ptr()->type_class_);
1579 } 1580 }
1580 RawObject* type_class_; // Either resolved class or unresolved class. 1581 RawObject* type_class_; // Either resolved class or unresolved class.
1581 RawTypeArguments* arguments_; 1582 RawTypeArguments* arguments_;
1582 RawLanguageError* error_; // Error object if type is malformed or malbounded. 1583 RawLanguageError* error_; // Error object if type is malformed or malbounded.
1583 RawObject** to() { 1584 RawObject** to() {
1584 return reinterpret_cast<RawObject**>(&ptr()->error_); 1585 return reinterpret_cast<RawObject**>(&ptr()->error_);
1585 } 1586 }
1586 int32_t token_pos_; 1587 TokenPosition token_pos_;
1587 int8_t type_state_; 1588 int8_t type_state_;
1588 }; 1589 };
1589 1590
1590 1591
1591 class RawFunctionType : public RawAbstractType { 1592 class RawFunctionType : public RawAbstractType {
1592 private: 1593 private:
1593 RAW_HEAP_OBJECT_IMPLEMENTATION(FunctionType); 1594 RAW_HEAP_OBJECT_IMPLEMENTATION(FunctionType);
1594 1595
1595 RawObject** from() { 1596 RawObject** from() {
1596 return reinterpret_cast<RawObject**>(&ptr()->scope_class_); 1597 return reinterpret_cast<RawObject**>(&ptr()->scope_class_);
1597 } 1598 }
1598 RawClass* scope_class_; 1599 RawClass* scope_class_;
1599 RawTypeArguments* arguments_; 1600 RawTypeArguments* arguments_;
1600 RawFunction* signature_; 1601 RawFunction* signature_;
1601 RawLanguageError* error_; // Error object if type is malformed or malbounded. 1602 RawLanguageError* error_; // Error object if type is malformed or malbounded.
1602 RawObject** to() { 1603 RawObject** to() {
1603 return reinterpret_cast<RawObject**>(&ptr()->error_); 1604 return reinterpret_cast<RawObject**>(&ptr()->error_);
1604 } 1605 }
1605 int32_t token_pos_; 1606 TokenPosition token_pos_;
1606 int8_t type_state_; 1607 int8_t type_state_;
1607 }; 1608 };
1608 1609
1609 1610
1610 class RawTypeRef : public RawAbstractType { 1611 class RawTypeRef : public RawAbstractType {
1611 private: 1612 private:
1612 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef); 1613 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeRef);
1613 1614
1614 RawObject** from() { 1615 RawObject** from() {
1615 return reinterpret_cast<RawObject**>(&ptr()->type_); 1616 return reinterpret_cast<RawObject**>(&ptr()->type_);
1616 } 1617 }
1617 RawAbstractType* type_; // The referenced type. 1618 RawAbstractType* type_; // The referenced type.
1618 RawObject** to() { 1619 RawObject** to() {
1619 return reinterpret_cast<RawObject**>(&ptr()->type_); 1620 return reinterpret_cast<RawObject**>(&ptr()->type_);
1620 } 1621 }
1621 }; 1622 };
1622 1623
1623 1624
1624 class RawTypeParameter : public RawAbstractType { 1625 class RawTypeParameter : public RawAbstractType {
1625 private: 1626 private:
1626 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter); 1627 RAW_HEAP_OBJECT_IMPLEMENTATION(TypeParameter);
1627 1628
1628 RawObject** from() { 1629 RawObject** from() {
1629 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_); 1630 return reinterpret_cast<RawObject**>(&ptr()->parameterized_class_);
1630 } 1631 }
1631 RawClass* parameterized_class_; 1632 RawClass* parameterized_class_;
1632 RawString* name_; 1633 RawString* name_;
1633 RawAbstractType* bound_; // ObjectType if no explicit bound specified. 1634 RawAbstractType* bound_; // ObjectType if no explicit bound specified.
1634 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); } 1635 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->bound_); }
1635 int32_t token_pos_; 1636 TokenPosition token_pos_;
1636 int16_t index_; 1637 int16_t index_;
1637 int8_t type_state_; 1638 int8_t type_state_;
1638 }; 1639 };
1639 1640
1640 1641
1641 class RawBoundedType : public RawAbstractType { 1642 class RawBoundedType : public RawAbstractType {
1642 private: 1643 private:
1643 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType); 1644 RAW_HEAP_OBJECT_IMPLEMENTATION(BoundedType);
1644 1645
1645 RawObject** from() { 1646 RawObject** from() {
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2334 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2334 kTypedDataInt8ArrayViewCid + 15); 2335 kTypedDataInt8ArrayViewCid + 15);
2335 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2336 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2336 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2337 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2337 return (kNullCid - kTypedDataInt8ArrayCid); 2338 return (kNullCid - kTypedDataInt8ArrayCid);
2338 } 2339 }
2339 2340
2340 } // namespace dart 2341 } // namespace dart
2341 2342
2342 #endif // VM_RAW_OBJECT_H_ 2343 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/precompiler.cc ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698