blob: 92adb20c1f06006c693f10f80380e15a3effb21a [file] [log] [blame]
Brian Carlstrom6449c622014-02-10 23:48:36 -08001/*
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
24namespace art {
25
Brian Carlstromc0a1b182014-03-04 23:19:06 -080026class CompilerCallbacksImpl FINAL : public CompilerCallbacks {
Brian Carlstrom6449c622014-02-10 23:48:36 -080027 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 Carlstromc0a1b182014-03-04 23:19:06 -080036 ~CompilerCallbacksImpl() { }
Brian Carlstrom6449c622014-02-10 23:48:36 -080037
Brian Carlstromc0a1b182014-03-04 23:19:06 -080038 bool MethodVerified(verifier::MethodVerifier* verifier)
Ian Rogers9758f792014-03-13 09:02:55 -070039 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) OVERRIDE;
Brian Carlstromc0a1b182014-03-04 23:19:06 -080040 void ClassRejected(ClassReference ref) OVERRIDE {
Brian Carlstrom6449c622014-02-10 23:48:36 -080041 verification_results_->AddRejectedClass(ref);
42 }
43
44 private:
Brian Carlstromae7083d2014-02-24 21:56:02 -080045 VerificationResults* const verification_results_;
46 DexFileToMethodInlinerMap* const method_inliner_map_;
Brian Carlstrom6449c622014-02-10 23:48:36 -080047};
48
Ian Rogers9758f792014-03-13 09:02:55 -070049inline 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 Carlstrom6449c622014-02-10 23:48:36 -080059} // namespace art
60
61#endif // ART_COMPILER_DRIVER_COMPILER_CALLBACKS_IMPL_H_