Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [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 | #ifndef ART_COMPILER_DRIVER_COMPILER_CALLBACKS_IMPL_H_ |
| 18 | #define ART_COMPILER_DRIVER_COMPILER_CALLBACKS_IMPL_H_ |
| 19 | |
| 20 | #include "compiler_callbacks.h" |
| 21 | #include "dex/quick/dex_file_to_method_inliner_map.h" |
| 22 | #include "verifier/method_verifier-inl.h" |
| 23 | |
| 24 | namespace art { |
| 25 | |
Brian Carlstrom | c0a1b18 | 2014-03-04 23:19:06 -0800 | [diff] [blame] | 26 | class CompilerCallbacksImpl FINAL : public CompilerCallbacks { |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 27 | public: |
| 28 | CompilerCallbacksImpl(VerificationResults* verification_results, |
| 29 | DexFileToMethodInlinerMap* method_inliner_map) |
| 30 | : verification_results_(verification_results), |
| 31 | method_inliner_map_(method_inliner_map) { |
| 32 | CHECK(verification_results != nullptr); |
| 33 | CHECK(method_inliner_map != nullptr); |
| 34 | } |
| 35 | |
Brian Carlstrom | c0a1b18 | 2014-03-04 23:19:06 -0800 | [diff] [blame] | 36 | ~CompilerCallbacksImpl() { } |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 37 | |
Brian Carlstrom | c0a1b18 | 2014-03-04 23:19:06 -0800 | [diff] [blame] | 38 | bool MethodVerified(verifier::MethodVerifier* verifier) |
Ian Rogers | 9758f79 | 2014-03-13 09:02:55 -0700 | [diff] [blame] | 39 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) OVERRIDE; |
Brian Carlstrom | c0a1b18 | 2014-03-04 23:19:06 -0800 | [diff] [blame] | 40 | void ClassRejected(ClassReference ref) OVERRIDE { |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 41 | verification_results_->AddRejectedClass(ref); |
| 42 | } |
| 43 | |
| 44 | private: |
Brian Carlstrom | ae7083d | 2014-02-24 21:56:02 -0800 | [diff] [blame] | 45 | VerificationResults* const verification_results_; |
| 46 | DexFileToMethodInlinerMap* const method_inliner_map_; |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 47 | }; |
| 48 | |
Ian Rogers | 9758f79 | 2014-03-13 09:02:55 -0700 | [diff] [blame] | 49 | inline bool CompilerCallbacksImpl::MethodVerified(verifier::MethodVerifier* verifier) { |
| 50 | bool result = verification_results_->ProcessVerifiedMethod(verifier); |
| 51 | if (result) { |
| 52 | MethodReference ref = verifier->GetMethodReference(); |
| 53 | method_inliner_map_->GetMethodInliner(ref.dex_file) |
| 54 | ->AnalyseMethodCode(verifier); |
| 55 | } |
| 56 | return result; |
| 57 | } |
| 58 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 59 | } // namespace art |
| 60 | |
| 61 | #endif // ART_COMPILER_DRIVER_COMPILER_CALLBACKS_IMPL_H_ |