Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 1 | /* |
| 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 Geoffray | 0d60a2b | 2020-06-17 14:31:56 +0100 | [diff] [blame] | 21 | #include "compilation_kind.h" |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 22 | |
David Srbecky | 46b5353 | 2019-08-06 13:39:05 +0100 | [diff] [blame] | 23 | #include "jit/jit.h" |
| 24 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 25 | namespace art { |
| 26 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 27 | class ArtMethod; |
Vladimir Marko | 038924b | 2019-02-19 15:09:35 +0000 | [diff] [blame] | 28 | class Compiler; |
Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 29 | class CompilerOptions; |
| 30 | class Thread; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 31 | |
| 32 | namespace jit { |
| 33 | |
Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 34 | class JitLogger; |
Nicolas Geoffray | 7f7539b | 2019-06-06 16:20:54 +0100 | [diff] [blame] | 35 | class JitMemoryRegion; |
Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 36 | |
David Srbecky | 46b5353 | 2019-08-06 13:39:05 +0100 | [diff] [blame] | 37 | class JitCompiler : public JitCompilerInterface { |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 38 | public: |
| 39 | static JitCompiler* Create(); |
| 40 | virtual ~JitCompiler(); |
Nicolas Geoffray | bcd94c8 | 2016-03-03 13:23:33 +0000 | [diff] [blame] | 41 | |
| 42 | // Compilation entrypoint. Returns whether the compilation succeeded. |
Nicolas Geoffray | 7f7539b | 2019-06-06 16:20:54 +0100 | [diff] [blame] | 43 | bool CompileMethod( |
Nicolas Geoffray | 0d60a2b | 2020-06-17 14:31:56 +0100 | [diff] [blame] | 44 | Thread* self, JitMemoryRegion* region, ArtMethod* method, CompilationKind kind) |
David Srbecky | 46b5353 | 2019-08-06 13:39:05 +0100 | [diff] [blame] | 45 | REQUIRES_SHARED(Locks::mutator_lock_) override; |
Nicolas Geoffray | bcd94c8 | 2016-03-03 13:23:33 +0000 | [diff] [blame] | 46 | |
Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 47 | const CompilerOptions& GetCompilerOptions() const { |
| 48 | return *compiler_options_.get(); |
Nicolas Geoffray | a25dce9 | 2016-01-12 16:41:10 +0000 | [diff] [blame] | 49 | } |
Nicolas Geoffray | c9de61c | 2018-11-27 17:34:31 +0000 | [diff] [blame] | 50 | |
Nicolas Geoffray | 8a608fa | 2021-11-29 14:47:21 +0000 | [diff] [blame] | 51 | bool IsBaselineCompiler() const override; |
| 52 | |
David Srbecky | 46b5353 | 2019-08-06 13:39:05 +0100 | [diff] [blame] | 53 | bool GenerateDebugInfo() override; |
| 54 | |
| 55 | void ParseCompilerOptions() override; |
| 56 | |
| 57 | void TypesLoaded(mirror::Class**, size_t count) REQUIRES_SHARED(Locks::mutator_lock_) override; |
Nicolas Geoffray | c9de61c | 2018-11-27 17:34:31 +0000 | [diff] [blame] | 58 | |
David Srbecky | e09b87e | 2019-08-19 21:31:31 +0100 | [diff] [blame] | 59 | std::vector<uint8_t> PackElfFileForJIT(ArrayRef<const JITCodeEntry*> elf_files, |
David Srbecky | 8fc2f95 | 2019-07-31 18:40:09 +0100 | [diff] [blame] | 60 | ArrayRef<const void*> removed_symbols, |
| 61 | bool compress, |
| 62 | /*out*/ size_t* num_symbols) override; |
| 63 | |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 64 | private: |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 65 | std::unique_ptr<CompilerOptions> compiler_options_; |
Vladimir Marko | 038924b | 2019-02-19 15:09:35 +0000 | [diff] [blame] | 66 | std::unique_ptr<Compiler> compiler_; |
xueliang.zhong | 383b57d | 2016-10-04 11:19:17 +0100 | [diff] [blame] | 67 | std::unique_ptr<JitLogger> jit_logger_; |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 68 | |
Nicolas Geoffray | 0c3c266 | 2015-10-15 13:53:04 +0100 | [diff] [blame] | 69 | JitCompiler(); |
| 70 | |
Mathieu Chartier | 3130cdf | 2015-05-03 15:20:23 -0700 | [diff] [blame] | 71 | DISALLOW_COPY_AND_ASSIGN(JitCompiler); |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | } // namespace jit |
Mathieu Chartier | e5f13e5 | 2015-02-24 09:37:21 -0800 | [diff] [blame] | 75 | } // namespace art |
| 76 | |
| 77 | #endif // ART_COMPILER_JIT_JIT_COMPILER_H_ |