| 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 memset(from_->pointer(), 0xf3, from_->size()); | 384 memset(from_->pointer(), 0xf3, from_->size()); |
| 385 #endif // defined(DEBUG) | 385 #endif // defined(DEBUG) |
| 386 if (invoke_api_callbacks) { | 386 if (invoke_api_callbacks) { |
| 387 isolate->gc_epilogue_callbacks().Invoke(); | 387 isolate->gc_epilogue_callbacks().Invoke(); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| 391 | 391 |
| 392 void Scavenger::IterateStoreBuffers(Isolate* isolate, | 392 void Scavenger::IterateStoreBuffers(Isolate* isolate, |
| 393 ScavengerVisitor* visitor) { | 393 ScavengerVisitor* visitor) { |
| 394 // Drain store buffer block into store buffer to deduplicate it. It might be |
| 395 // full of large objects repeated multiple times. |
| 396 // Use DrainBlock directly instead of ProcessBlock because we are in the |
| 397 // middle of a scavenge cycle and thus do not care if we are temporary |
| 398 // running over the max number of deduplication sets. |
| 399 StoreBufferBlock* block = isolate->store_buffer_block(); |
| 400 heap_->RecordData(kStoreBufferBlockEntries, block->Count()); |
| 401 isolate->store_buffer()->DrainBlock(block); |
| 402 |
| 394 // Iterating through the store buffers. | 403 // Iterating through the store buffers. |
| 395 // Grab the deduplication sets out of the store buffer. | 404 // Grab the deduplication sets out of the store buffer. |
| 396 StoreBuffer::DedupSet* pending = isolate->store_buffer()->DedupSets(); | 405 StoreBuffer::DedupSet* pending = isolate->store_buffer()->DedupSets(); |
| 397 intptr_t entries = 0; | 406 intptr_t entries = 0; |
| 398 while (pending != NULL) { | 407 while (pending != NULL) { |
| 399 StoreBuffer::DedupSet* next = pending->next(); | 408 StoreBuffer::DedupSet* next = pending->next(); |
| 400 HashSet* set = pending->set(); | 409 HashSet* set = pending->set(); |
| 401 intptr_t count = set->Count(); | 410 intptr_t count = set->Count(); |
| 402 intptr_t size = set->Size(); | 411 intptr_t size = set->Size(); |
| 403 intptr_t handled = 0; | 412 intptr_t handled = 0; |
| 404 entries += count; | 413 entries += count; |
| 405 for (intptr_t i = 0; i < size; i++) { | 414 for (intptr_t i = 0; i < size; i++) { |
| 406 RawObject* raw_object = reinterpret_cast<RawObject*>(set->At(i)); | 415 RawObject* raw_object = reinterpret_cast<RawObject*>(set->At(i)); |
| 407 if (raw_object != NULL) { | 416 if (raw_object != NULL) { |
| 408 visitor->VisitingOldObject(raw_object); | 417 visitor->VisitingOldObject(raw_object); |
| 409 raw_object->VisitPointers(visitor); | 418 raw_object->VisitPointers(visitor); |
| 410 handled++; | 419 handled++; |
| 411 if (handled == count) { | 420 if (handled == count) { |
| 412 break; | 421 break; |
| 413 } | 422 } |
| 414 } | 423 } |
| 415 } | 424 } |
| 416 delete pending; | 425 delete pending; |
| 417 pending = next; | 426 pending = next; |
| 418 } | 427 } |
| 419 heap_->RecordData(kStoreBufferEntries, entries); | 428 heap_->RecordData(kStoreBufferEntries, entries); |
| 420 StoreBufferBlock* block = isolate->store_buffer_block(); | |
| 421 entries = block->Count(); | |
| 422 for (intptr_t i = 0; i < entries; i++) { | |
| 423 RawObject* raw_object = reinterpret_cast<RawObject*>(block->At(i)); | |
| 424 ASSERT(raw_object->IsHeapObject()); | |
| 425 visitor->VisitingOldObject(raw_object); | |
| 426 raw_object->VisitPointers(visitor); | |
| 427 } | |
| 428 block->Reset(); | |
| 429 heap_->RecordData(kStoreBufferBlockEntries, entries); | |
| 430 // Done iterating through old objects remembered in the store buffers. | 429 // Done iterating through old objects remembered in the store buffers. |
| 431 visitor->VisitingOldObject(NULL); | 430 visitor->VisitingOldObject(NULL); |
| 432 } | 431 } |
| 433 | 432 |
| 434 | 433 |
| 435 void Scavenger::IterateRoots(Isolate* isolate, | 434 void Scavenger::IterateRoots(Isolate* isolate, |
| 436 ScavengerVisitor* visitor, | 435 ScavengerVisitor* visitor, |
| 437 bool visit_prologue_weak_persistent_handles) { | 436 bool visit_prologue_weak_persistent_handles) { |
| 438 int64_t start = OS::GetCurrentTimeMicros(); | 437 int64_t start = OS::GetCurrentTimeMicros(); |
| 439 isolate->VisitObjectPointers(visitor, | 438 isolate->VisitObjectPointers(visitor, |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 PeerTable::iterator it = peer_table_.find(raw_obj); | 696 PeerTable::iterator it = peer_table_.find(raw_obj); |
| 698 return (it == peer_table_.end()) ? NULL : it->second; | 697 return (it == peer_table_.end()) ? NULL : it->second; |
| 699 } | 698 } |
| 700 | 699 |
| 701 | 700 |
| 702 int64_t Scavenger::PeerCount() const { | 701 int64_t Scavenger::PeerCount() const { |
| 703 return static_cast<int64_t>(peer_table_.size()); | 702 return static_cast<int64_t>(peer_table_.size()); |
| 704 } | 703 } |
| 705 | 704 |
| 706 } // namespace dart | 705 } // namespace dart |
| OLD | NEW |