diff options
-rw-r--r-- | compiler/Android.mk | 3 | ||||
-rw-r--r-- | compiler/dex/bit_vector_block_iterator.cc | 32 | ||||
-rw-r--r-- | compiler/dex/bit_vector_block_iterator.h | 58 | ||||
-rw-r--r-- | compiler/dex/compiler_enums.h | 23 | ||||
-rw-r--r-- | compiler/dex/mir_graph.h | 2 | ||||
-rw-r--r-- | compiler/dex/ssa_transformation.cc | 5 | ||||
-rw-r--r-- | compiler/optimizing/nodes.h | 2 | ||||
-rw-r--r-- | compiler/utils/arena_allocator_test.cc | 2 | ||||
-rw-r--r-- | compiler/utils/arena_bit_vector.cc (renamed from compiler/dex/arena_bit_vector.cc) | 14 | ||||
-rw-r--r-- | compiler/utils/arena_bit_vector.h (renamed from compiler/dex/arena_bit_vector.h) | 59 |
10 files changed, 125 insertions, 75 deletions
diff --git a/compiler/Android.mk b/compiler/Android.mk index 77dc367..8f840cc 100644 --- a/compiler/Android.mk +++ b/compiler/Android.mk @@ -21,7 +21,6 @@ include art/build/Android.common.mk LIBART_COMPILER_SRC_FILES := \ compiled_method.cc \ dex/local_value_numbering.cc \ - dex/arena_bit_vector.cc \ dex/quick/arm/assemble_arm.cc \ dex/quick/arm/call_arm.cc \ dex/quick/arm/fp_arm.cc \ @@ -54,6 +53,7 @@ LIBART_COMPILER_SRC_FILES := \ dex/mir_optimization.cc \ dex/pass_driver.cc \ dex/bb_optimizations.cc \ + dex/bit_vector_block_iterator.cc \ dex/frontend.cc \ dex/mir_graph.cc \ dex/mir_analysis.cc \ @@ -72,6 +72,7 @@ LIBART_COMPILER_SRC_FILES := \ optimizing/nodes.cc \ trampolines/trampoline_compiler.cc \ utils/arena_allocator.cc \ + utils/arena_bit_vector.cc \ utils/arm/assembler_arm.cc \ utils/arm/managed_register_arm.cc \ utils/assembler.cc \ diff --git a/compiler/dex/bit_vector_block_iterator.cc b/compiler/dex/bit_vector_block_iterator.cc new file mode 100644 index 0000000..32d7d71 --- /dev/null +++ b/compiler/dex/bit_vector_block_iterator.cc @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "bit_vector_block_iterator.h" +#include "mir_graph.h" + +namespace art { + +BasicBlock* BitVectorBlockIterator::Next() { + int idx = internal_iterator_.Next(); + + if (idx == -1) { + return nullptr; + } + + return mir_graph_->GetBasicBlock(idx); +} + +} // namespace art diff --git a/compiler/dex/bit_vector_block_iterator.h b/compiler/dex/bit_vector_block_iterator.h new file mode 100644 index 0000000..0821e9e --- /dev/null +++ b/compiler/dex/bit_vector_block_iterator.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_COMPILER_DEX_BIT_VECTOR_BLOCK_ITERATOR_H_ +#define ART_COMPILER_DEX_BIT_VECTOR_BLOCK_ITERATOR_H_ + +#include "base/bit_vector.h" +#include "compiler_enums.h" +#include "utils/arena_bit_vector.h" +#include "utils/arena_allocator.h" +#include "compiler_ir.h" + +namespace art { + +class MIRGraph; + +/** + * @class BasicBlockIterator + * @brief Helper class to get the BasicBlocks when iterating through the ArenaBitVector. + */ +class BitVectorBlockIterator { + public: + explicit BitVectorBlockIterator(BitVector* bv, MIRGraph* mir_graph) + : mir_graph_(mir_graph), + internal_iterator_(bv) {} + + explicit BitVectorBlockIterator(BitVector* bv, CompilationUnit* c_unit) + : mir_graph_(c_unit->mir_graph.get()), + internal_iterator_(bv) {} + + BasicBlock* Next(); + + void* operator new(size_t size, ArenaAllocator* arena) { + return arena->Alloc(size, ArenaAllocator::kAllocGrowableArray); + }; + void operator delete(void* p) {} // Nop. + + private: + MIRGraph* const mir_graph_; + BitVector::Iterator internal_iterator_; +}; + +} // namespace art + +#endif // ART_COMPILER_DEX_BIT_VECTOR_BLOCK_ITERATOR_H_ diff --git a/compiler/dex/compiler_enums.h b/compiler/dex/compiler_enums.h index 2bc36a5..0cd9ba3 100644 --- a/compiler/dex/compiler_enums.h +++ b/compiler/dex/compiler_enums.h @@ -402,29 +402,6 @@ enum SelectInstructionKind { std::ostream& operator<<(std::ostream& os, const SelectInstructionKind& kind); -// Type of growable bitmap for memory tuning. -enum OatBitMapKind { - kBitMapMisc = 0, - kBitMapUse, - kBitMapDef, - kBitMapLiveIn, - kBitMapBMatrix, - kBitMapDominators, - kBitMapIDominated, - kBitMapDomFrontier, - kBitMapPhi, - kBitMapTmpBlocks, - kBitMapInputBlocks, - kBitMapRegisterV, - kBitMapTempSSARegisterV, - kBitMapNullCheck, - kBitMapTmpBlockV, - kBitMapPredecessors, - kNumBitMapKinds -}; - -std::ostream& operator<<(std::ostream& os, const OatBitMapKind& kind); - // LIR fixup kinds for Arm enum FixupKind { kFixupNone, diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h index 2174f67..d344055 100644 --- a/compiler/dex/mir_graph.h +++ b/compiler/dex/mir_graph.h @@ -20,7 +20,7 @@ #include "dex_file.h" #include "dex_instruction.h" #include "compiler_ir.h" -#include "arena_bit_vector.h" +#include "utils/arena_bit_vector.h" #include "utils/growable_array.h" namespace art { diff --git a/compiler/dex/ssa_transformation.cc b/compiler/dex/ssa_transformation.cc index 0f79f41..4e258ef 100644 --- a/compiler/dex/ssa_transformation.cc +++ b/compiler/dex/ssa_transformation.cc @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "bit_vector_block_iterator.h" #include "compiler_internals.h" #include "dataflow_iterator-inl.h" @@ -248,9 +249,9 @@ bool MIRGraph::ComputeDominanceFrontier(BasicBlock* bb) { } /* Calculate DF_up */ - ArenaBitVector::BasicBlockIterator it(bb->i_dominated, cu_); + BitVectorBlockIterator it(bb->i_dominated, cu_); for (BasicBlock *dominated_bb = it.Next(); dominated_bb != nullptr; dominated_bb = it.Next()) { - ArenaBitVector::BasicBlockIterator inner_it(dominated_bb->dom_frontier, cu_); + BitVectorBlockIterator inner_it(dominated_bb->dom_frontier, cu_); for (BasicBlock *df_up_block = inner_it.Next(); df_up_block != nullptr; df_up_block = inner_it.Next()) { CheckForDominanceFrontier(bb, df_up_block); diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 8f6a26c..3d5d531 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -18,8 +18,8 @@ #define ART_COMPILER_OPTIMIZING_NODES_H_ #include "utils/allocation.h" +#include "utils/arena_bit_vector.h" #include "utils/growable_array.h" -#include "dex/arena_bit_vector.h" namespace art { diff --git a/compiler/utils/arena_allocator_test.cc b/compiler/utils/arena_allocator_test.cc index b76fe74..7156540 100644 --- a/compiler/utils/arena_allocator_test.cc +++ b/compiler/utils/arena_allocator_test.cc @@ -14,9 +14,9 @@ * limitations under the License. */ -#include "dex/arena_bit_vector.h" #include "gtest/gtest.h" #include "utils/arena_allocator.h" +#include "utils/arena_bit_vector.h" namespace art { diff --git a/compiler/dex/arena_bit_vector.cc b/compiler/utils/arena_bit_vector.cc index 1b37b71..6f03524 100644 --- a/compiler/dex/arena_bit_vector.cc +++ b/compiler/utils/arena_bit_vector.cc @@ -14,8 +14,8 @@ * limitations under the License. */ -#include "compiler_internals.h" -#include "dex_file-inl.h" +#include "arena_allocator.h" +#include "arena_bit_vector.h" namespace art { @@ -44,14 +44,4 @@ ArenaBitVector::ArenaBitVector(ArenaAllocator* arena, unsigned int start_bits, bool expandable, OatBitMapKind kind) : BitVector(start_bits, expandable, new (arena) ArenaBitVectorAllocator(arena)), kind_(kind) {} -BasicBlock* ArenaBitVector::BasicBlockIterator::Next() { - int idx = internal_iterator_.Next(); - - if (idx == -1) { - return nullptr; - } - - return mir_graph_->GetBasicBlock(idx); -} - } // namespace art diff --git a/compiler/dex/arena_bit_vector.h b/compiler/utils/arena_bit_vector.h index cdd5c68..6c14617 100644 --- a/compiler/dex/arena_bit_vector.h +++ b/compiler/utils/arena_bit_vector.h @@ -14,51 +14,42 @@ * limitations under the License. */ -#ifndef ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ -#define ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ +#ifndef ART_COMPILER_UTILS_ARENA_BIT_VECTOR_H_ +#define ART_COMPILER_UTILS_ARENA_BIT_VECTOR_H_ #include "base/bit_vector.h" -#include "compiler_enums.h" #include "utils/arena_allocator.h" -#include "compiler_ir.h" namespace art { -// Forward declaration -class MIRGraph; +// Type of growable bitmap for memory tuning. +enum OatBitMapKind { + kBitMapMisc = 0, + kBitMapUse, + kBitMapDef, + kBitMapLiveIn, + kBitMapBMatrix, + kBitMapDominators, + kBitMapIDominated, + kBitMapDomFrontier, + kBitMapPhi, + kBitMapTmpBlocks, + kBitMapInputBlocks, + kBitMapRegisterV, + kBitMapTempSSARegisterV, + kBitMapNullCheck, + kBitMapTmpBlockV, + kBitMapPredecessors, + kNumBitMapKinds +}; + +std::ostream& operator<<(std::ostream& os, const OatBitMapKind& kind); /* * A BitVector implementation that uses Arena allocation. */ class ArenaBitVector : public BitVector { public: - /** - * @class BasicBlockIterator - * @brief Helper class to get the BasicBlocks when iterating through the ArenaBitVector. - */ - class BasicBlockIterator { - public: - explicit BasicBlockIterator(ArenaBitVector* bv, MIRGraph* mir_graph) - : mir_graph_(mir_graph), - internal_iterator_(bv) {} - - explicit BasicBlockIterator(ArenaBitVector* bv, CompilationUnit* c_unit) - : mir_graph_(c_unit->mir_graph.get()), - internal_iterator_(bv) {} - - BasicBlock* Next(); - - static void* operator new(size_t size, ArenaAllocator* arena) { - return arena->Alloc(sizeof(ArenaBitVector::BasicBlockIterator), - ArenaAllocator::kAllocGrowableArray); - }; - static void operator delete(void* p) {} // Nop. - - private: - MIRGraph* const mir_graph_; - Iterator internal_iterator_; - }; - ArenaBitVector(ArenaAllocator* arena, uint32_t start_bits, bool expandable, OatBitMapKind kind = kBitMapMisc); ~ArenaBitVector() {} @@ -75,4 +66,4 @@ class ArenaBitVector : public BitVector { } // namespace art -#endif // ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ +#endif // ART_COMPILER_UTILS_ARENA_BIT_VECTOR_H_ |