v8/test/inspector
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
..
console Revert "[inspector] RemoteObject.description should be empty for primitive type" 2018-05-31 18:52:08 +00:00
cpu-profiler Revert "[inspector] RemoteObject.description should be empty for primitive type" 2018-05-31 18:52:08 +00:00
debugger [async] Improve async function handling. 2018-10-10 06:37:53 +00:00
heap-profiler [heap-profiler] Annotate global handles retained by console and debugger. 2018-02-19 12:21:52 +00:00
runtime Remove always-true --harmony-bigint runtime flag 2018-10-01 11:31:13 +00:00
sessions inspector: return [[StableObjectId]] as internal property 2018-09-20 15:03:52 +00:00
type-profiler Reland "[inspector] fixed location of top level function return" 2018-06-18 21:37:49 +00:00
BUILD.gn Remove manual references to exe_and_shlib_deps 2018-06-04 18:35:43 +00:00
DEPS [inspector] introduce limit for amount of stored async stacks 2016-12-18 17:04:40 +00:00
inspector-test.cc [cleanup] Refactor inspector to use default members. 2018-09-18 09:13:59 +00:00
inspector.status [test] Disable a flaky command-line-api-without-side-effects test 2018-10-04 14:41:22 +00:00
isolate-data.cc [cleanup] Refactor inspector to use default members. 2018-09-18 09:13:59 +00:00
isolate-data.h [inspector] added V8InspectorClient::resourceNameToUrl 2018-08-09 21:36:24 +00:00
json-parse-expected.txt [inspector] Refactor protocol-test.js 2017-05-19 00:35:45 +00:00
json-parse.js [inspector] Refactor protocol-test.js 2017-05-19 00:35:45 +00:00
OWNERS Add COMPONENT tags to OWNERS files where appropriate 2017-05-22 10:15:28 +00:00
PRESUBMIT.py [inspector] added blink try bots on inspector tests change 2018-06-18 21:38:59 +00:00
protocol-test.js inspector: speedup InspectorTest.logMessage 2018-10-09 13:42:30 +00:00
task-runner.cc Cleanup: Use std::atomic<T> instead of base::AtomicNumber<T> in TaskRunner. 2018-07-12 07:22:06 +00:00
task-runner.h [cleanup] Refactor inspector to use default members. 2018-09-18 09:13:59 +00:00
testcfg.py [test] Add non-d8 test suites to Android testing 2018-09-11 11:12:21 +00:00