blob: 037a18ac7a20af63d77f6557bee2b8807367bb41 [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"
21#include "compiler_callbacks.h"
22#include "compiled_method.h"
23#include "dex/verification_results.h"
24#include "dex/quick/dex_file_to_method_inliner_map.h"
25#include "driver/compiler_driver.h"
26#include "driver/compiler_options.h"
27#include "oat_file.h"
28
29namespace art {
30
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080031class ArtMethod;
Mathieu Chartiere401d142015-04-22 13:56:20 -070032class InstructionSetFeatures;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080033
34namespace jit {
35
36class JitCompiler {
37 public:
38 static JitCompiler* Create();
39 virtual ~JitCompiler();
Mathieu Chartiere401d142015-04-22 13:56:20 -070040 bool CompileMethod(Thread* self, ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -070041 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080042 CompilerCallbacks* GetCompilerCallbacks() const;
43 size_t GetTotalCompileTime() const {
44 return total_time_;
45 }
Nicolas Geoffraya25dce92016-01-12 16:41:10 +000046 CompilerOptions* GetCompilerOptions() const {
47 return compiler_options_.get();
48 }
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080049
50 private:
51 uint64_t total_time_;
52 std::unique_ptr<CompilerOptions> compiler_options_;
53 std::unique_ptr<CumulativeLogger> cumulative_logger_;
54 std::unique_ptr<VerificationResults> verification_results_;
55 std::unique_ptr<DexFileToMethodInlinerMap> method_inliner_map_;
56 std::unique_ptr<CompilerCallbacks> callbacks_;
57 std::unique_ptr<CompilerDriver> compiler_driver_;
58 std::unique_ptr<const InstructionSetFeatures> instruction_set_features_;
Nicolas Geoffraya25dce92016-01-12 16:41:10 +000059 std::unique_ptr<File> perf_file_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080060
Nicolas Geoffray0c3c2662015-10-15 13:53:04 +010061 JitCompiler();
62
63 // This is in the compiler since the runtime doesn't have access to the compiled method
64 // structures.
65 bool AddToCodeCache(ArtMethod* method,
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +010066 const CompiledMethod* compiled_method)
67 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartier3130cdf2015-05-03 15:20:23 -070068
69 DISALLOW_COPY_AND_ASSIGN(JitCompiler);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080070};
71
72} // namespace jit
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080073} // namespace art
74
75#endif // ART_COMPILER_JIT_JIT_COMPILER_H_