Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: cherry-pick 2004594a46c8 from v8 (#33884)
* chore: cherry-pick 2004594a46c8 from v8 * chore: update patches * Trigger Build Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
- Loading branch information
1 parent
76f4ced
commit bd9c7c4
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Nico Hartmann <nicohartmann@chromium.org> | ||
Date: Thu, 17 Mar 2022 17:03:12 +0100 | ||
Subject: Fix NumberConstant used with Word32 rep in ISel | ||
|
||
Bug: chromium:1304658 | ||
|
||
(cherry picked from commit bbea5909c797dec7c620b9fee43d80a1420c2e08) | ||
|
||
No-Try: true | ||
No-Presubmit: true | ||
No-Tree-Checks: true | ||
Change-Id: I6a82603a7c5de5ae8f5a895990c1a904bbdd39b2 | ||
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3532263 | ||
Auto-Submit: Nico Hartmann <nicohartmann@chromium.org> | ||
Commit-Queue: Tobias Tebbi <tebbi@chromium.org> | ||
Cr-Original-Commit-Position: refs/heads/main@{#79526} | ||
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3541919 | ||
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> | ||
Commit-Queue: Roger Felipe Zanoni da Silva <rzanoni@google.com> | ||
Cr-Commit-Position: refs/branch-heads/9.6@{#58} | ||
Cr-Branched-From: 0b7bda016178bf438f09b3c93da572ae3663a1f7-refs/heads/9.6.180@{#1} | ||
Cr-Branched-From: 41a5a247d9430b953e38631e88d17790306f7a4c-refs/heads/main@{#77244} | ||
|
||
diff --git a/src/compiler/backend/instruction-selector.cc b/src/compiler/backend/instruction-selector.cc | ||
index f279ea15900976fd57ef577b67e4cbeca3eb6374..92c11e09b4445e1fe477ca1614166dd6999baf64 100644 | ||
--- a/src/compiler/backend/instruction-selector.cc | ||
+++ b/src/compiler/backend/instruction-selector.cc | ||
@@ -30,6 +30,14 @@ namespace v8 { | ||
namespace internal { | ||
namespace compiler { | ||
|
||
+Smi NumberConstantToSmi(Node* node) { | ||
+ DCHECK_EQ(node->opcode(), IrOpcode::kNumberConstant); | ||
+ const double d = OpParameter<double>(node->op()); | ||
+ Smi smi = Smi::FromInt(static_cast<int32_t>(d)); | ||
+ CHECK_EQ(smi.value(), d); | ||
+ return smi; | ||
+} | ||
+ | ||
InstructionSelector::InstructionSelector( | ||
Zone* zone, size_t node_count, Linkage* linkage, | ||
InstructionSequence* sequence, Schedule* schedule, | ||
@@ -502,11 +510,17 @@ InstructionOperand OperandForDeopt(Isolate* isolate, OperandGenerator* g, | ||
switch (input->opcode()) { | ||
case IrOpcode::kInt32Constant: | ||
case IrOpcode::kInt64Constant: | ||
- case IrOpcode::kNumberConstant: | ||
case IrOpcode::kFloat32Constant: | ||
case IrOpcode::kFloat64Constant: | ||
case IrOpcode::kDelayedStringConstant: | ||
return g->UseImmediate(input); | ||
+ case IrOpcode::kNumberConstant: | ||
+ if (rep == MachineRepresentation::kWord32) { | ||
+ Smi smi = NumberConstantToSmi(input); | ||
+ return g->UseImmediate(static_cast<int32_t>(smi.ptr())); | ||
+ } else { | ||
+ return g->UseImmediate(input); | ||
+ } | ||
case IrOpcode::kCompressedHeapConstant: | ||
case IrOpcode::kHeapConstant: { | ||
if (!CanBeTaggedOrCompressedPointer(rep)) { |