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