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