v8/test/cctest/interpreter/bytecode_expectations
Benedikt Meurer 0038e5f05f [async] Improve async function handling.
This change introduces new intrinsics used to desugar async functions
in the Parser and the BytecodeGenerator, namely we introduce a new
%_AsyncFunctionEnter intrinsic that constructs the generator object
for the async function (and in the future will also create the outer
promise for the async function). This generator object is internal
and never escapes to user code, plus since async functions don't have
a "prototype" property, we can just a single map here instead of tracking
the prototype/initial_map on every async function. This saves one word
per async function plus one initial_map per async function that was
invoked at least once.

We also introduce two new intrinsics %_AsyncFunctionReject, which
rejects the outer promise with the caught exception, and another
%_AsyncFunctionResolve, which resolves the outer promise with the
right hand side of the `return` statement. These functions also perform
the DevTools part of the job (aka popping from the promise stack and
sending the debug event). This allows us to get rid of the implicit
try-finally from async functions completely; because the finally
block only called to the %AsyncFunctionPromiseRelease builtin, which
was used to inform DevTools.

In essence we now turn an async function like

```js
async function f(x) { return await bar(x); }
```

into something like this (in Parser and BytecodeGenerator respectively):

```
function f(x) {
  .generator_object = %_AsyncFunctionEnter(.closure, this);
  .promise = %AsyncFunctionCreatePromise();
  try {
    .tmp = await bar(x);
    return %_AsyncFunctionResolve(.promise, .tmp);
  } catch (e) {
    return %_AsyncFunctionReject(.promise, e);
  }
}
```

Overall the bytecode for async functions gets significantly shorter
already (and will get even shorter once we put the outer promise into
the async function generator object). For example the bytecode for a
simple async function

```js
async function f(x) { return await x; }
```

goes from 175 bytes to 110 bytes (a ~38% reduction in size), which
is in particular due to the simplification around the try-finally
removal.

Overall this seems to improve the doxbee-async-es2017-native test by
around 2-3%. On the test case mentioned in v8:8276 we go from
1124ms to 441ms, which corresponds to a 60% reduction in total
execution time!

