1 /*
2 * Copyright (C) 2013 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 "verification_results.h"
18
19 #include <android-base/logging.h>
20
21 #include "base/mutex-inl.h"
22 #include "base/stl_util.h"
23 #include "runtime.h"
24 #include "thread-current-inl.h"
25 #include "thread.h"
26
27 namespace art {
28
VerificationResults()29 VerificationResults::VerificationResults()
30 : uncompilable_methods_lock_("compiler uncompilable methods lock"),
31 rejected_classes_lock_("compiler rejected classes lock") {}
32
33 // Non-inline version of the destructor, as it does some implicit work not worth
34 // inlining.
~VerificationResults()35 VerificationResults::~VerificationResults() {}
36
AddRejectedClass(ClassReference ref)37 void VerificationResults::AddRejectedClass(ClassReference ref) {
38 {
39 WriterMutexLock mu(Thread::Current(), rejected_classes_lock_);
40 rejected_classes_.insert(ref);
41 }
42 DCHECK(IsClassRejected(ref));
43 }
44
IsClassRejected(ClassReference ref) const45 bool VerificationResults::IsClassRejected(ClassReference ref) const {
46 ReaderMutexLock mu(Thread::Current(), rejected_classes_lock_);
47 return rejected_classes_.find(ref) != rejected_classes_.end();
48 }
49
AddUncompilableMethod(MethodReference ref)50 void VerificationResults::AddUncompilableMethod(MethodReference ref) {
51 {
52 WriterMutexLock mu(Thread::Current(), uncompilable_methods_lock_);
53 uncompilable_methods_.insert(ref);
54 }
55 DCHECK(IsUncompilableMethod(ref));
56 }
57
IsUncompilableMethod(MethodReference ref) const58 bool VerificationResults::IsUncompilableMethod(MethodReference ref) const {
59 ReaderMutexLock mu(Thread::Current(), uncompilable_methods_lock_);
60 return uncompilable_methods_.find(ref) != uncompilable_methods_.end();
61 }
62
63
64 } // namespace art
65