Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_UTILS_ARENA_BIT_VECTOR_H_ |
| 18 | #define ART_COMPILER_UTILS_ARENA_BIT_VECTOR_H_ |
| 19 | |
| 20 | #include "base/bit_vector.h" |
| 21 | #include "utils/arena_allocator.h" |
| 22 | |
| 23 | namespace art { |
| 24 | |
| 25 | // Type of growable bitmap for memory tuning. |
| 26 | enum OatBitMapKind { |
| 27 | kBitMapMisc = 0, |
| 28 | kBitMapUse, |
| 29 | kBitMapDef, |
| 30 | kBitMapLiveIn, |
| 31 | kBitMapBMatrix, |
| 32 | kBitMapDominators, |
| 33 | kBitMapIDominated, |
| 34 | kBitMapDomFrontier, |
| 35 | kBitMapPhi, |
| 36 | kBitMapTmpBlocks, |
| 37 | kBitMapInputBlocks, |
| 38 | kBitMapRegisterV, |
| 39 | kBitMapTempSSARegisterV, |
| 40 | kBitMapNullCheck, |
| 41 | kBitMapTmpBlockV, |
| 42 | kBitMapPredecessors, |
| 43 | kNumBitMapKinds |
| 44 | }; |
| 45 | |
| 46 | std::ostream& operator<<(std::ostream& os, const OatBitMapKind& kind); |
| 47 | |
| 48 | /* |
| 49 | * A BitVector implementation that uses Arena allocation. |
| 50 | */ |
| 51 | class ArenaBitVector : public BitVector { |
| 52 | public: |
| 53 | ArenaBitVector(ArenaAllocator* arena, uint32_t start_bits, bool expandable, |
| 54 | OatBitMapKind kind = kBitMapMisc); |
| 55 | ~ArenaBitVector() {} |
| 56 | |
| 57 | static void* operator new(size_t size, ArenaAllocator* arena) { |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame^] | 58 | return arena->Alloc(sizeof(ArenaBitVector), kArenaAllocGrowableBitMap); |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 59 | } |
| 60 | static void operator delete(void* p) {} // Nop. |
| 61 | |
| 62 | private: |
| 63 | const OatBitMapKind kind_; // for memory use tuning. TODO: currently unused. |
| 64 | }; |
| 65 | |
| 66 | |
| 67 | } // namespace art |
| 68 | |
| 69 | #endif // ART_COMPILER_UTILS_ARENA_BIT_VECTOR_H_ |