Commit c2e82d6e authored by jarin's avatar jarin Committed by Commit bot

[crankshaft] Fix inlining to always connect both branches of test context.

BUG=v8:4839
LOG=n

Review URL: https://codereview.chromium.org/1811693002

Cr-Commit-Position: refs/heads/master@{#34848}
parent 447b1156
......@@ -4928,9 +4928,8 @@ void HOptimizedGraphBuilder::VisitReturnStatement(ReturnStatement* stmt) {
// will always evaluate to true, in a value context the return value needs
// to be a JSObject.
if (context->IsTest()) {
TestContext* test = TestContext::cast(context);
CHECK_ALIVE(VisitForEffect(stmt->expression()));
Goto(test->if_true(), state);
context->ReturnValue(graph()->GetConstantTrue());
} else if (context->IsEffect()) {
CHECK_ALIVE(VisitForEffect(stmt->expression()));
Goto(function_return(), state);
......@@ -8568,7 +8567,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
// return value will always evaluate to true, in a value context the
// return value is the newly allocated receiver.
if (call_context()->IsTest()) {
Goto(inlined_test_context()->if_true(), state);
inlined_test_context()->ReturnValue(graph()->GetConstantTrue());
} else if (call_context()->IsEffect()) {
Goto(function_return(), state);
} else {
......@@ -8591,7 +8590,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
// Falling off the end of a normal inlined function. This basically means
// returning undefined.
if (call_context()->IsTest()) {
Goto(inlined_test_context()->if_false(), state);
inlined_test_context()->ReturnValue(graph()->GetConstantFalse());
} else if (call_context()->IsEffect()) {
Goto(function_return(), state);
} else {
......
// 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: --allow-natives-syntax
function dummy() { }
(function InlinedFunctionTestContext() {
var f = function() { }
function g() {
var s = "hey";
dummy(); // Force a deopt point.
if (f()) return s;
}
g();
g();
g();
%OptimizeFunctionOnNextCall(g);
f = function() { return true; }
assertEquals("hey", g());
})();
(function InlinedConstructorReturnTestContext() {
function c() { return 1; }
var f = function() { return !(new c()); }
function g() {
var s = "hey";
dummy(); // Force a deopt point.
if (f()) return s;
}
g();
g();
g();
%OptimizeFunctionOnNextCall(g);
f = function() { return true; }
assertEquals("hey", g());
})();
(function InlinedConstructorNoReturnTestContext() {
function c() { }
var f = function() { return !(new c()); }
function g() {
var s = "hey";
dummy(); // Force a deopt point.
if (f()) return s;
}
g();
g();
g();
%OptimizeFunctionOnNextCall(g);
f = function() { return true; }
assertEquals("hey", g());
})();
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