Mathieu Chartier | f95a75e | 2017-11-03 15:25:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | * Header file of an in-memory representation of DEX files. |
| 17 | */ |
| 18 | |
| 19 | #ifndef ART_DEXLAYOUT_COMPACT_DEX_WRITER_H_ |
| 20 | #define ART_DEXLAYOUT_COMPACT_DEX_WRITER_H_ |
| 21 | |
| 22 | #include "dex_writer.h" |
| 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | class CompactDexWriter : public DexWriter { |
| 27 | public: |
Mathieu Chartier | 3e0c517 | 2017-11-12 12:58:40 -0800 | [diff] [blame] | 28 | CompactDexWriter(dex_ir::Header* header, |
| 29 | MemMap* mem_map, |
| 30 | DexLayout* dex_layout, |
| 31 | CompactDexLevel compact_dex_level) |
| 32 | : DexWriter(header, mem_map, dex_layout, /*compute_offsets*/ true), |
| 33 | compact_dex_level_(compact_dex_level) {} |
Mathieu Chartier | f95a75e | 2017-11-03 15:25:52 -0700 | [diff] [blame] | 34 | |
| 35 | protected: |
Mathieu Chartier | 8892c6b | 2018-01-09 15:10:17 -0800 | [diff] [blame] | 36 | void WriteMemMap() OVERRIDE; |
| 37 | |
Mathieu Chartier | f95a75e | 2017-11-03 15:25:52 -0700 | [diff] [blame] | 38 | void WriteHeader() OVERRIDE; |
| 39 | |
Mathieu Chartier | f6e3147 | 2017-12-28 13:32:08 -0800 | [diff] [blame] | 40 | size_t GetHeaderSize() const OVERRIDE; |
| 41 | |
Mathieu Chartier | 8892c6b | 2018-01-09 15:10:17 -0800 | [diff] [blame] | 42 | uint32_t WriteDebugInfoOffsetTable(uint32_t offset); |
| 43 | |
Mathieu Chartier | f95a75e | 2017-11-03 15:25:52 -0700 | [diff] [blame] | 44 | const CompactDexLevel compact_dex_level_; |
| 45 | |
Mathieu Chartier | 8892c6b | 2018-01-09 15:10:17 -0800 | [diff] [blame] | 46 | uint32_t WriteCodeItem(dex_ir::CodeItem* code_item, uint32_t offset, bool reserve_only) OVERRIDE; |
| 47 | |
| 48 | void SortDebugInfosByMethodIndex(); |
| 49 | |
Mathieu Chartier | f95a75e | 2017-11-03 15:25:52 -0700 | [diff] [blame] | 50 | private: |
Mathieu Chartier | 8892c6b | 2018-01-09 15:10:17 -0800 | [diff] [blame] | 51 | // Position in the compact dex file for the debug info table data starts. |
| 52 | uint32_t debug_info_offsets_pos_ = 0u; |
| 53 | |
| 54 | // Offset into the debug info table data where the lookup table is. |
| 55 | uint32_t debug_info_offsets_table_offset_ = 0u; |
| 56 | |
| 57 | // Base offset of where debug info starts in the dex file. |
| 58 | uint32_t debug_info_base_ = 0u; |
| 59 | |
Mathieu Chartier | f95a75e | 2017-11-03 15:25:52 -0700 | [diff] [blame] | 60 | DISALLOW_COPY_AND_ASSIGN(CompactDexWriter); |
| 61 | }; |
| 62 | |
| 63 | } // namespace art |
| 64 | |
| 65 | #endif // ART_DEXLAYOUT_COMPACT_DEX_WRITER_H_ |