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

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

Issue 1541073002: Implement safepointing of threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix-typo Created 4 years, 10 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/lockers.h ('k') | runtime/vm/native_api_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 #include "platform/assert.h"
6 #include "vm/lockers.h"
7 #include "vm/safepoint.h"
8
9 namespace dart {
10
11
12 Monitor::WaitResult MonitorLocker::WaitWithSafepointCheck(Thread* thread,
13 int64_t millis) {
14 ASSERT(thread == Thread::Current());
15 thread->set_execution_state(Thread::kThreadInBlockedState);
16 thread->EnterSafepoint();
17 Monitor::WaitResult result = monitor_->Wait(millis);
18 // First try a fast update of the thread state to indicate it is not at a
19 // safepoint anymore.
20 uword old_state = Thread::SetAtSafepoint(true, 0);
21 uword addr =
22 reinterpret_cast<uword>(thread) + Thread::safepoint_state_offset();
23 if (AtomicOperations::CompareAndSwapWord(
24 reinterpret_cast<uword*>(addr), old_state, 0) != old_state) {
25 // Fast update failed which means we could potentially be in the middle
26 // of a safepoint operation and need to block for it.
27 monitor_->Exit();
28 SafepointHandler* handler = thread->isolate()->safepoint_handler();
29 handler->ExitSafepointUsingLock(thread);
30 monitor_->Enter();
31 }
32 thread->set_execution_state(Thread::kThreadInVM);
33 return result;
34 }
35
36
37 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/lockers.h ('k') | runtime/vm/native_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698