41f0c0bac8
This unifies and simplifies the way we instrument async functions for the purpose of async stack traces and async stepping. It does so while retaining the observable behavior on the inspector level (for now). Previously we'd mark the implicit promise of the async function object with the async task ID, and whenever we awaited, we'd copy the async task ID to the throwaway promise that is created by the `await`. This however made things unnecessarily interesting in the following regards: 1. We'd see `DebugDidHandle` and `DebugWillHandle` events after the `AsyncFunctionFinished` events, coming from the throwaway promises, while the implicit promise is "done". This is especially confusing with rejection propagation and requires very complex stepping logic for async functions (after this CL it'll be possible to unify and simplify the stepping logic). 2. We have to thread through the "can suspend" information from the Parser all the way through AsyncFunctionReject/AsyncFunctionResolve to the async function instrumentation to decide whether to cancel the pending task when the async function finishes. This CL changes the instrumentation to only happen (non recurringly) for the throwaway promises allocated upon `await`. This solves both problems mentioned above, and works because upon the first `await` the stack captured for the throwaway promise will include the synchronous part as expected, while upon later `await`s the synchronous part will be empty and the asynchronous part will be the stack captured for the previous throwaway promise (and the V8Debugger automatically short circuits stacks with empty synchronous part). Bug: chromium:1280519, chromium:1277451, chromium:1246867 Change-Id: Id604dabc19ea133ea2e9dd63181b1fc33ccb5eda Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3383775 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Maya Lekova <mslekova@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/main@{#78599}
305 lines
9.9 KiB
Plaintext
305 lines
9.9 KiB
Plaintext
#
|
|
# Autogenerated by generate-bytecode-expectations.
|
|
#
|
|
|
|
---
|
|
wrap: no
|
|
module: yes
|
|
top level: yes
|
|
|
|
---
|
|
snippet: "
|
|
await 42;
|
|
"
|
|
frame size: 6
|
|
parameter count: 1
|
|
bytecode array length: 112
|
|
bytecodes: [
|
|
B(SwitchOnGeneratorState), R(0), U8(0), U8(2),
|
|
B(Mov), R(closure), R(2),
|
|
B(Mov), R(this), R(3),
|
|
/* 0 E> */ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionEnter), R(2), U8(2),
|
|
B(Star0),
|
|
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(2), U8(0),
|
|
B(ResumeGenerator), R(0), R(0), U8(2),
|
|
B(Star2),
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
|
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
|
|
B(Ldar), R(2),
|
|
/* 0 E> */ B(Throw),
|
|
B(Ldar), R(2),
|
|
B(Return),
|
|
B(Mov), R(2), R(1),
|
|
B(Ldar), R(1),
|
|
B(Mov), R(context), R(2),
|
|
/* 0 S> */ B(LdaSmi), I8(42),
|
|
B(Star4),
|
|
B(Mov), R(0), R(3),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(3), U8(2),
|
|
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(3), U8(1),
|
|
B(ResumeGenerator), R(0), R(0), U8(3),
|
|
B(Star3),
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
|
B(Star4),
|
|
B(LdaZero),
|
|
B(TestReferenceEqual), R(4),
|
|
B(JumpIfTrue), U8(5),
|
|
B(Ldar), R(3),
|
|
B(ReThrow),
|
|
B(LdaUndefined),
|
|
B(Star4),
|
|
B(Mov), R(0), R(3),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(3), U8(2),
|
|
/* 10 S> */ B(Return),
|
|
B(Star3),
|
|
B(CreateCatchContext), R(3), U8(4),
|
|
B(Star2),
|
|
B(LdaTheHole),
|
|
B(SetPendingMessage),
|
|
B(Ldar), R(2),
|
|
B(PushContext), R(3),
|
|
B(LdaImmutableCurrentContextSlot), U8(2),
|
|
B(Star5),
|
|
B(Mov), R(0), R(4),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionReject), R(4), U8(2),
|
|
B(Return),
|
|
]
|
|
constant pool: [
|
|
Smi [20],
|
|
Smi [62],
|
|
Smi [10],
|
|
Smi [7],
|
|
SCOPE_INFO_TYPE,
|
|
]
|
|
handlers: [
|
|
[47, 90, 90],
|
|
]
|
|
|
|
---
|
|
snippet: "
|
|
await import(\"foo\");
|
|
"
|
|
frame size: 6
|
|
parameter count: 1
|
|
bytecode array length: 121
|
|
bytecodes: [
|
|
B(SwitchOnGeneratorState), R(0), U8(0), U8(2),
|
|
B(Mov), R(closure), R(2),
|
|
B(Mov), R(this), R(3),
|
|
/* 0 E> */ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionEnter), R(2), U8(2),
|
|
B(Star0),
|
|
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(2), U8(0),
|
|
B(ResumeGenerator), R(0), R(0), U8(2),
|
|
B(Star2),
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
|
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
|
|
B(Ldar), R(2),
|
|
/* 0 E> */ B(Throw),
|
|
B(Ldar), R(2),
|
|
B(Return),
|
|
B(Mov), R(2), R(1),
|
|
B(Ldar), R(1),
|
|
B(Mov), R(context), R(2),
|
|
/* 0 S> */ B(LdaConstant), U8(4),
|
|
B(Star4),
|
|
B(Mov), R(closure), R(3),
|
|
B(CallRuntime), U16(Runtime::kDynamicImportCall), R(3), U8(2),
|
|
B(Star4),
|
|
B(Mov), R(0), R(3),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(3), U8(2),
|
|
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(3), U8(1),
|
|
B(ResumeGenerator), R(0), R(0), U8(3),
|
|
B(Star3),
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
|
B(Star4),
|
|
B(LdaZero),
|
|
B(TestReferenceEqual), R(4),
|
|
B(JumpIfTrue), U8(5),
|
|
B(Ldar), R(3),
|
|
B(ReThrow),
|
|
B(LdaUndefined),
|
|
B(Star4),
|
|
B(Mov), R(0), R(3),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(3), U8(2),
|
|
/* 21 S> */ B(Return),
|
|
B(Star3),
|
|
B(CreateCatchContext), R(3), U8(5),
|
|
B(Star2),
|
|
B(LdaTheHole),
|
|
B(SetPendingMessage),
|
|
B(Ldar), R(2),
|
|
B(PushContext), R(3),
|
|
B(LdaImmutableCurrentContextSlot), U8(2),
|
|
B(Star5),
|
|
B(Mov), R(0), R(4),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionReject), R(4), U8(2),
|
|
B(Return),
|
|
]
|
|
constant pool: [
|
|
Smi [20],
|
|
Smi [71],
|
|
Smi [10],
|
|
Smi [7],
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["foo"],
|
|
SCOPE_INFO_TYPE,
|
|
]
|
|
handlers: [
|
|
[47, 99, 99],
|
|
]
|
|
|
|
---
|
|
snippet: "
|
|
await 42;
|
|
async function foo() {
|
|
await 42;
|
|
}
|
|
foo();
|
|
"
|
|
frame size: 7
|
|
parameter count: 1
|
|
bytecode array length: 122
|
|
bytecodes: [
|
|
B(SwitchOnGeneratorState), R(0), U8(0), U8(2),
|
|
B(Mov), R(closure), R(3),
|
|
B(Mov), R(this), R(4),
|
|
/* 0 E> */ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionEnter), R(3), U8(2),
|
|
B(Star0),
|
|
B(CreateClosure), U8(2), U8(0), U8(0),
|
|
B(Star1),
|
|
B(Ldar), R(0),
|
|
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(3), U8(0),
|
|
B(ResumeGenerator), R(0), R(0), U8(3),
|
|
B(Star3),
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
|
B(SwitchOnSmiNoFeedback), U8(3), U8(2), I8(0),
|
|
B(Ldar), R(3),
|
|
/* 0 E> */ B(Throw),
|
|
B(Ldar), R(3),
|
|
B(Return),
|
|
B(Mov), R(3), R(2),
|
|
B(Ldar), R(2),
|
|
B(Mov), R(context), R(3),
|
|
/* 0 S> */ B(LdaSmi), I8(42),
|
|
B(Star5),
|
|
B(Mov), R(0), R(4),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(4), U8(2),
|
|
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(4), U8(1),
|
|
B(ResumeGenerator), R(0), R(0), U8(4),
|
|
B(Star4),
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
|
B(Star5),
|
|
B(LdaZero),
|
|
B(TestReferenceEqual), R(5),
|
|
B(JumpIfTrue), U8(5),
|
|
B(Ldar), R(4),
|
|
B(ReThrow),
|
|
/* 47 S> */ B(CallUndefinedReceiver0), R(1), U8(0),
|
|
B(LdaUndefined),
|
|
B(Star5),
|
|
B(Mov), R(0), R(4),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(4), U8(2),
|
|
/* 54 S> */ B(Return),
|
|
B(Star4),
|
|
B(CreateCatchContext), R(4), U8(5),
|
|
B(Star3),
|
|
B(LdaTheHole),
|
|
B(SetPendingMessage),
|
|
B(Ldar), R(3),
|
|
B(PushContext), R(4),
|
|
B(LdaImmutableCurrentContextSlot), U8(2),
|
|
B(Star6),
|
|
B(Mov), R(0), R(5),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionReject), R(5), U8(2),
|
|
B(Return),
|
|
]
|
|
constant pool: [
|
|
Smi [27],
|
|
Smi [69],
|
|
SHARED_FUNCTION_INFO_TYPE,
|
|
Smi [10],
|
|
Smi [7],
|
|
SCOPE_INFO_TYPE,
|
|
]
|
|
handlers: [
|
|
[54, 100, 100],
|
|
]
|
|
|
|
---
|
|
snippet: "
|
|
import * as foo from \"bar\";
|
|
await import(\"goo\");
|
|
"
|
|
frame size: 7
|
|
parameter count: 1
|
|
bytecode array length: 131
|
|
bytecodes: [
|
|
B(SwitchOnGeneratorState), R(0), U8(0), U8(2),
|
|
B(Mov), R(closure), R(3),
|
|
B(Mov), R(this), R(4),
|
|
/* 0 E> */ B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionEnter), R(3), U8(2),
|
|
B(Star0),
|
|
B(LdaZero),
|
|
B(Star3),
|
|
B(CallRuntime), U16(Runtime::kGetModuleNamespace), R(3), U8(1),
|
|
B(Star1),
|
|
B(Ldar), R(0),
|
|
/* 0 E> */ B(SuspendGenerator), R(0), R(0), U8(3), U8(0),
|
|
B(ResumeGenerator), R(0), R(0), U8(3),
|
|
B(Star3),
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
|
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
|
|
B(Ldar), R(3),
|
|
/* 0 E> */ B(Throw),
|
|
B(Ldar), R(3),
|
|
B(Return),
|
|
B(Mov), R(3), R(2),
|
|
B(Ldar), R(2),
|
|
B(Mov), R(context), R(3),
|
|
/* 28 S> */ B(LdaConstant), U8(4),
|
|
B(Star5),
|
|
B(Mov), R(closure), R(4),
|
|
B(CallRuntime), U16(Runtime::kDynamicImportCall), R(4), U8(2),
|
|
B(Star5),
|
|
B(Mov), R(0), R(4),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionAwaitUncaught), R(4), U8(2),
|
|
/* 28 E> */ B(SuspendGenerator), R(0), R(0), U8(4), U8(1),
|
|
B(ResumeGenerator), R(0), R(0), U8(4),
|
|
B(Star4),
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
|
B(Star5),
|
|
B(LdaZero),
|
|
B(TestReferenceEqual), R(5),
|
|
B(JumpIfTrue), U8(5),
|
|
B(Ldar), R(4),
|
|
B(ReThrow),
|
|
B(LdaUndefined),
|
|
B(Star5),
|
|
B(Mov), R(0), R(4),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionResolve), R(4), U8(2),
|
|
/* 49 S> */ B(Return),
|
|
B(Star4),
|
|
B(CreateCatchContext), R(4), U8(5),
|
|
B(Star3),
|
|
B(LdaTheHole),
|
|
B(SetPendingMessage),
|
|
B(Ldar), R(3),
|
|
B(PushContext), R(4),
|
|
B(LdaImmutableCurrentContextSlot), U8(2),
|
|
B(Star6),
|
|
B(Mov), R(0), R(5),
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncFunctionReject), R(5), U8(2),
|
|
B(Return),
|
|
]
|
|
constant pool: [
|
|
Smi [30],
|
|
Smi [81],
|
|
Smi [10],
|
|
Smi [7],
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["goo"],
|
|
SCOPE_INFO_TYPE,
|
|
]
|
|
handlers: [
|
|
[57, 109, 109],
|
|
]
|
|
|