Skip to content

Commit e99e456

Browse files
committed
deps: V8: cherry-pick c449afa1953b
Original commit message: Merged: [compiler] Fix a bug in SimplifiedLowering Revision: ba1b2cc09ab98b51ca3828d29d19ae3b0a7c3a92 BUG=chromium:1150649 NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true (cherry picked from commit 966d0eb98dd2630e861d267288fa2c63be9b5465) Change-Id: Ic903e61ee00b7c240bed96633d1eab582c295308 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2557985 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Georg Neis <neis@chromium.org> Cr-Original-Commit-Position: refs/branch-heads/8.8@{#10} Cr-Original-Branched-From: 2dbcdc105b963ee2501c82139eef7e0603977ff0-refs/heads/8.8.278@{#1} Cr-Original-Branched-From: 366d30c99049b3f1c673f8a93deb9f879d0fa9f0-refs/heads/master@{#71094} Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2624749 Reviewed-by: Jana Grill <janagrill@chromium.org> Reviewed-by: Achuith Bhandarkar <achuith@chromium.org> Commit-Queue: Victor-Gabriel Savu <vsavu@google.com> Cr-Commit-Position: refs/branch-heads/8.6@{#52} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@c449afa PR-URL: #38275 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com>
1 parent 18a4cbf commit e99e456

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.38',
39+
'v8_embedder_string': '-node.39',
4040

4141
##### V8 defaults for Node.js #####
4242

deps/v8/src/compiler/simplified-lowering.cc

+10-3
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,6 @@ class RepresentationSelector {
13811381
IsSomePositiveOrderedNumber(input1_type)
13821382
? CheckForMinusZeroMode::kDontCheckForMinusZero
13831383
: CheckForMinusZeroMode::kCheckForMinusZero;
1384-
13851384
NodeProperties::ChangeOp(node, simplified()->CheckedInt32Mul(mz_mode));
13861385
}
13871386

@@ -1425,6 +1424,13 @@ class RepresentationSelector {
14251424

14261425
Type left_feedback_type = TypeOf(node->InputAt(0));
14271426
Type right_feedback_type = TypeOf(node->InputAt(1));
1427+
1428+
// Using Signed32 as restriction type amounts to promising there won't be
1429+
// signed overflow. This is incompatible with relying on a Word32
1430+
// truncation in order to skip the overflow check.
1431+
Type const restriction =
1432+
truncation.IsUsedAsWord32() ? Type::Any() : Type::Signed32();
1433+
14281434
// Handle the case when no int32 checks on inputs are necessary (but
14291435
// an overflow check is needed on the output). Note that we do not
14301436
// have to do any check if at most one side can be minus zero. For
@@ -1438,7 +1444,7 @@ class RepresentationSelector {
14381444
right_upper.Is(Type::Signed32OrMinusZero()) &&
14391445
(left_upper.Is(Type::Signed32()) || right_upper.Is(Type::Signed32()))) {
14401446
VisitBinop<T>(node, UseInfo::TruncatingWord32(),
1441-
MachineRepresentation::kWord32, Type::Signed32());
1447+
MachineRepresentation::kWord32, restriction);
14421448
} else {
14431449
// If the output's truncation is identify-zeros, we can pass it
14441450
// along. Moreover, if the operation is addition and we know the
@@ -1458,8 +1464,9 @@ class RepresentationSelector {
14581464
UseInfo right_use = CheckedUseInfoAsWord32FromHint(hint, FeedbackSource(),
14591465
kIdentifyZeros);
14601466
VisitBinop<T>(node, left_use, right_use, MachineRepresentation::kWord32,
1461-
Type::Signed32());
1467+
restriction);
14621468
}
1469+
14631470
if (lower<T>()) {
14641471
if (truncation.IsUsedAsWord32() ||
14651472
!CanOverflowSigned32(node->op(), left_feedback_type,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2020 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax
6+
7+
function foo(a) {
8+
var y = 0x7fffffff; // 2^31 - 1
9+
10+
// Widen the static type of y (this condition never holds).
11+
if (a == NaN) y = NaN;
12+
13+
// The next condition holds only in the warmup run. It leads to Smi
14+
// (SignedSmall) feedback being collected for the addition below.
15+
if (a) y = -1;
16+
17+
const z = (y + 1)|0;
18+
return z < 0;
19+
}
20+
21+
%PrepareFunctionForOptimization(foo);
22+
assertFalse(foo(true));
23+
%OptimizeFunctionOnNextCall(foo);
24+
assertTrue(foo(false));

0 commit comments

Comments
 (0)