| OLD | NEW |
| 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 #include "vm/pages.h" | 5 #include "vm/pages.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/gc_marker.h" | 8 #include "vm/gc_marker.h" |
| 9 #include "vm/gc_sweeper.h" | 9 #include "vm/gc_sweeper.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 while (page != NULL) { | 259 while (page != NULL) { |
| 260 if (page->Contains(addr)) { | 260 if (page->Contains(addr)) { |
| 261 return true; | 261 return true; |
| 262 } | 262 } |
| 263 page = page->next(); | 263 page = page->next(); |
| 264 } | 264 } |
| 265 return false; | 265 return false; |
| 266 } | 266 } |
| 267 | 267 |
| 268 | 268 |
| 269 void PageSpace::StartEndAddress(uword* start, uword* end) const { |
| 270 ASSERT(pages_ != NULL || large_pages_ != NULL); |
| 271 *start = static_cast<uword>(~0); |
| 272 *end = 0; |
| 273 for (HeapPage* page = pages_; page != NULL; page = page->next()) { |
| 274 *start = Utils::Minimum(*start, page->start()); |
| 275 *end = Utils::Maximum(*end, page->end()); |
| 276 } |
| 277 for (HeapPage* page = large_pages_; page != NULL; page = page->next()) { |
| 278 *start = Utils::Minimum(*start, page->start()); |
| 279 *end = Utils::Maximum(*end, page->end()); |
| 280 } |
| 281 ASSERT(*start != static_cast<uword>(~0)); |
| 282 ASSERT(*end != 0); |
| 283 } |
| 284 |
| 285 |
| 269 void PageSpace::VisitObjects(ObjectVisitor* visitor) const { | 286 void PageSpace::VisitObjects(ObjectVisitor* visitor) const { |
| 270 HeapPage* page = pages_; | 287 HeapPage* page = pages_; |
| 271 while (page != NULL) { | 288 while (page != NULL) { |
| 272 page->VisitObjects(visitor); | 289 page->VisitObjects(visitor); |
| 273 page = page->next(); | 290 page = page->next(); |
| 274 } | 291 } |
| 275 | 292 |
| 276 page = large_pages_; | 293 page = large_pages_; |
| 277 while (page != NULL) { | 294 while (page != NULL) { |
| 278 page->VisitObjects(visitor); | 295 page->VisitObjects(visitor); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 337 |
| 321 | 338 |
| 322 void PageSpace::MarkSweep(bool invoke_api_callbacks) { | 339 void PageSpace::MarkSweep(bool invoke_api_callbacks) { |
| 323 // MarkSweep is not reentrant. Make sure that is the case. | 340 // MarkSweep is not reentrant. Make sure that is the case. |
| 324 ASSERT(!sweeping_); | 341 ASSERT(!sweeping_); |
| 325 sweeping_ = true; | 342 sweeping_ = true; |
| 326 Isolate* isolate = Isolate::Current(); | 343 Isolate* isolate = Isolate::Current(); |
| 327 NoHandleScope no_handles(isolate); | 344 NoHandleScope no_handles(isolate); |
| 328 | 345 |
| 329 if (FLAG_verify_before_gc) { | 346 if (FLAG_verify_before_gc) { |
| 330 OS::PrintErr("Verifying before MarkSweep... "); | 347 OS::PrintErr("Verifying before MarkSweep..."); |
| 331 heap_->Verify(); | 348 heap_->Verify(); |
| 332 OS::PrintErr(" done.\n"); | 349 OS::PrintErr(" done.\n"); |
| 333 } | 350 } |
| 334 | 351 |
| 335 Timer timer(true, "MarkSweep"); | 352 Timer timer(true, "MarkSweep"); |
| 336 timer.Start(); | 353 timer.Start(); |
| 337 int64_t start = OS::GetCurrentTimeMillis(); | 354 int64_t start = OS::GetCurrentTimeMillis(); |
| 338 | 355 |
| 339 // Mark all reachable old-gen objects. | 356 // Mark all reachable old-gen objects. |
| 340 GCMarker marker(heap_); | 357 GCMarker marker(heap_); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 const intptr_t KB2 = KB / 2; | 409 const intptr_t KB2 = KB / 2; |
| 393 OS::PrintErr("Mark-Sweep[%d]: %lldus (%dK -> %dK, %dK)\n", | 410 OS::PrintErr("Mark-Sweep[%d]: %lldus (%dK -> %dK, %dK)\n", |
| 394 count_, | 411 count_, |
| 395 timer.TotalElapsedTime(), | 412 timer.TotalElapsedTime(), |
| 396 (in_use_before + (KB2)) / KB, | 413 (in_use_before + (KB2)) / KB, |
| 397 (in_use + (KB2)) / KB, | 414 (in_use + (KB2)) / KB, |
| 398 (capacity_ + KB2) / KB); | 415 (capacity_ + KB2) / KB); |
| 399 } | 416 } |
| 400 | 417 |
| 401 if (FLAG_verify_after_gc) { | 418 if (FLAG_verify_after_gc) { |
| 402 OS::PrintErr("Verifying after MarkSweep... "); | 419 OS::PrintErr("Verifying after MarkSweep..."); |
| 403 heap_->Verify(); | 420 heap_->Verify(); |
| 404 OS::PrintErr(" done.\n"); | 421 OS::PrintErr(" done.\n"); |
| 405 } | 422 } |
| 406 | 423 |
| 407 count_++; | 424 count_++; |
| 408 // Done, reset the marker. | 425 // Done, reset the marker. |
| 409 ASSERT(sweeping_); | 426 ASSERT(sweeping_); |
| 410 sweeping_ = false; | 427 sweeping_ = false; |
| 411 } | 428 } |
| 412 | 429 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 return 0; | 535 return 0; |
| 519 } else { | 536 } else { |
| 520 ASSERT(total_time >= gc_time); | 537 ASSERT(total_time >= gc_time); |
| 521 int result= static_cast<int>((static_cast<double>(gc_time) / | 538 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 522 static_cast<double>(total_time)) * 100); | 539 static_cast<double>(total_time)) * 100); |
| 523 return result; | 540 return result; |
| 524 } | 541 } |
| 525 } | 542 } |
| 526 | 543 |
| 527 } // namespace dart | 544 } // namespace dart |
| OLD | NEW |