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 "compiled_method.h" 22 #include "jit_logger.h" 23 #include "driver/compiler_driver.h" 24 #include "driver/compiler_options.h" 25 26 namespace art { 27 28 class ArtMethod; 29 class InstructionSetFeatures; 30 31 namespace jit { 32 33 class JitCompiler { 34 public: 35 static JitCompiler* Create(); 36 virtual ~JitCompiler(); 37 38 // Compilation entrypoint. Returns whether the compilation succeeded. 39 bool CompileMethod(Thread* self, ArtMethod* method, bool osr) 40 REQUIRES_SHARED(Locks::mutator_lock_); 41 GetCompilerOptions()42 CompilerOptions* GetCompilerOptions() const { 43 return compiler_options_.get(); 44 } GetCompilerDriver()45 CompilerDriver* GetCompilerDriver() const { 46 return compiler_driver_.get(); 47 } 48 49 private: 50 std::unique_ptr<CompilerOptions> compiler_options_; 51 std::unique_ptr<CumulativeLogger> cumulative_logger_; 52 std::unique_ptr<CompilerDriver> compiler_driver_; 53 std::unique_ptr<const InstructionSetFeatures> instruction_set_features_; 54 std::unique_ptr<JitLogger> jit_logger_; 55 56 JitCompiler(); 57 58 // This is in the compiler since the runtime doesn't have access to the compiled method 59 // structures. 60 bool AddToCodeCache(ArtMethod* method, const CompiledMethod* compiled_method) 61 REQUIRES_SHARED(Locks::mutator_lock_); 62 63 DISALLOW_COPY_AND_ASSIGN(JitCompiler); 64 }; 65 66 } // namespace jit 67 } // namespace art 68 69 #endif // ART_COMPILER_JIT_JIT_COMPILER_H_ 70