1 /** 2 * Copyright (c) 2021-2022 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_CHA_H 16 #define PANDA_CHA_H 17 18 #include "runtime/include/class.h" 19 20 namespace panda { 21 22 class ClassHierarchyAnalysis final { 23 public: 24 void Update(Class *klass); 25 void AddDependency(Method *callee, Method *caller); 26 27 private: 28 void InvalidateMethod(Method *method, PandaSet<Method *> *dependent_methods); 29 void InvalidateMethods(const PandaSet<Method *> &methods); 30 void UpdateMethod(Method *method); 31 bool HasSingleImplementation(Method *method); 32 void SetHasSingleImplementation(Method *method, bool single_implementation); GetLock()33 auto &GetLock() 34 { 35 return lock_; 36 } 37 38 private: 39 PandaMap<Method *, PandaSet<Method *>> dependency_map_; 40 os::memory::Mutex lock_; 41 }; 42 43 } // namespace panda 44 45 #endif // PANDA_CHA_H 46