OLD | NEW |
---|---|
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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. | 158 // Objects should be contained in the heap. |
159 // TODO(iposva): Add an appropriate assert here or in the return block | 159 // TODO(iposva): Add an appropriate assert here or in the return block |
Ivan Posva
2015/03/02 18:38:48
Aren't you addressing this TODO with the assertion
koda
2015/03/02 19:06:25
Done.
| |
160 // below. | 160 // below. |
161 | 161 |
162 // The scavenger is only interested in objects located in the from space. | 162 // The scavenger is only interested in objects located in the from space. |
163 // | 163 // |
164 // We are using address math here and relying on the unsigned underflow | 164 // We are using address math here and relying on the unsigned underflow |
165 // in the code below to avoid having two checks. | 165 // in the code below to avoid having two checks. |
166 uword obj_offset = reinterpret_cast<uword>(raw_obj) - from_start_; | 166 uword obj_offset = reinterpret_cast<uword>(raw_obj) - from_start_; |
167 if (obj_offset > from_size_) { | 167 if (obj_offset > from_size_) { |
168 ASSERT(scavenger_->to_->Contains(RawObject::ToAddr(raw_obj))); | |
168 return; | 169 return; |
169 } | 170 } |
170 | 171 |
171 uword raw_addr = RawObject::ToAddr(raw_obj); | 172 uword raw_addr = RawObject::ToAddr(raw_obj); |
172 // Read the header word of the object and determine if the object has | 173 // Read the header word of the object and determine if the object has |
173 // already been copied. | 174 // already been copied. |
174 uword header = *reinterpret_cast<uword*>(raw_addr); | 175 uword header = *reinterpret_cast<uword*>(raw_addr); |
175 uword new_addr = 0; | 176 uword new_addr = 0; |
176 if (IsForwarding(header)) { | 177 if (IsForwarding(header)) { |
177 // Get the new location of the object. | 178 // Get the new location of the object. |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 } | 904 } |
904 | 905 |
905 | 906 |
906 void Scavenger::FreeExternal(intptr_t size) { | 907 void Scavenger::FreeExternal(intptr_t size) { |
907 ASSERT(size >= 0); | 908 ASSERT(size >= 0); |
908 external_size_ -= size; | 909 external_size_ -= size; |
909 ASSERT(external_size_ >= 0); | 910 ASSERT(external_size_ >= 0); |
910 } | 911 } |
911 | 912 |
912 } // namespace dart | 913 } // namespace dart |
OLD | NEW |