blob: 08764991ea02085598636f9ff430e4ca3e4814c8 [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
31class InstructionSetFeatures;
32
33namespace mirror {
34class ArtMethod;
35}
36
37namespace jit {
38
39class JitCompiler {
40 public:
41 static JitCompiler* Create();
42 virtual ~JitCompiler();
43 bool CompileMethod(Thread* self, mirror::ArtMethod* method)
44 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
45 // This is in the compiler since the runtime doesn't have access to the compiled method
46 // structures.
47 bool AddToCodeCache(mirror::ArtMethod* method, const CompiledMethod* compiled_method,
48 OatFile::OatMethod* out_method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
49 CompilerCallbacks* GetCompilerCallbacks() const;
50 size_t GetTotalCompileTime() const {
51 return total_time_;
52 }
53
54 private:
55 uint64_t total_time_;
56 std::unique_ptr<CompilerOptions> compiler_options_;
57 std::unique_ptr<CumulativeLogger> cumulative_logger_;
58 std::unique_ptr<VerificationResults> verification_results_;
59 std::unique_ptr<DexFileToMethodInlinerMap> method_inliner_map_;
60 std::unique_ptr<CompilerCallbacks> callbacks_;
61 std::unique_ptr<CompilerDriver> compiler_driver_;
62 std::unique_ptr<const InstructionSetFeatures> instruction_set_features_;
63
64 explicit JitCompiler();
65 uint8_t* WriteMethodHeaderAndCode(
66 const CompiledMethod* compiled_method, uint8_t* reserve_begin, uint8_t* reserve_end,
67 const uint8_t* mapping_table, const uint8_t* vmap_table, const uint8_t* gc_map);
68 bool MakeExecutable(CompiledMethod* compiled_method, mirror::ArtMethod* method)
69 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
70};
71
72} // namespace jit
73
74} // namespace art
75
76#endif // ART_COMPILER_JIT_JIT_COMPILER_H_