Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: runtime/vm/scavenger.cc

Issue 193473002: Fix external size accounting for prologue weak persistent handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_state.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 intptr_t bytes_promoted_; 264 intptr_t bytes_promoted_;
265 RawObject* visiting_old_object_; 265 RawObject* visiting_old_object_;
266 bool in_scavenge_pointer_; 266 bool in_scavenge_pointer_;
267 267
268 DISALLOW_COPY_AND_ASSIGN(ScavengerVisitor); 268 DISALLOW_COPY_AND_ASSIGN(ScavengerVisitor);
269 }; 269 };
270 270
271 271
272 class ScavengerWeakVisitor : public HandleVisitor { 272 class ScavengerWeakVisitor : public HandleVisitor {
273 public: 273 public:
274 explicit ScavengerWeakVisitor(Scavenger* scavenger) 274 // 'prologue_weak_were_strong' is currently only used for sanity checking.
275 explicit ScavengerWeakVisitor(Scavenger* scavenger,
276 bool prologue_weak_were_strong)
275 : HandleVisitor(Isolate::Current()), 277 : HandleVisitor(Isolate::Current()),
276 scavenger_(scavenger) { 278 scavenger_(scavenger),
279 prologue_weak_were_strong_(prologue_weak_were_strong) {
277 } 280 }
278 281
279 void VisitHandle(uword addr, bool is_prologue_weak) { 282 void VisitHandle(uword addr, bool is_prologue_weak) {
280 FinalizablePersistentHandle* handle = 283 FinalizablePersistentHandle* handle =
281 reinterpret_cast<FinalizablePersistentHandle*>(addr); 284 reinterpret_cast<FinalizablePersistentHandle*>(addr);
282 RawObject** p = handle->raw_addr(); 285 RawObject** p = handle->raw_addr();
283 Heap::Space before = handle->SpaceForExternal();
284 if (scavenger_->IsUnreachable(p)) { 286 if (scavenger_->IsUnreachable(p)) {
287 ASSERT(!is_prologue_weak || !prologue_weak_were_strong_);
285 handle->UpdateUnreachable(isolate(), is_prologue_weak); 288 handle->UpdateUnreachable(isolate(), is_prologue_weak);
286 } else { 289 } else {
287 handle->UpdateRelocated(before, isolate()); 290 handle->UpdateRelocated(isolate());
288 } 291 }
289 } 292 }
290 293
291 private: 294 private:
292 Scavenger* scavenger_; 295 Scavenger* scavenger_;
296 bool prologue_weak_were_strong_;
293 297
294 DISALLOW_COPY_AND_ASSIGN(ScavengerWeakVisitor); 298 DISALLOW_COPY_AND_ASSIGN(ScavengerWeakVisitor);
295 }; 299 };
296 300
297 301
298 // Visitor used to verify that all old->new references have been added to the 302 // Visitor used to verify that all old->new references have been added to the
299 // StoreBuffers. 303 // StoreBuffers.
300 class VerifyStoreBufferPointerVisitor : public ObjectPointerVisitor { 304 class VerifyStoreBufferPointerVisitor : public ObjectPointerVisitor {
301 public: 305 public:
302 VerifyStoreBufferPointerVisitor(Isolate* isolate, MemoryRegion* to) 306 VerifyStoreBufferPointerVisitor(Isolate* isolate, MemoryRegion* to)
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 693 }
690 694
691 // During from/to flip and promoted stack use, move external allocation 695 // During from/to flip and promoted stack use, move external allocation
692 // out of tospace temporarily. 696 // out of tospace temporarily.
693 intptr_t saved_external = external_size_; 697 intptr_t saved_external = external_size_;
694 FreeExternal(saved_external); 698 FreeExternal(saved_external);
695 699
696 // Setup the visitor and run a scavenge. 700 // Setup the visitor and run a scavenge.
697 ScavengerVisitor visitor(isolate, this); 701 ScavengerVisitor visitor(isolate, this);
698 Prologue(isolate, invoke_api_callbacks); 702 Prologue(isolate, invoke_api_callbacks);
699 IterateRoots(isolate, &visitor, !invoke_api_callbacks); 703 const bool prologue_weak_are_strong = !invoke_api_callbacks;
704 IterateRoots(isolate, &visitor, prologue_weak_are_strong);
700 int64_t start = OS::GetCurrentTimeMicros(); 705 int64_t start = OS::GetCurrentTimeMicros();
701 ProcessToSpace(&visitor); 706 ProcessToSpace(&visitor);
702 int64_t middle = OS::GetCurrentTimeMicros(); 707 int64_t middle = OS::GetCurrentTimeMicros();
703 IterateWeakReferences(isolate, &visitor); 708 IterateWeakReferences(isolate, &visitor);
704 // Done with promoted stack; restore external allocation. 709 // Done with promoted stack; restore external allocation.
705 ASSERT(!PromotedStackHasMore()); 710 ASSERT(!PromotedStackHasMore());
706 AllocateExternal(saved_external); 711 AllocateExternal(saved_external);
707 ScavengerWeakVisitor weak_visitor(this); 712 ScavengerWeakVisitor weak_visitor(this, prologue_weak_are_strong);
708 IterateWeakRoots(isolate, &weak_visitor, invoke_api_callbacks); 713 // Include the prologue weak handles, since we must process any promotion.
714 const bool visit_prologue_weak_handles = true;
715 IterateWeakRoots(isolate, &weak_visitor, visit_prologue_weak_handles);
709 visitor.Finalize(); 716 visitor.Finalize();
710 ProcessWeakTables(); 717 ProcessWeakTables();
711 int64_t end = OS::GetCurrentTimeMicros(); 718 int64_t end = OS::GetCurrentTimeMicros();
712 heap_->RecordTime(kProcessToSpace, middle - start); 719 heap_->RecordTime(kProcessToSpace, middle - start);
713 heap_->RecordTime(kIterateWeaks, end - middle); 720 heap_->RecordTime(kIterateWeaks, end - middle);
714 Epilogue(isolate, &visitor, invoke_api_callbacks); 721 Epilogue(isolate, &visitor, invoke_api_callbacks);
715 722
716 if (FLAG_verify_after_gc) { 723 if (FLAG_verify_after_gc) {
717 OS::PrintErr("Verifying after Scavenge..."); 724 OS::PrintErr("Verifying after Scavenge...");
718 heap_->Verify(); 725 heap_->Verify();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 761
755 762
756 void Scavenger::FreeExternal(intptr_t size) { 763 void Scavenger::FreeExternal(intptr_t size) {
757 ASSERT(size >= 0); 764 ASSERT(size >= 0);
758 external_size_ -= size; 765 external_size_ -= size;
759 ASSERT(external_size_ >= 0); 766 ASSERT(external_size_ >= 0);
760 end_ = Utils::Minimum(to_->end(), end_ + size); 767 end_ = Utils::Minimum(to_->end(), end_ + size);
761 } 768 }
762 769
763 } // namespace dart 770 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698