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

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

Issue 2995543004: [vm, gc] Require a safepoint for heap iteration. (Closed)
Patch Set: explicit-thread Created 3 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/safepoint.h ('k') | runtime/vm/scavenger.cc » ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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/safepoint.h" 5 #include "vm/safepoint.h"
6 6
7 #include "vm/thread.h" 7 #include "vm/thread.h"
8 #include "vm/thread_registry.h" 8 #include "vm/thread_registry.h"
9 9
10 namespace dart { 10 namespace dart {
11 11
12 SafepointOperationScope::SafepointOperationScope(Thread* T) : StackResource(T) { 12 SafepointOperationScope::SafepointOperationScope(Thread* T) : StackResource(T) {
13 ASSERT(T != NULL); 13 ASSERT(T != NULL);
14 Isolate* I = T->isolate(); 14 Isolate* I = T->isolate();
15 ASSERT(I != NULL); 15 ASSERT(I != NULL);
16 ASSERT(T->no_safepoint_scope_depth() == 0);
17 16
18 SafepointHandler* handler = I->safepoint_handler(); 17 SafepointHandler* handler = I->safepoint_handler();
19 ASSERT(handler != NULL); 18 ASSERT(handler != NULL);
20 19
21 // Signal all threads to get to a safepoint and wait for them to 20 // Signal all threads to get to a safepoint and wait for them to
22 // get to a safepoint. 21 // get to a safepoint.
23 handler->SafepointThreads(T); 22 handler->SafepointThreads(T);
24 } 23 }
25 24
26 SafepointOperationScope::~SafepointOperationScope() { 25 SafepointOperationScope::~SafepointOperationScope() {
(...skipping 17 matching lines...) Expand all
44 43
45 SafepointHandler::~SafepointHandler() { 44 SafepointHandler::~SafepointHandler() {
46 ASSERT(owner_ == NULL); 45 ASSERT(owner_ == NULL);
47 ASSERT(safepoint_operation_count_ == 0); 46 ASSERT(safepoint_operation_count_ == 0);
48 delete safepoint_lock_; 47 delete safepoint_lock_;
49 safepoint_lock_ = NULL; 48 safepoint_lock_ = NULL;
50 isolate_ = NULL; 49 isolate_ = NULL;
51 } 50 }
52 51
53 void SafepointHandler::SafepointThreads(Thread* T) { 52 void SafepointHandler::SafepointThreads(Thread* T) {
53 ASSERT(T->no_safepoint_scope_depth() == 0);
54 ASSERT(T->execution_state() == Thread::kThreadInVM);
55
54 { 56 {
55 // First grab the threads list lock for this isolate 57 // First grab the threads list lock for this isolate
56 // and check if a safepoint is already in progress. This 58 // and check if a safepoint is already in progress. This
57 // ensures that two threads do not start a safepoint operation 59 // ensures that two threads do not start a safepoint operation
58 // at the same time. 60 // at the same time.
59 MonitorLocker sl(threads_lock()); 61 MonitorLocker sl(threads_lock());
60 62
61 // Now check to see if a safepoint operation is already in progress 63 // Now check to see if a safepoint operation is already in progress
62 // for this isolate, block if an operation is in progress. 64 // for this isolate, block if an operation is in progress.
63 while (SafepointInProgress()) { 65 while (SafepointInProgress()) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 while (T->IsSafepointRequested()) { 185 while (T->IsSafepointRequested()) {
184 T->SetBlockedForSafepoint(true); 186 T->SetBlockedForSafepoint(true);
185 tl.Wait(); 187 tl.Wait();
186 T->SetBlockedForSafepoint(false); 188 T->SetBlockedForSafepoint(false);
187 } 189 }
188 T->SetAtSafepoint(false); 190 T->SetAtSafepoint(false);
189 } 191 }
190 } 192 }
191 193
192 } // namespace dart 194 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/safepoint.h ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698