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 3029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3040 | 3040 |
3041 void PrintToJSONObject(JSONObject* jsobj) const; | 3041 void PrintToJSONObject(JSONObject* jsobj) const; |
3042 | 3042 |
3043 // We would have a VisitPointers function here to traverse the | 3043 // We would have a VisitPointers function here to traverse the |
3044 // pc descriptors table to visit objects if any in the table. | 3044 // pc descriptors table to visit objects if any in the table. |
3045 // Note: never return a reference to a RawPcDescriptors::PcDescriptorRec | 3045 // Note: never return a reference to a RawPcDescriptors::PcDescriptorRec |
3046 // as the object can move. | 3046 // as the object can move. |
3047 class Iterator : ValueObject { | 3047 class Iterator : ValueObject { |
3048 public: | 3048 public: |
3049 Iterator(const PcDescriptors& descriptors, intptr_t kind_mask) | 3049 Iterator(const PcDescriptors& descriptors, intptr_t kind_mask) |
3050 : descriptors_(descriptors), kind_mask_(kind_mask), current_ix_(0) { | 3050 : descriptors_(descriptors), |
3051 kind_mask_(kind_mask), | |
3052 next_ix_(0), | |
3053 current_ix_(-1) { | |
3051 MoveToMatching(); | 3054 MoveToMatching(); |
3052 } | 3055 } |
3053 | 3056 |
3054 bool HasNext() const { return current_ix_ < descriptors_.Length(); } | 3057 bool HasNext() const { return next_ix_ < descriptors_.Length(); } |
3055 | 3058 |
3056 intptr_t NextDeoptId() { | 3059 intptr_t NextDeoptId() { |
hausner
2014/07/17 23:22:56
I find it a bit awkward that you have two accessor
srdjan
2014/07/18 18:16:45
Good suggestion, changed to:
while (i.MoveNext())
| |
3057 ASSERT(HasNext()); | 3060 ASSERT(HasNext()); |
3058 const intptr_t res = descriptors_.recAt(current_ix_++)->deopt_id(); | 3061 const intptr_t res = descriptors_.recAt(next_ix_)->deopt_id(); |
3062 current_ix_ = next_ix_++; | |
3059 MoveToMatching(); | 3063 MoveToMatching(); |
3060 return res; | 3064 return res; |
3061 } | 3065 } |
3062 | 3066 |
3063 uword NextPc() { | 3067 uword NextPc() { |
3064 ASSERT(HasNext()); | 3068 ASSERT(HasNext()); |
3065 const uword res = descriptors_.recAt(current_ix_++)->pc(); | 3069 const uword res = descriptors_.recAt(next_ix_)->pc(); |
3070 current_ix_ = next_ix_++; | |
3066 MoveToMatching(); | 3071 MoveToMatching(); |
3067 return res; | 3072 return res; |
3068 } | 3073 } |
3069 | 3074 |
3070 void NextRec(RawPcDescriptors::PcDescriptorRec* result) { | 3075 intptr_t NextTokenPos() { |
3071 ASSERT(HasNext()); | 3076 ASSERT(HasNext()); |
3072 const RawPcDescriptors::PcDescriptorRec* r = | 3077 const intptr_t res = descriptors_.recAt(next_ix_)->token_pos(); |
3073 descriptors_.recAt(current_ix_++); | 3078 current_ix_ = next_ix_++; |
3074 r->CopyTo(result); | |
3075 MoveToMatching(); | 3079 MoveToMatching(); |
3080 return res; | |
3081 } | |
3082 | |
3083 uword current_pc() const { return descriptors_.recAt(current_ix_)->pc(); } | |
3084 intptr_t current_deopt_id() const { | |
3085 return descriptors_.recAt(current_ix_)->deopt_id(); | |
3086 } | |
3087 intptr_t current_token_pos() const { | |
3088 return descriptors_.recAt(current_ix_)->token_pos(); | |
3089 } | |
3090 intptr_t current_try_index() const { | |
3091 return descriptors_.recAt(current_ix_)->try_index(); | |
3092 } | |
3093 RawPcDescriptors::Kind current_kind() const { | |
3094 return descriptors_.recAt(current_ix_)->kind(); | |
3076 } | 3095 } |
3077 | 3096 |
3078 private: | 3097 private: |
3079 friend class PcDescriptors; | 3098 friend class PcDescriptors; |
3080 | 3099 |
3081 // For nested iterations, starting at element after. | 3100 // For nested iterations, starting at element after. |
3082 explicit Iterator(const Iterator& iter) | 3101 explicit Iterator(const Iterator& iter) |
3083 : ValueObject(), | 3102 : ValueObject(), |
3084 descriptors_(iter.descriptors_), | 3103 descriptors_(iter.descriptors_), |
3085 kind_mask_(iter.kind_mask_), | 3104 kind_mask_(iter.kind_mask_), |
3105 next_ix_(iter.next_ix_), | |
3086 current_ix_(iter.current_ix_) {} | 3106 current_ix_(iter.current_ix_) {} |
3087 | 3107 |
3088 // Moves to record that matches kind_mask_. | 3108 // Moves to record that matches kind_mask_. |
3089 void MoveToMatching() { | 3109 void MoveToMatching() { |
3090 while (current_ix_ < descriptors_.Length()) { | 3110 while (next_ix_ < descriptors_.Length()) { |
3091 const RawPcDescriptors::PcDescriptorRec& rec = | 3111 const RawPcDescriptors::PcDescriptorRec& rec = |
3092 *descriptors_.recAt(current_ix_); | 3112 *descriptors_.recAt(next_ix_); |
3093 if ((rec.kind() & kind_mask_) != 0) { | 3113 if ((rec.kind() & kind_mask_) != 0) { |
3094 return; // Current is valid. | 3114 return; // Current is valid. |
3095 } else { | 3115 } else { |
3096 ++current_ix_; | 3116 ++next_ix_; |
3097 } | 3117 } |
3098 } | 3118 } |
3099 } | 3119 } |
3100 | 3120 |
3101 const PcDescriptors& descriptors_; | 3121 const PcDescriptors& descriptors_; |
3102 const intptr_t kind_mask_; | 3122 const intptr_t kind_mask_; |
3123 intptr_t next_ix_; | |
3103 intptr_t current_ix_; | 3124 intptr_t current_ix_; |
3104 }; | 3125 }; |
3105 | 3126 |
3106 private: | 3127 private: |
3107 static const char* KindAsStr(RawPcDescriptors::Kind kind); | 3128 static const char* KindAsStr(RawPcDescriptors::Kind kind); |
3108 | 3129 |
3109 intptr_t Length() const; | 3130 intptr_t Length() const; |
3110 void SetLength(intptr_t value) const; | 3131 void SetLength(intptr_t value) const; |
3111 | 3132 |
3112 void SetRecordSizeInBytes(intptr_t value) const; | 3133 void SetRecordSizeInBytes(intptr_t value) const; |
3113 intptr_t RecordSizeInBytes() const; | 3134 intptr_t RecordSizeInBytes() const; |
3114 | 3135 |
3115 RawPcDescriptors::PcDescriptorRec* recAt(intptr_t ix) const { | 3136 RawPcDescriptors::PcDescriptorRec* recAt(intptr_t ix) const { |
3116 ASSERT(ix < Length()); | 3137 ASSERT((0 <= ix) && (ix < Length())); |
3117 uint8_t* d = raw_ptr()->data() + (ix * RecordSizeInBytes()); | 3138 uint8_t* d = raw_ptr()->data() + (ix * RecordSizeInBytes()); |
3118 return reinterpret_cast<RawPcDescriptors::PcDescriptorRec*>(d); | 3139 return reinterpret_cast<RawPcDescriptors::PcDescriptorRec*>(d); |
3119 } | 3140 } |
3120 | 3141 |
3121 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object); | 3142 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object); |
3122 friend class Class; | 3143 friend class Class; |
3123 friend class Object; | 3144 friend class Object; |
3124 }; | 3145 }; |
3125 | 3146 |
3126 | 3147 |
(...skipping 4113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7240 | 7261 |
7241 | 7262 |
7242 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7263 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7243 intptr_t index) { | 7264 intptr_t index) { |
7244 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7265 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7245 } | 7266 } |
7246 | 7267 |
7247 } // namespace dart | 7268 } // namespace dart |
7248 | 7269 |
7249 #endif // VM_OBJECT_H_ | 7270 #endif // VM_OBJECT_H_ |
OLD | NEW |