Skip to content

Commit 4c057ae

Browse files
committed
fibers
1 parent 1de937d commit 4c057ae

File tree

7 files changed

+42
-16
lines changed

7 files changed

+42
-16
lines changed

runtime/vm/flag_list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ constexpr bool FLAG_support_il_printer = false;
200200
D(trace_optimization, bool, false, "Print optimization details.") \
201201
R(trace_profiler, false, bool, false, "Profiler trace") \
202202
D(trace_profiler_verbose, bool, false, "Verbose profiler trace") \
203-
D(trace_runtime_calls, bool, false, "Trace runtime calls.") \
203+
D(trace_runtime_calls, bool, true, "Trace runtime calls.") \
204204
R(trace_ssa_allocator, false, bool, false, \
205205
"Trace register allocation over SSA.") \
206206
P(trace_strong_mode_types, bool, false, \

runtime/vm/heap/marker.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@ void GCMarker::ResetSlices() {
747747
}
748748

749749
void GCMarker::IterateRoots(ObjectPointerVisitor* visitor) {
750+
OS::Print("IterateRoots start\n");
750751
for (;;) {
751752
intptr_t slice = root_slices_started_.fetch_add(1);
752753
if (slice >= root_slices_count_) {
@@ -775,6 +776,7 @@ void GCMarker::IterateRoots(ObjectPointerVisitor* visitor) {
775776
ml.Notify();
776777
}
777778
}
779+
OS::Print("IterateRoots end\n");
778780
}
779781

780782
enum WeakSlices {

runtime/vm/heap/pages.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,9 @@ void PageSpace::CollectGarbageHelper(Thread* thread,
10671067
// Abandon the remainder of the bump allocation block.
10681068
ReleaseBumpAllocation();
10691069

1070+
OS::Print("MarkObjects start\n");
10701071
marker_->MarkObjects(this);
1072+
OS::Print("MarkObjects end\n");
10711073
usage_.used_in_words = marker_->marked_words() + allocated_black_in_words_;
10721074
allocated_black_in_words_ = 0;
10731075
mark_words_per_micro_ = marker_->MarkedWordsPerMicro();

runtime/vm/stack_frame.cc

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void StackFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) {
212212
// helper functions to the raw object interface.
213213
NoSafepointScope no_safepoint;
214214
Code code;
215-
215+
OS::Print(" pc 0x%" Pp " fp 0x%" Pp " sp 0x%" Pp "\n", pc_, fp_, sp_);
216216
CompressedStackMaps::RawPayloadHandle maps;
217217
CompressedStackMaps::RawPayloadHandle global_table;
218218

@@ -303,7 +303,6 @@ void StackFrame::VisitObjectPointers(ObjectPointerVisitor* visitor) {
303303
// to an osr function. In each of these cases, all stack slots contain
304304
// tagged pointers, so fall through.
305305
#if defined(DEBUG)
306-
OS::Print(" pc 0x%" Pp " fp 0x%" Pp " sp 0x%" Pp "\n", pc_, fp_, sp_);
307306
if (FLAG_precompiled_mode) {
308307
ASSERT(IsStubFrame());
309308
} else {
@@ -626,22 +625,26 @@ void StackFrameIterator::FrameSetIterator::Unpoison() {
626625
StackFrame* StackFrameIterator::FrameSetIterator::NextFrame(bool validate) {
627626
StackFrame* frame;
628627
ASSERT(HasNext());
628+
if (StubCode::InCoroutineStub(stack_frame_.pc_)) {
629+
frame = &stack_frame_;
630+
frame->sp_ = sp_;
631+
frame->fp_ = fp_;
632+
frame->pc_ = pc_;
633+
OS::Print("Coroutine stub frame\n");
634+
OS::Print(" pc 0x%" Pp " fp 0x%" Pp " sp 0x%" Pp "\n", pc_, fp_, sp_);
635+
sp_ = frame->GetCallerSp();
636+
fp_ = frame->GetCallerFp();
637+
pc_ = frame->GetCallerPc();
638+
Unpoison();
639+
return NextFrame(validate);
640+
}
629641
frame = &stack_frame_;
630642
frame->sp_ = sp_;
631643
frame->fp_ = fp_;
632644
frame->pc_ = pc_;
633645
sp_ = frame->GetCallerSp();
634646
fp_ = frame->GetCallerFp();
635647
pc_ = frame->GetCallerPc();
636-
OS::Print(" pc 0x%" Pp " fp 0x%" Pp " sp 0x%" Pp "\n", pc_, fp_, sp_);
637-
StackFrame nframe{frame->thread()};
638-
nframe.fp_ = fp_;
639-
nframe.pc_ = pc_;
640-
nframe.sp_ = sp_;
641-
uword nsp_ = nframe.GetCallerSp();
642-
uword nfp_ = nframe.GetCallerFp();
643-
uword npc_ = nframe.GetCallerPc();
644-
OS::Print(" pc 0x%" Pp " fp 0x%" Pp " sp 0x%" Pp "\n", npc_, nfp_, nsp_);
645648
Unpoison();
646649
ASSERT(!validate || frame->IsValid());
647650
return frame;

runtime/vm/stub_code.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,9 @@ void StubCode::Init() {
9191
#undef STUB_CODE_GENERATE
9292
#undef STUB_CODE_SET_OBJECT_POOL
9393

94-
CodePtr StubCode::Generate(
95-
const char* name,
96-
compiler::ObjectPoolBuilder* object_pool_builder,
97-
void (compiler::StubCodeCompiler::* GenerateStub)()) {
94+
CodePtr StubCode::Generate(const char* name,
95+
compiler::ObjectPoolBuilder* object_pool_builder,
96+
void (compiler::StubCodeCompiler::*GenerateStub)()) {
9897
auto thread = Thread::Current();
9998
SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
10099

@@ -144,6 +143,16 @@ bool StubCode::InJumpToFrameStub(uword pc) {
144143
return (pc >= entry) && (pc < (entry + size));
145144
}
146145

146+
bool StubCode::InCoroutineStub(uword pc) {
147+
ASSERT(HasBeenInitialized());
148+
uword entry = StubCode::CoroutineInitialize().EntryPoint();
149+
uword size = StubCode::CoroutineInitializeSize();
150+
if ((pc >= entry) && (pc < (entry + size))) return true;
151+
entry = StubCode::CoroutineFork().EntryPoint();
152+
size = StubCode::CoroutineForkSize();
153+
return ((pc >= entry) && (pc < (entry + size)));
154+
}
155+
147156
#if !defined(DART_PRECOMPILED_RUNTIME)
148157
ArrayPtr compiler::StubCodeCompiler::BuildStaticCallsTable(
149158
Zone* zone,

runtime/vm/stub_code.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class StubCode : public AllStatic {
5151

5252
// Check if the specified pc is in the jump to frame stub.
5353
static bool InJumpToFrameStub(uword pc);
54+
55+
static bool InCoroutineStub(uword pc);
5456

5557
// Returns nullptr if no stub found.
5658
static const char* NameOfStub(uword entry_point);

runtime/vm/thread.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,13 +841,17 @@ ErrorPtr Thread::HandleInterrupts() {
841841
// occur that does promote them.
842842
heap()->CollectGarbage(this, GCType::kEvacuate, GCReason::kStoreBuffer);
843843
}
844+
OS::Print("After CollectGarbage\n");
844845
heap()->CheckFinalizeMarking(this);
846+
OS::Print("After CheckFinalizeMarking\n");
845847

846848
#if !defined(PRODUCT)
847849
if (isolate()->TakeHasCompletedBlocks()) {
848850
Profiler::ProcessCompletedBlocks(isolate());
849851
}
850852
#endif // !defined(PRODUCT)
853+
854+
OS::Print("After ProcessCompletedBlocks");
851855

852856
#if !defined(PRODUCT) || defined(FORCE_INCLUDE_SAMPLING_HEAP_PROFILER)
853857
HeapProfileSampler& sampler = heap_sampler();
@@ -1100,6 +1104,8 @@ void Thread::VisitObjectPointers(ObjectPointerVisitor* visitor,
11001104
const StackFrameIterator::CrossThreadPolicy cross_thread_policy =
11011105
StackFrameIterator::kAllowCrossThreadIteration;
11021106

1107+
OS::Print("Thread::VisitObjectPointers\n");
1108+
11031109
// Iterate over all the stack frames and visit objects on the stack.
11041110
StackFrameIterator frames_iterator(top_exit_frame_info(), validation_policy,
11051111
this, cross_thread_policy);
@@ -1114,6 +1120,8 @@ void Thread::VisitObjectPointers(ObjectPointerVisitor* visitor,
11141120
// We are not on the mutator thread.
11151121
RELEASE_ASSERT(top_exit_frame_info() == 0);
11161122
}
1123+
1124+
OS::Print("Thread::VisitObjectPointers end\n");
11171125
}
11181126

11191127
class RestoreWriteBarrierInvariantVisitor : public ObjectPointerVisitor {

0 commit comments

Comments
 (0)