Commit 9bee8f10 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] Fix lowering of Number.isNaN().

BUG=v8:6082
R=yangguo@chromium.org

Review-Url: https://codereview.chromium.org/2743183003
Cr-Commit-Position: refs/heads/master@{#43735}
parent 35b06c51
...@@ -1513,6 +1513,11 @@ Reduction JSBuiltinReducer::ReduceNumberIsInteger(Node* node) { ...@@ -1513,6 +1513,11 @@ Reduction JSBuiltinReducer::ReduceNumberIsInteger(Node* node) {
// ES6 section 20.1.2.4 Number.isNaN ( number ) // ES6 section 20.1.2.4 Number.isNaN ( number )
Reduction JSBuiltinReducer::ReduceNumberIsNaN(Node* node) { Reduction JSBuiltinReducer::ReduceNumberIsNaN(Node* node) {
JSCallReduction r(node); JSCallReduction r(node);
if (r.InputsMatchZero()) {
// Number.isNaN() -> #false
Node* value = jsgraph()->FalseConstant();
return Replace(value);
}
// Number.isNaN(a:number) -> ObjectIsNaN(a) // Number.isNaN(a:number) -> ObjectIsNaN(a)
Node* input = r.GetJSCallInput(0); Node* input = r.GetJSCallInput(0);
Node* value = graph()->NewNode(simplified()->ObjectIsNaN(), input); Node* value = graph()->NewNode(simplified()->ObjectIsNaN(), input);
......
// 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());
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