blob: b7117bd223c04b8c0f16c7c2d54cb7ce7278f9af [file] [log] [blame]
Ian Rogerse63db272014-07-15 15:36:11 -07001/*
2 * Copyright (C) 2011 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_DEX_QUICK_COMPILER_CALLBACKS_H_
18#define ART_COMPILER_DEX_QUICK_COMPILER_CALLBACKS_H_
19
20#include "compiler_callbacks.h"
Nicolas Geoffray6bb7f1b2016-11-03 10:52:49 +000021#include "verifier/verifier_deps.h"
Ian Rogerse63db272014-07-15 15:36:11 -070022
23namespace art {
24
Mathieu Chartier9e050df2017-08-09 10:05:47 -070025class CompilerDriver;
Andreas Gampee9934582018-01-19 21:23:04 -080026class DexFile;
Ian Rogerse63db272014-07-15 15:36:11 -070027class VerificationResults;
Ian Rogerse63db272014-07-15 15:36:11 -070028
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010029class QuickCompilerCallbacks final : public CompilerCallbacks {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010030 public:
31 explicit QuickCompilerCallbacks(CompilerCallbacks::CallbackMode mode)
Andreas Gampee9934582018-01-19 21:23:04 -080032 : CompilerCallbacks(mode), dex_files_(nullptr) {}
Ian Rogerse63db272014-07-15 15:36:11 -070033
Nicolas Geoffray486dda02017-09-11 14:15:52 +010034 ~QuickCompilerCallbacks() { }
Ian Rogerse63db272014-07-15 15:36:11 -070035
Nicolas Geoffray486dda02017-09-11 14:15:52 +010036 void MethodVerified(verifier::MethodVerifier* verifier)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010037 REQUIRES_SHARED(Locks::mutator_lock_) override;
Ian Rogerse63db272014-07-15 15:36:11 -070038
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010039 void ClassRejected(ClassReference ref) override;
Ian Rogerse63db272014-07-15 15:36:11 -070040
Nicolas Geoffray486dda02017-09-11 14:15:52 +010041 // We are running in an environment where we can call patchoat safely so we should.
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010042 bool IsRelocationPossible() override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010043 return true;
44 }
Alex Lighta59dd802014-07-02 16:28:08 -070045
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010046 verifier::VerifierDeps* GetVerifierDeps() const override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010047 return verifier_deps_.get();
48 }
David Brazdilca3c8c32016-09-06 14:04:48 +010049
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010050 void SetVerifierDeps(verifier::VerifierDeps* deps) override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010051 verifier_deps_.reset(deps);
52 }
David Brazdilca3c8c32016-09-06 14:04:48 +010053
Nicolas Geoffray486dda02017-09-11 14:15:52 +010054 void SetVerificationResults(VerificationResults* verification_results) {
55 verification_results_ = verification_results;
56 }
Mathieu Chartiere01b6f62017-07-19 16:55:04 -070057
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010058 ClassStatus GetPreviousClassState(ClassReference ref) override;
Mathieu Chartier9e050df2017-08-09 10:05:47 -070059
Nicolas Geoffray486dda02017-09-11 14:15:52 +010060 void SetDoesClassUnloading(bool does_class_unloading, CompilerDriver* compiler_driver)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010061 override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010062 does_class_unloading_ = does_class_unloading;
63 compiler_driver_ = compiler_driver;
64 DCHECK(!does_class_unloading || compiler_driver_ != nullptr);
65 }
Mathieu Chartier9e050df2017-08-09 10:05:47 -070066
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010067 void UpdateClassState(ClassReference ref, ClassStatus state) override;
Nicolas Geoffray486dda02017-09-11 14:15:52 +010068
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010069 bool CanUseOatStatusForVerification(mirror::Class* klass) override
Andreas Gampee9934582018-01-19 21:23:04 -080070 REQUIRES_SHARED(Locks::mutator_lock_);
71
72 void SetDexFiles(const std::vector<const DexFile*>* dex_files) {
73 dex_files_ = dex_files;
74 }
75
Nicolas Geoffray486dda02017-09-11 14:15:52 +010076 private:
77 VerificationResults* verification_results_ = nullptr;
78 bool does_class_unloading_ = false;
79 CompilerDriver* compiler_driver_ = nullptr;
80 std::unique_ptr<verifier::VerifierDeps> verifier_deps_;
Andreas Gampee9934582018-01-19 21:23:04 -080081 const std::vector<const DexFile*>* dex_files_;
Ian Rogerse63db272014-07-15 15:36:11 -070082};
83
84} // namespace art
85
86#endif // ART_COMPILER_DEX_QUICK_COMPILER_CALLBACKS_H_