1 /* 2 * Copyright (C) 2013 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_RUNTIME_COMPILER_CALLBACKS_H_ 18 #define ART_RUNTIME_COMPILER_CALLBACKS_H_ 19 20 #include "base/locks.h" 21 #include "class_status.h" 22 #include "dex/class_reference.h" 23 #include "dex/method_reference.h" 24 25 namespace art { 26 27 class CompilerDriver; 28 29 namespace mirror { 30 31 class Class; 32 33 } // namespace mirror 34 35 namespace verifier { 36 37 class VerifierDeps; 38 39 } // namespace verifier 40 41 class CompilerCallbacks { 42 public: 43 enum class CallbackMode { // private 44 kCompileBootImage, 45 kCompileApp 46 }; 47 ~CompilerCallbacks()48 virtual ~CompilerCallbacks() { } 49 50 virtual void AddUncompilableMethod(MethodReference ref) = 0; 51 virtual void ClassRejected(ClassReference ref) = 0; 52 53 virtual verifier::VerifierDeps* GetVerifierDeps() const = 0; SetVerifierDeps(verifier::VerifierDeps * deps ATTRIBUTE_UNUSED)54 virtual void SetVerifierDeps(verifier::VerifierDeps* deps ATTRIBUTE_UNUSED) {} 55 56 // Return the class status of a previous stage of the compilation. This can be used, for example, 57 // when class unloading is enabled during multidex compilation. GetPreviousClassState(ClassReference ref ATTRIBUTE_UNUSED)58 virtual ClassStatus GetPreviousClassState(ClassReference ref ATTRIBUTE_UNUSED) { 59 return ClassStatus::kNotReady; 60 } 61 SetDoesClassUnloading(bool does_class_unloading ATTRIBUTE_UNUSED,CompilerDriver * compiler_driver ATTRIBUTE_UNUSED)62 virtual void SetDoesClassUnloading(bool does_class_unloading ATTRIBUTE_UNUSED, 63 CompilerDriver* compiler_driver ATTRIBUTE_UNUSED) {} 64 IsBootImage()65 bool IsBootImage() { 66 return mode_ == CallbackMode::kCompileBootImage; 67 } 68 UpdateClassState(ClassReference ref ATTRIBUTE_UNUSED,ClassStatus state ATTRIBUTE_UNUSED)69 virtual void UpdateClassState(ClassReference ref ATTRIBUTE_UNUSED, 70 ClassStatus state ATTRIBUTE_UNUSED) {} 71 CanUseOatStatusForVerification(mirror::Class * klass ATTRIBUTE_UNUSED)72 virtual bool CanUseOatStatusForVerification(mirror::Class* klass ATTRIBUTE_UNUSED) 73 REQUIRES_SHARED(Locks::mutator_lock_) { 74 return false; 75 } 76 77 protected: CompilerCallbacks(CallbackMode mode)78 explicit CompilerCallbacks(CallbackMode mode) : mode_(mode) { } 79 80 private: 81 // Whether the compiler is creating a boot image. 82 const CallbackMode mode_; 83 }; 84 85 } // namespace art 86 87 #endif // ART_RUNTIME_COMPILER_CALLBACKS_H_ 88