OLD | NEW |
---|---|
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 #ifndef VM_SAFEPOINT_H_ | 5 #ifndef VM_SAFEPOINT_H_ |
6 #define VM_SAFEPOINT_H_ | 6 #define VM_SAFEPOINT_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
10 #include "vm/thread.h" | 10 #include "vm/thread.h" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
306 if (execution_state_ == Thread::kThreadInNative) { | 306 if (execution_state_ == Thread::kThreadInNative) { |
307 thread()->set_execution_state(Thread::kThreadInNative); | 307 thread()->set_execution_state(Thread::kThreadInNative); |
308 thread()->EnterSafepoint(); | 308 thread()->EnterSafepoint(); |
309 } else { | 309 } else { |
310 ASSERT(execution_state_ == Thread::kThreadInVM); | 310 ASSERT(execution_state_ == Thread::kThreadInVM); |
311 thread()->set_execution_state(Thread::kThreadInVM); | 311 thread()->set_execution_state(Thread::kThreadInVM); |
312 } | 312 } |
313 } | 313 } |
314 | 314 |
315 private: | 315 private: |
316 int16_t execution_state_; | 316 int16_t execution_state_; |
rmacnak
2016/05/27 20:08:29
Ditto
siva
2016/05/27 20:53:16
Done.
| |
317 DISALLOW_COPY_AND_ASSIGN(TransitionToGenerated); | 317 DISALLOW_COPY_AND_ASSIGN(TransitionToGenerated); |
318 }; | 318 }; |
319 | 319 |
320 | |
321 // TransitionToVM is used to transition the safepoint state of a | |
322 // thread from "running native code" to "running vm code" | |
323 // and ensures that the state is reverted back to "running native code" | |
324 // when exiting the scope/frame. | |
325 // This transition helper is mainly used in the error path of the | |
326 // Dart API implementations where we sometimes do not have an explicit | |
327 // transition set up. | |
328 class TransitionToVM : public TransitionSafepointState { | |
329 public: | |
330 explicit TransitionToVM(Thread* T) : TransitionSafepointState(T), | |
331 execution_state_(T->execution_state()) { | |
332 ASSERT(T == Thread::Current()); | |
333 ASSERT((execution_state_ == Thread::kThreadInVM) || | |
334 (execution_state_ == Thread::kThreadInNative)); | |
335 if (execution_state_ == Thread::kThreadInNative) { | |
336 T->ExitSafepoint(); | |
337 T->set_execution_state(Thread::kThreadInVM); | |
338 } | |
339 ASSERT(T->execution_state() == Thread::kThreadInVM); | |
340 } | |
341 | |
342 ~TransitionToVM() { | |
343 ASSERT(thread()->execution_state() == Thread::kThreadInVM); | |
344 if (execution_state_ == Thread::kThreadInNative) { | |
345 thread()->set_execution_state(Thread::kThreadInNative); | |
346 thread()->EnterSafepoint(); | |
347 } | |
348 } | |
349 | |
350 private: | |
351 int16_t execution_state_; | |
rmacnak
2016/05/27 20:08:29
In Thread this is uint32_t.
siva
2016/05/27 20:53:16
Done.
| |
352 DISALLOW_COPY_AND_ASSIGN(TransitionToVM); | |
353 }; | |
354 | |
320 } // namespace dart | 355 } // namespace dart |
321 | 356 |
322 #endif // VM_SAFEPOINT_H_ | 357 #endif // VM_SAFEPOINT_H_ |
OLD | NEW |