Commit 337bb36e authored by bmeurer's avatar bmeurer Committed by Commit Bot

[deoptimizer] Teach the Deoptimizer about bound functions.

The inlining of Function.prototype.bind can lead to escape analyzed
bound functions, which weren't handled by the Deoptimizer previously.

BUG=chromium:729573
R=jarin@chromium.org,cbruni@chromium.org

Review-Url: https://codereview.chromium.org/2931483003
Cr-Commit-Position: refs/heads/master@{#45751}
parent 645d4a46
......@@ -4061,6 +4061,23 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
object->set_length(*array_length);
return object;
}
case JS_BOUND_FUNCTION_TYPE: {
Handle<JSBoundFunction> object = Handle<JSBoundFunction>::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> bound_target_function = materializer.FieldAt(value_index);
Handle<Object> bound_this = materializer.FieldAt(value_index);
Handle<Object> bound_arguments = materializer.FieldAt(value_index);
object->set_properties(FixedArray::cast(*properties));
object->set_elements(FixedArrayBase::cast(*elements));
object->set_bound_target_function(
JSReceiver::cast(*bound_target_function));
object->set_bound_this(*bound_this);
object->set_bound_arguments(FixedArray::cast(*bound_arguments));
return object;
}
case CONS_STRING_TYPE: {
Handle<ConsString> object = Handle<ConsString>::cast(
isolate_->factory()
......@@ -4178,7 +4195,6 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
case JS_WEAK_SET_TYPE:
case JS_PROMISE_CAPABILITY_TYPE:
case JS_PROMISE_TYPE:
case JS_BOUND_FUNCTION_TYPE:
case JS_PROXY_TYPE:
case MAP_TYPE:
case ALLOCATION_SITE_TYPE:
......
// 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() {
function foo() {
var a = foo.bind(this);
%DeoptimizeNow();
if (!a) return a;
return 0;
}
assertEquals(0, foo());
assertEquals(0, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals(0, foo());
})();
(function() {
"use strict";
function foo() {
var a = foo.bind(this);
%DeoptimizeNow();
if (!a) return a;
return 0;
}
assertEquals(0, foo());
assertEquals(0, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals(0, foo());
})();
(function() {
function foo() {
var a = foo.bind(this);
%DeoptimizeNow();
if (!a) return a;
return 0;
}
foo.prototype = {custom: "prototype"};
assertEquals(0, foo());
assertEquals(0, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals(0, foo());
})();
(function() {
"use strict";
function foo() {
var a = foo.bind(this);
%DeoptimizeNow();
if (!a) return a;
return 0;
}
foo.prototype = {custom: "prototype"};
assertEquals(0, foo());
assertEquals(0, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals(0, foo());
})();
// 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 bar(x) {
"use strict";
return this + x;
}
function foo(f) {
var a = bar.bind(42, 1);
return f() ? 0 : a;
}
function t() { return true; }
assertEquals(0, foo(t));
assertEquals(0, foo(t));
%OptimizeFunctionOnNextCall(foo);
var a = foo(_ => false);
assertEquals(43, a());
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