Commit b6e68438 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

Fix parseInt fast-path to return -0 when needed

Bug: v8:7369
Change-Id: I35b69295a4f9ffab0d5d0501f2f0252dee1a48a3
Reviewed-on: https://chromium-review.googlesource.com/887428
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50911}
parent b0e4bf13
......@@ -319,12 +319,14 @@ TF_BUILTIN(NumberParseInt, CodeStubAssembler) {
GotoIf(Float64Equal(input_value, ChangeInt32ToFloat64(input_value32)),
&if_inputissigned32);
// Check if the absolute {input} value is in the ]0.01,1e9[ range.
// Check if the absolute {input} value is in the [1,1<<31[ range.
// Take the generic path for the range [0,1[ because the result
// could be -0.
Node* input_value_abs = Float64Abs(input_value);
GotoIfNot(Float64LessThan(input_value_abs, Float64Constant(1e9)),
GotoIfNot(Float64LessThan(input_value_abs, Float64Constant(1u << 31)),
&if_generic);
Branch(Float64LessThan(Float64Constant(0.01), input_value_abs),
Branch(Float64LessThanOrEqual(Float64Constant(1), input_value_abs),
&if_inputissigned32, &if_generic);
// Return the truncated int32 value, and return the tagged result.
......
// Copyright 2018 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.
assertEquals(-Infinity, 1/parseInt(-0.9));
assertEquals(-Infinity, 1/parseInt("-0.9"));
assertEquals(-Infinity, 1/parseInt(-0.09));
assertEquals(-Infinity, 1/parseInt(-0.009));
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