1 /* 2 * Copyright (c) 2021 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 16 #ifndef PANDA_RUNTIME_INCLUDE_IMTABLE_BUILDER_H_ 17 #define PANDA_RUNTIME_INCLUDE_IMTABLE_BUILDER_H_ 18 19 #include "libpandabase/macros.h" 20 #include "libpandafile/class_data_accessor.h" 21 #include "runtime/include/class-inl.h" 22 #include "runtime/include/mem/panda_smart_pointers.h" 23 24 namespace panda { 25 26 class ClassLinker; 27 28 class IMTableBuilder { 29 public: 30 static constexpr uint32_t OVERSIZE_MULTIPLE = 2; 31 32 void Build(const panda_file::ClassDataAccessor *cda, ITable itable); 33 34 void Build(ITable itable, bool is_interface); 35 36 void UpdateClass(Class *klass); 37 38 bool AddMethod(panda::Span<panda::Method *> imtable, uint32_t imtable_size, uint32_t id, Method *method); 39 40 void DumpIMTable(Class *klass); 41 GetIMTSize()42 size_t GetIMTSize() const 43 { 44 return imt_size; 45 } 46 SetIMTSize(size_t size)47 void SetIMTSize(size_t size) 48 { 49 imt_size = size; 50 } 51 52 IMTableBuilder() = default; 53 ~IMTableBuilder() = default; 54 55 NO_COPY_SEMANTIC(IMTableBuilder); 56 NO_MOVE_SEMANTIC(IMTableBuilder); 57 58 private: 59 size_t imt_size = 0; 60 }; 61 62 } // namespace panda 63 64 #endif // PANDA_RUNTIME_INCLUDE_IMTABLE_BUILDER_H_ 65