ea7499f5da
Currently, we context allocate all parameters for generators. With this CL, we keep arguments on stack (unless they escape to inner closure) and copy them between the stack and the generator's register file on suspend/resume. This will save context allocation in most cases. Note: There is an asymmetry between suspend and resume. - Suspend copies arguments and registers to the generator. - Resume copies only the registers from the generator, the arguments are copied by the ResumeGenerator trampoline. Bug: v8:5164 Change-Id: I6333898c60abf461b1ab1b5c6d3dc7188fa95649 Reviewed-on: https://chromium-review.googlesource.com/1063712 Commit-Queue: Jaroslav Sevcik <jarin@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#53327}
44 lines
842 B
JavaScript
44 lines
842 B
JavaScript
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
//
|
|
|
|
var failure = null;
|
|
var args;
|
|
|
|
function listener(event, exec_state, event_data, data) {
|
|
if (event != debug.Debug.DebugEvent.Break) return;
|
|
try {
|
|
args = exec_state.frame(0).evaluate('arguments').value();
|
|
} catch (e) {
|
|
failure = e;
|
|
}
|
|
}
|
|
|
|
debug.Debug.setListener(listener);
|
|
|
|
function* gen(a, b) {
|
|
debugger;
|
|
yield a;
|
|
yield b;
|
|
}
|
|
|
|
var foo = gen(1, 2);
|
|
|
|
foo.next()
|
|
assertEquals(2, args.length);
|
|
assertEquals(1, args[0]);
|
|
assertEquals(2, args[1]);
|
|
|
|
foo.next()
|
|
assertEquals(2, args.length);
|
|
assertEquals(1, args[0]);
|
|
assertEquals(2, args[1]);
|
|
|
|
foo.next()
|
|
assertEquals(2, args.length);
|
|
assertEquals(1, args[0]);
|
|
assertEquals(2, args[1]);
|
|
|
|
assertNull(failure);
|