diff options
author | Vladimir Marko <vmarko@google.com> | 2016-05-17 16:30:10 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2016-06-02 19:04:20 +0100 |
commit | 372f10e5b0b34e2bb6e2b79aeba6c441e14afd1f (patch) | |
tree | 1f29c2467c8909ef0e0147f37f176caa1bcd2ccc /compiler/optimizing/graph_visualizer.cc | |
parent | 1b66fdf3f33c72dfdda4d31f6f17b6a0d8607402 (diff) |
Refactor handling of input records.
Introduce HInstruction::GetInputRecords(), a new virtual
function that returns an ArrayRef<> to all input records.
Implement all other functions dealing with input records as
wrappers around GetInputRecords(). Rewrite functions that
previously used multiple virtual calls to deal with input
records, especially in loops, to prefetch the ArrayRef<>
only once for each instruction. Besides avoiding all the
extra calls, this also allows the compiler (clang++) to
perform additional optimizations.
This speeds up the Nexus 5 boot image compilation by ~0.5s
(4% of "Compile Dex File", 2% of dex2oat time) on AOSP ToT.
Change-Id: Id8ebe0fb9405e38d918972a11bd724146e4ca578
Diffstat (limited to 'compiler/optimizing/graph_visualizer.cc')
-rw-r--r-- | compiler/optimizing/graph_visualizer.cc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index 6aec463549..3084a4ff2b 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -497,12 +497,13 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { void PrintInstruction(HInstruction* instruction) { output_ << instruction->DebugName(); - if (instruction->InputCount() > 0) { - StringList inputs; - for (HInputIterator it(instruction); !it.Done(); it.Advance()) { - inputs.NewEntryStream() << GetTypeId(it.Current()->GetType()) << it.Current()->GetId(); + auto&& inputs = instruction->GetInputs(); + if (!inputs.empty()) { + StringList input_list; + for (const HInstruction* input : inputs) { + input_list.NewEntryStream() << GetTypeId(input->GetType()) << input->GetId(); } - StartAttributeStream() << inputs; + StartAttributeStream() << input_list; } instruction->Accept(this); if (instruction->HasEnvironment()) { @@ -544,12 +545,12 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { StartAttributeStream("liveness") << instruction->GetLifetimePosition(); LocationSummary* locations = instruction->GetLocations(); if (locations != nullptr) { - StringList inputs; - for (size_t i = 0; i < instruction->InputCount(); ++i) { - DumpLocation(inputs.NewEntryStream(), locations->InAt(i)); + StringList input_list; + for (size_t i = 0, e = locations->GetInputCount(); i < e; ++i) { + DumpLocation(input_list.NewEntryStream(), locations->InAt(i)); } std::ostream& attr = StartAttributeStream("locations"); - attr << inputs << "->"; + attr << input_list << "->"; DumpLocation(attr, locations->Out()); } } @@ -739,8 +740,8 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { HInstruction* instruction = it.Current(); output_ << instruction->GetId() << " " << GetTypeId(instruction->GetType()) << instruction->GetId() << "[ "; - for (HInputIterator inputs(instruction); !inputs.Done(); inputs.Advance()) { - output_ << inputs.Current()->GetId() << " "; + for (const HInstruction* input : instruction->GetInputs()) { + output_ << input->GetId() << " "; } output_ << "]\n"; } |