From 85c9f0018ac5b671973b916a85692cec2a0c6d3d Mon Sep 17 00:00:00 2001 From: bmeurer Date: Wed, 29 Jun 2016 01:17:21 -0700 Subject: [PATCH] [turbofan] Run representation selection without the Typer decorator. It's not safe to magically compute types during representation selection, so better disable the Typer decorator before we start to do the representation/truncation analysis. This will also allow us to move to a world where we can run representation selection concurrently eventually. R=jarin@chromium.org Review-Url: https://codereview.chromium.org/2103363004 Cr-Commit-Position: refs/heads/master@{#37367} --- src/compiler/pipeline.cc | 10 +++++---- src/compiler/simplified-lowering.cc | 32 ++++++++++++++--------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc index d592000911..73d484ba19 100644 --- a/src/compiler/pipeline.cc +++ b/src/compiler/pipeline.cc @@ -1444,12 +1444,14 @@ bool PipelineImpl::CreateGraph() { Run(); RunPrintAndVerify("Escape Analysed"); } - - // Select representations. - Run(); - RunPrintAndVerify("Representations selected", true); } + // Select representations. This has to run w/o the Typer decorator, because + // we cannot compute meaningful types anyways, and the computed types might + // even conflict with the representation/truncation logic. + Run(); + RunPrintAndVerify("Representations selected", true); + #ifdef DEBUG // From now on it is invalid to look at types on the nodes, because: // diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc index 1905c75107..b36b777224 100644 --- a/src/compiler/simplified-lowering.cc +++ b/src/compiler/simplified-lowering.cc @@ -671,6 +671,11 @@ class RepresentationSelector { Type* GetUpperBound(Node* node) { return NodeProperties::GetType(node); } + bool InputCannotBe(Node* node, Type* type) { + DCHECK_EQ(1, node->op()->ValueInputCount()); + return !GetUpperBound(node->InputAt(0))->Maybe(type); + } + bool InputIs(Node* node, Type* type) { DCHECK_EQ(1, node->op()->ValueInputCount()); return GetUpperBound(node->InputAt(0))->Is(type); @@ -1703,11 +1708,11 @@ class RepresentationSelector { return; } case IrOpcode::kCheckTaggedPointer: { - VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); - if (lower()) { - if (InputIs(node, Type::TaggedPointer())) { - DeferReplacement(node, node->InputAt(0)); - } + if (InputCannotBe(node, Type::SignedSmall())) { + VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); + if (lower()) DeferReplacement(node, node->InputAt(0)); + } else { + VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); } return; } @@ -1719,11 +1724,6 @@ class RepresentationSelector { if (lower()) DeferReplacement(node, node->InputAt(0)); } else { VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged); - if (lower()) { - if (InputIs(node, Type::TaggedSigned())) { - DeferReplacement(node, node->InputAt(0)); - } - } } return; } @@ -1743,15 +1743,15 @@ class RepresentationSelector { } case IrOpcode::kStoreField: { FieldAccess access = FieldAccessOf(node->op()); + WriteBarrierKind write_barrier_kind = WriteBarrierKindFor( + access.base_is_tagged, access.machine_type.representation(), + access.offset, access.type, node->InputAt(1)); ProcessInput(node, 0, UseInfoForBasePointer(access)); ProcessInput(node, 1, TruncatingUseInfoFromRepresentation( access.machine_type.representation())); ProcessRemainingInputs(node, 2); SetOutput(node, MachineRepresentation::kNone); if (lower()) { - WriteBarrierKind write_barrier_kind = WriteBarrierKindFor( - access.base_is_tagged, access.machine_type.representation(), - access.offset, access.type, node->InputAt(1)); if (write_barrier_kind < access.write_barrier_kind) { access.write_barrier_kind = write_barrier_kind; NodeProperties::ChangeOp( @@ -1816,6 +1816,9 @@ class RepresentationSelector { } case IrOpcode::kStoreElement: { ElementAccess access = ElementAccessOf(node->op()); + WriteBarrierKind write_barrier_kind = WriteBarrierKindFor( + access.base_is_tagged, access.machine_type.representation(), + access.type, node->InputAt(2)); ProcessInput(node, 0, UseInfoForBasePointer(access)); // base ProcessInput(node, 1, UseInfo::TruncatingWord32()); // index ProcessInput(node, 2, @@ -1824,9 +1827,6 @@ class RepresentationSelector { ProcessRemainingInputs(node, 3); SetOutput(node, MachineRepresentation::kNone); if (lower()) { - WriteBarrierKind write_barrier_kind = WriteBarrierKindFor( - access.base_is_tagged, access.machine_type.representation(), - access.type, node->InputAt(2)); if (write_barrier_kind < access.write_barrier_kind) { access.write_barrier_kind = write_barrier_kind; NodeProperties::ChangeOp(