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

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
« runtime/vm/dart_api_state.h ('K') | « 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 explicit ScavengerWeakVisitor(Scavenger* scavenger,
275 bool prologue_weak_were_strong)
275 : HandleVisitor(Isolate::Current()), 276 : HandleVisitor(Isolate::Current()),
276 scavenger_(scavenger) { 277 scavenger_(scavenger),
278 prologue_weak_were_strong_(prologue_weak_were_strong) {
277 } 279 }
278 280
279 void VisitHandle(uword addr, bool is_prologue_weak) { 281 void VisitHandle(uword addr, bool is_prologue_weak) {
280 FinalizablePersistentHandle* handle = 282 FinalizablePersistentHandle* handle =
281 reinterpret_cast<FinalizablePersistentHandle*>(addr); 283 reinterpret_cast<FinalizablePersistentHandle*>(addr);
282 RawObject** p = handle->raw_addr(); 284 RawObject** p = handle->raw_addr();
283 Heap::Space before = handle->SpaceForExternal();
284 if (scavenger_->IsUnreachable(p)) { 285 if (scavenger_->IsUnreachable(p)) {
286 ASSERT(!is_prologue_weak || prologue_weak_were_strong_);
285 handle->UpdateUnreachable(isolate(), is_prologue_weak); 287 handle->UpdateUnreachable(isolate(), is_prologue_weak);
286 } else { 288 } else {
287 handle->UpdateRelocated(before, isolate()); 289 handle->UpdateRelocated(isolate());
288 } 290 }
289 } 291 }
290 292
291 private: 293 private:
292 Scavenger* scavenger_; 294 Scavenger* scavenger_;
295 bool prologue_weak_were_strong_;
293 296
294 DISALLOW_COPY_AND_ASSIGN(ScavengerWeakVisitor); 297 DISALLOW_COPY_AND_ASSIGN(ScavengerWeakVisitor);
295 }; 298 };
296 299
297 300
298 // Visitor used to verify that all old->new references have been added to the 301 // Visitor used to verify that all old->new references have been added to the
299 // StoreBuffers. 302 // StoreBuffers.
300 class VerifyStoreBufferPointerVisitor : public ObjectPointerVisitor { 303 class VerifyStoreBufferPointerVisitor : public ObjectPointerVisitor {
301 public: 304 public:
302 VerifyStoreBufferPointerVisitor(Isolate* isolate, MemoryRegion* to) 305 VerifyStoreBufferPointerVisitor(Isolate* isolate, MemoryRegion* to)
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 ScavengerVisitor visitor(isolate, this); 700 ScavengerVisitor visitor(isolate, this);
698 Prologue(isolate, invoke_api_callbacks); 701 Prologue(isolate, invoke_api_callbacks);
699 IterateRoots(isolate, &visitor, !invoke_api_callbacks); 702 IterateRoots(isolate, &visitor, !invoke_api_callbacks);
700 int64_t start = OS::GetCurrentTimeMicros(); 703 int64_t start = OS::GetCurrentTimeMicros();
701 ProcessToSpace(&visitor); 704 ProcessToSpace(&visitor);
702 int64_t middle = OS::GetCurrentTimeMicros(); 705 int64_t middle = OS::GetCurrentTimeMicros();
703 IterateWeakReferences(isolate, &visitor); 706 IterateWeakReferences(isolate, &visitor);
704 // Done with promoted stack; restore external allocation. 707 // Done with promoted stack; restore external allocation.
705 ASSERT(!PromotedStackHasMore()); 708 ASSERT(!PromotedStackHasMore());
706 AllocateExternal(saved_external); 709 AllocateExternal(saved_external);
707 ScavengerWeakVisitor weak_visitor(this); 710 ScavengerWeakVisitor weak_visitor(this, !invoke_api_callbacks);
708 IterateWeakRoots(isolate, &weak_visitor, invoke_api_callbacks); 711 IterateWeakRoots(isolate, &weak_visitor, true);
siva 2014/03/11 16:35:01 Why did you set the parameter 'visit_prologue_weak
koda 2014/03/11 17:35:45 Because we must visit the prologue weak persistent
709 visitor.Finalize(); 712 visitor.Finalize();
710 ProcessWeakTables(); 713 ProcessWeakTables();
711 int64_t end = OS::GetCurrentTimeMicros(); 714 int64_t end = OS::GetCurrentTimeMicros();
712 heap_->RecordTime(kProcessToSpace, middle - start); 715 heap_->RecordTime(kProcessToSpace, middle - start);
713 heap_->RecordTime(kIterateWeaks, end - middle); 716 heap_->RecordTime(kIterateWeaks, end - middle);
714 Epilogue(isolate, &visitor, invoke_api_callbacks); 717 Epilogue(isolate, &visitor, invoke_api_callbacks);
715 718
716 if (FLAG_verify_after_gc) { 719 if (FLAG_verify_after_gc) {
717 OS::PrintErr("Verifying after Scavenge..."); 720 OS::PrintErr("Verifying after Scavenge...");
718 heap_->Verify(); 721 heap_->Verify();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 756
754 757
755 void Scavenger::FreeExternal(intptr_t size) { 758 void Scavenger::FreeExternal(intptr_t size) {
756 ASSERT(size >= 0); 759 ASSERT(size >= 0);
757 external_size_ -= size; 760 external_size_ -= size;
758 ASSERT(external_size_ >= 0); 761 ASSERT(external_size_ >= 0);
759 end_ = Utils::Minimum(to_->end(), end_ + size); 762 end_ = Utils::Minimum(to_->end(), end_ + size);
760 } 763 }
761 764
762 } // namespace dart 765 } // namespace dart
OLDNEW
« runtime/vm/dart_api_state.h ('K') | « runtime/vm/dart_api_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698