blob: 37f6ff11a05923b9da079372ed494e9043f36fde [file] [log] [blame]
Mathieu Chartierf95a75e2017-11-03 15:25:52 -07001/*
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
24namespace art {
25
26class CompactDexWriter : public DexWriter {
27 public:
Mathieu Chartier3e0c5172017-11-12 12:58:40 -080028 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 Chartierf95a75e2017-11-03 15:25:52 -070034
35 protected:
Mathieu Chartier8892c6b2018-01-09 15:10:17 -080036 void WriteMemMap() OVERRIDE;
37
Mathieu Chartierf95a75e2017-11-03 15:25:52 -070038 void WriteHeader() OVERRIDE;
39
Mathieu Chartierf6e31472017-12-28 13:32:08 -080040 size_t GetHeaderSize() const OVERRIDE;
41
Mathieu Chartier8892c6b2018-01-09 15:10:17 -080042 uint32_t WriteDebugInfoOffsetTable(uint32_t offset);
43
Mathieu Chartierf95a75e2017-11-03 15:25:52 -070044 const CompactDexLevel compact_dex_level_;
45
Mathieu Chartier8892c6b2018-01-09 15:10:17 -080046 uint32_t WriteCodeItem(dex_ir::CodeItem* code_item, uint32_t offset, bool reserve_only) OVERRIDE;
47
48 void SortDebugInfosByMethodIndex();
49
Mathieu Chartierf95a75e2017-11-03 15:25:52 -070050 private:
Mathieu Chartier8892c6b2018-01-09 15:10:17 -080051 // 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 Chartierf95a75e2017-11-03 15:25:52 -070060 DISALLOW_COPY_AND_ASSIGN(CompactDexWriter);
61};
62
63} // namespace art
64
65#endif // ART_DEXLAYOUT_COMPACT_DEX_WRITER_H_