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

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

Issue 2041373004: Revert "Background finalization." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
« no previous file with comments | « runtime/vm/profiler.h ('k') | runtime/vm/thread.h » ('j') | 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 RawObject* visiting_old_object_; 186 RawObject* visiting_old_object_;
187 187
188 friend class Scavenger; 188 friend class Scavenger;
189 189
190 DISALLOW_COPY_AND_ASSIGN(ScavengerVisitor); 190 DISALLOW_COPY_AND_ASSIGN(ScavengerVisitor);
191 }; 191 };
192 192
193 193
194 class ScavengerWeakVisitor : public HandleVisitor { 194 class ScavengerWeakVisitor : public HandleVisitor {
195 public: 195 public:
196 ScavengerWeakVisitor(Thread* thread, 196 explicit ScavengerWeakVisitor(Scavenger* scavenger)
197 Scavenger* scavenger, 197 : HandleVisitor(Thread::Current()),
198 FinalizationQueue* finalization_queue) : 198 scavenger_(scavenger) {
199 HandleVisitor(thread), 199 ASSERT(scavenger->heap_->isolate() == Thread::Current()->isolate());
200 scavenger_(scavenger),
201 queue_(finalization_queue) {
202 ASSERT(scavenger->heap_->isolate() == thread->isolate());
203 } 200 }
204 201
205 void VisitHandle(uword addr) { 202 void VisitHandle(uword addr) {
206 FinalizablePersistentHandle* handle = 203 FinalizablePersistentHandle* handle =
207 reinterpret_cast<FinalizablePersistentHandle*>(addr); 204 reinterpret_cast<FinalizablePersistentHandle*>(addr);
208 RawObject** p = handle->raw_addr(); 205 RawObject** p = handle->raw_addr();
209 if (scavenger_->IsUnreachable(p)) { 206 if (scavenger_->IsUnreachable(p)) {
210 handle->UpdateUnreachable(thread()->isolate(), queue_); 207 handle->UpdateUnreachable(thread()->isolate());
211 } else { 208 } else {
212 handle->UpdateRelocated(thread()->isolate()); 209 handle->UpdateRelocated(thread()->isolate());
213 } 210 }
214 } 211 }
215 212
216 private: 213 private:
217 Scavenger* scavenger_; 214 Scavenger* scavenger_;
218 FinalizationQueue* queue_;
219 215
220 DISALLOW_COPY_AND_ASSIGN(ScavengerWeakVisitor); 216 DISALLOW_COPY_AND_ASSIGN(ScavengerWeakVisitor);
221 }; 217 };
222 218
223 219
224 // Visitor used to verify that all old->new references have been added to the 220 // Visitor used to verify that all old->new references have been added to the
225 // StoreBuffers. 221 // StoreBuffers.
226 class VerifyStoreBufferPointerVisitor : public ObjectPointerVisitor { 222 class VerifyStoreBufferPointerVisitor : public ObjectPointerVisitor {
227 public: 223 public:
228 VerifyStoreBufferPointerVisitor(Isolate* isolate, 224 VerifyStoreBufferPointerVisitor(Isolate* isolate,
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 StackZone zone(thread); 805 StackZone zone(thread);
810 // Setup the visitor and run the scavenge. 806 // Setup the visitor and run the scavenge.
811 ScavengerVisitor visitor(isolate, this, from); 807 ScavengerVisitor visitor(isolate, this, from);
812 page_space->AcquireDataLock(); 808 page_space->AcquireDataLock();
813 IterateRoots(isolate, &visitor); 809 IterateRoots(isolate, &visitor);
814 int64_t start = OS::GetCurrentTimeMicros(); 810 int64_t start = OS::GetCurrentTimeMicros();
815 ProcessToSpace(&visitor); 811 ProcessToSpace(&visitor);
816 int64_t middle = OS::GetCurrentTimeMicros(); 812 int64_t middle = OS::GetCurrentTimeMicros();
817 { 813 {
818 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing"); 814 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing");
819 FinalizationQueue* queue = new FinalizationQueue(); 815 ScavengerWeakVisitor weak_visitor(this);
820 ScavengerWeakVisitor weak_visitor(thread, this, queue);
821 IterateWeakRoots(isolate, &weak_visitor); 816 IterateWeakRoots(isolate, &weak_visitor);
822 if (queue->length() > 0) {
823 Dart::thread_pool()->Run(new BackgroundFinalizer(isolate, queue));
824 } else {
825 delete queue;
826 }
827 } 817 }
828 ProcessWeakReferences(); 818 ProcessWeakReferences();
829 page_space->ReleaseDataLock(); 819 page_space->ReleaseDataLock();
830 820
831 // Scavenge finished. Run accounting. 821 // Scavenge finished. Run accounting.
832 int64_t end = OS::GetCurrentTimeMicros(); 822 int64_t end = OS::GetCurrentTimeMicros();
833 heap_->RecordTime(kProcessToSpace, middle - start); 823 heap_->RecordTime(kProcessToSpace, middle - start);
834 heap_->RecordTime(kIterateWeaks, end - middle); 824 heap_->RecordTime(kIterateWeaks, end - middle);
835 stats_history_.Add( 825 stats_history_.Add(
836 ScavengeStats(start, end, 826 ScavengeStats(start, end,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } 884 }
895 885
896 886
897 void Scavenger::FreeExternal(intptr_t size) { 887 void Scavenger::FreeExternal(intptr_t size) {
898 ASSERT(size >= 0); 888 ASSERT(size >= 0);
899 external_size_ -= size; 889 external_size_ -= size;
900 ASSERT(external_size_ >= 0); 890 ASSERT(external_size_ >= 0);
901 } 891 }
902 892
903 } // namespace dart 893 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler.h ('k') | runtime/vm/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698