Commit 54b405ce authored by neis's avatar neis Committed by Commit bot

[generators] Make runtime functions more robust.

Only look at the --ignition-generators flag when determining whether to use
Ignition (in compiler.cc).  In generator runtime functions, instead of looking
at the flag, determine the generator kind based on whether the generator has a
bytecode array.  This allows compiling some generator function using
full-codegen and others using Ignition, e.g when using --ignition-filter.

R=mstarzinger@chromium.org
BUG=chromium:618657,v8:4907

Review-Url: https://codereview.chromium.org/2052873002
Cr-Commit-Position: refs/heads/master@{#36864}
parent 769d3326
......@@ -21,11 +21,12 @@ RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) {
CHECK(function->shared()->is_resumable());
Handle<FixedArray> operand_stack;
if (FLAG_ignition && FLAG_ignition_generators) {
if (function->shared()->HasBytecodeArray()) {
// New-style generators.
int size = function->shared()->bytecode_array()->register_count();
operand_stack = isolate->factory()->NewFixedArray(size);
} else {
DCHECK(!function->shared()->HasBytecodeArray());
// Old-style generators.
operand_stack = handle(isolate->heap()->empty_fixed_array());
}
......@@ -148,9 +149,8 @@ RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) {
if (!generator->is_suspended()) return isolate->heap()->undefined_value();
if (FLAG_ignition && FLAG_ignition_generators) UNIMPLEMENTED();
if (generator->function()->shared()->HasBytecodeArray()) UNIMPLEMENTED();
DCHECK(!generator->function()->shared()->HasBytecodeArray());
Handle<Code> code(generator->function()->code(), isolate);
int offset = generator->continuation();
CHECK(0 <= offset && offset < code->instruction_size());
......
// 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.
// Flags: --ignition --ignition-generators --ignition-filter=-foo
function* foo() { yield 42 }
var g = foo();
assertEquals(42, g.next().value);
assertEquals(true, g.next().done);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment