Skip to content

Commit 9bfb0f3

Browse files
committed
deps: V8: cherry-pick 3066b7b2fcb3
Original commit message: [LTS-M86][compiler][x64] Fix bug in InstructionSelector::ChangeInt32ToInt64 (cherry picked from commit 02f84c745fc0cae5927a66dc4a3e81334e8f60a6) No-Try: true No-Presubmit: true No-Tree-Checks: true Bug: chromium:1196683 Change-Id: Ib4ea738b47b64edc81450583be4c80a41698c3d1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2820971 Commit-Queue: Georg Neis <[email protected]> Reviewed-by: Nico Hartmann <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#73903} Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2821959 Commit-Queue: Jana Grill <[email protected]> Reviewed-by: Georg Neis <[email protected]> Reviewed-by: Victor-Gabriel Savu <[email protected]> Cr-Commit-Position: refs/branch-heads/8.6@{#75} Cr-Branched-From: a64aed2333abf49e494d2a5ce24bbd14fff19f60-refs/heads/8.6.395@{#1} Cr-Branched-From: a626bc036236c9bf92ac7b87dc40c9e538b087e3-refs/heads/master@{#69472} Refs: v8/v8@3066b7b PR-URL: #38275 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Shelley Vohr <[email protected]>
1 parent 5dc8246 commit 9bfb0f3

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
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.49',
39+
'v8_embedder_string': '-node.50',
4040

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

deps/v8/src/compiler/backend/x64/instruction-selector-x64.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,9 @@ void InstructionSelector::VisitChangeInt32ToInt64(Node* node) {
12701270
opcode = load_rep.IsSigned() ? kX64Movsxwq : kX64Movzxwq;
12711271
break;
12721272
case MachineRepresentation::kWord32:
1273-
opcode = load_rep.IsSigned() ? kX64Movsxlq : kX64Movl;
1273+
// ChangeInt32ToInt64 must interpret its input as a _signed_ 32-bit
1274+
// integer, so here we must sign-extend the loaded value in any case.
1275+
opcode = kX64Movsxlq;
12741276
break;
12751277
default:
12761278
UNREACHABLE();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright 2021 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+
8+
(function() {
9+
const arr = new Uint32Array([2**31]);
10+
function foo() {
11+
return (arr[0] ^ 0) + 1;
12+
}
13+
%PrepareFunctionForOptimization(foo);
14+
assertEquals(-(2**31) + 1, foo());
15+
%OptimizeFunctionOnNextCall(foo);
16+
assertEquals(-(2**31) + 1, foo());
17+
});
18+
19+
20+
// The remaining tests already passed without the bugfix.
21+
22+
23+
(function() {
24+
const arr = new Uint16Array([2**15]);
25+
function foo() {
26+
return (arr[0] ^ 0) + 1;
27+
}
28+
%PrepareFunctionForOptimization(foo);
29+
assertEquals(2**15 + 1, foo());
30+
%OptimizeFunctionOnNextCall(foo);
31+
assertEquals(2**15 + 1, foo());
32+
})();
33+
34+
35+
(function() {
36+
const arr = new Uint8Array([2**7]);
37+
function foo() {
38+
return (arr[0] ^ 0) + 1;
39+
}
40+
%PrepareFunctionForOptimization(foo);
41+
assertEquals(2**7 + 1, foo());
42+
%OptimizeFunctionOnNextCall(foo);
43+
assertEquals(2**7 + 1, foo());
44+
})();
45+
46+
47+
(function() {
48+
const arr = new Int32Array([-(2**31)]);
49+
function foo() {
50+
return (arr[0] >>> 0) + 1;
51+
}
52+
%PrepareFunctionForOptimization(foo);
53+
assertEquals(2**31 + 1, foo());
54+
%OptimizeFunctionOnNextCall(foo);
55+
assertEquals(2**31 + 1, foo());
56+
})();

0 commit comments

Comments
 (0)