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

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

Issue 396213005: Fix PcDescriptor iteratot to never return a pointer to a memory location since the data can move wi… (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
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3024 matching lines...) Expand 10 before | Expand all | Expand 10 after
3035 3035
3036 // Verify (assert) assumptions about pc descriptors in debug mode. 3036 // Verify (assert) assumptions about pc descriptors in debug mode.
3037 void Verify(const Function& function) const; 3037 void Verify(const Function& function) const;
3038 3038
3039 static void PrintHeaderString(); 3039 static void PrintHeaderString();
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 3045 // Note: never return a reference to a RawPcDescriptors::PcDescriptorRec
3046 // as the object can move.
3046 class Iterator : ValueObject { 3047 class Iterator : ValueObject {
3047 public: 3048 public:
3048 Iterator(const PcDescriptors& descriptors, intptr_t kind_mask) 3049 Iterator(const PcDescriptors& descriptors, intptr_t kind_mask)
3049 : descriptors_(descriptors), kind_mask_(kind_mask), current_ix_(0) { 3050 : descriptors_(descriptors), kind_mask_(kind_mask), current_ix_(0) {
3050 MoveToMatching(); 3051 MoveToMatching();
3051 } 3052 }
3052 3053
3053 bool HasNext() const { return current_ix_ < descriptors_.Length(); } 3054 bool HasNext() const { return current_ix_ < descriptors_.Length(); }
3054 3055
3055 const RawPcDescriptors::PcDescriptorRec& Next() { 3056 intptr_t NextDeoptId() {
3056 ASSERT(HasNext()); 3057 ASSERT(HasNext());
3057 const RawPcDescriptors::PcDescriptorRec* res = 3058 const intptr_t res = descriptors_.recAt(current_ix_++)->deopt_id();
3058 descriptors_.recAt(current_ix_++);
3059 MoveToMatching(); 3059 MoveToMatching();
3060 return *res; 3060 return res;
3061 }
3062
3063 uword NextPc() {
3064 ASSERT(HasNext());
3065 const uword res = descriptors_.recAt(current_ix_++)->pc();
3066 MoveToMatching();
3067 return res;
3068 }
3069
3070 void NextRec(RawPcDescriptors::PcDescriptorRec* result) {
3071 ASSERT(HasNext());
3072 const RawPcDescriptors::PcDescriptorRec* r =
3073 descriptors_.recAt(current_ix_++);
3074 r->CopyTo(result);
3075 MoveToMatching();
3061 } 3076 }
3062 3077
3063 private: 3078 private:
3064 friend class PcDescriptors; 3079 friend class PcDescriptors;
3065 3080
3066 // For nested iterations, starting at element after. 3081 // For nested iterations, starting at element after.
3067 explicit Iterator(const Iterator& iter) 3082 explicit Iterator(const Iterator& iter)
3068 : ValueObject(), 3083 : ValueObject(),
3069 descriptors_(iter.descriptors_), 3084 descriptors_(iter.descriptors_),
3070 kind_mask_(iter.kind_mask_), 3085 kind_mask_(iter.kind_mask_),
(...skipping 4123 matching lines...) Expand 10 before | Expand all | Expand 10 after
7194 7209
7195 7210
7196 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7211 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7197 intptr_t index) { 7212 intptr_t index) {
7198 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7213 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7199 } 7214 }
7200 7215
7201 } // namespace dart 7216 } // namespace dart
7202 7217
7203 #endif // VM_OBJECT_H_ 7218 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698