v8/test/debugger/regress
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
..
regress-1639-2.js [tests] Fix assertFalse(exception) anti-pattern 2018-03-21 10:59:46 +00:00
regress-2318.js [inspector] gracefully handle stack overflows in the inspector. 2016-12-19 14:07:55 +00:00
regress-5575-1.js [debugger,compiler] do not recompile already compiled inner functions. 2016-11-11 15:53:33 +00:00
regress-5575-2.js [debugger,compiler] do not recompile already compiled inner functions. 2016-11-11 15:53:33 +00:00
regress-5575-3.js [debugger,compiler] do not recompile already compiled inner functions. 2016-11-11 15:53:33 +00:00
regress-5610.js [async] Improve async function handling. 2018-10-10 06:37:53 +00:00
regress-5901-1.js [fullcodegen] Remove --stress-fullcodegen flag. 2017-08-10 09:52:49 +00:00
regress-5901-2.js [inspector] improve return position of explicit return in non-async function 2017-07-14 19:10:13 +00:00
regress-5950.js [debug] Handle OOM events in debugger tests 2017-02-16 11:48:22 +00:00
regress-6085.js [debugger] fix switch block source positions. 2017-03-13 12:47:48 +00:00
regress-6526.js Add exception prediction for ArrayForEachLoopLazyDeoptContinuation 2017-06-28 10:37:13 +00:00
regress-7421.js [debug] do not leak optimized code into no-side-effect evaluate. 2018-02-20 11:22:32 +00:00
regress-crbug-507070.js [debug] remove legacy implementation for break points. 2018-02-26 10:01:39 +00:00
regress-crbug-724858.js [inspector] improve return position of explicit return in non-async function 2017-07-14 19:10:13 +00:00
regress-crbug-736758.js Fix debugger's frame inspection for optimized Array.forEach. 2017-06-27 10:56:42 +00:00
regress-crbug-808973.js Revert "[builtins] Mega-revert to address the Dev blocker in crbug.com/808911." 2018-02-08 17:25:13 +00:00
regress-crbug-835973.js [interpreter] correctly advance over debug scaling prefixes. 2018-05-03 07:02:57 +00:00
regress-crbug-840288.js [wasm] Create module object in async compilation earlier. 2018-05-09 07:54:56 +00:00
regress-crbug-882664.js [debug] fix scaling prefix patching for debug evaluate 2018-09-14 14:33:07 +00:00