diff options
author | 2015-03-16 17:31:52 +0000 | |
---|---|---|
committer | 2015-03-24 17:28:37 +0000 | |
commit | 46e2a3915aa68c77426b71e95b9f3658250646b7 (patch) | |
tree | 2b0a4470b05291894db73c631fe94f0fdff8c46b /compiler/optimizing/code_generator.cc | |
parent | bce0855ca1dbb1fa226c5b6a81760272ce0b64ef (diff) |
ART: Boolean simplifier
The optimization recognizes the negation pattern generated by 'javac'
and replaces it with a single condition. To this end, boolean values
are now consistently assumed to be represented by an integer.
This is a first optimization which deletes blocks from the HGraph and
does so by replacing the corresponding entries with null. Hence,
existing code can continue indexing the list of blocks with the block
ID, but must check for null when iterating over the list.
Change-Id: I7779da69cfa925c6521938ad0bcc11bc52335583
Diffstat (limited to 'compiler/optimizing/code_generator.cc')
-rw-r--r-- | compiler/optimizing/code_generator.cc | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc index 561dcb7315..22d5ac6ac9 100644 --- a/compiler/optimizing/code_generator.cc +++ b/compiler/optimizing/code_generator.cc @@ -40,16 +40,6 @@ size_t CodeGenerator::GetCacheOffset(uint32_t index) { return mirror::ObjectArray<mirror::Object>::OffsetOfElement(index).SizeValue(); } -static bool IsSingleGoto(HBasicBlock* block) { - HLoopInformation* loop_info = block->GetLoopInformation(); - // TODO: Remove the null check b/19084197. - return (block->GetFirstInstruction() != nullptr) - && (block->GetFirstInstruction() == block->GetLastInstruction()) - && block->GetLastInstruction()->IsGoto() - // Back edges generate the suspend check. - && (loop_info == nullptr || !loop_info->IsBackEdge(block)); -} - void CodeGenerator::CompileBaseline(CodeAllocator* allocator, bool is_leaf) { Initialize(); if (!is_leaf) { @@ -74,7 +64,7 @@ bool CodeGenerator::GoesToNextBlock(HBasicBlock* current, HBasicBlock* next) con HBasicBlock* CodeGenerator::GetNextBlockToEmit() const { for (size_t i = current_block_index_ + 1; i < block_order_->Size(); ++i) { HBasicBlock* block = block_order_->Get(i); - if (!IsSingleGoto(block)) { + if (!block->IsSingleGoto()) { return block; } } @@ -82,7 +72,7 @@ HBasicBlock* CodeGenerator::GetNextBlockToEmit() const { } HBasicBlock* CodeGenerator::FirstNonEmptyBlock(HBasicBlock* block) const { - while (IsSingleGoto(block)) { + while (block->IsSingleGoto()) { block = block->GetSuccessors().Get(0); } return block; @@ -97,7 +87,7 @@ void CodeGenerator::CompileInternal(CodeAllocator* allocator, bool is_baseline) // Don't generate code for an empty block. Its predecessors will branch to its successor // directly. Also, the label of that block will not be emitted, so this helps catch // errors where we reference that label. - if (IsSingleGoto(block)) continue; + if (block->IsSingleGoto()) continue; Bind(block); for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) { HInstruction* current = it.Current(); |