[turbofan] Handle CheckHeapObject as rename in LoadElimination.

Thus far the LoadElimination didn't consider CheckHeapObject a renaming
operation and would therefore miss opportunities to eliminate redundant
loads or map checks where the input is not checked for sminess in all
cases. This kind of pattern is very common with code that results from
builtin inlining in JSCallReducer, as here we don't unconditionally
insert CheckHeapObject nodes if we can tell from the graph that the
receiver already has a certain map (by walking the effect chain
upwards).

Bug: v8:8070
Change-Id: I980f382205757a754f93a5741de1ee08b75ee070
Reviewed-on: https://chromium-review.googlesource.com/1188129
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55408}
This commit is contained in:
Benedikt Meurer 2018-08-24 09:46:37 +02:00 committed by Commit Bot
parent 318e5230ea
commit e81480cd82

View File

@ -19,6 +19,7 @@ namespace {
bool IsRename(Node* node) {
switch (node->opcode()) {
case IrOpcode::kCheckHeapObject:
case IrOpcode::kFinishRegion:
case IrOpcode::kTypeGuard:
return true;
@ -35,12 +36,14 @@ Node* ResolveRenames(Node* node) {
}
bool MayAlias(Node* a, Node* b) {
if (a == b) return true;
if (!NodeProperties::GetType(a).Maybe(NodeProperties::GetType(b))) {
return false;
}
switch (b->opcode()) {
case IrOpcode::kAllocate: {
if (a != b) {
if (!NodeProperties::GetType(a).Maybe(NodeProperties::GetType(b))) {
return false;
} else if (IsRename(b)) {
return MayAlias(a, b->InputAt(0));
} else if (IsRename(a)) {
return MayAlias(a->InputAt(0), b);
} else if (b->opcode() == IrOpcode::kAllocate) {
switch (a->opcode()) {
case IrOpcode::kAllocate:
case IrOpcode::kHeapConstant:
@ -49,16 +52,7 @@ bool MayAlias(Node* a, Node* b) {
default:
break;
}
break;
}
case IrOpcode::kFinishRegion:
case IrOpcode::kTypeGuard:
return MayAlias(a, b->InputAt(0));
default:
break;
}
switch (a->opcode()) {
case IrOpcode::kAllocate: {
} else if (a->opcode() == IrOpcode::kAllocate) {
switch (b->opcode()) {
case IrOpcode::kHeapConstant:
case IrOpcode::kParameter:
@ -66,13 +60,7 @@ bool MayAlias(Node* a, Node* b) {
default:
break;
}
break;
}
case IrOpcode::kFinishRegion:
case IrOpcode::kTypeGuard:
return MayAlias(a->InputAt(0), b);
default:
break;
}
return true;
}