Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Mathieu Chartier | 9e050df | 2017-08-09 10:05:47 -0700 | [diff] [blame] | 19 | #include "driver/compiler_driver.h" |
Andreas Gampe | e993458 | 2018-01-19 21:23:04 -0800 | [diff] [blame] | 20 | #include "mirror/class-inl.h" |
| 21 | #include "mirror/object.h" |
| 22 | #include "obj_ptr-inl.h" |
| 23 | #include "thread-current-inl.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 24 | #include "verification_results.h" |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 25 | #include "verifier/method_verifier-inl.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 26 | |
| 27 | namespace art { |
| 28 | |
Andreas Gampe | 53e32d1 | 2015-12-09 21:03:23 -0800 | [diff] [blame] | 29 | void QuickCompilerCallbacks::MethodVerified(verifier::MethodVerifier* verifier) { |
Mathieu Chartier | 0733dc8 | 2017-07-17 14:05:28 -0700 | [diff] [blame] | 30 | if (verification_results_ != nullptr) { |
| 31 | verification_results_->ProcessVerifiedMethod(verifier); |
| 32 | } |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | void QuickCompilerCallbacks::ClassRejected(ClassReference ref) { |
Mathieu Chartier | 0733dc8 | 2017-07-17 14:05:28 -0700 | [diff] [blame] | 36 | if (verification_results_ != nullptr) { |
| 37 | verification_results_->AddRejectedClass(ref); |
| 38 | } |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Andreas Gampe | 5d3b002 | 2017-08-31 10:36:31 -0700 | [diff] [blame] | 41 | ClassStatus QuickCompilerCallbacks::GetPreviousClassState(ClassReference ref) { |
Mathieu Chartier | 9e050df | 2017-08-09 10:05:47 -0700 | [diff] [blame] | 42 | // If we don't have class unloading enabled in the compiler, we will never see class that were |
| 43 | // previously verified. Return false to avoid overhead from the lookup in the compiler driver. |
| 44 | if (!does_class_unloading_) { |
Vladimir Marko | 2c64a83 | 2018-01-04 11:31:56 +0000 | [diff] [blame] | 45 | return ClassStatus::kNotReady; |
Mathieu Chartier | 9e050df | 2017-08-09 10:05:47 -0700 | [diff] [blame] | 46 | } |
| 47 | DCHECK(compiler_driver_ != nullptr); |
| 48 | // In the case of the quicken filter: avoiding verification of quickened instructions, which the |
| 49 | // verifier doesn't currently support. |
| 50 | // In the case of the verify filter, avoiding verifiying twice. |
Nicolas Geoffray | 486dda0 | 2017-09-11 14:15:52 +0100 | [diff] [blame] | 51 | return compiler_driver_->GetClassStatus(ref); |
| 52 | } |
| 53 | |
| 54 | void QuickCompilerCallbacks::UpdateClassState(ClassReference ref, ClassStatus status) { |
| 55 | // Driver is null when bootstrapping the runtime. |
| 56 | if (compiler_driver_ != nullptr) { |
| 57 | compiler_driver_->RecordClassStatus(ref, status); |
Andreas Gampe | 5d3b002 | 2017-08-31 10:36:31 -0700 | [diff] [blame] | 58 | } |
Mathieu Chartier | 9e050df | 2017-08-09 10:05:47 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Andreas Gampe | e993458 | 2018-01-19 21:23:04 -0800 | [diff] [blame] | 61 | bool QuickCompilerCallbacks::CanUseOatStatusForVerification(mirror::Class* klass) { |
| 62 | // No dex files: conservatively false. |
| 63 | if (dex_files_ == nullptr) { |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | // If the class isn't from one of the dex files, accept oat file data. |
| 68 | const DexFile* dex_file = &klass->GetDexFile(); |
| 69 | return std::find(dex_files_->begin(), dex_files_->end(), dex_file) == dex_files_->end(); |
| 70 | } |
| 71 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 72 | } // namespace art |