Tbr: marja@chromium.org
Bug: v8:7253, v8:7522, v8:8276
Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;luci.chromium.try:linux_chromium_rel_ng;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: Id29dc92de7490b387ff697860c900cee44c9a7a4
Reviewed-on: https://chromium-review.googlesource.com/c/1269041
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56502}
2018-10-10 06:37:53 +00:00
..
ArrayLiterals.golden Reland "[interpreter] Add bytecode for leading array spreads." 2018-09-05 09:29:51 +00:00
AssignmentsInBinaryExpression.golden [parser] Add an n-ary node for large binop chains 2017-10-25 11:28:55 +00:00
AsyncGenerators.golden [async] Initial async generator support for --async-stack-traces. 2018-10-05 13:41:53 +00:00
BasicBlockToBoolean.golden [objects] Make feedback vector a first-class object 2017-07-27 13:31:55 +00:00
BasicLoops.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
BreakableBlocks.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
CallAndSpread.golden Reland "[interpreter] Add bytecode for leading array spreads." 2018-09-05 09:29:51 +00:00
CallGlobal.golden [Cleanup][Interpreter] Move feedback slot allocation to bytecode generator 2017-10-19 16:17:14 +00:00
CallLookupSlot.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
CallNew.golden [Cleanup][Interpreter] Move feedback slot allocation to bytecode generator 2017-10-19 16:17:14 +00:00
CallRuntime.golden [cleanup] Drop spread.js for good. 2018-03-12 09:44:11 +00:00
ClassAndSuperClass.golden [class] Initialize class fields after binding this 2018-04-17 13:40:39 +00:00
ClassDeclarations.golden [class] Make class field initializers breakable in the debugger 2018-09-17 22:25:44 +00:00
CompareNil.golden [Cleanup][Interpreter] Move feedback slot allocation to bytecode generator 2017-10-19 16:17:14 +00:00
CompareTypeOf.golden [inspector] improve return position of explicit return in non-async function 2017-07-14 19:10:13 +00:00
CompoundExpressions.golden [runtime][parser] Use ArrayBoilerplateDescription all the way 2018-07-05 19:31:03 +00:00
Conditional.golden [objects] Make feedback vector a first-class object 2017-07-27 13:31:55 +00:00
ConstVariable.golden [ignition] removed nop bytecode 2017-07-18 16:14:29 +00:00
ConstVariableContextSlot.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
ContextParameters.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
ContextVariables.golden [Interpreter] Share feedback slots for load / store named properties 2018-05-14 10:21:42 +00:00
CountOperators.golden [runtime][parser] Use ArrayBoilerplateDescription all the way 2018-07-05 19:31:03 +00:00
CreateArguments.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
CreateRestParameter.golden [Cleanup][Interpreter] Move feedback slot allocation to bytecode generator 2017-10-19 16:17:14 +00:00
DeadCodeRemoval.golden [inspector] improve return position of explicit return in non-async function 2017-07-14 19:10:13 +00:00
DeclareGlobals.golden Reland "[inspector] fixed location of top level function return" 2018-06-18 21:37:49 +00:00
Delete.golden [runtime][parser] Use ArrayBoilerplateDescription all the way 2018-07-05 19:31:03 +00:00
DeleteLookupSlotInEval.golden [inspector] improve return position of explicit return in non-async function 2017-07-14 19:10:13 +00:00
DoDebugger.golden [interpreter] Remove redundant flag from bytecode cctest suite. 2016-10-04 16:30:15 +00:00
DoExpression.golden [objects] Make feedback vector a first-class object 2017-07-27 13:31:55 +00:00
Eval.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
ForAwaitOf.golden [async] Improve async function handling. 2018-10-10 06:37:53 +00:00
ForIn.golden [runtime][parser] Use ArrayBoilerplateDescription all the way 2018-07-05 19:31:03 +00:00
ForOf.golden Reland "[interpreter] Add bytecode for leading array spreads." 2018-09-05 09:29:51 +00:00
ForOfLoop.golden [async] Improve async function handling. 2018-10-10 06:37:53 +00:00
FunctionLiterals.golden [Cleanup][Interpreter] Move feedback slot allocation to bytecode generator 2017-10-19 16:17:14 +00:00
GenerateTestUndetectable.golden [runtime][parser] Use ArrayBoilerplateDescription all the way 2018-07-05 19:31:03 +00:00
Generators.golden Reland "[interpreter] Add bytecode for leading array spreads." 2018-09-05 09:29:51 +00:00
GlobalCompoundExpressions.golden [interpreter] Merge StaGlobal[Sloppy/Strict] into one bytecode. 2017-12-14 10:03:00 +00:00
GlobalCountOperators.golden [interpreter] Merge StaGlobal[Sloppy/Strict] into one bytecode. 2017-12-14 10:03:00 +00:00
GlobalDelete.golden [ignition] Fix return value of delete on global lexical variables 2017-08-23 16:17:48 +00:00
HeapNumberConstants.golden [ast] Move AstValue implementation into Literal 2017-10-27 20:21:29 +00:00
IfConditions.golden [turbofan] Introduce InstanceOfIC to collect rhs feedback. 2017-10-23 10:15:36 +00:00
IIFEWithOneshotOpt.golden Reland "[interpreter] Separate bytecodes for one-shot property loads and stores" 2018-09-27 13:56:53 +00:00
IIFEWithoutOneshotOpt.golden [Interpreter] Create and use CallNoFeedback bytecode for one-shot code 2018-09-17 11:28:25 +00:00
IntegerConstants.golden [inspector] improve return position of explicit return in non-async function 2017-07-14 19:10:13 +00:00
LetVariable.golden [ignition] removed nop bytecode 2017-07-18 16:14:29 +00:00
LetVariableContextSlot.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
LoadGlobal.golden [Interpreter] Share feedback slots for load / store named properties 2018-05-14 10:21:42 +00:00
LogicalExpressions.golden [objects] Make feedback vector a first-class object 2017-07-27 13:31:55 +00:00
LookupSlot.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
LookupSlotInEval.golden [objects] Make feedback vector a first-class object 2017-07-27 13:31:55 +00:00
Modules.golden [interpreter][runtime] Avoid AllocationSites for oneshot code 2018-08-10 13:34:13 +00:00
NewAndSpread.golden Reland "[interpreter] Add bytecode for leading array spreads." 2018-09-05 09:29:51 +00:00
NewTarget.golden [Interpreter] Remove new.target from fixed frame slot. 2017-08-11 17:04:08 +00:00
ObjectLiterals.golden [Runtime] Use Runtime_SetNamedProperty for property stores in one-shot code. 2018-09-11 13:42:25 +00:00
OuterContextVariables.golden [objects] Make feedback vector a first-class object 2017-07-27 13:31:55 +00:00
Parameters.golden [inspector] improve return position of explicit return in non-async function 2017-07-14 19:10:13 +00:00
PrimitiveExpressions.golden [objects] Make feedback vector a first-class object 2017-07-27 13:31:55 +00:00
PrimitiveReturnStatements.golden [inspector] improve return position of explicit return in non-async function 2017-07-14 19:10:13 +00:00
PrivateClassFields.golden Replace Context::closure with Context::scope_info, allowing closure to die. 2018-05-03 12:34:17 +00:00
PropertyCall.golden [Interpreter] Enable sharing of load / store named property feedback 2018-06-05 09:21:59 +00:00
PropertyLoads.golden [Interpreter] Share feedback slots for load / store named properties 2018-05-14 10:21:42 +00:00
PropertyLoadStoreOneShot.golden Reland "[interpreter] Separate bytecodes for one-shot property loads and stores" 2018-09-27 13:56:53 +00:00
PropertyLoadStoreWithoutOneShot.golden [interpreter][runtime] Avoid AllocationSites for oneshot code 2018-08-10 13:34:13 +00:00
PropertyStores.golden [Interpreter] Enable sharing of load / store named property feedback 2018-06-05 09:21:59 +00:00
PublicClassFields.golden [class] Make class field initializers breakable in the debugger 2018-09-17 22:25:44 +00:00
RegExpLiterals.golden [Cleanup][Interpreter] Move feedback slot allocation to bytecode generator 2017-10-19 16:17:14 +00:00
RemoveRedundantLdar.golden [objects] Make feedback vector a first-class object 2017-07-27 13:31:55 +00:00
StandardForLoop.golden [async] Improve async function handling. 2018-10-10 06:37:53 +00:00
StaticClassFields.golden [class] Make class field initializers breakable in the debugger 2018-09-17 22:25:44 +00:00
StoreGlobal.golden [Interpreter] Share feedback slots for load / store named properties 2018-05-14 10:21:42 +00:00
StringConcat.golden [parser] Add an n-ary node for large binop chains 2017-10-25 11:28:55 +00:00
StringConstants.golden [inspector] improve return position of explicit return in non-async function 2017-07-14 19:10:13 +00:00
SuperCallAndSpread.golden Reland "[interpreter] Add bytecode for leading array spreads." 2018-09-05 09:29:51 +00:00
Switch.golden [FeedbackVector] Case statements can share a single vector slot 2017-11-07 11:16:47 +00:00
TemplateLiterals.golden Reland "[esnext] re-implement template strings" 2018-03-14 18:12:09 +00:00
ThisFunction.golden Move function name var initialization to BytecodeGenerator 2017-11-27 18:37:47 +00:00
Throw.golden [ignition] Expect 'I' for signed bytecode operands 2017-01-25 17:39:24 +00:00
TopLevelObjectLiterals.golden [runtime][parser] Use ArrayBoilerplateDescription all the way 2018-07-05 19:31:03 +00:00
TryCatch.golden Remove the catch variable name from the extension field of catch contexts 2018-05-04 10:12:08 +00:00
TryFinally.golden Remove the catch variable name from the extension field of catch contexts 2018-05-04 10:12:08 +00:00
Typeof.golden [objects] Make feedback vector a first-class object 2017-07-27 13:31:55 +00:00
UnaryOperators.golden [Cleanup][Interpreter] Move feedback slot allocation to bytecode generator 2017-10-19 16:17:14 +00:00
WideRegisters.golden [Cleanup][Interpreter] Move feedback slot allocation to bytecode generator 2017-10-19 16:17:14 +00:00
WithStatement.golden [runtime][parser] Use ArrayBoilerplateDescription all the way 2018-07-05 19:31:03 +00:00