diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc index 66c212dfcb..40aaef91f9 100644 --- a/src/compiler/js-builtin-reducer.cc +++ b/src/compiler/js-builtin-reducer.cc @@ -1513,6 +1513,11 @@ Reduction JSBuiltinReducer::ReduceNumberIsInteger(Node* node) { // ES6 section 20.1.2.4 Number.isNaN ( number ) Reduction JSBuiltinReducer::ReduceNumberIsNaN(Node* node) { JSCallReduction r(node); + if (r.InputsMatchZero()) { + // Number.isNaN() -> #false + Node* value = jsgraph()->FalseConstant(); + return Replace(value); + } // Number.isNaN(a:number) -> ObjectIsNaN(a) Node* input = r.GetJSCallInput(0); Node* value = graph()->NewNode(simplified()->ObjectIsNaN(), input); diff --git a/test/mjsunit/regress/regress-6082.js b/test/mjsunit/regress/regress-6082.js new file mode 100644 index 0000000000..aec1be0fb7 --- /dev/null +++ b/test/mjsunit/regress/regress-6082.js @@ -0,0 +1,11 @@ +// Copyright 2017 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 foo() { return Number.isNaN(); } +assertFalse(foo()); +assertFalse(foo()); +%OptimizeFunctionOnNextCall(foo); +assertFalse(foo());