• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 MPL2MPL_INCLUDE_CLASS_INIT_H
17 #define MPL2MPL_INCLUDE_CLASS_INIT_H
18 #include "phase_impl.h"
19 #include "class_hierarchy_phase.h"
20 #include "maple_phase_manager.h"
21 
22 namespace maple {
23 class ClassInit : public FuncOptimizeImpl {
24 public:
ClassInit(MIRModule & mod,KlassHierarchy * kh,bool dump)25     ClassInit(MIRModule &mod, KlassHierarchy *kh, bool dump) : FuncOptimizeImpl(mod, kh, dump) {}
26     ~ClassInit() = default;
27 
Clone()28     FuncOptimizeImpl *Clone() override
29     {
30         return new ClassInit(*this);
31     }
32 
33 private:
34     void GenClassInitCheckProfile(MIRFunction &func, const MIRSymbol &classInfo, StmtNode *clinit) const;
35     void GenPreClassInitCheck(MIRFunction &func, const MIRSymbol &classInfo, const StmtNode *clinit) const;
36     void GenPostClassInitCheck(MIRFunction &func, const MIRSymbol &classInfo, const StmtNode *clinit) const;
37     MIRSymbol *GetClassInfo(const std::string &classname);
38     bool CanRemoveClinitCheck(const std::string &clinitClassname) const;
39 };
40 
41 }  // namespace maple
42 #endif  // MPL2MPL_INCLUDE_CLASS_INIT_H
43