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_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 #include "include/dart_api.h" | 9 #include "include/dart_api.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2972 static RawLocalVarDescriptors* New(intptr_t num_variables); | 2972 static RawLocalVarDescriptors* New(intptr_t num_variables); |
2973 | 2973 |
2974 private: | 2974 private: |
2975 FINAL_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors, Object); | 2975 FINAL_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors, Object); |
2976 friend class Class; | 2976 friend class Class; |
2977 }; | 2977 }; |
2978 | 2978 |
2979 | 2979 |
2980 class PcDescriptors : public Object { | 2980 class PcDescriptors : public Object { |
2981 public: | 2981 public: |
2982 enum Kind { | |
2983 kDeopt, // Deoptimization continuation point. | |
2984 kIcCall, // IC call. | |
2985 kOptStaticCall, // Call directly to known target, e.g. static call. | |
2986 kUnoptStaticCall, // Call to a known target via a stub. | |
2987 kClosureCall, // Closure call. | |
2988 kRuntimeCall, // Runtime call. | |
2989 kOsrEntry, // OSR entry point in unoptimized code. | |
2990 kOther | |
2991 }; | |
2992 | |
2993 intptr_t Length() const; | |
2994 | |
2995 uword PC(intptr_t index) const { | |
2996 ASSERT(index < Length()); | |
2997 return raw_ptr()->data()[index].pc; | |
2998 } | |
2999 PcDescriptors::Kind DescriptorKind(intptr_t index) const { | |
3000 ASSERT(index < Length()); | |
3001 return static_cast<PcDescriptors::Kind>(raw_ptr()->data()[index].kind); | |
3002 } | |
3003 intptr_t DeoptId(intptr_t index) const { | |
3004 ASSERT(index < Length()); | |
3005 return raw_ptr()->data()[index].deopt_id; | |
3006 } | |
3007 intptr_t TokenPos(intptr_t index) const { | |
3008 ASSERT(index < Length()); | |
3009 return raw_ptr()->data()[index].token_pos; | |
3010 } | |
3011 intptr_t TryIndex(intptr_t index) const { | |
3012 ASSERT(index < Length()); | |
3013 return raw_ptr()->data()[index].try_index; | |
3014 } | |
3015 const char* KindAsStr(intptr_t index) const; | |
siva
2014/07/01 18:37:11
Why was it necessary to move the description of ki
srdjan
2014/07/07 18:01:26
Because PcDescriptorRec is defined in RawPcDescrip
| |
3016 | |
3017 void AddDescriptor(intptr_t index, | 2982 void AddDescriptor(intptr_t index, |
3018 uword pc, | 2983 uword pc, |
3019 PcDescriptors::Kind kind, | 2984 RawPcDescriptors::Kind kind, |
3020 int64_t deopt_id, | 2985 int64_t deopt_id, |
3021 int64_t token_pos, // Or deopt reason. | 2986 int64_t token_pos, // Or deopt reason. |
3022 intptr_t try_index) const { // Or deopt index. | 2987 intptr_t try_index) const { // Or deopt index. |
3023 RawPcDescriptors::PcDescriptorRec* rec = &raw_ptr()->data()[index]; | 2988 RawPcDescriptors::PcDescriptorRec* rec = recAt(index); |
3024 rec->pc = pc; | 2989 rec->pc = pc; |
3025 rec->kind = kind; | 2990 rec->kind_ = kind; |
3026 ASSERT(Utils::IsInt(32, deopt_id)); | 2991 ASSERT(Utils::IsInt(32, deopt_id)); |
3027 rec->deopt_id = deopt_id; | 2992 rec->deopt_id = deopt_id; |
3028 ASSERT(Utils::IsInt(32, token_pos)); | 2993 ASSERT(Utils::IsInt(32, token_pos)); |
3029 rec->token_pos = token_pos; | 2994 rec->token_pos = token_pos; |
3030 ASSERT(Utils::IsInt(16, try_index)); | 2995 ASSERT(Utils::IsInt(16, try_index)); |
3031 rec->try_index = try_index; | 2996 rec->try_index = try_index; |
3032 } | 2997 } |
3033 | 2998 |
3034 static const intptr_t kBytesPerElement = | 2999 static const intptr_t kBytesPerElement = |
3035 sizeof(RawPcDescriptors::PcDescriptorRec); | 3000 sizeof(RawPcDescriptors::PcDescriptorRec); |
3036 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 3001 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
3037 | 3002 |
3038 static intptr_t InstanceSize() { | 3003 static intptr_t InstanceSize() { |
3039 ASSERT(sizeof(RawPcDescriptors) == | 3004 ASSERT(sizeof(RawPcDescriptors) == |
3040 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data)); | 3005 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data)); |
3041 return 0; | 3006 return 0; |
3042 } | 3007 } |
3043 static intptr_t InstanceSize(intptr_t len) { | 3008 static intptr_t InstanceSize(intptr_t len) { |
3044 ASSERT(0 <= len && len <= kMaxElements); | 3009 ASSERT(0 <= len && len <= kMaxElements); |
3045 return RoundedAllocationSize( | 3010 return RoundedAllocationSize( |
3046 sizeof(RawPcDescriptors) + (len * kBytesPerElement)); | 3011 sizeof(RawPcDescriptors) + (len * kBytesPerElement)); |
3047 } | 3012 } |
3048 | 3013 |
3049 static RawPcDescriptors* New(intptr_t num_descriptors); | 3014 static RawPcDescriptors* New(intptr_t num_descriptors); |
3050 | 3015 |
3051 // Returns 0 if not found. | 3016 // Returns 0 if not found. |
3052 uword GetPcForKind(Kind kind) const; | 3017 uword GetPcForKind(RawPcDescriptors::Kind kind) const; |
3053 | 3018 |
3054 // Verify (assert) assumptions about pc descriptors in debug mode. | 3019 // Verify (assert) assumptions about pc descriptors in debug mode. |
3055 void Verify(const Function& function) const; | 3020 void Verify(const Function& function) const; |
3056 | 3021 |
3057 static void PrintHeaderString(); | 3022 static void PrintHeaderString(); |
3058 | 3023 |
3059 void PrintToJSONObject(JSONObject* jsobj) const; | 3024 void PrintToJSONObject(JSONObject* jsobj) const; |
3060 | 3025 |
3061 // We would have a VisitPointers function here to traverse the | 3026 // We would have a VisitPointers function here to traverse the |
3062 // pc descriptors table to visit objects if any in the table. | 3027 // pc descriptors table to visit objects if any in the table. |
3063 | 3028 |
3029 class Iterator : public ValueObject { | |
3030 public: | |
3031 explicit Iterator(const PcDescriptors& descriptors) | |
3032 : descriptors_(descriptors), current_ix_(0) {} | |
3033 | |
3034 // For nested iterations, starting at element after. | |
3035 explicit Iterator(const Iterator& iter) | |
3036 : descriptors_(iter.descriptors_), current_ix_(iter.current_ix_) {} | |
3037 | |
3038 bool HasNext() { return current_ix_ < descriptors_.Length(); } | |
3039 | |
3040 const RawPcDescriptors::PcDescriptorRec& Next() { | |
3041 ASSERT(HasNext()); | |
3042 return *descriptors_.recAt(current_ix_++); | |
3043 } | |
3044 | |
3045 private: | |
3046 const PcDescriptors& descriptors_; | |
3047 intptr_t current_ix_; | |
3048 }; | |
3049 | |
3064 private: | 3050 private: |
3051 static const char* KindAsStr(RawPcDescriptors::Kind kind); | |
3052 | |
3053 intptr_t Length() const; | |
3054 | |
3055 RawPcDescriptors::PcDescriptorRec* recAt(intptr_t ix) const { | |
3056 ASSERT(ix < Length()); | |
3057 return &raw_ptr()->data()[ix]; | |
3058 } | |
3065 void SetLength(intptr_t value) const; | 3059 void SetLength(intptr_t value) const; |
3066 | 3060 |
3067 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object); | 3061 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object); |
3068 friend class Class; | 3062 friend class Class; |
3069 friend class Object; | 3063 friend class Object; |
3070 }; | 3064 }; |
3071 | 3065 |
3072 | 3066 |
3073 class Stackmap : public Object { | 3067 class Stackmap : public Object { |
3074 public: | 3068 public: |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3671 kInvalidPc = -1 | 3665 kInvalidPc = -1 |
3672 }; | 3666 }; |
3673 | 3667 |
3674 // Returns 0 if code is not patchable | 3668 // Returns 0 if code is not patchable |
3675 uword GetEntryPatchPc() const; | 3669 uword GetEntryPatchPc() const; |
3676 uword GetPatchCodePc() const; | 3670 uword GetPatchCodePc() const; |
3677 | 3671 |
3678 uword GetLazyDeoptPc() const; | 3672 uword GetLazyDeoptPc() const; |
3679 | 3673 |
3680 // Find pc, return 0 if not found. | 3674 // Find pc, return 0 if not found. |
3681 uword GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const; | 3675 uword GetPcForDeoptId(intptr_t deopt_id, RawPcDescriptors::Kind kind) const; |
3682 intptr_t GetDeoptIdForOsr(uword pc) const; | 3676 intptr_t GetDeoptIdForOsr(uword pc) const; |
3683 | 3677 |
3684 // Returns true if there is an object in the code between 'start_offset' | 3678 // Returns true if there is an object in the code between 'start_offset' |
3685 // (inclusive) and 'end_offset' (exclusive). | 3679 // (inclusive) and 'end_offset' (exclusive). |
3686 bool ObjectExistsInArea(intptr_t start_offest, intptr_t end_offset) const; | 3680 bool ObjectExistsInArea(intptr_t start_offest, intptr_t end_offset) const; |
3687 | 3681 |
3688 RawString* Name() const; | 3682 RawString* Name() const; |
3689 RawString* PrettyName() const; | 3683 RawString* PrettyName() const; |
3690 | 3684 |
3691 int64_t compile_timestamp() const { | 3685 int64_t compile_timestamp() const { |
(...skipping 3449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7141 | 7135 |
7142 | 7136 |
7143 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7137 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7144 intptr_t index) { | 7138 intptr_t index) { |
7145 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7139 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7146 } | 7140 } |
7147 | 7141 |
7148 } // namespace dart | 7142 } // namespace dart |
7149 | 7143 |
7150 #endif // VM_OBJECT_H_ | 7144 #endif // VM_OBJECT_H_ |
OLD | NEW |