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

Side by Side Diff: runtime/vm/stack_frame.cc

Issue 10835034: Fix an off-by-one error in the stack frame iteration. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/object.cc ('k') | no next file » | 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) 2011, 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 #include "vm/stack_frame.h" 5 #include "vm/stack_frame.h"
6 6
7 #include "vm/assembler_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
11 #include "vm/os.h" 11 #include "vm/os.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 Code code; 55 Code code;
56 code = LookupDartCode(); 56 code = LookupDartCode();
57 if (!code.IsNull()) { 57 if (!code.IsNull()) {
58 Array maps; 58 Array maps;
59 maps = Array::null(); 59 maps = Array::null();
60 Stackmap map; 60 Stackmap map;
61 map = code.GetStackmap(pc(), &maps, &map); 61 map = code.GetStackmap(pc(), &maps, &map);
62 if (!map.IsNull()) { 62 if (!map.IsNull()) {
63 // A stack map is present in the code object, use the stack map to visit 63 // A stack map is present in the code object, use the stack map to visit
64 // frame slots which are marked as having objects. 64 // frame slots which are marked as having objects.
65 intptr_t bit_offset = map.MinimumBitOffset(); 65 intptr_t bit_index = map.MinimumBitOffset();
Vyacheslav Egorov (Google) 2012/07/30 13:00:38 s/MinimumBitOffset/MinimumBitIndex/
Kevin Millikin (Google) 2012/07/30 13:41:03 OK, but that caused a cascade of offset -> index r
66 intptr_t end_bit_offset = map.MaximumBitOffset(); 66 intptr_t end_bit_index = map.MaximumBitOffset();
67 while (bit_offset <= end_bit_offset) { 67 uword base_addr =
68 uword addr = (fp() - ((bit_offset + 1) * kWordSize)); 68 fp() + (ParsedFunction::kFirstLocalSlotIndex * kWordSize);
69 while (bit_index <= end_bit_index) {
70 uword addr = base_addr - (bit_index * kWordSize);
69 ASSERT(addr >= sp()); 71 ASSERT(addr >= sp());
70 if (map.IsObject(bit_offset)) { 72 if (map.IsObject(bit_index)) {
71 visitor->VisitPointer(reinterpret_cast<RawObject**>(addr)); 73 visitor->VisitPointer(reinterpret_cast<RawObject**>(addr));
72 } 74 }
73 bit_offset += 1; 75 ++bit_index;
74 } 76 }
75 return; 77 return;
76 } 78 }
77 } 79 }
78 // No stack maps are present in the code object which means this 80 // No stack maps are present in the code object which means this
79 // frame relies on tagged pointers and hence we visit each entry 81 // frame relies on tagged pointers and hence we visit each entry
80 // on the frame between SP and FP. 82 // on the frame between SP and FP.
81 ASSERT(visitor != NULL); 83 ASSERT(visitor != NULL);
82 RawObject** start = reinterpret_cast<RawObject**>(sp()); 84 RawObject** start = reinterpret_cast<RawObject**>(sp());
Vyacheslav Egorov (Google) 2012/07/30 13:00:38 I find it a bit suspicious that we don't visit cod
83 RawObject** end = reinterpret_cast<RawObject**>( 85 RawObject** end = reinterpret_cast<RawObject**>(
84 fp() + (ParsedFunction::kFirstLocalSlotIndex * kWordSize)); 86 fp() + (ParsedFunction::kFirstLocalSlotIndex * kWordSize));
85 visitor->VisitPointers(start, end); 87 visitor->VisitPointers(start, end);
86 } 88 }
87 89
88 90
89 RawFunction* StackFrame::LookupDartFunction() const { 91 RawFunction* StackFrame::LookupDartFunction() const {
90 const Code& code = Code::Handle(LookupDartCode()); 92 const Code& code = Code::Handle(LookupDartCode());
91 if (!code.IsNull()) { 93 if (!code.IsNull()) {
92 return code.function(); 94 return code.function();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 EntryFrame* StackFrameIterator::NextEntryFrame() { 245 EntryFrame* StackFrameIterator::NextEntryFrame() {
244 ASSERT(!frames_.HasNext()); 246 ASSERT(!frames_.HasNext());
245 entry_.sp_ = frames_.sp_; 247 entry_.sp_ = frames_.sp_;
246 entry_.fp_ = frames_.fp_; 248 entry_.fp_ = frames_.fp_;
247 SetupNextExitFrameData(); // Setup data for next exit frame in chain. 249 SetupNextExitFrameData(); // Setup data for next exit frame in chain.
248 ASSERT(entry_.IsValid()); 250 ASSERT(entry_.IsValid());
249 return &entry_; 251 return &entry_;
250 } 252 }
251 253
252 } // namespace dart 254 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698