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" |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 22 | #include "utils/scoped_arena_allocator.h" |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | // Type of growable bitmap for memory tuning. |
| 27 | enum OatBitMapKind { |
| 28 | kBitMapMisc = 0, |
| 29 | kBitMapUse, |
| 30 | kBitMapDef, |
| 31 | kBitMapLiveIn, |
| 32 | kBitMapBMatrix, |
| 33 | kBitMapDominators, |
| 34 | kBitMapIDominated, |
| 35 | kBitMapDomFrontier, |
| 36 | kBitMapPhi, |
| 37 | kBitMapTmpBlocks, |
| 38 | kBitMapInputBlocks, |
| 39 | kBitMapRegisterV, |
| 40 | kBitMapTempSSARegisterV, |
| 41 | kBitMapNullCheck, |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 42 | kBitMapClInitCheck, |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 43 | kBitMapTmpBlockV, |
| 44 | kBitMapPredecessors, |
| 45 | kNumBitMapKinds |
| 46 | }; |
| 47 | |
| 48 | std::ostream& operator<<(std::ostream& os, const OatBitMapKind& kind); |
| 49 | |
| 50 | /* |
| 51 | * A BitVector implementation that uses Arena allocation. |
| 52 | */ |
| 53 | class ArenaBitVector : public BitVector { |
| 54 | public: |
| 55 | ArenaBitVector(ArenaAllocator* arena, uint32_t start_bits, bool expandable, |
| 56 | OatBitMapKind kind = kBitMapMisc); |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 57 | ArenaBitVector(ScopedArenaAllocator* arena, uint32_t start_bits, bool expandable, |
| 58 | OatBitMapKind kind = kBitMapMisc); |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 59 | ~ArenaBitVector() {} |
| 60 | |
| 61 | static void* operator new(size_t size, ArenaAllocator* arena) { |
Vladimir Marko | 83cc7ae | 2014-02-12 18:02:05 +0000 | [diff] [blame] | 62 | return arena->Alloc(sizeof(ArenaBitVector), kArenaAllocGrowableBitMap); |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 63 | } |
Vladimir Marko | bfea9c2 | 2014-01-17 17:49:33 +0000 | [diff] [blame] | 64 | static void* operator new(size_t size, ScopedArenaAllocator* arena) { |
| 65 | return arena->Alloc(sizeof(ArenaBitVector), kArenaAllocGrowableBitMap); |
| 66 | } |
Nicolas Geoffray | 0e33643 | 2014-02-26 18:24:38 +0000 | [diff] [blame] | 67 | static void operator delete(void* p) {} // Nop. |
| 68 | |
| 69 | private: |
| 70 | const OatBitMapKind kind_; // for memory use tuning. TODO: currently unused. |
| 71 | }; |
| 72 | |
| 73 | |
| 74 | } // namespace art |
| 75 | |
| 76 | #endif // ART_COMPILER_UTILS_ARENA_BIT_VECTOR_H_ |