blob: 11223ff3c8106d6d68f9240d1c834ceb10d52000 [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#include "quick_compiler_callbacks.h"
18
Vladimir Marko327497e2019-03-04 12:53:20 +000019#include "dex/verification_results.h"
Mathieu Chartier9e050df2017-08-09 10:05:47 -070020#include "driver/compiler_driver.h"
Andreas Gampee9934582018-01-19 21:23:04 -080021#include "mirror/class-inl.h"
Ian Rogerse63db272014-07-15 15:36:11 -070022
23namespace art {
24
Nicolas Geoffray9e050ab2021-07-14 14:59:25 +010025void QuickCompilerCallbacks::AddUncompilableMethod(MethodReference ref) {
Mathieu Chartier0733dc82017-07-17 14:05:28 -070026 if (verification_results_ != nullptr) {
Nicolas Geoffray9e050ab2021-07-14 14:59:25 +010027 verification_results_->AddUncompilableMethod(ref);
Mathieu Chartier0733dc82017-07-17 14:05:28 -070028 }
Ian Rogerse63db272014-07-15 15:36:11 -070029}
30
31void QuickCompilerCallbacks::ClassRejected(ClassReference ref) {
Mathieu Chartier0733dc82017-07-17 14:05:28 -070032 if (verification_results_ != nullptr) {
33 verification_results_->AddRejectedClass(ref);
34 }
Ian Rogerse63db272014-07-15 15:36:11 -070035}
36
Andreas Gampe5d3b0022017-08-31 10:36:31 -070037ClassStatus QuickCompilerCallbacks::GetPreviousClassState(ClassReference ref) {
Mathieu Chartier9e050df2017-08-09 10:05:47 -070038 // If we don't have class unloading enabled in the compiler, we will never see class that were
39 // previously verified. Return false to avoid overhead from the lookup in the compiler driver.
40 if (!does_class_unloading_) {
Vladimir Marko2c64a832018-01-04 11:31:56 +000041 return ClassStatus::kNotReady;
Mathieu Chartier9e050df2017-08-09 10:05:47 -070042 }
43 DCHECK(compiler_driver_ != nullptr);
44 // In the case of the quicken filter: avoiding verification of quickened instructions, which the
45 // verifier doesn't currently support.
46 // In the case of the verify filter, avoiding verifiying twice.
Nicolas Geoffray486dda02017-09-11 14:15:52 +010047 return compiler_driver_->GetClassStatus(ref);
48}
49
50void QuickCompilerCallbacks::UpdateClassState(ClassReference ref, ClassStatus status) {
51 // Driver is null when bootstrapping the runtime.
52 if (compiler_driver_ != nullptr) {
53 compiler_driver_->RecordClassStatus(ref, status);
Andreas Gampe5d3b0022017-08-31 10:36:31 -070054 }
Mathieu Chartier9e050df2017-08-09 10:05:47 -070055}
56
Andreas Gampee9934582018-01-19 21:23:04 -080057bool QuickCompilerCallbacks::CanUseOatStatusForVerification(mirror::Class* klass) {
58 // No dex files: conservatively false.
59 if (dex_files_ == nullptr) {
60 return false;
61 }
62
63 // If the class isn't from one of the dex files, accept oat file data.
64 const DexFile* dex_file = &klass->GetDexFile();
65 return std::find(dex_files_->begin(), dex_files_->end(), dex_file) == dex_files_->end();
66}
67
Ian Rogerse63db272014-07-15 15:36:11 -070068} // namespace art