Commit 78e9a2df authored by bmeurer's avatar bmeurer Committed by Commit bot

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