| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 301 } |
| 302 | 302 |
| 303 page = large_pages_; | 303 page = large_pages_; |
| 304 while (page != NULL) { | 304 while (page != NULL) { |
| 305 page->VisitObjects(visitor); | 305 page->VisitObjects(visitor); |
| 306 page = page->next(); | 306 page = page->next(); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 | 309 |
| 310 | 310 |
| 311 void PageSpace::SetPeer(RawObject* raw_obj, void* peer) { |
| 312 if (peer == NULL) { |
| 313 peer_.erase(raw_obj); |
| 314 } else { |
| 315 peer_[raw_obj] = peer; |
| 316 } |
| 317 } |
| 318 |
| 319 |
| 320 void* PageSpace::GetPeer(RawObject* raw_obj) { |
| 321 std::map<RawObject*, void*>::iterator it = peer_.find(raw_obj); |
| 322 return (it == peer_.end()) ? NULL : it->second; |
| 323 } |
| 324 |
| 325 |
| 326 int64_t PageSpace::PeerCount() const { |
| 327 return static_cast<int64_t>(peer_.size()); |
| 328 } |
| 329 |
| 330 |
| 311 void PageSpace::VisitObjectPointers(ObjectPointerVisitor* visitor) const { | 331 void PageSpace::VisitObjectPointers(ObjectPointerVisitor* visitor) const { |
| 312 HeapPage* page = pages_; | 332 HeapPage* page = pages_; |
| 313 while (page != NULL) { | 333 while (page != NULL) { |
| 314 page->VisitObjectPointers(visitor); | 334 page->VisitObjectPointers(visitor); |
| 315 page = page->next(); | 335 page = page->next(); |
| 316 } | 336 } |
| 317 | 337 |
| 318 page = large_pages_; | 338 page = large_pages_; |
| 319 while (page != NULL) { | 339 while (page != NULL) { |
| 320 page->VisitObjectPointers(visitor); | 340 page->VisitObjectPointers(visitor); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 } | 398 } |
| 379 | 399 |
| 380 if (FLAG_verbose_gc) { | 400 if (FLAG_verbose_gc) { |
| 381 OS::PrintErr("Start mark sweep for %s collection\n", gc_reason); | 401 OS::PrintErr("Start mark sweep for %s collection\n", gc_reason); |
| 382 } | 402 } |
| 383 Timer timer(true, "MarkSweep"); | 403 Timer timer(true, "MarkSweep"); |
| 384 timer.Start(); | 404 timer.Start(); |
| 385 int64_t start = OS::GetCurrentTimeMillis(); | 405 int64_t start = OS::GetCurrentTimeMillis(); |
| 386 | 406 |
| 387 // Mark all reachable old-gen objects. | 407 // Mark all reachable old-gen objects. |
| 388 GCMarker marker(heap_); | 408 GCMarker marker(heap_, &peer_); |
| 389 marker.MarkObjects(isolate, this, invoke_api_callbacks); | 409 marker.MarkObjects(isolate, this, invoke_api_callbacks); |
| 390 | 410 |
| 391 // Reset the bump allocation page to unused. | 411 // Reset the bump allocation page to unused. |
| 392 bump_page_ = NULL; | 412 bump_page_ = NULL; |
| 393 // Reset the freelists and setup sweeping. | 413 // Reset the freelists and setup sweeping. |
| 394 freelist_.Reset(); | 414 freelist_.Reset(); |
| 395 GCSweeper sweeper(heap_); | 415 GCSweeper sweeper(heap_); |
| 396 intptr_t in_use = 0; | 416 intptr_t in_use = 0; |
| 397 | 417 |
| 398 HeapPage* prev_page = NULL; | 418 HeapPage* prev_page = NULL; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 return 0; | 601 return 0; |
| 582 } else { | 602 } else { |
| 583 ASSERT(total_time >= gc_time); | 603 ASSERT(total_time >= gc_time); |
| 584 int result= static_cast<int>((static_cast<double>(gc_time) / | 604 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 585 static_cast<double>(total_time)) * 100); | 605 static_cast<double>(total_time)) * 100); |
| 586 return result; | 606 return result; |
| 587 } | 607 } |
| 588 } | 608 } |
| 589 | 609 |
| 590 } // namespace dart | 610 } // namespace dart |
| OLD | NEW |