Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Friends | List of all members
dart::SafepointHandler Class Reference

#include <safepoint.h>

Public Member Functions

 SafepointHandler (IsolateGroup *I)
 
 ~SafepointHandler ()
 
void EnterSafepointUsingLock (Thread *T)
 
void ExitSafepointUsingLock (Thread *T)
 
void BlockForSafepoint (Thread *T)
 
SafepointLevel InnermostSafepointOperation (const Thread *current_thread) const
 
bool AnySafepointInProgressLocked ()
 

Friends

class Isolate
 
class IsolateGroup
 
class SafepointOperationScope
 
class ForceGrowthSafepointOperationScope
 
class HeapIterationScope
 

Detailed Description

Definition at line 81 of file safepoint.h.

Constructor & Destructor Documentation

◆ SafepointHandler()

dart::SafepointHandler::SafepointHandler ( IsolateGroup I)
explicit

Definition at line 62 of file safepoint.cc.

63 : isolate_group_(isolate_group) {
64 handlers_[SafepointLevel::kGC] =
65 new LevelHandler(isolate_group, SafepointLevel::kGC);
67 new LevelHandler(isolate_group, SafepointLevel::kGCAndDeopt);
69 new LevelHandler(isolate_group, SafepointLevel::kGCAndDeoptAndReload);
70}
@ kGC
Definition thread.h:291
@ kGCAndDeoptAndReload
Definition thread.h:295
@ kGCAndDeopt
Definition thread.h:293

◆ ~SafepointHandler()

dart::SafepointHandler::~SafepointHandler ( )

Definition at line 72 of file safepoint.cc.

72 {
73 for (intptr_t level = 0; level < SafepointLevel::kNumLevels; ++level) {
74 ASSERT(handlers_[level]->owner_ == nullptr);
75 delete handlers_[level];
76 }
77}
#define ASSERT(E)
@ kNumLevels
Definition thread.h:297

Member Function Documentation

◆ AnySafepointInProgressLocked()

bool dart::SafepointHandler::AnySafepointInProgressLocked ( )
inline

Definition at line 108 of file safepoint.h.

108 {
109 for (intptr_t level = 0; level < SafepointLevel::kNumLevels; ++level) {
110 if (handlers_[level]->SafepointInProgress()) {
111 return true;
112 }
113 }
114 return false;
115 }

◆ BlockForSafepoint()

void dart::SafepointHandler::BlockForSafepoint ( Thread T)

Definition at line 324 of file safepoint.cc.

324 {
325 ASSERT(!T->BypassSafepoints());
326 MonitorLocker tl(T->thread_lock());
327 // This takes into account the safepoint level the thread can participate in.
328 const SafepointLevel level = T->current_safepoint_level();
329 if (T->IsSafepointRequestedLocked(level)) {
330 EnterSafepointLocked(T, &tl, level);
331 ExitSafepointLocked(T, &tl, level);
332 ASSERT(!T->IsSafepointRequestedLocked(level));
333 }
334}
SafepointLevel
Definition thread.h:289
#define T

◆ EnterSafepointUsingLock()

void dart::SafepointHandler::EnterSafepointUsingLock ( Thread T)

Definition at line 279 of file safepoint.cc.

279 {
280 MonitorLocker tl(T->thread_lock());
281 EnterSafepointLocked(T, &tl, T->current_safepoint_level());
282}

◆ ExitSafepointUsingLock()

void dart::SafepointHandler::ExitSafepointUsingLock ( Thread T)

Definition at line 284 of file safepoint.cc.

284 {
285 MonitorLocker tl(T->thread_lock());
286 ASSERT(T->IsAtSafepoint());
287 ExitSafepointLocked(T, &tl, T->current_safepoint_level());
288 ASSERT(!T->IsSafepointRequestedLocked(T->current_safepoint_level()));
289}

◆ InnermostSafepointOperation()

SafepointLevel dart::SafepointHandler::InnermostSafepointOperation ( const Thread current_thread) const

Definition at line 291 of file safepoint.cc.

292 {
293 // The [current_thread] may not own the active safepoint.
294 intptr_t last_count = -1;
296
297 // Notice: We access SafepointLevel::{owner_,operation_count_} fields
298 // without lock. This is ok since:
299 //
300 // * If the current thread is the owner, then it will be the one that has
301 // last written `Thread::Current()` to the `owner_` field (as well as
302 // updated the `operation_count_`) - nobody else can update those fields
303 // in the meantime. Once the current thread exits we set it to `nullptr`.
304 //
305 // * If there's no owner or another thread is the owner the value cannot be
306 // `Thread::Current()`: only our thread can write that particular value.
307 //
308 // => Even if there's racy writes by another thread, the logic is still
309 // safe.
310 //
311 for (intptr_t level = 0; level < SafepointLevel::kNumLevels; ++level) {
312 if (handlers_[level]->owner_ == current_thread) {
313 const intptr_t count = handlers_[level]->operation_count_;
314 if (count < last_count) return last_level;
315 last_count = count;
316 last_level = static_cast<SafepointLevel>(level);
317 } else {
318 return last_level;
319 }
320 }
321 return last_level;
322}
int count
@ kNoSafepoint
Definition thread.h:300

Friends And Related Symbol Documentation

◆ ForceGrowthSafepointOperationScope

Definition at line 208 of file safepoint.h.

◆ HeapIterationScope

friend class HeapIterationScope
friend

Definition at line 209 of file safepoint.h.

◆ Isolate

friend class Isolate
friend

Definition at line 205 of file safepoint.h.

◆ IsolateGroup

friend class IsolateGroup
friend

Definition at line 206 of file safepoint.h.

◆ SafepointOperationScope

friend class SafepointOperationScope
friend

Definition at line 207 of file safepoint.h.


The documentation for this class was generated from the following files: