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

Unified Diff: runtime/vm/gc_sweeper.cc

Issue 1292353004: Safepointing in GC (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Scavenger again. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/gc_sweeper.h ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/gc_sweeper.cc
diff --git a/runtime/vm/gc_sweeper.cc b/runtime/vm/gc_sweeper.cc
index 4cd224377b14c6ad084004ff16f48e6a541c358c..ff53575a0e5a06ef7e3d1234763c370a9836015f 100644
--- a/runtime/vm/gc_sweeper.cc
+++ b/runtime/vm/gc_sweeper.cc
@@ -96,12 +96,18 @@ class SweeperTask : public ThreadPool::Task {
PageSpace* old_space,
HeapPage* first,
HeapPage* last,
- FreeList* freelist)
+ FreeList* freelist,
+ Monitor* started_monitor,
+ bool* started_flag,
+ SafepointId pass_safepoint)
: task_isolate_(isolate),
old_space_(old_space),
first_(first),
last_(last),
- freelist_(freelist) {
+ freelist_(freelist),
+ started_monitor_(started_monitor),
+ started_flag_(started_flag),
+ pass_safepoint_(pass_safepoint) {
ASSERT(task_isolate_ != NULL);
ASSERT(first_ != NULL);
ASSERT(old_space_ != NULL);
@@ -113,7 +119,13 @@ class SweeperTask : public ThreadPool::Task {
}
virtual void Run() {
- Thread::EnterIsolateAsHelper(task_isolate_);
+ Thread::EnterIsolateAsHelper(task_isolate_, pass_safepoint_);
+ {
+ MonitorLocker ml(started_monitor_);
+ ASSERT(!*started_flag_);
+ *started_flag_ = true;
+ ml.Notify();
+ }
GCSweeper sweeper;
HeapPage* page = first_;
@@ -153,20 +165,35 @@ class SweeperTask : public ThreadPool::Task {
HeapPage* first_;
HeapPage* last_;
FreeList* freelist_;
+ Monitor* started_monitor_;
+ bool* started_flag_;
+ SafepointId pass_safepoint_;
};
void GCSweeper::SweepConcurrent(Isolate* isolate,
HeapPage* first,
HeapPage* last,
- FreeList* freelist) {
+ FreeList* freelist,
+ SafepointId pass_safepoint) {
+ Monitor started_monitor;
+ bool started_flag = false;
SweeperTask* task =
new SweeperTask(isolate,
isolate->heap()->old_space(),
first, last,
- freelist);
+ freelist,
+ &started_monitor,
+ &started_flag,
+ pass_safepoint);
ThreadPool* pool = Dart::thread_pool();
pool->Run(task);
+ {
+ MonitorLocker ml(&started_monitor);
Ivan Posva 2015/08/19 08:00:04 I don't expect it to be needed to wait for the swe
+ while (!started_flag) {
+ ml.Wait();
+ }
+ }
}
} // namespace dart
« no previous file with comments | « runtime/vm/gc_sweeper.h ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698