Generators: Avoid calling into runtime if operand stack is empty
authorwingo@igalia.com <wingo@igalia.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 20 Jun 2013 12:59:45 +0000 (12:59 +0000)
committerwingo@igalia.com <wingo@igalia.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 20 Jun 2013 12:59:45 +0000 (12:59 +0000)
commit646a34e1e00e164f841663f975158ce9b0fbe457
tree34af933d3eb5b43f5cf9202d885b2233136bd873
parent8202410ccaa872797582d6c71e6f5ad2d85874b0
Generators: Avoid calling into runtime if operand stack is empty

This patch makes yield sites save the resume continuation and context
inline.  If the operand stack is empty, we can avoid a call into the
runtime.  This also makes the SuspendJSGeneratorObject runtime function
less magical: it just has to save the operand stack and stack handlers.

This speeds up the following case by a factor of 3 or so:

  function* until(n) {
    for (var i = 0; i < n; i++)
      yield i;
  }

  function sum(iter) {
    var sum = 0;
    for (var x of iter) sum += x;
    return sum;
  }

  for (var i = 0; i < 10000; i++) sum(until(1000))

Also, there is no more sentinel value as the generators will resume in
the right place already, allowing me to remove the hack added to the
--debug-code check in r14437.

R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/15990004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15240 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
src/arm/full-codegen-arm.cc
src/ia32/code-stubs-ia32.cc
src/ia32/full-codegen-ia32.cc
src/runtime.cc
src/x64/full-codegen-x64.cc