blob: d35ae66e051e9f004062621c1a4acf697deeee4c [file] [log] [blame]
Vladimir Markodc151b22015-10-15 18:02:30 +01001/*
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 "optimization.h"
21
22namespace art {
23
24class CodeGenerator;
25class CompilerDriver;
26class DexCompilationUnit;
27class HInvokeStaticOrDirect;
28
29// Optimization that tries to improve the way we dispatch methods and access types,
30// fields, etc. Besides actual method sharpening based on receiver type (for example
31// virtual->direct), this includes selecting the best available dispatch for
32// invoke-static/-direct based on code generator support.
33class HSharpening : public HOptimization {
34 public:
35 HSharpening(HGraph* graph,
36 CodeGenerator* codegen,
37 const DexCompilationUnit& compilation_unit,
38 CompilerDriver* compiler_driver)
39 : HOptimization(graph, kSharpeningPassName),
40 codegen_(codegen),
41 compilation_unit_(compilation_unit),
42 compiler_driver_(compiler_driver) { }
43
44 void Run() OVERRIDE;
45
46 static constexpr const char* kSharpeningPassName = "sharpening";
47
48 private:
49 void ProcessInvokeStaticOrDirect(HInvokeStaticOrDirect* invoke);
Vladimir Markodbb7f5b2016-03-30 13:23:58 +010050 void ProcessLoadClass(HLoadClass* load_class);
Vladimir Markocac5a7e2016-02-22 10:39:50 +000051 void ProcessLoadString(HLoadString* load_string);
Vladimir Markodc151b22015-10-15 18:02:30 +010052
53 CodeGenerator* codegen_;
54 const DexCompilationUnit& compilation_unit_;
55 CompilerDriver* compiler_driver_;
56};
57
58} // namespace art
59
60#endif // ART_COMPILER_OPTIMIZING_SHARPENING_H_