| 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/atomic.h" | 9 #include "vm/atomic.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 } | 406 } |
| 407 bool IsScript() { | 407 bool IsScript() { |
| 408 return ((GetClassId() == kScriptCid)); | 408 return ((GetClassId() == kScriptCid)); |
| 409 } | 409 } |
| 410 bool IsFunction() { | 410 bool IsFunction() { |
| 411 return ((GetClassId() == kFunctionCid)); | 411 return ((GetClassId() == kFunctionCid)); |
| 412 } | 412 } |
| 413 bool IsInstructions() { | 413 bool IsInstructions() { |
| 414 return ((GetClassId() == kInstructionsCid)); | 414 return ((GetClassId() == kInstructionsCid)); |
| 415 } | 415 } |
| 416 bool IsCode() { |
| 417 return ((GetClassId() == kCodeCid)); |
| 418 } |
| 416 | 419 |
| 417 intptr_t Size() const { | 420 intptr_t Size() const { |
| 418 uword tags = ptr()->tags_; | 421 uword tags = ptr()->tags_; |
| 419 intptr_t result = SizeTag::decode(tags); | 422 intptr_t result = SizeTag::decode(tags); |
| 420 if (result != 0) { | 423 if (result != 0) { |
| 421 ASSERT(result == SizeFromClass()); | 424 ASSERT(result == SizeFromClass()); |
| 422 return result; | 425 return result; |
| 423 } | 426 } |
| 424 result = SizeFromClass(); | 427 result = SizeFromClass(); |
| 425 ASSERT(result > SizeTag::kMaxSizeTag); | 428 ASSERT(result > SizeTag::kMaxSizeTag); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 friend class ExternalTypedData; | 574 friend class ExternalTypedData; |
| 572 friend class ForwardList; | 575 friend class ForwardList; |
| 573 friend class GrowableObjectArray; // StorePointer | 576 friend class GrowableObjectArray; // StorePointer |
| 574 friend class Heap; | 577 friend class Heap; |
| 575 friend class HeapMapAsJSONVisitor; | 578 friend class HeapMapAsJSONVisitor; |
| 576 friend class ClassStatsVisitor; | 579 friend class ClassStatsVisitor; |
| 577 friend class MarkingVisitor; | 580 friend class MarkingVisitor; |
| 578 friend class Mint; | 581 friend class Mint; |
| 579 friend class Object; | 582 friend class Object; |
| 580 friend class OneByteString; // StoreSmi | 583 friend class OneByteString; // StoreSmi |
| 584 friend class RawCode; |
| 581 friend class RawExternalTypedData; | 585 friend class RawExternalTypedData; |
| 582 friend class RawInstructions; | 586 friend class RawInstructions; |
| 583 friend class RawInstance; | 587 friend class RawInstance; |
| 584 friend class RawTypedData; | 588 friend class RawTypedData; |
| 585 friend class Scavenger; | 589 friend class Scavenger; |
| 586 friend class ScavengerVisitor; | 590 friend class ScavengerVisitor; |
| 587 friend class SizeExcludingClassVisitor; // GetClassId | 591 friend class SizeExcludingClassVisitor; // GetClassId |
| 588 friend class RetainingPathVisitor; // GetClassId | 592 friend class RetainingPathVisitor; // GetClassId |
| 589 friend class SkippedCodeFunctions; // StorePointer | 593 friend class SkippedCodeFunctions; // StorePointer |
| 590 friend class InstructionsReader; // tags_ check | 594 friend class InstructionsReader; // tags_ check |
| 591 friend class InstructionsWriter; | 595 friend class InstructionsWriter; |
| 592 friend class SnapshotReader; | 596 friend class SnapshotReader; |
| 593 friend class SnapshotWriter; | 597 friend class SnapshotWriter; |
| 594 friend class String; | 598 friend class String; |
| 595 friend class TypedData; | 599 friend class TypedData; |
| 596 friend class TypedDataView; | 600 friend class TypedDataView; |
| 597 friend class WeakProperty; // StorePointer | 601 friend class WeakProperty; // StorePointer |
| 598 friend class Instance; // StorePointer | 602 friend class Instance; // StorePointer |
| 603 friend class StackFrame; // GetCodeObject assertion. |
| 599 | 604 |
| 600 DISALLOW_ALLOCATION(); | 605 DISALLOW_ALLOCATION(); |
| 601 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); | 606 DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); |
| 602 }; | 607 }; |
| 603 | 608 |
| 604 | 609 |
| 605 class RawClass : public RawObject { | 610 class RawClass : public RawObject { |
| 606 public: | 611 public: |
| 607 enum ClassFinalizedState { | 612 enum ClassFinalizedState { |
| 608 kAllocated = 0, // Initial state. | 613 kAllocated = 0, // Initial state. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 RawObject** to_snapshot() { | 772 RawObject** to_snapshot() { |
| 768 return reinterpret_cast<RawObject**>(&ptr()->data_); | 773 return reinterpret_cast<RawObject**>(&ptr()->data_); |
| 769 } | 774 } |
| 770 RawArray* ic_data_array_; // ICData of unoptimized code. | 775 RawArray* ic_data_array_; // ICData of unoptimized code. |
| 771 RawObject** to_optimized_snapshot() { | 776 RawObject** to_optimized_snapshot() { |
| 772 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); | 777 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); |
| 773 } | 778 } |
| 774 RawObject** to_no_code() { | 779 RawObject** to_no_code() { |
| 775 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); | 780 return reinterpret_cast<RawObject**>(&ptr()->ic_data_array_); |
| 776 } | 781 } |
| 777 RawInstructions* instructions_; // Instructions of currently active code. | 782 RawCode* code_; // Currently active code. |
| 778 RawCode* unoptimized_code_; // Unoptimized code, keep it after optimization. | 783 RawCode* unoptimized_code_; // Unoptimized code, keep it after optimization. |
| 779 RawObject** to() { | 784 RawObject** to() { |
| 780 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); | 785 return reinterpret_cast<RawObject**>(&ptr()->unoptimized_code_); |
| 781 } | 786 } |
| 782 uword entry_point_; | 787 uword entry_point_; |
| 783 | 788 |
| 784 int32_t token_pos_; | 789 int32_t token_pos_; |
| 785 int32_t end_token_pos_; | 790 int32_t end_token_pos_; |
| 786 int32_t usage_counter_; // Incremented while function is running. | 791 int32_t usage_counter_; // Incremented while function is running. |
| 787 int16_t num_fixed_parameters_; | 792 int16_t num_fixed_parameters_; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 class RawCode : public RawObject { | 1002 class RawCode : public RawObject { |
| 998 enum InlinedMetadataIndex { | 1003 enum InlinedMetadataIndex { |
| 999 kInlinedIntervalsIndex = 0, | 1004 kInlinedIntervalsIndex = 0, |
| 1000 kInlinedIdToFunctionIndex = 1, | 1005 kInlinedIdToFunctionIndex = 1, |
| 1001 kInlinedCallerIdMapIndex = 2, | 1006 kInlinedCallerIdMapIndex = 2, |
| 1002 kInlinedMetadataSize = 3, | 1007 kInlinedMetadataSize = 3, |
| 1003 }; | 1008 }; |
| 1004 | 1009 |
| 1005 RAW_HEAP_OBJECT_IMPLEMENTATION(Code); | 1010 RAW_HEAP_OBJECT_IMPLEMENTATION(Code); |
| 1006 | 1011 |
| 1012 uword entry_point_; |
| 1013 |
| 1007 RawObject** from() { | 1014 RawObject** from() { |
| 1008 return reinterpret_cast<RawObject**>(&ptr()->instructions_); | 1015 return reinterpret_cast<RawObject**>(&ptr()->active_instructions_); |
| 1009 } | 1016 } |
| 1017 RawInstructions* active_instructions_; |
| 1010 RawInstructions* instructions_; | 1018 RawInstructions* instructions_; |
| 1019 RawObjectPool* object_pool_; |
| 1011 // If owner_ is Function::null() the owner is a regular stub. | 1020 // If owner_ is Function::null() the owner is a regular stub. |
| 1012 // If owner_ is a Class the owner is the allocation stub for that class. | 1021 // If owner_ is a Class the owner is the allocation stub for that class. |
| 1013 // Else, owner_ is a regular Dart Function. | 1022 // Else, owner_ is a regular Dart Function. |
| 1014 RawObject* owner_; // Function, Null, or a Class. | 1023 RawObject* owner_; // Function, Null, or a Class. |
| 1015 RawExceptionHandlers* exception_handlers_; | 1024 RawExceptionHandlers* exception_handlers_; |
| 1016 RawPcDescriptors* pc_descriptors_; | 1025 RawPcDescriptors* pc_descriptors_; |
| 1017 RawArray* deopt_info_array_; | 1026 RawArray* deopt_info_array_; |
| 1018 RawArray* static_calls_target_table_; // (code-offset, function, code). | 1027 RawArray* static_calls_target_table_; // (code-offset, function, code). |
| 1019 RawArray* stackmaps_; | 1028 RawArray* stackmaps_; |
| 1020 RawLocalVarDescriptors* var_descriptors_; | 1029 RawLocalVarDescriptors* var_descriptors_; |
| 1021 RawArray* inlined_metadata_; | 1030 RawArray* inlined_metadata_; |
| 1022 RawArray* comments_; | 1031 RawArray* comments_; |
| 1023 // If return_address_metadata_ is a Smi, it is the offset to the prologue. | 1032 // If return_address_metadata_ is a Smi, it is the offset to the prologue. |
| 1024 // Else, return_address_metadata_ is null. | 1033 // Else, return_address_metadata_ is null. |
| 1025 RawObject* return_address_metadata_; | 1034 RawObject* return_address_metadata_; |
| 1026 RawObject** to() { | 1035 RawObject** to() { |
| 1027 return reinterpret_cast<RawObject**>(&ptr()->return_address_metadata_); | 1036 return reinterpret_cast<RawObject**>(&ptr()->return_address_metadata_); |
| 1028 } | 1037 } |
| 1029 uword entry_point_; | |
| 1030 | 1038 |
| 1031 // Compilation timestamp. | 1039 // Compilation timestamp. |
| 1032 int64_t compile_timestamp_; | 1040 int64_t compile_timestamp_; |
| 1033 | 1041 |
| 1034 // state_bits_ is a bitfield with three fields: | 1042 // state_bits_ is a bitfield with three fields: |
| 1035 // The optimized bit, the alive bit, and a count of the number of pointer | 1043 // The optimized bit, the alive bit, and a count of the number of pointer |
| 1036 // offsets. | 1044 // offsets. |
| 1037 // Alive: If true, the embedded object pointers will be visited during GC. | 1045 // Alive: If true, the embedded object pointers will be visited during GC. |
| 1038 int32_t state_bits_; | 1046 int32_t state_bits_; |
| 1039 | 1047 |
| 1040 // PC offsets for code patching. | 1048 // PC offsets for code patching. |
| 1041 int32_t entry_patch_pc_offset_; | |
| 1042 int32_t patch_code_pc_offset_; | |
| 1043 int32_t lazy_deopt_pc_offset_; | 1049 int32_t lazy_deopt_pc_offset_; |
| 1044 | 1050 |
| 1045 // Variable length data follows here. | 1051 // Variable length data follows here. |
| 1046 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } | 1052 int32_t* data() { OPEN_ARRAY_START(int32_t, int32_t); } |
| 1047 const int32_t* data() const { OPEN_ARRAY_START(int32_t, int32_t); } | 1053 const int32_t* data() const { OPEN_ARRAY_START(int32_t, int32_t); } |
| 1048 | 1054 |
| 1055 static bool ContainsPC(RawObject* raw_obj, uword pc); |
| 1056 |
| 1049 friend class Function; | 1057 friend class Function; |
| 1050 friend class MarkingVisitor; | 1058 friend class MarkingVisitor; |
| 1051 friend class SkippedCodeFunctions; | 1059 friend class SkippedCodeFunctions; |
| 1052 friend class StackFrame; | 1060 friend class StackFrame; |
| 1061 friend class Profiler; |
| 1053 }; | 1062 }; |
| 1054 | 1063 |
| 1055 | 1064 |
| 1056 class RawObjectPool : public RawObject { | 1065 class RawObjectPool : public RawObject { |
| 1057 RAW_HEAP_OBJECT_IMPLEMENTATION(ObjectPool); | 1066 RAW_HEAP_OBJECT_IMPLEMENTATION(ObjectPool); |
| 1058 | 1067 |
| 1059 intptr_t length_; | 1068 intptr_t length_; |
| 1060 RawTypedData* info_array_; | 1069 RawTypedData* info_array_; |
| 1061 | 1070 |
| 1062 struct Entry { | 1071 struct Entry { |
| 1063 union { | 1072 union { |
| 1064 RawObject* raw_obj_; | 1073 RawObject* raw_obj_; |
| 1065 uword raw_value_; | 1074 uword raw_value_; |
| 1066 }; | 1075 }; |
| 1067 }; | 1076 }; |
| 1068 Entry* data() { OPEN_ARRAY_START(Entry, Entry); } | 1077 Entry* data() { OPEN_ARRAY_START(Entry, Entry); } |
| 1069 Entry const* data() const { OPEN_ARRAY_START(Entry, Entry); } | 1078 Entry const* data() const { OPEN_ARRAY_START(Entry, Entry); } |
| 1070 | 1079 |
| 1071 Entry* first_entry() { return &ptr()->data()[0]; } | 1080 Entry* first_entry() { return &ptr()->data()[0]; } |
| 1072 | 1081 |
| 1073 friend class Object; | 1082 friend class Object; |
| 1074 friend class SnapshotReader; | 1083 friend class SnapshotReader; |
| 1075 }; | 1084 }; |
| 1076 | 1085 |
| 1077 | 1086 |
| 1078 class RawInstructions : public RawObject { | 1087 class RawInstructions : public RawObject { |
| 1079 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); | 1088 RAW_HEAP_OBJECT_IMPLEMENTATION(Instructions); |
| 1080 | 1089 |
| 1081 RawObject** from() { | |
| 1082 return reinterpret_cast<RawObject**>(&ptr()->code_); | |
| 1083 } | |
| 1084 RawCode* code_; | |
| 1085 RawObjectPool* object_pool_; | |
| 1086 RawObject** to() { | |
| 1087 return reinterpret_cast<RawObject**>(&ptr()->object_pool_); | |
| 1088 } | |
| 1089 int32_t size_; | 1090 int32_t size_; |
| 1090 | 1091 |
| 1091 // Variable length data follows here. | 1092 // Variable length data follows here. |
| 1092 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } | 1093 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } |
| 1093 | 1094 |
| 1094 // Private helper function used while visiting stack frames. The | 1095 // Private helper function used while visiting stack frames. The |
| 1095 // code which iterates over dart frames is also called during GC and | 1096 // code which iterates over dart frames is also called during GC and |
| 1096 // is not allowed to create handles. | 1097 // is not allowed to create handles. |
| 1097 static bool ContainsPC(RawObject* raw_obj, uword pc); | 1098 static bool ContainsPC(RawInstructions* raw_instr, uword pc); |
| 1098 | 1099 |
| 1099 friend class RawCode; | 1100 friend class RawCode; |
| 1100 friend class RawFunction; | 1101 friend class RawFunction; |
| 1101 friend class Code; | 1102 friend class Code; |
| 1102 friend class StackFrame; | 1103 friend class StackFrame; |
| 1103 friend class MarkingVisitor; | 1104 friend class MarkingVisitor; |
| 1104 friend class SkippedCodeFunctions; | 1105 friend class SkippedCodeFunctions; |
| 1105 friend class Function; | 1106 friend class Function; |
| 1106 friend class InstructionsReader; | 1107 friend class InstructionsReader; |
| 1107 friend class InstructionsWriter; | 1108 friend class InstructionsWriter; |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2231 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2232 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2232 kTypedDataInt8ArrayViewCid + 15); | 2233 kTypedDataInt8ArrayViewCid + 15); |
| 2233 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2234 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2234 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2235 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2235 return (kNullCid - kTypedDataInt8ArrayCid); | 2236 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2236 } | 2237 } |
| 2237 | 2238 |
| 2238 } // namespace dart | 2239 } // namespace dart |
| 2239 | 2240 |
| 2240 #endif // VM_RAW_OBJECT_H_ | 2241 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |