Skip to content

Commit dc61e09

Browse files
bnoordhuisBethGriggs
authored andcommitted
v8: fix load elimination liveness checks
This commit back-ports the implementations of IsRename() and MayAlias() from the upstream 8.0 branch wholesale. Fixes several bugs where V8's load elimination pass considered values to be alive when they weren't. Fixes: #31484 PR-URL: #31613 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Beth Griggs <[email protected]>
1 parent f29fb14 commit dc61e09

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

‎deps/v8/src/compiler/load-elimination.cc‎

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ bool IsRename(Node* node){
2121
switch (node->opcode()){
2222
case IrOpcode::kFinishRegion:
2323
case IrOpcode::kTypeGuard:
24-
returntrue;
24+
return!node->IsDead();
2525
default:
2626
returnfalse;
2727
}
@@ -35,12 +35,14 @@ Node* ResolveRenames(Node* node){
3535
}
3636

3737
boolMayAlias(Node* a, Node* b){
38-
if (a == b) returntrue;
39-
if (!NodeProperties::GetType(a).Maybe(NodeProperties::GetType(b))){
40-
returnfalse;
41-
}
42-
switch (b->opcode()){
43-
case IrOpcode::kAllocate:{
38+
if (a != b){
39+
if (!NodeProperties::GetType(a).Maybe(NodeProperties::GetType(b))){
40+
returnfalse;
41+
} elseif (IsRename(b)){
42+
returnMayAlias(a, b->InputAt(0));
43+
} elseif (IsRename(a)){
44+
returnMayAlias(a->InputAt(0), b);
45+
} elseif (b->opcode() == IrOpcode::kAllocate){
4446
switch (a->opcode()){
4547
case IrOpcode::kAllocate:
4648
case IrOpcode::kHeapConstant:
@@ -49,30 +51,15 @@ bool MayAlias(Node* a, Node* b){
4951
default:
5052
break;
5153
}
52-
break;
53-
}
54-
case IrOpcode::kFinishRegion:
55-
case IrOpcode::kTypeGuard:
56-
returnMayAlias(a, b->InputAt(0));
57-
default:
58-
break;
59-
}
60-
switch (a->opcode()){
61-
case IrOpcode::kAllocate:{
54+
} elseif (a->opcode() == IrOpcode::kAllocate){
6255
switch (b->opcode()){
6356
case IrOpcode::kHeapConstant:
6457
case IrOpcode::kParameter:
6558
returnfalse;
6659
default:
6760
break;
6861
}
69-
break;
7062
}
71-
case IrOpcode::kFinishRegion:
72-
case IrOpcode::kTypeGuard:
73-
returnMayAlias(a->InputAt(0), b);
74-
default:
75-
break;
7663
}
7764
returntrue;
7865
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2018 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+
for(x=0;x<10000;++x){
6+
[(x)=>x,[,4294967295].find((x)=>x),,2].includes('x',-0);
7+
}

0 commit comments

Comments
(0)