blob: 4447e02ccb7b0659160ed62d454fb9e5d5db7d26 [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 Geoffray9e050ab2021-07-14 14:59:25 +010036 void AddUncompilableMethod(MethodReference ref) override;
Ian Rogerse63db272014-07-15 15:36:11 -070037
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010038 void ClassRejected(ClassReference ref) override;
Ian Rogerse63db272014-07-15 15:36:11 -070039
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010040 verifier::VerifierDeps* GetVerifierDeps() const override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010041 return verifier_deps_.get();
42 }
David Brazdilca3c8c32016-09-06 14:04:48 +010043
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010044 void SetVerifierDeps(verifier::VerifierDeps* deps) override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010045 verifier_deps_.reset(deps);
46 }
David Brazdilca3c8c32016-09-06 14:04:48 +010047
Nicolas Geoffray486dda02017-09-11 14:15:52 +010048 void SetVerificationResults(VerificationResults* verification_results) {
49 verification_results_ = verification_results;
50 }
Mathieu Chartiere01b6f62017-07-19 16:55:04 -070051
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010052 ClassStatus GetPreviousClassState(ClassReference ref) override;
Mathieu Chartier9e050df2017-08-09 10:05:47 -070053
Nicolas Geoffray486dda02017-09-11 14:15:52 +010054 void SetDoesClassUnloading(bool does_class_unloading, CompilerDriver* compiler_driver)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010055 override {
Nicolas Geoffray486dda02017-09-11 14:15:52 +010056 does_class_unloading_ = does_class_unloading;
57 compiler_driver_ = compiler_driver;
58 DCHECK(!does_class_unloading || compiler_driver_ != nullptr);
59 }
Mathieu Chartier9e050df2017-08-09 10:05:47 -070060
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010061 void UpdateClassState(ClassReference ref, ClassStatus state) override;
Nicolas Geoffray486dda02017-09-11 14:15:52 +010062
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010063 bool CanUseOatStatusForVerification(mirror::Class* klass) override
Andreas Gampee9934582018-01-19 21:23:04 -080064 REQUIRES_SHARED(Locks::mutator_lock_);
65
66 void SetDexFiles(const std::vector<const DexFile*>* dex_files) {
67 dex_files_ = dex_files;
68 }
69
Nicolas Geoffray486dda02017-09-11 14:15:52 +010070 private:
71 VerificationResults* verification_results_ = nullptr;
72 bool does_class_unloading_ = false;
73 CompilerDriver* compiler_driver_ = nullptr;
74 std::unique_ptr<verifier::VerifierDeps> verifier_deps_;
Andreas Gampee9934582018-01-19 21:23:04 -080075 const std::vector<const DexFile*>* dex_files_;
Ian Rogerse63db272014-07-15 15:36:11 -070076};
77
78} // namespace art
79
Vladimir Marko327497e2019-03-04 12:53:20 +000080#endif // ART_DEX2OAT_DEX_QUICK_COMPILER_CALLBACKS_H_