Commit 417b3010 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[generators] Add asserts preventing mixed functions.

This adds assertions to generator support functions that distinguish
between old-style and new-style generators which make sure only one
of those styles is actually used. Even though normal functions can soon
be mixed (bytecode and baseline code at the same time), generator
functions are still exclusively in only one tier.

R=neis@chromium.org
BUG=v8:5265

Review-Url: https://codereview.chromium.org/2233863002
Cr-Commit-Position: refs/heads/master@{#38541}
parent 9e60db1f
......@@ -19212,6 +19212,7 @@ int JSGeneratorObject::source_position() const {
int code_offset;
if (function()->shared()->HasBytecodeArray()) {
// New-style generators.
DCHECK(!function()->shared()->HasBaselineCode());
code_offset = Smi::cast(input_or_debug_pos())->value();
// The stored bytecode offset is relative to a different base than what
// is used in the source position table, hence the subtraction.
......@@ -19219,6 +19220,7 @@ int JSGeneratorObject::source_position() const {
code = AbstractCode::cast(function()->shared()->bytecode_array());
} else {
// Old-style generators.
DCHECK(function()->shared()->HasBaselineCode());
code_offset = continuation();
CHECK(0 <= code_offset);
CHECK(code_offset < function()->code()->instruction_size());
......
......@@ -23,10 +23,12 @@ RUNTIME_FUNCTION(Runtime_CreateJSGeneratorObject) {
Handle<FixedArray> operand_stack;
if (function->shared()->HasBytecodeArray()) {
// New-style generators.
DCHECK(!function->shared()->HasBaselineCode());
int size = function->shared()->bytecode_array()->register_count();
operand_stack = isolate->factory()->NewFixedArray(size);
} else {
// Old-style generators.
DCHECK(function->shared()->HasBaselineCode());
operand_stack = isolate->factory()->empty_fixed_array();
}
......
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