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

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

Issue 383523005: Specify descriptor kind to iterate on. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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_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 3016 matching lines...) Expand 10 before | Expand all | Expand 10 after
3027 3027
3028 static void PrintHeaderString(); 3028 static void PrintHeaderString();
3029 3029
3030 void PrintToJSONObject(JSONObject* jsobj) const; 3030 void PrintToJSONObject(JSONObject* jsobj) const;
3031 3031
3032 // We would have a VisitPointers function here to traverse the 3032 // We would have a VisitPointers function here to traverse the
3033 // pc descriptors table to visit objects if any in the table. 3033 // pc descriptors table to visit objects if any in the table.
3034 3034
3035 class Iterator : ValueObject { 3035 class Iterator : ValueObject {
3036 public: 3036 public:
3037 explicit Iterator(const PcDescriptors& descriptors) 3037 Iterator(const PcDescriptors& descriptors, intptr_t kind_mask)
3038 : descriptors_(descriptors), current_ix_(0) {} 3038 : descriptors_(descriptors), kind_mask_(kind_mask), current_ix_(0) {
3039 MoveToMatching();
3040 }
3041
3042 bool HasNext() const { return current_ix_ < descriptors_.Length(); }
3043
3044 const RawPcDescriptors::PcDescriptorRec& Next() {
3045 ASSERT(HasNext());
3046 const RawPcDescriptors::PcDescriptorRec* res =
3047 descriptors_.recAt(current_ix_++);
3048 MoveToMatching();
3049 return *res;
3050 }
3051
3052 private:
3053 friend class PcDescriptors;
3039 3054
3040 // For nested iterations, starting at element after. 3055 // For nested iterations, starting at element after.
3041 explicit Iterator(const Iterator& iter) 3056 explicit Iterator(const Iterator& iter)
3042 : ValueObject(), 3057 : ValueObject(),
3043 descriptors_(iter.descriptors_), 3058 descriptors_(iter.descriptors_),
3059 kind_mask_(iter.kind_mask_),
3044 current_ix_(iter.current_ix_) {} 3060 current_ix_(iter.current_ix_) {}
3045 3061
3046 bool HasNext() { return current_ix_ < descriptors_.Length(); } 3062 // Moves to record that matches kind_mask_.
3047 3063 void MoveToMatching() {
3048 const RawPcDescriptors::PcDescriptorRec& Next() { 3064 while (current_ix_ < descriptors_.Length()) {
3049 ASSERT(HasNext()); 3065 const RawPcDescriptors::PcDescriptorRec& rec =
3050 return *descriptors_.recAt(current_ix_++); 3066 *descriptors_.recAt(current_ix_);
3067 if ((rec.kind_ & kind_mask_) != 0) {
3068 return; // Current is valid.
3069 } else {
3070 ++current_ix_;
3071 }
3072 }
3051 } 3073 }
3052 3074
3053 private:
3054 const PcDescriptors& descriptors_; 3075 const PcDescriptors& descriptors_;
3076 const intptr_t kind_mask_;
3055 intptr_t current_ix_; 3077 intptr_t current_ix_;
3056 }; 3078 };
3057 3079
3058 private: 3080 private:
3059 static const char* KindAsStr(RawPcDescriptors::Kind kind); 3081 static const char* KindAsStr(RawPcDescriptors::Kind kind);
3060 3082
3061 intptr_t Length() const; 3083 intptr_t Length() const;
3062 3084
3063 RawPcDescriptors::PcDescriptorRec* recAt(intptr_t ix) const { 3085 RawPcDescriptors::PcDescriptorRec* recAt(intptr_t ix) const {
3064 ASSERT(ix < Length()); 3086 ASSERT(ix < Length());
(...skipping 4083 matching lines...) Expand 10 before | Expand all | Expand 10 after
7148 7170
7149 7171
7150 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7172 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7151 intptr_t index) { 7173 intptr_t index) {
7152 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7174 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7153 } 7175 }
7154 7176
7155 } // namespace dart 7177 } // namespace dart
7156 7178
7157 #endif // VM_OBJECT_H_ 7179 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698