diff options
author | David Brazdil <dbrazdil@google.com> | 2015-01-23 14:39:08 +0000 |
---|---|---|
committer | David Brazdil <dbrazdil@google.com> | 2015-02-04 13:47:49 +0000 |
commit | 5e8b137d28c840b128e2488f954cccee3e86db14 (patch) | |
tree | c56e4c709ce07d605ab4b754e89f7739264feb73 /compiler/optimizing/builder.cc | |
parent | f9af19413333c271192c3b11425f865bd8054c0c (diff) | |
download | android_art-5e8b137d28c840b128e2488f954cccee3e86db14.tar.gz android_art-5e8b137d28c840b128e2488f954cccee3e86db14.tar.bz2 android_art-5e8b137d28c840b128e2488f954cccee3e86db14.zip |
Create HGraph outside Builder, print timings
This patch refactors the way HGraph objects are created, moving the
instantiation out of the Builder class and creating the CodeGenerator
earlier. The patch uses this to build a single interface for printing
timings info and dumping the CFG.
Change-Id: I2eb63eabf28e2d0f5cdc7affaa690c3a4b1bdd21
Diffstat (limited to 'compiler/optimizing/builder.cc')
-rw-r--r-- | compiler/optimizing/builder.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index c50960666a..20a1b03a67 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -259,13 +259,14 @@ bool HGraphBuilder::SkipCompilation(size_t number_of_dex_instructions, return false; } -HGraph* HGraphBuilder::BuildGraph(const DexFile::CodeItem& code_item, int start_instruction_id) { +bool HGraphBuilder::BuildGraph(const DexFile::CodeItem& code_item) { + DCHECK(graph_->GetBlocks().IsEmpty()); + const uint16_t* code_ptr = code_item.insns_; const uint16_t* code_end = code_item.insns_ + code_item.insns_size_in_code_units_; code_start_ = code_ptr; // Setup the graph with the entry block and exit block. - graph_ = new (arena_) HGraph(arena_, start_instruction_id); entry_block_ = new (arena_) HBasicBlock(graph_, 0); graph_->AddBlock(entry_block_); exit_block_ = new (arena_) HBasicBlock(graph_, kNoDexPc); @@ -289,7 +290,7 @@ HGraph* HGraphBuilder::BuildGraph(const DexFile::CodeItem& code_item, int start_ // Note that the compiler driver is null when unit testing. if ((compiler_driver_ != nullptr) && SkipCompilation(number_of_dex_instructions, number_of_blocks, number_of_branches)) { - return nullptr; + return false; } // Also create blocks for catch handlers. @@ -319,7 +320,7 @@ HGraph* HGraphBuilder::BuildGraph(const DexFile::CodeItem& code_item, int start_ MaybeUpdateCurrentBlock(dex_pc); const Instruction& instruction = *Instruction::At(code_ptr); if (!AnalyzeDexInstruction(instruction, dex_pc)) { - return nullptr; + return false; } dex_pc += instruction.SizeInCodeUnits(); code_ptr += instruction.SizeInCodeUnits(); @@ -331,7 +332,8 @@ HGraph* HGraphBuilder::BuildGraph(const DexFile::CodeItem& code_item, int start_ // Add the suspend check to the entry block. entry_block_->AddInstruction(new (arena_) HSuspendCheck(0)); entry_block_->AddInstruction(new (arena_) HGoto()); - return graph_; + + return true; } void HGraphBuilder::MaybeUpdateCurrentBlock(size_t index) { |