Commit 2abd768e authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Respect effect input when lowering JSToBoolean for string inputs.

This allows us to re-enable the mjsunit/tools/profile test case.

R=jarin@chromium.org
BUG=v8:4493
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#31416}
parent aeffa39e
......@@ -696,9 +696,10 @@ Reduction JSTypedLowering::ReduceJSUnaryNot(Node* node) {
Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) {
Node* const input = node->InputAt(0);
Type* const input_type = NodeProperties::GetType(input);
Node* const effect = NodeProperties::GetEffectInput(node);
if (input_type->Is(Type::Boolean())) {
// JSToBoolean(x:boolean) => x
ReplaceWithValue(node, input);
ReplaceWithValue(node, input, effect);
return Replace(input);
} else if (input_type->Is(Type::OrderedNumber())) {
// JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0))
......@@ -711,10 +712,8 @@ Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) {
} else if (input_type->Is(Type::String())) {
// JSToBoolean(x:string) => NumberLessThan(#0,x.length)
FieldAccess const access = AccessBuilder::ForStringLength(graph()->zone());
// It is safe for the load to be effect-free (i.e. not linked into effect
// chain) because we assume String::length to be immutable.
Node* length = graph()->NewNode(simplified()->LoadField(access), input,
graph()->start(), graph()->start());
effect, graph()->start());
ReplaceWithValue(node, node, length);
node->ReplaceInput(0, jsgraph()->ZeroConstant());
node->ReplaceInput(1, length);
......
......@@ -154,7 +154,6 @@
# Issue 4493: Bugs due to --turbo-inlining.
'harmony/reflect': [PASS, NO_VARIANTS],
'tools/profile': [PASS, NO_VARIANTS],
# Assumptions about optimization need investigation in TurboFan.
'compiler/inlined-call': [PASS, NO_VARIANTS],
......
// Copyright 2015 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 baz(x, f) { return x.length; };
function bar(x, y) {
if (y) {}
baz(x, function() { return x; });
};
function foo(x) { bar(x, ''); }
%OptimizeFunctionOnNextCall(foo);
foo(['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