Skip to content

Commit 5372f1f

Browse files
committed
deps: V8: cherry-pick a59e3ac1d7fa
Original commit message: Merged: [compiler] Fix bug in SimplifiedLowering's overflow computation Revision: e371325bcb03f20a362ebfa48225159702c6fde7 BUG=chromium:1126249 NOTRY=true NOPRESUBMIT=true NOTREECHECKS=true [email protected] Change-Id: I411d9233f77992e73da12784cef59c885999b556 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2415988 Reviewed-by: Tobias Tebbi <[email protected]> Commit-Queue: Georg Neis <[email protected]> Cr-Commit-Position: refs/branch-heads/8.6@{#8} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@a59e3ac PR-URL: #38275 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Shelley Vohr <[email protected]>
1 parent 31154a5 commit 5372f1f

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
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.30',
39+
'v8_embedder_string': '-node.31',
4040

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

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

+12-5
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,16 @@ void ReplaceEffectControlUses(Node* node, Node* effect, Node* control) {
178178
}
179179

180180
bool CanOverflowSigned32(const Operator* op, Type left, Type right,
181-
Zone* type_zone) {
182-
// We assume the inputs are checked Signed32 (or known statically
183-
// to be Signed32). Technically, the inputs could also be minus zero, but
184-
// that cannot cause overflow.
181+
TypeCache const* type_cache, Zone* type_zone) {
182+
// We assume the inputs are checked Signed32 (or known statically to be
183+
// Signed32). Technically, the inputs could also be minus zero, which we treat
184+
// as 0 for the purpose of this function.
185+
if (left.Maybe(Type::MinusZero())) {
186+
left = Type::Union(left, type_cache->kSingletonZero, type_zone);
187+
}
188+
if (right.Maybe(Type::MinusZero())) {
189+
right = Type::Union(right, type_cache->kSingletonZero, type_zone);
190+
}
185191
left = Type::Intersect(left, Type::Signed32(), type_zone);
186192
right = Type::Intersect(right, Type::Signed32(), type_zone);
187193
if (left.IsNone() || right.IsNone()) return false;
@@ -1457,7 +1463,8 @@ class RepresentationSelector {
14571463
if (lower<T>()) {
14581464
if (truncation.IsUsedAsWord32() ||
14591465
!CanOverflowSigned32(node->op(), left_feedback_type,
1460-
right_feedback_type, graph_zone())) {
1466+
right_feedback_type, type_cache_,
1467+
graph_zone())) {
14611468
ChangeToPureOp(node, Int32Op(node));
14621469

14631470
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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(b) {
8+
var x = -0;
9+
var y = -0x80000000;
10+
11+
if (b) {
12+
x = -1;
13+
y = 1;
14+
}
15+
16+
return (x - y) == -0x80000000;
17+
}
18+
19+
%PrepareFunctionForOptimization(foo);
20+
assertFalse(foo(true));
21+
%OptimizeFunctionOnNextCall(foo);
22+
assertFalse(foo(false));

0 commit comments

Comments
 (0)