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