Index: src/compiler/js-builtin-reducer.cc |
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
index a09e6f1b2139b95677dc258b87dfe8187403d68b..8bc03fae6239b850a901aab90cc41bf09ee30983 100644 |
--- a/src/compiler/js-builtin-reducer.cc |
+++ b/src/compiler/js-builtin-reducer.cc |
@@ -107,6 +107,19 @@ JSBuiltinReducer::JSBuiltinReducer(Editor* editor, JSGraph* jsgraph, |
namespace { |
+// TODO(turbofan): Shall we move this to the NodeProperties? Or some (untyped) |
+// alias analyzer? |
+bool IsSame(Node* a, Node* b) { |
+ if (a == b) { |
+ return true; |
+ } else if (a->opcode() == IrOpcode::kCheckHeapObject) { |
+ return IsSame(a->InputAt(0), b); |
+ } else if (b->opcode() == IrOpcode::kCheckHeapObject) { |
+ return IsSame(a, b->InputAt(0)); |
+ } |
+ return false; |
+} |
+ |
MaybeHandle<Map> GetMapWitness(Node* node) { |
Node* receiver = NodeProperties::GetValueInput(node, 1); |
Node* effect = NodeProperties::GetEffectInput(node); |
@@ -114,7 +127,7 @@ MaybeHandle<Map> GetMapWitness(Node* node) { |
// for the {receiver}, and if so use that map for the lowering below. |
for (Node* dominator = effect;;) { |
if (dominator->opcode() == IrOpcode::kCheckMaps && |
- dominator->InputAt(0) == receiver) { |
+ IsSame(dominator->InputAt(0), receiver)) { |
if (dominator->op()->ValueInputCount() == 2) { |
HeapObjectMatcher m(dominator->InputAt(1)); |
if (m.HasValue()) return Handle<Map>::cast(m.Value()); |
@@ -331,7 +344,7 @@ bool HasInstanceTypeWitness(Node* receiver, Node* effect, |
InstanceType instance_type) { |
for (Node* dominator = effect;;) { |
if (dominator->opcode() == IrOpcode::kCheckMaps && |
- dominator->InputAt(0) == receiver) { |
+ IsSame(dominator->InputAt(0), receiver)) { |
// Check if all maps have the given {instance_type}. |
for (int i = 1; i < dominator->op()->ValueInputCount(); ++i) { |
Node* const map = NodeProperties::GetValueInput(dominator, i); |
@@ -922,7 +935,7 @@ Node* GetStringWitness(Node* node) { |
// the lowering below. |
for (Node* dominator = effect;;) { |
if (dominator->opcode() == IrOpcode::kCheckString && |
- dominator->InputAt(0) == receiver) { |
+ IsSame(dominator->InputAt(0), receiver)) { |
return dominator; |
} |
if (dominator->op()->EffectInputCount() != 1) { |