[turbofan] NaN is never truish.

BUG=v8:4207
LOG=y
R=jkummerow@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#29230}
This commit is contained in:
bmeurer 2015-06-23 05:24:47 -07:00 committed by Commit bot
parent d783b76362
commit 78e9a2dff2
2 changed files with 19 additions and 2 deletions

View File

@ -3641,8 +3641,10 @@ Node* AstGraphBuilder::BuildToBoolean(Node* input) {
// TODO(bmeurer, mstarzinger): Refactor this into a separate optimization
// method.
switch (input->opcode()) {
case IrOpcode::kNumberConstant:
return jsgraph_->BooleanConstant(!NumberMatcher(input).Is(0));
case IrOpcode::kNumberConstant: {
NumberMatcher m(input);
return jsgraph_->BooleanConstant(!m.Is(0) && !m.IsNaN());
}
case IrOpcode::kHeapConstant: {
Handle<HeapObject> object = HeapObjectMatcher(input).Value().handle();
return jsgraph_->BooleanConstant(object->BooleanValue());

View File

@ -0,0 +1,15 @@
// 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 bar() { return 0/0 && 1; }
assertEquals(NaN, bar());
%OptimizeFunctionOnNextCall(bar);
assertEquals(NaN, bar());
function foo() { return 0/0 || 1; }
assertEquals(1, foo());
%OptimizeFunctionOnNextCall(foo);
assertEquals(1, foo());