Browse Source

chore: cherry-pick 512cd5e179f4 from v8 (#28753)

* chore: cherry-pick 512cd5e179f4 from v8

* update patches
Electron Bot 4 years ago
parent
commit
bcf2d0969c
2 changed files with 110 additions and 0 deletions
  1. 1 0
      patches/v8/.patches
  2. 109 0
      patches/v8/cherry-pick-512cd5e179f4.patch

+ 1 - 0
patches/v8/.patches

@@ -8,3 +8,4 @@ do_not_export_private_v8_symbols_on_windows.patch
 fix_build_deprecated_attirbute_for_older_msvc_versions.patch
 skip_global_registration_of_shared_arraybuffer_backing_stores.patch
 cherry-pick-02f84c745fc0.patch
+cherry-pick-512cd5e179f4.patch

+ 109 - 0
patches/v8/cherry-pick-512cd5e179f4.patch

@@ -0,0 +1,109 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Georg Neis <[email protected]>
+Date: Wed, 14 Apr 2021 13:19:44 +0200
+Subject: Merged: [compiler] Fix bug in
+ RepresentationChanger::GetWord32RepresentationFor
+
+Revision: fd29e246f65a7cee130e72cd10f618f3b82af232
+
+BUG=chromium:1195777
+NOTRY=true
+NOPRESUBMIT=true
+NOTREECHECKS=true
[email protected]
+
+Change-Id: I0400b3ae5736ef86dbeae558d15bfcca2e9f351a
+Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2826114
+Commit-Queue: Georg Neis <[email protected]>
+Reviewed-by: Nico Hartmann <[email protected]>
+Cr-Commit-Position: refs/branch-heads/9.0@{#34}
+Cr-Branched-From: bd0108b4c88e0d6f2350cb79b5f363fbd02f3eb7-refs/heads/9.0.257@{#1}
+Cr-Branched-From: 349bcc6a075411f1a7ce2d866c3dfeefc2efa39d-refs/heads/master@{#73001}
+
+diff --git a/src/compiler/representation-change.cc b/src/compiler/representation-change.cc
+index 64b274cdccddf4db63fdf5d80c0527405906ee75..3d937ada1e7e505bfc5cf2307ad4a8a5efef5a19 100644
+--- a/src/compiler/representation-change.cc
++++ b/src/compiler/representation-change.cc
+@@ -949,10 +949,10 @@ Node* RepresentationChanger::GetWord32RepresentationFor(
+     return node;
+   } else if (output_rep == MachineRepresentation::kWord64) {
+     if (output_type.Is(Type::Signed32()) ||
+-        output_type.Is(Type::Unsigned32())) {
+-      op = machine()->TruncateInt64ToInt32();
+-    } else if (output_type.Is(cache_->kSafeInteger) &&
+-               use_info.truncation().IsUsedAsWord32()) {
++        (output_type.Is(Type::Unsigned32()) &&
++         use_info.type_check() == TypeCheckKind::kNone) ||
++        (output_type.Is(cache_->kSafeInteger) &&
++         use_info.truncation().IsUsedAsWord32())) {
+       op = machine()->TruncateInt64ToInt32();
+     } else if (use_info.type_check() == TypeCheckKind::kSignedSmall ||
+                use_info.type_check() == TypeCheckKind::kSigned32 ||
+diff --git a/test/mjsunit/compiler/regress-1195777.js b/test/mjsunit/compiler/regress-1195777.js
+new file mode 100644
+index 0000000000000000000000000000000000000000..b122f4f0169af573723d4318b9f1127c857c9e35
+--- /dev/null
++++ b/test/mjsunit/compiler/regress-1195777.js
+@@ -0,0 +1,62 @@
++// Copyright 2021 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() {
++  function foo(b) {
++    let y = (new Date(42)).getMilliseconds();
++    let x = -1;
++    if (b) x = 0xFFFF_FFFF;
++    return y < Math.max(1 << y, x, 1 + y);
++  }
++  assertTrue(foo(true));
++  %PrepareFunctionForOptimization(foo);
++  assertTrue(foo(false));
++  %OptimizeFunctionOnNextCall(foo);
++  assertTrue(foo(true));
++})();
++
++
++(function() {
++  function foo(b) {
++    let x = 0;
++    if (b) x = -1;
++    return x == Math.max(-1, x >>> Infinity);
++  }
++  assertFalse(foo(true));
++  %PrepareFunctionForOptimization(foo);
++  assertTrue(foo(false));
++  %OptimizeFunctionOnNextCall(foo);
++  assertFalse(foo(true));
++})();
++
++
++(function() {
++  function foo(b) {
++    let x = -1;
++    if (b) x = 0xFFFF_FFFF;
++    return -1 < Math.max(0, x, -1);
++  }
++  assertTrue(foo(true));
++  %PrepareFunctionForOptimization(foo);
++  assertTrue(foo(false));
++  %OptimizeFunctionOnNextCall(foo);
++  assertTrue(foo(true));
++})();
++
++
++(function() {
++  function foo(b) {
++    let x = 0x7FFF_FFFF;
++    if (b) x = 0;
++    return 0 < (Math.max(-5 >>> x, -5) % -5);
++  }
++  assertTrue(foo(true));
++  %PrepareFunctionForOptimization(foo);
++  assertTrue(foo(false));
++  %OptimizeFunctionOnNextCall(foo);
++  assertTrue(foo(true));
++})();