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

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

Issue 2930943002: Debug garbage collector does not correctly remove cross-gen garbage (Closed)
Patch Set: Removes an extra space introduced in the last set. Created 3 years, 6 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
« runtime/vm/object_test.cc ('K') | « runtime/vm/scavenger.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 "vm/dart.h" 7 #include "vm/dart.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 new_addr = 150 new_addr =
151 page_space_->TryAllocatePromoLocked(size, PageSpace::kForceGrowth); 151 page_space_->TryAllocatePromoLocked(size, PageSpace::kForceGrowth);
152 if (new_addr != 0) { 152 if (new_addr != 0) {
153 // If promotion succeeded then we need to remember it so that it can 153 // If promotion succeeded then we need to remember it so that it can
154 // be traversed later. 154 // be traversed later.
155 scavenger_->PushToPromotedStack(new_addr); 155 scavenger_->PushToPromotedStack(new_addr);
156 bytes_promoted_ += size; 156 bytes_promoted_ += size;
157 NOT_IN_PRODUCT(class_table->UpdateAllocatedOld(cid, size)); 157 NOT_IN_PRODUCT(class_table->UpdateAllocatedOld(cid, size));
158 } else { 158 } else {
159 // Promotion did not succeed. Copy into the to space instead. 159 // Promotion did not succeed. Copy into the to space instead.
160 scavenger_->failed_to_promote_ = true;
160 new_addr = scavenger_->TryAllocate(size); 161 new_addr = scavenger_->TryAllocate(size);
161 NOT_IN_PRODUCT(class_table->UpdateLiveNew(cid, size)); 162 NOT_IN_PRODUCT(class_table->UpdateLiveNew(cid, size));
162 } 163 }
163 } 164 }
164 // During a scavenge we always succeed to at least copy all of the 165 // During a scavenge we always succeed to at least copy all of the
165 // current objects to the to space. 166 // current objects to the to space.
166 ASSERT(new_addr != 0); 167 ASSERT(new_addr != 0);
167 // Copy the object to the new location. 168 // Copy the object to the new location.
168 memmove(reinterpret_cast<void*>(new_addr), 169 memmove(reinterpret_cast<void*>(new_addr),
169 reinterpret_cast<void*>(raw_addr), size); 170 reinterpret_cast<void*>(raw_addr), size);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 Scavenger::Scavenger(Heap* heap, 331 Scavenger::Scavenger(Heap* heap,
331 intptr_t max_semi_capacity_in_words, 332 intptr_t max_semi_capacity_in_words,
332 uword object_alignment) 333 uword object_alignment)
333 : heap_(heap), 334 : heap_(heap),
334 max_semi_capacity_in_words_(max_semi_capacity_in_words), 335 max_semi_capacity_in_words_(max_semi_capacity_in_words),
335 object_alignment_(object_alignment), 336 object_alignment_(object_alignment),
336 scavenging_(false), 337 scavenging_(false),
337 delayed_weak_properties_(NULL), 338 delayed_weak_properties_(NULL),
338 gc_time_micros_(0), 339 gc_time_micros_(0),
339 collections_(0), 340 collections_(0),
340 external_size_(0) { 341 external_size_(0),
342 failed_to_promote_(false) {
341 // Verify assumptions about the first word in objects which the scavenger is 343 // Verify assumptions about the first word in objects which the scavenger is
342 // going to use for forwarding pointers. 344 // going to use for forwarding pointers.
343 ASSERT(Object::tags_offset() == 0); 345 ASSERT(Object::tags_offset() == 0);
344 346
345 // Set initial size resulting in a total of three different levels. 347 // Set initial size resulting in a total of three different levels.
346 const intptr_t initial_semi_capacity_in_words = 348 const intptr_t initial_semi_capacity_in_words =
347 max_semi_capacity_in_words / 349 max_semi_capacity_in_words /
348 (FLAG_new_gen_growth_factor * FLAG_new_gen_growth_factor); 350 (FLAG_new_gen_growth_factor * FLAG_new_gen_growth_factor);
349 to_ = SemiSpace::New(initial_semi_capacity_in_words); 351 to_ = SemiSpace::New(initial_semi_capacity_in_words);
350 if (to_ == NULL) { 352 if (to_ == NULL) {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 782
781 int64_t pre_safe_point = OS::GetCurrentMonotonicMicros(); 783 int64_t pre_safe_point = OS::GetCurrentMonotonicMicros();
782 784
783 Thread* thread = Thread::Current(); 785 Thread* thread = Thread::Current();
784 SafepointOperationScope safepoint_scope(thread); 786 SafepointOperationScope safepoint_scope(thread);
785 787
786 // Scavenging is not reentrant. Make sure that is the case. 788 // Scavenging is not reentrant. Make sure that is the case.
787 ASSERT(!scavenging_); 789 ASSERT(!scavenging_);
788 scavenging_ = true; 790 scavenging_ = true;
789 791
792 failed_to_promote_ = false;
793
790 PageSpace* page_space = heap_->old_space(); 794 PageSpace* page_space = heap_->old_space();
791 NoSafepointScope no_safepoints; 795 NoSafepointScope no_safepoints;
792 796
793 int64_t post_safe_point = OS::GetCurrentMonotonicMicros(); 797 int64_t post_safe_point = OS::GetCurrentMonotonicMicros();
794 heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point); 798 heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point);
795 799
796 // TODO(koda): Make verification more compatible with concurrent sweep. 800 // TODO(koda): Make verification more compatible with concurrent sweep.
797 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { 801 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) {
798 OS::PrintErr("Verifying before Scavenge..."); 802 OS::PrintErr("Verifying before Scavenge...");
799 heap_->Verify(kForbidMarked); 803 heap_->Verify(kForbidMarked);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 external_size_ += size; 893 external_size_ += size;
890 } 894 }
891 895
892 896
893 void Scavenger::FreeExternal(intptr_t size) { 897 void Scavenger::FreeExternal(intptr_t size) {
894 ASSERT(size >= 0); 898 ASSERT(size >= 0);
895 external_size_ -= size; 899 external_size_ -= size;
896 ASSERT(external_size_ >= 0); 900 ASSERT(external_size_ >= 0);
897 } 901 }
898 902
903 void Scavenger::Evacuate() {
904 SafepointOperationScope scope(Thread::Current());
905 Scavenge();
rmacnak 2017/06/19 19:29:00 Can't we just update the promotion threshold and s
906 Scavenge();
907
908 // It is possible for objects to stay in the new space
909 // if the VM cannot create more pages for these objects.
910 ASSERT(UsedInWords() == 0 || failed_to_promote_);
911 }
912
899 } // namespace dart 913 } // namespace dart
OLDNEW
« runtime/vm/object_test.cc ('K') | « runtime/vm/scavenger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698