blob: 18632dc6c6752c7fe88a5b4fbbe6d51ce24d54fa [file] [log] [blame]
Vladimir Marko2b5eaa22013-12-13 13:59:30 +00001/*
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
Andreas Gampe7fbc4a52018-11-28 08:26:47 -080020#include "base/locks.h"
David Sehr312f3b22018-03-19 08:39:26 -070021#include "dex/class_reference.h"
Andreas Gampe5d3b0022017-08-31 10:36:31 -070022#include "class_status.h"
Vladimir Marko2b5eaa22013-12-13 13:59:30 +000023
24namespace art {
25
Mathieu Chartier9e050df2017-08-09 10:05:47 -070026class CompilerDriver;
27
Andreas Gampee9934582018-01-19 21:23:04 -080028namespace mirror {
29
30class Class;
31
32} // namespace mirror
33
Vladimir Marko2b5eaa22013-12-13 13:59:30 +000034namespace verifier {
35
36class MethodVerifier;
David Brazdilca3c8c32016-09-06 14:04:48 +010037class VerifierDeps;
Vladimir Marko2b5eaa22013-12-13 13:59:30 +000038
39} // namespace verifier
40
41class CompilerCallbacks {
Andreas Gampe4585f872015-03-27 23:45:15 -070042 public:
43 enum class CallbackMode { // private
44 kCompileBootImage,
45 kCompileApp
46 };
Vladimir Marko2b5eaa22013-12-13 13:59:30 +000047
Andreas Gampe4585f872015-03-27 23:45:15 -070048 virtual ~CompilerCallbacks() { }
Vladimir Marko2b5eaa22013-12-13 13:59:30 +000049
Andreas Gampe53e32d12015-12-09 21:03:23 -080050 virtual void MethodVerified(verifier::MethodVerifier* verifier)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070051 REQUIRES_SHARED(Locks::mutator_lock_) = 0;
Andreas Gampe4585f872015-03-27 23:45:15 -070052 virtual void ClassRejected(ClassReference ref) = 0;
Alex Lighta59dd802014-07-02 16:28:08 -070053
David Brazdilca3c8c32016-09-06 14:04:48 +010054 virtual verifier::VerifierDeps* GetVerifierDeps() const = 0;
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +000055 virtual void SetVerifierDeps(verifier::VerifierDeps* deps ATTRIBUTE_UNUSED) {}
David Brazdilca3c8c32016-09-06 14:04:48 +010056
Andreas Gampe5d3b0022017-08-31 10:36:31 -070057 // Return the class status of a previous stage of the compilation. This can be used, for example,
58 // when class unloading is enabled during multidex compilation.
59 virtual ClassStatus GetPreviousClassState(ClassReference ref ATTRIBUTE_UNUSED) {
Vladimir Marko2c64a832018-01-04 11:31:56 +000060 return ClassStatus::kNotReady;
Mathieu Chartier9e050df2017-08-09 10:05:47 -070061 }
62
63 virtual void SetDoesClassUnloading(bool does_class_unloading ATTRIBUTE_UNUSED,
64 CompilerDriver* compiler_driver ATTRIBUTE_UNUSED) {}
65
Andreas Gampe4585f872015-03-27 23:45:15 -070066 bool IsBootImage() {
67 return mode_ == CallbackMode::kCompileBootImage;
68 }
Andreas Gampe81c6f8d2015-03-25 17:19:53 -070069
Nicolas Geoffray486dda02017-09-11 14:15:52 +010070 virtual void UpdateClassState(ClassReference ref ATTRIBUTE_UNUSED,
71 ClassStatus state ATTRIBUTE_UNUSED) {}
72
Andreas Gampee9934582018-01-19 21:23:04 -080073 virtual bool CanUseOatStatusForVerification(mirror::Class* klass ATTRIBUTE_UNUSED)
74 REQUIRES_SHARED(Locks::mutator_lock_) {
75 return false;
76 }
77
Andreas Gampe4585f872015-03-27 23:45:15 -070078 protected:
79 explicit CompilerCallbacks(CallbackMode mode) : mode_(mode) { }
80
81 private:
82 // Whether the compiler is creating a boot image.
83 const CallbackMode mode_;
Vladimir Marko2b5eaa22013-12-13 13:59:30 +000084};
85
86} // namespace art
87
88#endif // ART_RUNTIME_COMPILER_CALLBACKS_H_