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

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

Issue 975443003: Catch corrupted pointers earlier. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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/raw_object.h ('k') | runtime/vm/scavenger_test.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/scavenger.h" 5 #include "vm/scavenger.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 ASSERT(!in_scavenge_pointer_); 148 ASSERT(!in_scavenge_pointer_);
149 BoolScope bs(&in_scavenge_pointer_, true); 149 BoolScope bs(&in_scavenge_pointer_, true);
150 #endif 150 #endif
151 151
152 RawObject* raw_obj = *p; 152 RawObject* raw_obj = *p;
153 153
154 if (raw_obj->IsSmiOrOldObject()) { 154 if (raw_obj->IsSmiOrOldObject()) {
155 return; 155 return;
156 } 156 }
157 157
158 // Objects should be contained in the heap.
159 // TODO(iposva): Add an appropriate assert here or in the return block
160 // below.
161
162 // The scavenger is only interested in objects located in the from space. 158 // The scavenger is only interested in objects located in the from space.
163 // 159 //
164 // We are using address math here and relying on the unsigned underflow 160 // We are using address math here and relying on the unsigned underflow
165 // in the code below to avoid having two checks. 161 // in the code below to avoid having two checks.
166 uword obj_offset = reinterpret_cast<uword>(raw_obj) - from_start_; 162 uword obj_offset = reinterpret_cast<uword>(raw_obj) - from_start_;
167 if (obj_offset > from_size_) { 163 if (obj_offset > from_size_) {
164 ASSERT(scavenger_->to_->Contains(RawObject::ToAddr(raw_obj)));
168 return; 165 return;
169 } 166 }
170 167
171 uword raw_addr = RawObject::ToAddr(raw_obj); 168 uword raw_addr = RawObject::ToAddr(raw_obj);
172 // Read the header word of the object and determine if the object has 169 // Read the header word of the object and determine if the object has
173 // already been copied. 170 // already been copied.
174 uword header = *reinterpret_cast<uword*>(raw_addr); 171 uword header = *reinterpret_cast<uword*>(raw_addr);
175 uword new_addr = 0; 172 uword new_addr = 0;
176 if (IsForwarding(header)) { 173 if (IsForwarding(header)) {
177 // Get the new location of the object. 174 // Get the new location of the object.
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 } 900 }
904 901
905 902
906 void Scavenger::FreeExternal(intptr_t size) { 903 void Scavenger::FreeExternal(intptr_t size) {
907 ASSERT(size >= 0); 904 ASSERT(size >= 0);
908 external_size_ -= size; 905 external_size_ -= size;
909 ASSERT(external_size_ >= 0); 906 ASSERT(external_size_ >= 0);
910 } 907 }
911 908
912 } // namespace dart 909 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/scavenger_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698