1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ART_COMPILER_OPTIMIZING_SHARPENING_H_
18 #define ART_COMPILER_OPTIMIZING_SHARPENING_H_
19 
20 #include "nodes.h"
21 #include "optimization.h"
22 
23 namespace art {
24 
25 class CodeGenerator;
26 class DexCompilationUnit;
27 
28 // Utility methods that try to improve the way we dispatch methods, and access
29 // types and strings.
30 class HSharpening {
31  public:
32   // Used by the builder and InstructionSimplifier.
33   static HInvokeStaticOrDirect::DispatchInfo SharpenInvokeStaticOrDirect(
34       ArtMethod* callee, CodeGenerator* codegen);
35 
36   // Used by the builder and the inliner.
37   static HLoadClass::LoadKind ComputeLoadClassKind(HLoadClass* load_class,
38                                                    CodeGenerator* codegen,
39                                                    const DexCompilationUnit& dex_compilation_unit)
40       REQUIRES_SHARED(Locks::mutator_lock_);
41 
42   // Used by the builder.
43   static TypeCheckKind ComputeTypeCheckKind(ObjPtr<mirror::Class> klass,
44                                             CodeGenerator* codegen,
45                                             bool needs_access_check)
46       REQUIRES_SHARED(Locks::mutator_lock_);
47 
48   // Used by the builder.
49   static void ProcessLoadString(HLoadString* load_string,
50                                 CodeGenerator* codegen,
51                                 const DexCompilationUnit& dex_compilation_unit,
52                                 VariableSizedHandleScope* handles);
53 };
54 
55 }  // namespace art
56 
57 #endif  // ART_COMPILER_OPTIMIZING_SHARPENING_H_
58