Add ScopedThreadSuspension
Fixes the TransitionFromRunnableToSuspended and
TransitionFromSuspendedToRunnable pattern that was prone to errors.
Change-Id: Ie6ae9c0357c83b4fc4899d05dfa0975553170267
diff --git a/runtime/arch/arch_test.cc b/runtime/arch/arch_test.cc
index 40e2cd3..4a45f49 100644
--- a/runtime/arch/arch_test.cc
+++ b/runtime/arch/arch_test.cc
@@ -32,20 +32,17 @@
static void CheckFrameSize(InstructionSet isa, Runtime::CalleeSaveType type, uint32_t save_size)
NO_THREAD_SAFETY_ANALYSIS {
- Runtime* r = Runtime::Current();
+ Runtime* const runtime = Runtime::Current();
+ Thread* const self = Thread::Current();
+ ScopedObjectAccess soa(self); // So we can create callee-save methods.
- Thread* t = Thread::Current();
- t->TransitionFromSuspendedToRunnable(); // So we can create callee-save methods.
-
- r->SetInstructionSet(isa);
- ArtMethod* save_method = r->CreateCalleeSaveMethod();
- r->SetCalleeSaveMethod(save_method, type);
+ runtime->SetInstructionSet(isa);
+ ArtMethod* save_method = runtime->CreateCalleeSaveMethod();
+ runtime->SetCalleeSaveMethod(save_method, type);
QuickMethodFrameInfo frame_info = save_method->GetQuickFrameInfo();
EXPECT_EQ(frame_info.FrameSizeInBytes(), save_size) << "Expected and real size differs for "
<< type << " core spills=" << std::hex << frame_info.CoreSpillMask() << " fp spills="
<< frame_info.FpSpillMask() << std::dec;
-
- t->TransitionFromRunnableToSuspended(ThreadState::kNative); // So we can shut down.
}
};