From 0663c225f8550ff8329c60a60f71038d9ae7bb74 Mon Sep 17 00:00:00 2001 From: mvstanton Date: Mon, 2 Jan 2017 05:23:25 -0800 Subject: [PATCH] [Turbofan] Simplified lowering to be done concurrently. R=jarin@chromium.org BUG=v8:5428 Review-Url: https://codereview.chromium.org/2611523002 Cr-Commit-Position: refs/heads/master@{#42012} --- src/compiler/pipeline.cc | 36 +++++++++++++-------------- src/compiler/representation-change.cc | 9 +++++-- src/compiler/simplified-lowering.cc | 19 ++++++-------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/compiler/pipeline.cc b/src/compiler/pipeline.cc index 10daaefc49..aec27c4f3c 100644 --- a/src/compiler/pipeline.cc +++ b/src/compiler/pipeline.cc @@ -945,8 +945,8 @@ struct EscapeAnalysisPhase { } }; -struct RepresentationSelectionPhase { - static const char* phase_name() { return "representation selection"; } +struct SimplifiedLoweringPhase { + static const char* phase_name() { return "simplified lowering"; } void Run(PipelineData* data, Zone* temp_zone) { SimplifiedLowering lowering(data->jsgraph(), temp_zone, @@ -1553,11 +1553,22 @@ bool PipelineImpl::CreateGraph() { } } - // 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); + // Do some hacky things to prepare generic lowering. + Run(); + + data->EndPhaseKind(); + + return true; +} + +bool PipelineImpl::OptimizeGraph(Linkage* linkage) { + PipelineData* data = this->data_; + + // Perform simplified lowering. 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("Simplified lowering", true); #ifdef DEBUG // From now on it is invalid to look at types on the nodes, because: @@ -1576,17 +1587,6 @@ bool PipelineImpl::CreateGraph() { RunPrintAndVerify("Untyped", true); #endif - // Do some hacky things to prepare generic lowering. - Run(); - - data->EndPhaseKind(); - - return true; -} - -bool PipelineImpl::OptimizeGraph(Linkage* linkage) { - PipelineData* data = this->data_; - // Run generic lowering pass. Run(); RunPrintAndVerify("Generic lowering", true); diff --git a/src/compiler/representation-change.cc b/src/compiler/representation-change.cc index 6e1341321c..7002b2d9b2 100644 --- a/src/compiler/representation-change.cc +++ b/src/compiler/representation-change.cc @@ -9,6 +9,7 @@ #include "src/base/bits.h" #include "src/code-factory.h" #include "src/compiler/machine-operator.h" +#include "src/compiler/node-matchers.h" namespace v8 { namespace internal { @@ -694,8 +695,12 @@ Node* RepresentationChanger::GetBitRepresentationFor( // Eagerly fold representation changes for constants. switch (node->opcode()) { case IrOpcode::kHeapConstant: { - Handle value = OpParameter>(node); - return jsgraph()->Int32Constant(value->BooleanValue() ? 1 : 0); + HeapObjectMatcher m(node); + if (m.Is(factory()->false_value())) { + return jsgraph()->Int32Constant(0); + } else if (m.Is(factory()->true_value())) { + return jsgraph()->Int32Constant(1); + } } default: break; diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc index be7fda558c..794fa85f09 100644 --- a/src/compiler/simplified-lowering.cc +++ b/src/compiler/simplified-lowering.cc @@ -1109,17 +1109,14 @@ class RepresentationSelector { return kNoWriteBarrier; } if (value_type->IsHeapConstant()) { - Handle value_object = value_type->AsHeapConstant()->Value(); - RootIndexMap root_index_map(jsgraph_->isolate()); - int root_index = root_index_map.Lookup(*value_object); - if (root_index != RootIndexMap::kInvalidRootIndex && - jsgraph_->isolate()->heap()->RootIsImmortalImmovable(root_index)) { - // Write barriers are unnecessary for immortal immovable roots. - return kNoWriteBarrier; - } - if (value_object->IsMap()) { - // Write barriers for storing maps are cheaper. - return kMapWriteBarrier; + Heap::RootListIndex root_index; + Heap* heap = jsgraph_->isolate()->heap(); + if (heap->IsRootHandle(value_type->AsHeapConstant()->Value(), + &root_index)) { + if (heap->RootIsImmortalImmovable(root_index)) { + // Write barriers are unnecessary for immortal immovable roots. + return kNoWriteBarrier; + } } } if (field_representation == MachineRepresentation::kTaggedPointer ||