From 36f9547f3bce0787059103e3e893eefe76a8a2c0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 18 Aug 2021 10:44:32 +0900 Subject: [PATCH 1/2] chore: cherry-pick fix for 1234770 from v8 --- patches/v8/.patches | 1 + patches/v8/cherry-pick-1234770.patch | 75 ++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 patches/v8/cherry-pick-1234770.patch diff --git a/patches/v8/.patches b/patches/v8/.patches index 1f6a9e89bd817..207c83545d17e 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -7,3 +7,4 @@ workaround_an_undefined_symbol_error.patch do_not_export_private_v8_symbols_on_windows.patch fix_build_deprecated_attirbute_for_older_msvc_versions.patch cherry-pick-e38d55313ad9.patch +cherry-pick-1234770.patch diff --git a/patches/v8/cherry-pick-1234770.patch b/patches/v8/cherry-pick-1234770.patch new file mode 100644 index 0000000000000..ac5279c7c42dd --- /dev/null +++ b/patches/v8/cherry-pick-1234770.patch @@ -0,0 +1,75 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Georg Neis +Date: Mon Aug 9 09:57:12 2021 +0200 + +Subject: Merged: [compiler] Fix a bug in MachineOperatorReducer's BitfieldCheck + +Revision: 574ca6b71c6160d38b5fcf4b8e133bc7f6ba2387 + +BUG=chromium:1234770 +NOTRY=true +NOPRESUBMIT=true +NOTREECHECKS=true +R=nicohartmann@chromium.org + +Change-Id: I15af5a94e89b54c2a540442c3544ed459b832e0a +Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3080564 +Reviewed-by: Lutz Vahl +Commit-Queue: Georg Neis +Cr-Commit-Position: refs/branch-heads/9.3@{#21} +Cr-Branched-From: 7744dce208a555494e4a33e24fadc71ea20b3895-refs/heads/9.3.345@{#1} +Cr-Branched-From: 4b6b4cabf3b6a20cdfda72b369df49f3311c4344-refs/heads/master@{#75728} + +diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc +index 5d61dfac6a..b4b16f931f 100644 +--- a/src/compiler/machine-operator-reducer.cc ++++ b/src/compiler/machine-operator-reducer.cc +@@ -1718,11 +1718,21 @@ Reduction MachineOperatorReducer::ReduceWordNAnd(Node* node) { + namespace { + + // Represents an operation of the form `(source & mask) == masked_value`. ++// where each bit set in masked_value also has to be set in mask. + struct BitfieldCheck { +- Node* source; +- uint32_t mask; +- uint32_t masked_value; +- bool truncate_from_64_bit; ++ Node* const source; ++ uint32_t const mask; ++ uint32_t const masked_value; ++ bool const truncate_from_64_bit; ++ ++ BitfieldCheck(Node* source, uint32_t mask, uint32_t masked_value, ++ bool truncate_from_64_bit) ++ : source(source), ++ mask(mask), ++ masked_value(masked_value), ++ truncate_from_64_bit(truncate_from_64_bit) { ++ CHECK_EQ(masked_value & ~mask, 0); ++ } + + static base::Optional Detect(Node* node) { + // There are two patterns to check for here: +@@ -1737,14 +1747,16 @@ struct BitfieldCheck { + if (eq.left().IsWord32And()) { + Uint32BinopMatcher mand(eq.left().node()); + if (mand.right().HasResolvedValue() && eq.right().HasResolvedValue()) { +- BitfieldCheck result{mand.left().node(), mand.right().ResolvedValue(), +- eq.right().ResolvedValue(), false}; ++ uint32_t mask = mand.right().ResolvedValue(); ++ uint32_t masked_value = eq.right().ResolvedValue(); ++ if ((masked_value & ~mask) != 0) return {}; + if (mand.left().IsTruncateInt64ToInt32()) { +- result.truncate_from_64_bit = true; +- result.source = +- NodeProperties::GetValueInput(mand.left().node(), 0); ++ return BitfieldCheck( ++ NodeProperties::GetValueInput(mand.left().node(), 0), mask, ++ masked_value, true); ++ } else { ++ return BitfieldCheck(mand.left().node(), mask, masked_value, false); + } +- return result; + } + } + } else { From 3353d15e0d83a6576a8f72a42b6db1a3fd304f1b Mon Sep 17 00:00:00 2001 From: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Date: Wed, 18 Aug 2021 01:54:38 +0000 Subject: [PATCH 2/2] chore: update patches --- patches/v8/cherry-pick-1234770.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/v8/cherry-pick-1234770.patch b/patches/v8/cherry-pick-1234770.patch index ac5279c7c42dd..8876954a3678f 100644 --- a/patches/v8/cherry-pick-1234770.patch +++ b/patches/v8/cherry-pick-1234770.patch @@ -1,8 +1,8 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Georg Neis -Date: Mon Aug 9 09:57:12 2021 +0200 - -Subject: Merged: [compiler] Fix a bug in MachineOperatorReducer's BitfieldCheck +Date: Mon, 9 Aug 2021 09:57:12 +0200 +Subject: Merged: [compiler] Fix a bug in MachineOperatorReducer's + BitfieldCheck Revision: 574ca6b71c6160d38b5fcf4b8e133bc7f6ba2387 @@ -21,7 +21,7 @@ Cr-Branched-From: 7744dce208a555494e4a33e24fadc71ea20b3895-refs/heads/9.3.345@{# Cr-Branched-From: 4b6b4cabf3b6a20cdfda72b369df49f3311c4344-refs/heads/master@{#75728} diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc -index 5d61dfac6a..b4b16f931f 100644 +index 5d61dfac6ab46687b0adde2ff9777a0252e16494..b4b16f931f0927e9b683f38b393b0d275727f25e 100644 --- a/src/compiler/machine-operator-reducer.cc +++ b/src/compiler/machine-operator-reducer.cc @@ -1718,11 +1718,21 @@ Reduction MachineOperatorReducer::ReduceWordNAnd(Node* node) {