Skip to content
Permalink
Browse files

[deoptimizer] Add support for materializing Generator objects.

This adds support for materializing objects of {JSGeneratorObject} type
during deoptimization. Cases where soft-deopts remove any escaping use
of the implicit generator object can cause it to be escape analyzed.

R=jarin@chromium.org
TEST=mjsunit/regress/regress-crbug-732169
BUG=chromium:732169

Change-Id: I2ec10b2a509a4f37a456a8ca2fd74b8de2fb55be
Reviewed-on: https://chromium-review.googlesource.com/530847
Reviewed-by: Georg Neis <neis@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45849}
  • Loading branch information...
Michael Starzinger Commit Bot
Michael Starzinger authored and Commit Bot committed Jun 12, 2017
1 parent f6c8ba8 commit f555a6922dd1b425ed845370cd01428b3ba46f93
Showing with 38 additions and 1 deletion.
  1. +24 −1 src/deoptimizer.cc
  2. +14 −0 test/mjsunit/regress/regress-crbug-732169.js
@@ -4442,6 +4442,30 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
object->set_bound_arguments(FixedArray::cast(*bound_arguments));
return object;
}
case JS_GENERATOR_OBJECT_TYPE: {
Handle<JSGeneratorObject> object = Handle<JSGeneratorObject>::cast(
isolate_->factory()->NewJSObjectFromMap(map, NOT_TENURED));
slot->value_ = object;
Handle<Object> properties = materializer.FieldAt(value_index);
Handle<Object> elements = materializer.FieldAt(value_index);
Handle<Object> function = materializer.FieldAt(value_index);
Handle<Object> context = materializer.FieldAt(value_index);
Handle<Object> receiver = materializer.FieldAt(value_index);
Handle<Object> input_or_debug_pos = materializer.FieldAt(value_index);
Handle<Object> resume_mode = materializer.FieldAt(value_index);
Handle<Object> continuation_offset = materializer.FieldAt(value_index);
Handle<Object> register_file = materializer.FieldAt(value_index);
object->set_properties(FixedArray::cast(*properties));
object->set_elements(FixedArrayBase::cast(*elements));
object->set_function(JSFunction::cast(*function));
object->set_context(Context::cast(*context));
object->set_receiver(*receiver);
object->set_input_or_debug_pos(*input_or_debug_pos);
object->set_resume_mode(Smi::cast(*resume_mode)->value());
object->set_continuation(Smi::cast(*continuation_offset)->value());
object->set_register_file(FixedArray::cast(*register_file));
return object;
}
case CONS_STRING_TYPE: {
Handle<ConsString> object = Handle<ConsString>::cast(
isolate_->factory()
@@ -4544,7 +4568,6 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
case JS_MESSAGE_OBJECT_TYPE:
case JS_DATE_TYPE:
case JS_CONTEXT_EXTENSION_OBJECT_TYPE:
case JS_GENERATOR_OBJECT_TYPE:
case JS_ASYNC_GENERATOR_OBJECT_TYPE:
case JS_MODULE_NAMESPACE_TYPE:
case JS_ARRAY_BUFFER_TYPE:
@@ -0,0 +1,14 @@
// Copyright 2017 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: --allow-natives-syntax

function* f([x]) { yield x }
// No warm-up of {f} to trigger soft deopt.
%OptimizeFunctionOnNextCall(f);
var gen = f([23]);

assertEquals("[object Generator]", gen.toString());
assertEquals({ done:false, value:23 }, gen.next());
assertEquals({ done:true, value:undefined }, gen.next());

0 comments on commit f555a69

Please sign in to comment.
You can’t perform that action at this time.