1. 29 Oct, 2018 1 commit
  2. 26 Oct, 2018 1 commit
    • Benedikt Meurer's avatar
      [async] Add Promise.all() support to --async-stack-traces. · 6f39ab89
      Benedikt Meurer authored
      This adds support for Promise.all() to --async-stack-traces (also at
      zero cost, since we can derive the relevant information from the resolve
      element closure and context). In case of `Promise.all(a)` the stack
      trace even tells you which element of `a` is responsible, for example
      
      ```js
      async function fine() {}
      async function thrower() { await fine(); throw new Error(); }
      async function test() { await Promise.all([fine(), thrower()]); }
      ```
      
      will generate the following stack trace
      
      ```
      Error
          at thrower (something.js:1:9)
          at async Promise.all (index 1)
          at async test (something.js:3:3)
      ```
      
      so it not only shows the async Promise.all() frames, but even tells the
      user exactly that the second element of `[fine(), thrower()]` is the
      relevant one.
      
      Bug: v8:7522
      Change-Id: I279a845888e06053cf0e3c9338ab71caabaabf45
      Reviewed-on: https://chromium-review.googlesource.com/c/1299248Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
      Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#57023}
      6f39ab89
  3. 04 Oct, 2018 1 commit
    • Benedikt Meurer's avatar
      [async] First prototype of zero-cost async stack traces. · f537d778
      Benedikt Meurer authored
      This introduces a new flag --async-stack-traces, which enables zero-cost
      async stack traces. This enriches the non-standard Error.stack property
      with async stack frames computed from walking up the promise chains and
      collecting all the await suspension points along the way. In Error.stack
      these async frames are marked with "async" to make it possible to
      distinguish them from regular frames, for example:
      
      ```
      Error: Some error message
          at bar (<anonymous>)
          at async foo (<anonymous>)
      ```
      
      It's zero-cost because no additional information is collected during the
      execution of the program, but only the information already present in the
      promise chains is used to reconstruct an approximation of the async stack
      in case of an exception. But this approximation is limited to suspension
      points at await's in async functions. This depends on a recent ECMAScript
      specification change, flagged behind --harmony-await-optimization and
      implied the --async-stack-traces flag. Without this change there's no
      way to get from the outer promise of an async function to the rest of
      the promise chain, since the link is broken by the indirection introduced
      by await.
      
      For async functions the special outer promise, named .promise in the
      Parser desugaring, is now forcible allocated to stack slot 0 during
      scope resolution, to make it accessible to the stack frame construction
      logic. Note that this first prototype doesn't yet work fully support
      async generators and might have other limitations.
      
      Bug: v8:7522
      Ref: nodejs/node#11865
      Change-Id: I0cc8e3cdfe45dab56d3d506be2d25907409b01a9
      Design-Document: http://bit.ly/v8-zero-cost-async-stack-traces
      Reviewed-on: https://chromium-review.googlesource.com/c/1256762
      Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
      Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
      Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
      Cr-Commit-Position: refs/heads/master@{#56363}
      f537d778