Commit 2d0d7cb6 authored by Lewis Baker's avatar Lewis Baker Committed by Facebook GitHub Bot

Simplify logic for popping the current AsyncStackFrame

Summary:
Rather than conditionally calling either popAsyncStackFrameCallee()
or deactivateAsyncStackFrame() depending on whether there is a
parent frame, we now extend popAsyncStackFrameCallee() to handle
the null parent case.

Reviewed By: andriigrynenko

Differential Revision: D24554471

fbshipit-source-id: 7f7ce64da63db1fa726d9fb23669fe49d03c2d6c
parent 11de2a3f
...@@ -56,11 +56,12 @@ inline void pushAsyncStackFrameCallerCallee( ...@@ -56,11 +56,12 @@ inline void pushAsyncStackFrameCallerCallee(
inline void popAsyncStackFrameCallee( inline void popAsyncStackFrameCallee(
folly::AsyncStackFrame& calleeFrame) noexcept { folly::AsyncStackFrame& calleeFrame) noexcept {
checkAsyncStackFrameIsActive(calleeFrame); checkAsyncStackFrameIsActive(calleeFrame);
assert(calleeFrame.parentFrame != nullptr); auto* callerFrame = calleeFrame.parentFrame;
auto& callerFrame = *calleeFrame.parentFrame; auto* stackRoot = calleeFrame.stackRoot;
auto& stackRoot = *calleeFrame.stackRoot; if (callerFrame != nullptr) {
callerFrame.stackRoot = &stackRoot; callerFrame->stackRoot = stackRoot;
stackRoot.topFrame.store(&callerFrame, std::memory_order_release); }
stackRoot->topFrame.store(callerFrame, std::memory_order_release);
// Clearing out non-top-frame's stackRoot is not strictly necessary // Clearing out non-top-frame's stackRoot is not strictly necessary
// but it may help with debugging. // but it may help with debugging.
......
...@@ -241,8 +241,9 @@ void pushAsyncStackFrameCallerCallee( ...@@ -241,8 +241,9 @@ void pushAsyncStackFrameCallerCallee(
// you are about to call/resume the caller. e.g. performing a symmetric // you are about to call/resume the caller. e.g. performing a symmetric
// transfer to the calling coroutine in final_suspend(). // transfer to the calling coroutine in final_suspend().
// //
// Assumes that there is actually a parent frame. If there is no parent // If calleeFrame.getParentFrame() is null then this method is equivalent
// frame then use deactivateAsyncStackFrame() instead. // to deactivateAsyncStackFrame(), leaving no active AsyncStackFrame on
// the current AsyncStackRoot.
void popAsyncStackFrameCallee(folly::AsyncStackFrame& calleeFrame) noexcept; void popAsyncStackFrameCallee(folly::AsyncStackFrame& calleeFrame) noexcept;
// Get a pointer to a special frame that can be used as the root-frame // Get a pointer to a special frame that can be used as the root-frame
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment