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