• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
21 #include "compilation_kind.h"
22 
23 #include "jit/jit.h"
24 
25 namespace art {
26 
27 class ArtMethod;
28 class Compiler;
29 class CompilerOptions;
30 class Thread;
31 
32 namespace jit {
33 
34 class JitLogger;
35 class JitMemoryRegion;
36 
37 class JitCompiler : public JitCompilerInterface {
38  public:
39   static JitCompiler* Create();
40   virtual ~JitCompiler();
41 
42   // Compilation entrypoint. Returns whether the compilation succeeded.
43   bool CompileMethod(
44       Thread* self, JitMemoryRegion* region, ArtMethod* method, CompilationKind kind)
45       REQUIRES_SHARED(Locks::mutator_lock_) override;
46 
GetCompilerOptions()47   const CompilerOptions& GetCompilerOptions() const {
48     return *compiler_options_.get();
49   }
50 
51   bool GenerateDebugInfo() override;
52 
53   void ParseCompilerOptions() override;
54 
55   void TypesLoaded(mirror::Class**, size_t count) REQUIRES_SHARED(Locks::mutator_lock_) override;
56 
57   std::vector<uint8_t> PackElfFileForJIT(ArrayRef<const JITCodeEntry*> elf_files,
58                                          ArrayRef<const void*> removed_symbols,
59                                          bool compress,
60                                          /*out*/ size_t* num_symbols) override;
61 
62  private:
63   std::unique_ptr<CompilerOptions> compiler_options_;
64   std::unique_ptr<Compiler> compiler_;
65   std::unique_ptr<JitLogger> jit_logger_;
66 
67   JitCompiler();
68 
69   DISALLOW_COPY_AND_ASSIGN(JitCompiler);
70 };
71 
72 }  // namespace jit
73 }  // namespace art
74 
75 #endif  // ART_COMPILER_JIT_JIT_COMPILER_H_
76