Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::TaskWithZoneAllocation Class Reference
Inheritance diagram for dart::TaskWithZoneAllocation:
dart::ThreadPool::Task dart::IntrusiveDListEntry< Task >

Public Member Functions

 TaskWithZoneAllocation (IsolateGroup *isolate_group, Monitor *monitor, bool *done, intptr_t id)
 
virtual void Run ()
 
- Public Member Functions inherited from dart::ThreadPool::Task
virtual ~Task ()
 
virtual void Run ()=0
 
- Public Member Functions inherited from dart::IntrusiveDListEntry< Task >
 IntrusiveDListEntry ()
 
 ~IntrusiveDListEntry ()
 

Additional Inherited Members

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

Detailed Description

Definition at line 115 of file thread_test.cc.

Constructor & Destructor Documentation

◆ TaskWithZoneAllocation()

dart::TaskWithZoneAllocation::TaskWithZoneAllocation ( IsolateGroup isolate_group,
Monitor monitor,
bool *  done,
intptr_t  id 
)
inline

Definition at line 117 of file thread_test.cc.

121 : isolate_group_(isolate_group),
122 monitor_(monitor),
123 done_(done),
124 id_(id) {}
static void done(const char *config, const char *src, const char *srcOptions, const char *name)
Definition: DM.cpp:263

Member Function Documentation

◆ Run()

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

Implements dart::ThreadPool::Task.

Definition at line 125 of file thread_test.cc.

125 {
126 const bool kBypassSafepoint = false;
128 kBypassSafepoint);
129 {
130 Thread* thread = Thread::Current();
131 // Create a zone (which is also a stack resource) and exercise it a bit.
132 StackZone stack_zone(thread);
133 Zone* zone = thread->zone();
134 EXPECT_EQ(zone, stack_zone.GetZone());
135 ZoneGrowableArray<bool>* a0 = new (zone) ZoneGrowableArray<bool>(zone, 1);
136 GrowableArray<bool> a1(zone, 1);
137 for (intptr_t i = 0; i < 100000; ++i) {
138 a0->Add(true);
139 a1.Add(true);
140 }
141 // Check that we can create handles and allocate in old space.
142 String& str = String::Handle(zone, String::New("old", Heap::kOld));
143 EXPECT(str.Equals("old"));
144
145 const intptr_t unique_smi = id_ + 928327281;
146 Smi& smi = Smi::Handle(zone, Smi::New(unique_smi));
147 EXPECT(smi.Value() == unique_smi);
148 {
149 HeapIterationScope iteration(thread);
150 ObjectCounter counter(isolate_group_, &smi);
151 // Ensure that our particular zone is visited.
152 iteration.IterateStackPointers(&counter,
154 EXPECT_EQ(1, counter.count());
155 }
156 char* unique_chars = zone->PrintToString("unique_str_%" Pd, id_);
157 String& unique_str = String::Handle(zone);
158 {
159 // String::New may create additional handles in the topmost scope that
160 // we don't want to count, so wrap this in its own scope.
161 HANDLESCOPE(thread);
162 unique_str = String::New(unique_chars, Heap::kOld);
163 }
164 EXPECT(unique_str.Equals(unique_chars));
165 {
166 HeapIterationScope iteration(thread);
167 ObjectCounter str_counter(isolate_group_, &unique_str);
168 // Ensure that our particular zone is visited.
169 iteration.IterateStackPointers(&str_counter,
171 // We should visit the string object exactly once.
172 EXPECT_EQ(1, str_counter.count());
173 }
174 }
175 Thread::ExitIsolateGroupAsHelper(kBypassSafepoint);
176 {
177 MonitorLocker ml(monitor_);
178 *done_ = true;
179 ml.Notify();
180 }
181 }
#define EXPECT(type, expectedAlignment, expectedSize)
@ kOld
Definition: heap.h:39
static Object & Handle()
Definition: object.h:407
static SmiPtr New(intptr_t value)
Definition: object.h:10006
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
Definition: object.cc:23698
@ kUnknownTask
Definition: thread.h:346
static Thread * Current()
Definition: thread.h:362
static void ExitIsolateGroupAsHelper(bool bypass_safepoint)
Definition: thread.cc:499
static bool EnterIsolateGroupAsHelper(IsolateGroup *isolate_group, TaskKind kind, bool bypass_safepoint)
Definition: thread.cc:481
#define HANDLESCOPE(thread)
Definition: handles.h:321
#define Pd
Definition: globals.h:408

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