Skip to content

Commit c9e567b

Browse files
committed
[Async CC] Save parent context into child context.
When an async function is called from an async function, it stores its own context pointer into the callee's callerContext.
1 parent 904876e commit c9e567b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2196,9 +2196,16 @@ class AsyncCallEmission final : public CallEmission {
21962196
super::setArgs(asyncExplosion, false, witnessMetadata);
21972197
SILFunctionConventions fnConv(getCallee().getSubstFunctionType(),
21982198
IGF.getSILModule());
2199+
auto layout = getAsyncContextLayout();
21992200

2201+
// Set caller info into the context.
2202+
{ // caller context
2203+
Explosion explosion;
2204+
explosion.add(IGF.getAsyncContext());
2205+
auto fieldLayout = layout.getParentLayout();
2206+
saveValue(fieldLayout, explosion, isOutlined);
2207+
}
22002208
// Move all the arguments into the context.
2201-
auto layout = getAsyncContextLayout();
22022209
for (unsigned index = 0, count = layout.getIndirectReturnCount();
22032210
index < count; ++index) {
22042211
auto fieldLayout = layout.getIndirectReturnLayout(index);

0 commit comments

Comments
 (0)