blob: 578a1f56e76fbb3a026b896f59b90490508f5b7d [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
Vladimir Marko327497e2019-03-04 12:53:20 +000017#ifndef ART_DEX2OAT_DEX_QUICK_COMPILER_CALLBACKS_H_
18#define ART_DEX2OAT_DEX_QUICK_COMPILER_CALLBACKS_H_
Ian Rogerse63db272014-07-15 15:36:11 -070019
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
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010041 verifier::VerifierDeps* GetVerifierDeps() const override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010042 return verifier_deps_.get();
43 }
David Brazdilca3c8c32016-09-06 14:04:48 +010044
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010045 void SetVerifierDeps(verifier::VerifierDeps* deps) override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010046 verifier_deps_.reset(deps);
47 }
David Brazdilca3c8c32016-09-06 14:04:48 +010048
Nicolas Geoffray486dda02017-09-11 14:15:52 +010049 void SetVerificationResults(VerificationResults* verification_results) {
50 verification_results_ = verification_results;
51 }
Mathieu Chartiere01b6f62017-07-19 16:55:04 -070052
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010053 ClassStatus GetPreviousClassState(ClassReference ref) override;
Mathieu Chartier9e050df2017-08-09 10:05:47 -070054
Nicolas Geoffray486dda02017-09-11 14:15:52 +010055 void SetDoesClassUnloading(bool does_class_unloading, CompilerDriver* compiler_driver)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010056 override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010057 does_class_unloading_ = does_class_unloading;
58 compiler_driver_ = compiler_driver;
59 DCHECK(!does_class_unloading || compiler_driver_ != nullptr);
60 }
Mathieu Chartier9e050df2017-08-09 10:05:47 -070061
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010062 void UpdateClassState(ClassReference ref, ClassStatus state) override;
Nicolas Geoffray486dda02017-09-11 14:15:52 +010063
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010064 bool CanUseOatStatusForVerification(mirror::Class* klass) override
Andreas Gampee9934582018-01-19 21:23:04 -080065 REQUIRES_SHARED(Locks::mutator_lock_);
66
67 void SetDexFiles(const std::vector<const DexFile*>* dex_files) {
68 dex_files_ = dex_files;
69 }
70
Nicolas Geoffray486dda02017-09-11 14:15:52 +010071 private:
72 VerificationResults* verification_results_ = nullptr;
73 bool does_class_unloading_ = false;
74 CompilerDriver* compiler_driver_ = nullptr;
75 std::unique_ptr<verifier::VerifierDeps> verifier_deps_;
Andreas Gampee9934582018-01-19 21:23:04 -080076 const std::vector<const DexFile*>* dex_files_;
Ian Rogerse63db272014-07-15 15:36:11 -070077};
78
79} // namespace art
80
Vladimir Marko327497e2019-03-04 12:53:20 +000081#endif // ART_DEX2OAT_DEX_QUICK_COMPILER_CALLBACKS_H_