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

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

Issue 2960063002: Revert "Modifies the debug garbage collector (CollectAllGarbage()) to correctly remove inter-genera… (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « 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;
161 new_addr = scavenger_->TryAllocate(size); 160 new_addr = scavenger_->TryAllocate(size);
162 NOT_IN_PRODUCT(class_table->UpdateLiveNew(cid, size)); 161 NOT_IN_PRODUCT(class_table->UpdateLiveNew(cid, size));
163 } 162 }
164 } 163 }
165 // During a scavenge we always succeed to at least copy all of the 164 // During a scavenge we always succeed to at least copy all of the
166 // current objects to the to space. 165 // current objects to the to space.
167 ASSERT(new_addr != 0); 166 ASSERT(new_addr != 0);
168 // Copy the object to the new location. 167 // Copy the object to the new location.
169 memmove(reinterpret_cast<void*>(new_addr), 168 memmove(reinterpret_cast<void*>(new_addr),
170 reinterpret_cast<void*>(raw_addr), size); 169 reinterpret_cast<void*>(raw_addr), size);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 Scavenger::Scavenger(Heap* heap, 331 Scavenger::Scavenger(Heap* heap,
333 intptr_t max_semi_capacity_in_words, 332 intptr_t max_semi_capacity_in_words,
334 uword object_alignment) 333 uword object_alignment)
335 : heap_(heap), 334 : heap_(heap),
336 max_semi_capacity_in_words_(max_semi_capacity_in_words), 335 max_semi_capacity_in_words_(max_semi_capacity_in_words),
337 object_alignment_(object_alignment), 336 object_alignment_(object_alignment),
338 scavenging_(false), 337 scavenging_(false),
339 delayed_weak_properties_(NULL), 338 delayed_weak_properties_(NULL),
340 gc_time_micros_(0), 339 gc_time_micros_(0),
341 collections_(0), 340 collections_(0),
342 external_size_(0), 341 external_size_(0) {
343 failed_to_promote_(false) {
344 // Verify assumptions about the first word in objects which the scavenger is 342 // Verify assumptions about the first word in objects which the scavenger is
345 // going to use for forwarding pointers. 343 // going to use for forwarding pointers.
346 ASSERT(Object::tags_offset() == 0); 344 ASSERT(Object::tags_offset() == 0);
347 345
348 // Set initial size resulting in a total of three different levels. 346 // Set initial size resulting in a total of three different levels.
349 const intptr_t initial_semi_capacity_in_words = 347 const intptr_t initial_semi_capacity_in_words =
350 max_semi_capacity_in_words / 348 max_semi_capacity_in_words /
351 (FLAG_new_gen_growth_factor * FLAG_new_gen_growth_factor); 349 (FLAG_new_gen_growth_factor * FLAG_new_gen_growth_factor);
352 350
353 const intptr_t kVmNameSize = 128; 351 const intptr_t kVmNameSize = 128;
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 789
792 int64_t pre_safe_point = OS::GetCurrentMonotonicMicros(); 790 int64_t pre_safe_point = OS::GetCurrentMonotonicMicros();
793 791
794 Thread* thread = Thread::Current(); 792 Thread* thread = Thread::Current();
795 SafepointOperationScope safepoint_scope(thread); 793 SafepointOperationScope safepoint_scope(thread);
796 794
797 // Scavenging is not reentrant. Make sure that is the case. 795 // Scavenging is not reentrant. Make sure that is the case.
798 ASSERT(!scavenging_); 796 ASSERT(!scavenging_);
799 scavenging_ = true; 797 scavenging_ = true;
800 798
801 failed_to_promote_ = false;
802
803 PageSpace* page_space = heap_->old_space(); 799 PageSpace* page_space = heap_->old_space();
804 NoSafepointScope no_safepoints; 800 NoSafepointScope no_safepoints;
805 801
806 int64_t post_safe_point = OS::GetCurrentMonotonicMicros(); 802 int64_t post_safe_point = OS::GetCurrentMonotonicMicros();
807 heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point); 803 heap_->RecordTime(kSafePoint, post_safe_point - pre_safe_point);
808 804
809 // TODO(koda): Make verification more compatible with concurrent sweep. 805 // TODO(koda): Make verification more compatible with concurrent sweep.
810 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { 806 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) {
811 OS::PrintErr("Verifying before Scavenge..."); 807 OS::PrintErr("Verifying before Scavenge...");
812 heap_->Verify(kForbidMarked); 808 heap_->Verify(kForbidMarked);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 external_size_ += size; 898 external_size_ += size;
903 } 899 }
904 900
905 901
906 void Scavenger::FreeExternal(intptr_t size) { 902 void Scavenger::FreeExternal(intptr_t size) {
907 ASSERT(size >= 0); 903 ASSERT(size >= 0);
908 external_size_ -= size; 904 external_size_ -= size;
909 ASSERT(external_size_ >= 0); 905 ASSERT(external_size_ >= 0);
910 } 906 }
911 907
912
913 void Scavenger::Evacuate() {
914 // We need a safepoint here to prevent allocation right before or right after
915 // the scavenge.
916 // The former can introduce an object that we might fail to collect.
917 // The latter means even if the scavenge promotes every object in the new
918 // space, the new allocation means the space is not empty,
919 // causing the assertion below to fail.
920 SafepointOperationScope scope(Thread::Current());
921
922 // Forces the next scavenge to promote all the objects in the new space.
923 survivor_end_ = top_;
924 Scavenge();
925
926 // It is possible for objects to stay in the new space
927 // if the VM cannot create more pages for these objects.
928 ASSERT((UsedInWords() == 0) || failed_to_promote_);
929 }
930
931 } // namespace dart 908 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/scavenger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698