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

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

Issue 343803002: Finishes removing intptr_t from raw object fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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/globals.h" 9 #include "vm/globals.h"
10 #include "vm/token.h" 10 #include "vm/token.h"
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 RawArray* static_calls_target_table_; // (code-offset, function, code). 845 RawArray* static_calls_target_table_; // (code-offset, function, code).
846 RawArray* stackmaps_; 846 RawArray* stackmaps_;
847 RawLocalVarDescriptors* var_descriptors_; 847 RawLocalVarDescriptors* var_descriptors_;
848 RawArray* comments_; 848 RawArray* comments_;
849 RawObject** to() { 849 RawObject** to() {
850 return reinterpret_cast<RawObject**>(&ptr()->comments_); 850 return reinterpret_cast<RawObject**>(&ptr()->comments_);
851 } 851 }
852 852
853 // Compilation timestamp. 853 // Compilation timestamp.
854 int64_t compile_timestamp_; 854 int64_t compile_timestamp_;
855 intptr_t pointer_offsets_length_; 855 int32_t pointer_offsets_length_;
856 // Alive: If true, the embedded object pointers will be visited during GC. 856 // Alive: If true, the embedded object pointers will be visited during GC.
857 // This field cannot be shorter because of alignment issues on x64 857 // This field cannot be shorter because of alignment issues on x64
858 // architectures. 858 // architectures.
859 intptr_t state_bits_; // state, is_optimized, is_alive. 859 int32_t state_bits_; // state, is_optimized, is_alive.
Ivan Posva 2014/06/26 09:02:04 Can we merge some of these fields into a bit field
zra 2014/07/01 20:37:01 Combined pointer_offsets_length_ and state_bits_ w
860 860
861 // PC offsets for code patching. 861 // PC offsets for code patching.
862 intptr_t entry_patch_pc_offset_; 862 int32_t entry_patch_pc_offset_;
863 intptr_t patch_code_pc_offset_; 863 int32_t patch_code_pc_offset_;
864 intptr_t lazy_deopt_pc_offset_; 864 int32_t lazy_deopt_pc_offset_;
865 865
866 // Variable length data follows here. 866 // Variable length data follows here.
867 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } 867 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); }
868 868
869 friend class StackFrame; 869 friend class StackFrame;
870 friend class MarkingVisitor; 870 friend class MarkingVisitor;
871 friend class Function; 871 friend class Function;
872 }; 872 };
873 873
874 874
875 class RawInstructions : public RawObject { 875 class RawInstructions : public RawObject {
876 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); 876 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions);
877 877
878 RawObject** from() { 878 RawObject** from() {
879 return reinterpret_cast<RawObject**>(&ptr()->code_); 879 return reinterpret_cast<RawObject**>(&ptr()->code_);
880 } 880 }
881 RawCode* code_; 881 RawCode* code_;
882 RawArray* object_pool_; 882 RawArray* object_pool_;
883 RawObject** to() { 883 RawObject** to() {
884 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); 884 return reinterpret_cast<RawObject**>(&ptr()->object_pool_);
885 } 885 }
886 intptr_t size_; 886 int32_t size_;
siva 2014/08/25 17:33:20 Instructions::kMaxElements should be changed to re
zra 2014/09/02 17:37:56 Done.
887 887
888 // Variable length data follows here. 888 // Variable length data follows here.
889 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 889 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
890 890
891 // Private helper function used while visiting stack frames. The 891 // Private helper function used while visiting stack frames. The
892 // code which iterates over dart frames is also called during GC and 892 // code which iterates over dart frames is also called during GC and
893 // is not allowed to create handles. 893 // is not allowed to create handles.
894 static bool ContainsPC(RawObject* raw_obj, uword pc); 894 static bool ContainsPC(RawObject* raw_obj, uword pc);
895 895
896 friend class RawCode; 896 friend class RawCode;
897 friend class Code; 897 friend class Code;
898 friend class StackFrame; 898 friend class StackFrame;
899 friend class MarkingVisitor; 899 friend class MarkingVisitor;
900 friend class Function; 900 friend class Function;
901 }; 901 };
902 902
903 903
904 class RawPcDescriptors : public RawObject { 904 class RawPcDescriptors : public RawObject {
905 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); 905 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors);
906 906
907 intptr_t length_; // Number of descriptors. 907 int32_t length_; // Number of descriptors.
siva 2014/08/25 17:33:20 PcDescriptors::kMaxElements should be changed to r
zra 2014/09/02 17:37:56 Done.
908 908
909 // Variable length data follows here. 909 // Variable length data follows here.
910 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); } 910 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); }
911 911
912 friend class Object; 912 friend class Object;
913 }; 913 };
914 914
915 915
916 // Stackmap is an immutable representation of the layout of the stack at a 916 // Stackmap is an immutable representation of the layout of the stack at a
917 // PC. The stack map representation consists of a bit map which marks each 917 // PC. The stack map representation consists of a bit map which marks each
918 // live object index starting from the base of the frame. 918 // live object index starting from the base of the frame.
919 // 919 //
920 // The Stackmap also consists of a link to the code object corresponding to 920 // The Stackmap also consists of a link to the code object corresponding to
921 // the frame which the stack map is describing. The bit map representation 921 // the frame which the stack map is describing. The bit map representation
922 // is optimized for dense and small bit maps, without any upper bound. 922 // is optimized for dense and small bit maps, without any upper bound.
923 class RawStackmap : public RawObject { 923 class RawStackmap : public RawObject {
924 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap); 924 RAW_HEAP_OBJECT_IMPLEMENTATION(Stackmap);
925 925
926 // TODO(kmillikin): We need a small number of bits to encode the register 926 // TODO(kmillikin): We need a small number of bits to encode the register
927 // count. Consider packing them in with the length. 927 // count. Consider packing them in with the length.
928 intptr_t length_; // Length of payload, in bits. 928 int32_t length_; // Length of payload, in bits.
929 intptr_t register_bit_count_; // Live register bits, included in length_. 929 int32_t register_bit_count_; // Live register bits, included in length_.
Ivan Posva 2014/06/26 09:02:04 BitField?
zra 2014/07/01 20:37:01 On arm64 register_bit_count_ could be as high as 9
siva 2014/08/25 17:33:20 should the signatures of RegisterBitCount SetRegis
zra 2014/09/02 17:37:56 Added ASSERT to SetRegisterBitCount. Thoughts on c
930 930
931 uword pc_; // PC corresponding to this stack map representation. 931 uword pc_; // PC corresponding to this stack map representation.
Ivan Posva 2014/06/26 09:02:04 We should encode most of these PCs as offset from
zra 2014/07/01 20:37:01 This one done.
932 932
933 // Variable length data follows here (bitmap of the stack layout). 933 // Variable length data follows here (bitmap of the stack layout).
934 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 934 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
935 }; 935 };
936 936
937 937
938 class RawLocalVarDescriptors : public RawObject { 938 class RawLocalVarDescriptors : public RawObject {
939 public: 939 public:
940 enum VarInfoKind { 940 enum VarInfoKind {
941 kStackVar = 1, 941 kStackVar = 1,
942 kContextVar, 942 kContextVar,
943 kContextLevel, 943 kContextLevel,
944 kSavedEntryContext, 944 kSavedEntryContext,
945 kSavedCurrentContext 945 kSavedCurrentContext
946 }; 946 };
947 947
948 struct VarInfo { 948 struct VarInfo {
949 intptr_t index; // Slot index on stack or in context. 949 int32_t index; // Slot index on stack or in context.
950 int8_t kind; // Entry kind of type VarInfoKind. 950 int8_t kind; // Entry kind of type VarInfoKind.
Ivan Posva 2014/06/26 09:02:04 The index and kind field could be merged into a bi
zra 2014/07/01 20:37:01 Done.
951 int16_t scope_id; // Scope to which the variable belongs. 951 int16_t scope_id; // Scope to which the variable belongs.
952 intptr_t begin_pos; // Token position of scope start. 952 int32_t begin_pos; // Token position of scope start.
953 intptr_t end_pos; // Token position of scope end. 953 int32_t end_pos; // Token position of scope end.
954 }; 954 };
955 955
956 private: 956 private:
957 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); 957 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors);
958 intptr_t length_; // Number of descriptors. 958 int32_t length_; // Number of descriptors.
959 RawArray* names_; // Array of [length_] variable names. 959 RawArray* names_; // Array of [length_] variable names.
Ivan Posva 2014/06/26 09:02:04 These two fields should be swapped to get better a
zra 2014/07/01 20:37:01 Done.
960 960
961 // Variable info with [length_] entries. 961 // Variable info with [length_] entries.
962 VarInfo* data() { OPEN_ARRAY_START(VarInfo, intptr_t); } 962 VarInfo* data() { OPEN_ARRAY_START(VarInfo, intptr_t); }
Ivan Posva 2014/06/26 09:02:04 The alignment here should probably be int32_t, as
zra 2014/07/01 20:37:01 Done.
963 }; 963 };
964 964
965 965
966 class RawExceptionHandlers : public RawObject { 966 class RawExceptionHandlers : public RawObject {
967 public: 967 public:
968 // The index into the ExceptionHandlers table corresponds to 968 // The index into the ExceptionHandlers table corresponds to
969 // the try_index of the handler. 969 // the try_index of the handler.
970 struct HandlerInfo { 970 struct HandlerInfo {
971 intptr_t handler_pc; // PC value of handler. 971 intptr_t handler_pc; // PC value of handler.
972 int16_t outer_try_index; // Try block index of enclosing try block. 972 int16_t outer_try_index; // Try block index of enclosing try block.
973 int8_t needs_stacktrace; // True if a stacktrace is needed. 973 int8_t needs_stacktrace; // True if a stacktrace is needed.
974 int8_t has_catch_all; // Catches all exceptions. 974 int8_t has_catch_all; // Catches all exceptions.
975 }; 975 };
976 976
977 private: 977 private:
978 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers); 978 RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers);
979 979
980 // Number of exception handler entries. 980 // Number of exception handler entries.
981 intptr_t length_; 981 int32_t length_;
982 982
983 // Array with [length_] entries. Each entry is an array of all handled 983 // Array with [length_] entries. Each entry is an array of all handled
984 // exception types. 984 // exception types.
985 RawArray* handled_types_data_; 985 RawArray* handled_types_data_;
986 986
987 // Exception handler info of length [length_]. 987 // Exception handler info of length [length_].
988 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); } 988 HandlerInfo* data() { OPEN_ARRAY_START(HandlerInfo, intptr_t); }
989 }; 989 };
990 990
991 991
992 // Contains an array of deoptimization commands, e.g., move a specific register 992 // Contains an array of deoptimization commands, e.g., move a specific register
993 // into a specific slot of unoptimized frame. 993 // into a specific slot of unoptimized frame.
994 class RawDeoptInfo : public RawObject { 994 class RawDeoptInfo : public RawObject {
995 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo); 995 RAW_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo);
996 996
997 RawSmi* length_; // Number of deoptimization commands 997 RawSmi* length_; // Number of deoptimization commands
998 998
999 // Variable length data follows here. 999 // Variable length data follows here.
1000 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); } 1000 intptr_t* data() { OPEN_ARRAY_START(intptr_t, intptr_t); }
1001 }; 1001 };
1002 1002
1003 1003
1004 class RawContext : public RawObject { 1004 class RawContext : public RawObject {
1005 RAW_HEAP_OBJECT_IMPLEMENTATION(Context); 1005 RAW_HEAP_OBJECT_IMPLEMENTATION(Context);
1006 1006
1007 intptr_t num_variables_; 1007 int32_t num_variables_;
1008 Isolate* isolate_; 1008 Isolate* isolate_;
1009 1009
1010 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); } 1010 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->parent_); }
1011 RawContext* parent_; 1011 RawContext* parent_;
1012 1012
1013 // Variable length data follows here. 1013 // Variable length data follows here.
1014 RawInstance** data() { OPEN_ARRAY_START(RawInstance*, RawInstance*); } 1014 RawInstance** data() { OPEN_ARRAY_START(RawInstance*, RawInstance*); }
1015 RawObject** to(intptr_t num_vars) { 1015 RawObject** to(intptr_t num_vars) {
1016 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]); 1016 return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]);
1017 } 1017 }
1018 1018
1019 friend class SnapshotReader; 1019 friend class SnapshotReader;
1020 }; 1020 };
1021 1021
1022 1022
1023 class RawContextScope : public RawObject { 1023 class RawContextScope : public RawObject {
1024 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope); 1024 RAW_HEAP_OBJECT_IMPLEMENTATION(ContextScope);
1025 1025
1026 // TODO(iposva): Switch to convential enum offset based structure to avoid 1026 // TODO(iposva): Switch to conventional enum offset based structure to avoid
1027 // alignment mishaps. 1027 // alignment mishaps.
1028 struct VariableDesc { 1028 struct VariableDesc {
1029 RawSmi* token_pos; 1029 RawSmi* token_pos;
1030 RawString* name; 1030 RawString* name;
1031 RawBool* is_final; 1031 RawBool* is_final;
1032 RawBool* is_const; 1032 RawBool* is_const;
1033 union { 1033 union {
1034 RawAbstractType* type; 1034 RawAbstractType* type;
1035 RawInstance* value; // iff is_const is true 1035 RawInstance* value; // iff is_const is true
1036 }; 1036 };
1037 RawSmi* context_index; 1037 RawSmi* context_index;
1038 RawSmi* context_level; 1038 RawSmi* context_level;
1039 }; 1039 };
1040 1040
1041 intptr_t num_variables_; 1041 int32_t num_variables_;
1042 1042
1043 RawObject** from() { 1043 RawObject** from() {
1044 return reinterpret_cast<RawObject**>(&ptr()->data()[0]); 1044 return reinterpret_cast<RawObject**>(&ptr()->data()[0]);
1045 } 1045 }
1046 // Variable length data follows here. 1046 // Variable length data follows here.
1047 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); } 1047 RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); }
1048 RawObject** to(intptr_t num_vars) { 1048 RawObject** to(intptr_t num_vars) {
1049 const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize); 1049 const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize);
1050 return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]); 1050 return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]);
1051 } 1051 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 friend class SnapshotReader; 1300 friend class SnapshotReader;
1301 }; 1301 };
1302 1302
1303 1303
1304 class RawBigint : public RawInteger { 1304 class RawBigint : public RawInteger {
1305 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint); 1305 RAW_HEAP_OBJECT_IMPLEMENTATION(Bigint);
1306 1306
1307 // Actual length in chunks at the time of allocation (later we may 1307 // Actual length in chunks at the time of allocation (later we may
1308 // clamp the operational length but we need to maintain a consistent 1308 // clamp the operational length but we need to maintain a consistent
1309 // object length so that the object can be traversed during GC). 1309 // object length so that the object can be traversed during GC).
1310 intptr_t allocated_length_; 1310 int32_t allocated_length_;
1311 1311
1312 // Operational length in chunks of the bigint object, clamping can 1312 // Operational length in chunks of the bigint object, clamping can
1313 // cause this length to be reduced. If the signed_length_ is 1313 // cause this length to be reduced. If the signed_length_ is
1314 // negative then the number is negative. 1314 // negative then the number is negative.
1315 intptr_t signed_length_; 1315 int32_t signed_length_;
1316 1316
1317 // A sequence of Chunks (typedef in Bignum) representing bignum digits. 1317 // A sequence of Chunks (typedef in Bignum) representing bignum digits.
1318 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)]; 1318 // Bignum::Chunk chunks_[Utils::Abs(signed_length_)];
1319 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1319 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1320 1320
1321 friend class SnapshotReader; 1321 friend class SnapshotReader;
1322 }; 1322 };
1323 1323
1324 1324
1325 class RawDouble : public RawNumber { 1325 class RawDouble : public RawNumber {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 RawObject** from() { 1599 RawObject** from() {
1600 return reinterpret_cast<RawObject**>(&ptr()->data_length_); 1600 return reinterpret_cast<RawObject**>(&ptr()->data_length_);
1601 } 1601 }
1602 RawSmi* data_length_; 1602 RawSmi* data_length_;
1603 RawSmi* num_bracket_expressions_; 1603 RawSmi* num_bracket_expressions_;
1604 RawString* pattern_; // Pattern to be used for matching. 1604 RawString* pattern_; // Pattern to be used for matching.
1605 RawObject** to() { 1605 RawObject** to() {
1606 return reinterpret_cast<RawObject**>(&ptr()->pattern_); 1606 return reinterpret_cast<RawObject**>(&ptr()->pattern_);
1607 } 1607 }
1608 1608
1609 intptr_t type_; // Uninitialized, simple or complex. 1609 int32_t type_; // Uninitialized, simple or complex.
1610 intptr_t flags_; // Represents global/local, case insensitive, multiline. 1610 int32_t flags_; // Represents global/local, case insensitive, multiline.
Ivan Posva 2014/06/26 09:02:04 How many values can each of these fields contain?
zra 2014/07/01 20:37:01 type_ can be 3, and flags can be 4. I've changed t
1611 1611
1612 // Variable length data follows here. 1612 // Variable length data follows here.
1613 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1613 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1614 }; 1614 };
1615 1615
1616 1616
1617 class RawWeakProperty : public RawInstance { 1617 class RawWeakProperty : public RawInstance {
1618 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty); 1618 RAW_HEAP_OBJECT_IMPLEMENTATION(WeakProperty);
1619 1619
1620 RawObject** from() { 1620 RawObject** from() {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); 1873 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14);
1874 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 1874 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
1875 kTypedDataInt8ArrayViewCid + 15); 1875 kTypedDataInt8ArrayViewCid + 15);
1876 COMPILE_ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); 1876 COMPILE_ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14);
1877 return (kNullCid - kTypedDataInt8ArrayCid); 1877 return (kNullCid - kTypedDataInt8ArrayCid);
1878 } 1878 }
1879 1879
1880 } // namespace dart 1880 } // namespace dart
1881 1881
1882 #endif // VM_RAW_OBJECT_H_ 1882 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | runtime/vm/snapshot.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698