| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 248 |
| 249 DISALLOW_COPY_AND_ASSIGN(ScavengerVisitor); | 249 DISALLOW_COPY_AND_ASSIGN(ScavengerVisitor); |
| 250 }; | 250 }; |
| 251 | 251 |
| 252 | 252 |
| 253 class ScavengerWeakVisitor : public HandleVisitor { | 253 class ScavengerWeakVisitor : public HandleVisitor { |
| 254 public: | 254 public: |
| 255 // 'prologue_weak_were_strong' is currently only used for sanity checking. | 255 // 'prologue_weak_were_strong' is currently only used for sanity checking. |
| 256 explicit ScavengerWeakVisitor(Scavenger* scavenger, | 256 explicit ScavengerWeakVisitor(Scavenger* scavenger, |
| 257 bool prologue_weak_were_strong) | 257 bool prologue_weak_were_strong) |
| 258 : HandleVisitor(Isolate::Current()), | 258 : HandleVisitor(scavenger->heap_->isolate()), |
| 259 scavenger_(scavenger), | 259 scavenger_(scavenger), |
| 260 prologue_weak_were_strong_(prologue_weak_were_strong) { | 260 prologue_weak_were_strong_(prologue_weak_were_strong) { |
| 261 } | 261 } |
| 262 | 262 |
| 263 void VisitHandle(uword addr) { | 263 void VisitHandle(uword addr) { |
| 264 FinalizablePersistentHandle* handle = | 264 FinalizablePersistentHandle* handle = |
| 265 reinterpret_cast<FinalizablePersistentHandle*>(addr); | 265 reinterpret_cast<FinalizablePersistentHandle*>(addr); |
| 266 RawObject** p = handle->raw_addr(); | 266 RawObject** p = handle->raw_addr(); |
| 267 if (scavenger_->IsUnreachable(p)) { | 267 if (scavenger_->IsUnreachable(p)) { |
| 268 ASSERT(!handle->IsPrologueWeakPersistent() || | 268 ASSERT(!handle->IsPrologueWeakPersistent() || |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 // TODO(cshapiro): Add a decision procedure for determining when the | 690 // TODO(cshapiro): Add a decision procedure for determining when the |
| 691 // the API callbacks should be invoked. | 691 // the API callbacks should be invoked. |
| 692 Scavenge(false); | 692 Scavenge(false); |
| 693 } | 693 } |
| 694 | 694 |
| 695 | 695 |
| 696 void Scavenger::Scavenge(bool invoke_api_callbacks) { | 696 void Scavenger::Scavenge(bool invoke_api_callbacks) { |
| 697 // Scavenging is not reentrant. Make sure that is the case. | 697 // Scavenging is not reentrant. Make sure that is the case. |
| 698 ASSERT(!scavenging_); | 698 ASSERT(!scavenging_); |
| 699 scavenging_ = true; | 699 scavenging_ = true; |
| 700 Isolate* isolate = Isolate::Current(); | 700 Isolate* isolate = heap_->isolate(); |
| 701 NoHandleScope no_handles(isolate); | 701 NoHandleScope no_handles(isolate); |
| 702 | 702 |
| 703 if (FLAG_verify_before_gc) { | 703 if (FLAG_verify_before_gc) { |
| 704 OS::PrintErr("Verifying before Scavenge..."); | 704 OS::PrintErr("Verifying before Scavenge..."); |
| 705 heap_->Verify(); | 705 heap_->Verify(); |
| 706 OS::PrintErr(" done.\n"); | 706 OS::PrintErr(" done.\n"); |
| 707 } | 707 } |
| 708 | 708 |
| 709 // Setup the visitor and run a scavenge. | 709 // Setup the visitor and run a scavenge. |
| 710 ScavengerVisitor visitor(isolate, this); | 710 ScavengerVisitor visitor(isolate, this); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 } | 766 } |
| 767 | 767 |
| 768 | 768 |
| 769 void Scavenger::FreeExternal(intptr_t size) { | 769 void Scavenger::FreeExternal(intptr_t size) { |
| 770 ASSERT(size >= 0); | 770 ASSERT(size >= 0); |
| 771 external_size_ -= size; | 771 external_size_ -= size; |
| 772 ASSERT(external_size_ >= 0); | 772 ASSERT(external_size_ >= 0); |
| 773 } | 773 } |
| 774 | 774 |
| 775 } // namespace dart | 775 } // namespace dart |
| OLD | NEW |