1 /**
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef PANDA_QUICKENER_QUICKENER_H
16 #define PANDA_QUICKENER_QUICKENER_H
17 
18 #include "file.h"
19 #include "file_item_container.h"
20 #include "file_items.h"
21 #include "libpandafile/class_data_accessor-inl.h"
22 #include "source_lang_enum.h"
23 #include "bytecode_instruction.h"
24 #include "bytecode_instruction-inl.h"
25 #include "bytecode_instruction_enum_gen.h"
26 #include "debug_data_accessor.h"
27 #include <cstdint>
28 
29 namespace ark::quick {
30 class Quickener final {
31 public:
Quickener(panda_file::ItemContainer *container, panda_file::File *file, const std::map<panda_file::File::EntityId, panda_file::BaseItem *> *items)32     Quickener(panda_file::ItemContainer *container, panda_file::File *file,
33               const std::map<panda_file::File::EntityId, panda_file::BaseItem *> *items)
34         : container_(container), file_(file), items_(items) {};
35 
36     void QuickContainer();
37 
38 private:
39     panda_file::CodeItem *GetQuickenedCode(panda_file::CodeItem *code,
40                                            const std::unordered_map<uint32_t, uint32_t> *translation_map);
41 
42     panda_file::DebugInfoItem *CreateDebugInfoItem(panda_file::File::EntityId debug_info_id);
43 
44     void UpdateDebugInfo(panda_file::DebugInfoItem *debug_info_item, panda_file::File::EntityId debug_info_id);
45 
46     panda_file::ItemContainer *container_;
47 
48     panda_file::File *file_;
49 
50     std::unordered_map<panda_file::File::EntityId, panda_file::BaseItem *> ids_done;
51 
52     const std::map<panda_file::File::EntityId, panda_file::BaseItem *> *items_;
53 };
54 
55 #include <translation_table_gen.h>
56 }  // namespace ark::quick
57 
58 #endif  // PANDA_QUICKENER_QUICKENER_H
59