blob: 533dccf2163afcfa54a8e49966a462a0e8302288 [file] [log] [blame]
Mathieu Chartiere5f13e52015-02-24 09:37:21 -08001/*
2 * Copyright 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_JIT_JIT_COMPILER_H_
18#define ART_COMPILER_JIT_JIT_COMPILER_H_
19
20#include "base/mutex.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080021#include "compiled_method.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080022#include "dex/quick/dex_file_to_method_inliner_map.h"
23#include "driver/compiler_driver.h"
24#include "driver/compiler_options.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080025
26namespace art {
27
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080028class ArtMethod;
Mathieu Chartiere401d142015-04-22 13:56:20 -070029class InstructionSetFeatures;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080030
31namespace jit {
32
33class JitCompiler {
34 public:
35 static JitCompiler* Create();
36 virtual ~JitCompiler();
Nicolas Geoffraybcd94c82016-03-03 13:23:33 +000037
38 // Compilation entrypoint. Returns whether the compilation succeeded.
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +000039 bool CompileMethod(Thread* self, ArtMethod* method, bool osr)
Mathieu Chartier90443472015-07-16 20:32:27 -070040 SHARED_REQUIRES(Locks::mutator_lock_);
Nicolas Geoffraybcd94c82016-03-03 13:23:33 +000041
Nicolas Geoffraya25dce92016-01-12 16:41:10 +000042 CompilerOptions* GetCompilerOptions() const {
43 return compiler_options_.get();
44 }
David Srbecky5d811202016-03-08 13:21:22 +000045 CompilerDriver* GetCompilerDriver() const {
46 return compiler_driver_.get();
47 }
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080048
49 private:
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080050 std::unique_ptr<CompilerOptions> compiler_options_;
51 std::unique_ptr<CumulativeLogger> cumulative_logger_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080052 std::unique_ptr<DexFileToMethodInlinerMap> method_inliner_map_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080053 std::unique_ptr<CompilerDriver> compiler_driver_;
54 std::unique_ptr<const InstructionSetFeatures> instruction_set_features_;
Nicolas Geoffraya25dce92016-01-12 16:41:10 +000055 std::unique_ptr<File> perf_file_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080056
Nicolas Geoffray0c3c2662015-10-15 13:53:04 +010057 JitCompiler();
58
59 // This is in the compiler since the runtime doesn't have access to the compiled method
60 // structures.
Nicolas Geoffraybcd94c82016-03-03 13:23:33 +000061 bool AddToCodeCache(ArtMethod* method, const CompiledMethod* compiled_method)
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +010062 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartier3130cdf2015-05-03 15:20:23 -070063
64 DISALLOW_COPY_AND_ASSIGN(JitCompiler);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080065};
66
67} // namespace jit
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080068} // namespace art
69
70#endif // ART_COMPILER_JIT_JIT_COMPILER_H_