blob: e9cdb5367fd8a9dc4a5bfff91d2133527675ab88 [file] [log] [blame]
Vladimir Markoc7f83202014-01-24 17:55:18 +00001/*
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#ifndef ART_COMPILER_DEX_VERIFICATION_RESULTS_H_
18#define ART_COMPILER_DEX_VERIFICATION_RESULTS_H_
19
20#include <stdint.h>
21#include <set>
22#include <vector>
23
24#include "base/macros.h"
25#include "base/mutex.h"
26#include "class_reference.h"
27#include "method_reference.h"
28#include "safe_map.h"
29
30namespace art {
31
32namespace verifier {
33class MethodVerifier;
34} // namespace verifier
35
36class VerifiedMethod;
37
38class VerificationResults {
39 public:
40 VerificationResults();
41 ~VerificationResults();
42
43 bool ProcessVerifiedMethod(verifier::MethodVerifier* method_verifier)
44 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
45 LOCKS_EXCLUDED(verified_methods_lock_);
46
47 const VerifiedMethod* GetVerifiedMethod(MethodReference ref)
48 LOCKS_EXCLUDED(verified_methods_lock_);
49
50 const std::vector<uint8_t>* GetDexGcMap(MethodReference ref)
51 LOCKS_EXCLUDED(verified_methods_lock_);
52
53 const MethodReference* GetDevirtMap(const MethodReference& ref, uint32_t dex_pc)
54 LOCKS_EXCLUDED(verified_methods_lock_);
55
56 // Returns true if the cast can statically be verified to be redundant
57 // by using the check-cast elision peephole optimization in the verifier.
58 bool IsSafeCast(MethodReference ref, uint32_t pc) LOCKS_EXCLUDED(safecast_map_lock_);
59
60 void AddRejectedClass(ClassReference ref) LOCKS_EXCLUDED(rejected_classes_lock_);
61 bool IsClassRejected(ClassReference ref) LOCKS_EXCLUDED(rejected_classes_lock_);
62
63 static bool IsCandidateForCompilation(MethodReference& method_ref,
64 const uint32_t access_flags);
65
66 private:
67 // Verified methods.
68 typedef SafeMap<MethodReference, const VerifiedMethod*,
69 MethodReferenceComparator> VerifiedMethodMap;
70 ReaderWriterMutex verified_methods_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
71 VerifiedMethodMap verified_methods_;
72
73 // Rejected classes.
74 ReaderWriterMutex rejected_classes_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
75 std::set<ClassReference> rejected_classes_ GUARDED_BY(rejected_classes_lock_);
76};
77
78} // namespace art
79
80#endif // ART_COMPILER_DEX_VERIFICATION_RESULTS_H_