blob: 8e9966db0e26f65e7e5850ea7b88bf47e113cba0 [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"
Nicolas Geoffray0d60a2b2020-06-17 14:31:56 +010021#include "compilation_kind.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080022
David Srbecky46b53532019-08-06 13:39:05 +010023#include "jit/jit.h"
24
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080025namespace art {
26
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080027class ArtMethod;
Vladimir Marko038924b2019-02-19 15:09:35 +000028class Compiler;
Vladimir Markoa0431112018-06-25 09:32:54 +010029class CompilerOptions;
30class Thread;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080031
32namespace jit {
33
Vladimir Markoa0431112018-06-25 09:32:54 +010034class JitLogger;
Nicolas Geoffray7f7539b2019-06-06 16:20:54 +010035class JitMemoryRegion;
Vladimir Markoa0431112018-06-25 09:32:54 +010036
David Srbecky46b53532019-08-06 13:39:05 +010037class JitCompiler : public JitCompilerInterface {
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080038 public:
39 static JitCompiler* Create();
40 virtual ~JitCompiler();
Nicolas Geoffraybcd94c82016-03-03 13:23:33 +000041
42 // Compilation entrypoint. Returns whether the compilation succeeded.
Nicolas Geoffray7f7539b2019-06-06 16:20:54 +010043 bool CompileMethod(
Nicolas Geoffray0d60a2b2020-06-17 14:31:56 +010044 Thread* self, JitMemoryRegion* region, ArtMethod* method, CompilationKind kind)
David Srbecky46b53532019-08-06 13:39:05 +010045 REQUIRES_SHARED(Locks::mutator_lock_) override;
Nicolas Geoffraybcd94c82016-03-03 13:23:33 +000046
Vladimir Markoa0431112018-06-25 09:32:54 +010047 const CompilerOptions& GetCompilerOptions() const {
48 return *compiler_options_.get();
Nicolas Geoffraya25dce92016-01-12 16:41:10 +000049 }
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +000050
Nicolas Geoffray8a608fa2021-11-29 14:47:21 +000051 bool IsBaselineCompiler() const override;
52
David Srbecky46b53532019-08-06 13:39:05 +010053 bool GenerateDebugInfo() override;
54
55 void ParseCompilerOptions() override;
56
57 void TypesLoaded(mirror::Class**, size_t count) REQUIRES_SHARED(Locks::mutator_lock_) override;
Nicolas Geoffrayc9de61c2018-11-27 17:34:31 +000058
David Srbeckye09b87e2019-08-19 21:31:31 +010059 std::vector<uint8_t> PackElfFileForJIT(ArrayRef<const JITCodeEntry*> elf_files,
David Srbecky8fc2f952019-07-31 18:40:09 +010060 ArrayRef<const void*> removed_symbols,
61 bool compress,
62 /*out*/ size_t* num_symbols) override;
63
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080064 private:
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080065 std::unique_ptr<CompilerOptions> compiler_options_;
Vladimir Marko038924b2019-02-19 15:09:35 +000066 std::unique_ptr<Compiler> compiler_;
xueliang.zhong383b57d2016-10-04 11:19:17 +010067 std::unique_ptr<JitLogger> jit_logger_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080068
Nicolas Geoffray0c3c2662015-10-15 13:53:04 +010069 JitCompiler();
70
Mathieu Chartier3130cdf2015-05-03 15:20:23 -070071 DISALLOW_COPY_AND_ASSIGN(JitCompiler);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080072};
73
74} // namespace jit
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080075} // namespace art
76
77#endif // ART_COMPILER_JIT_JIT_COMPILER_H_