Reland of [turbofan] Fix deoptimization of boolean bit constants. (patchset #1 id:1 of https://codereview.chromium.org/2495243002)

This reverts commit 1c9528c4c4.

BUG=chromium:664490

Review-Url: https://codereview.chromium.org/2503763003
Cr-Commit-Position: refs/heads/master@{#40994}
This commit is contained in:
jarin 2016-11-15 05:55:08 -08:00 committed by Commit bot
parent 1a36eaea4b
commit 7ae7e84340
3 changed files with 27 additions and 1 deletions

View File

@ -872,12 +872,18 @@ void CodeGenerator::AddTranslationForOperand(Translation* translation,
constant_object =
handle(reinterpret_cast<Smi*>(constant.ToInt32()), isolate());
DCHECK(constant_object->IsSmi());
} else if (type.representation() == MachineRepresentation::kBit) {
if (constant.ToInt32() == 0) {
constant_object = isolate()->factory()->false_value();
} else {
DCHECK_EQ(1, constant.ToInt32());
constant_object = isolate()->factory()->true_value();
}
} else {
// TODO(jarin,bmeurer): We currently pass in raw pointers to the
// JSFunction::entry here. We should really consider fixing this.
DCHECK(type == MachineType::Int32() ||
type == MachineType::Uint32() ||
type.representation() == MachineRepresentation::kBit ||
type.representation() == MachineRepresentation::kWord32 ||
type.representation() == MachineRepresentation::kNone);
DCHECK(type.representation() != MachineRepresentation::kNone ||

View File

@ -1030,6 +1030,8 @@ class RepresentationSelector {
MachineRepresentation::kWord32 ||
machine_type.semantic() == MachineSemantic::kInt32 ||
machine_type.semantic() == MachineSemantic::kUint32);
DCHECK(machine_type.representation() != MachineRepresentation::kBit ||
input_type->Is(Type::Boolean()));
(*types)[i] = machine_type;
}
}

View File

@ -0,0 +1,18 @@
// 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
var foo = function(msg) {};
foo = function (value) {
assertEquals(false, value);
}
function f() {
foo(undefined == 0);
}
%OptimizeFunctionOnNextCall(f);
f();