Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
dart::SafepointTestTask Class Reference
Inheritance diagram for dart::SafepointTestTask:
dart::ThreadPool::Task dart::IntrusiveDListEntry< Task >

Public Member Functions

 SafepointTestTask (Isolate *isolate, Monitor *monitor, intptr_t *expected_count, intptr_t *total_done, intptr_t *exited)
 
virtual void Run ()
 
- Public Member Functions inherited from dart::ThreadPool::Task
virtual ~Task ()
 
- Public Member Functions inherited from dart::IntrusiveDListEntry< Task >
 IntrusiveDListEntry ()
 
 ~IntrusiveDListEntry ()
 

Static Public Attributes

static constexpr intptr_t kTaskCount = 5
 

Additional Inherited Members

- Protected Member Functions inherited from dart::ThreadPool::Task
 Task ()
 

Detailed Description

Definition at line 523 of file thread_test.cc.

Constructor & Destructor Documentation

◆ SafepointTestTask()

dart::SafepointTestTask::SafepointTestTask ( Isolate isolate,
Monitor monitor,
intptr_t *  expected_count,
intptr_t *  total_done,
intptr_t *  exited 
)
inline

Definition at line 527 of file thread_test.cc.

532 : isolate_(isolate),
533 monitor_(monitor),
534 expected_count_(expected_count),
535 total_done_(total_done),
536 exited_(exited),
537 local_done_(false) {}

Member Function Documentation

◆ Run()

virtual void dart::SafepointTestTask::Run ( )
inlinevirtual

Implements dart::ThreadPool::Task.

Definition at line 539 of file thread_test.cc.

539 {
540 const bool kBypassSafepoint = false;
542 kBypassSafepoint);
543 {
544 MonitorLocker ml(monitor_);
545 ++*expected_count_;
546 }
547 Thread* thread = Thread::Current();
548 for (int i = reinterpret_cast<intptr_t>(thread);; ++i) {
549 StackZone stack_zone(thread);
550 Zone* zone = thread->zone();
551 const intptr_t kUniqueSmi = 928327281;
552 Smi& smi = Smi::Handle(zone, Smi::New(kUniqueSmi));
553 if ((i % 100) != 0) {
554 // Usually, we just cooperate.
555 TransitionVMToBlocked transition(thread);
556 } else {
557 // But occasionally, organize a rendezvous.
558 HeapIterationScope iteration(thread); // Establishes a safepoint.
559 ASSERT(thread->OwnsSafepoint());
560 ObjectCounter counter(isolate_->group(), &smi);
561 iteration.IterateStackPointers(&counter,
563 {
564 MonitorLocker ml(monitor_);
565 EXPECT_EQ(*expected_count_, counter.count());
566 }
567 UserTag& tag = UserTag::Handle(zone, isolate_->current_tag());
568 if (tag.ptr() != isolate_->default_tag()) {
569 String& label = String::Handle(zone, tag.label());
570 EXPECT(label.Equals("foo"));
571 MonitorLocker ml(monitor_);
572 if (*expected_count_ == kTaskCount && !local_done_) {
573 // Success for the first time! Remember that we are done, and
574 // update the total count.
575 local_done_ = true;
576 ++*total_done_;
577 }
578 }
579 }
580 // Check whether everyone is done.
581 {
582 MonitorLocker ml(monitor_);
583 if (*total_done_ == kTaskCount) {
584 // Another task might be at SafepointThreads when resuming. Ensure its
585 // expectation reflects reality, since we pop our handles here.
586 --*expected_count_;
587 break;
588 }
589 }
590 }
591 Thread::ExitIsolateGroupAsHelper(kBypassSafepoint);
592 {
593 MonitorLocker ml(monitor_);
594 ++*exited_;
595 ml.Notify();
596 }
597 }
#define EXPECT(type, expectedAlignment, expectedSize)
UserTagPtr current_tag() const
Definition isolate.h:1301
UserTagPtr default_tag() const
Definition isolate.h:1304
IsolateGroup * group() const
Definition isolate.h:990
static Object & Handle()
Definition object.h:407
static constexpr intptr_t kTaskCount
static SmiPtr New(intptr_t value)
Definition object.h:9985
static Thread * Current()
Definition thread.h:361
static void ExitIsolateGroupAsHelper(bool bypass_safepoint)
Definition thread.cc:494
static bool EnterIsolateGroupAsHelper(IsolateGroup *isolate_group, TaskKind kind, bool bypass_safepoint)
Definition thread.cc:476
#define ASSERT(E)

Member Data Documentation

◆ kTaskCount

constexpr intptr_t dart::SafepointTestTask::kTaskCount = 5
staticconstexpr

Definition at line 525 of file thread_test.cc.


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