Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 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 | #ifndef ART_RUNTIME_VERIFIER_METHOD_VERIFIER_INL_H_ |
| 18 | #define ART_RUNTIME_VERIFIER_METHOD_VERIFIER_INL_H_ |
| 19 | |
| 20 | #include "base/logging.h" |
| 21 | #include "method_verifier.h" |
| 22 | #include "mirror/class_loader.h" |
| 23 | #include "mirror/dex_cache.h" |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 24 | #include "handle_scope-inl.h" |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 25 | |
| 26 | namespace art { |
| 27 | namespace verifier { |
| 28 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 29 | inline const DexFile::CodeItem* MethodVerifier::CodeItem() const { |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 30 | return code_item_; |
| 31 | } |
| 32 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 33 | inline RegisterLine* MethodVerifier::GetRegLine(uint32_t dex_pc) { |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 34 | return reg_table_.GetLine(dex_pc); |
| 35 | } |
| 36 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 37 | inline const InstructionFlags& MethodVerifier::GetInstructionFlags(size_t index) const { |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 38 | return insn_flags_[index]; |
| 39 | } |
| 40 | |
Mathieu Chartier | de40d47 | 2015-10-15 17:47:48 -0700 | [diff] [blame] | 41 | inline InstructionFlags& MethodVerifier::GetInstructionFlags(size_t index) { |
| 42 | return insn_flags_[index]; |
| 43 | } |
| 44 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 45 | inline mirror::ClassLoader* MethodVerifier::GetClassLoader() { |
Mathieu Chartier | bf99f77 | 2014-08-23 16:37:27 -0700 | [diff] [blame] | 46 | return class_loader_.Get(); |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 49 | inline mirror::DexCache* MethodVerifier::GetDexCache() { |
Mathieu Chartier | bf99f77 | 2014-08-23 16:37:27 -0700 | [diff] [blame] | 50 | return dex_cache_.Get(); |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 51 | } |
| 52 | |
Vladimir Marko | be10e8e | 2016-01-22 12:09:44 +0000 | [diff] [blame] | 53 | inline ArtMethod* MethodVerifier::GetMethod() const { |
| 54 | return mirror_method_; |
| 55 | } |
| 56 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 57 | inline MethodReference MethodVerifier::GetMethodReference() const { |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 58 | return MethodReference(dex_file_, dex_method_idx_); |
| 59 | } |
| 60 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 61 | inline uint32_t MethodVerifier::GetAccessFlags() const { |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 62 | return method_access_flags_; |
| 63 | } |
| 64 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 65 | inline bool MethodVerifier::HasCheckCasts() const { |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 66 | return has_check_casts_; |
| 67 | } |
| 68 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 69 | inline bool MethodVerifier::HasVirtualOrInterfaceInvokes() const { |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 70 | return has_virtual_or_interface_invokes_; |
| 71 | } |
| 72 | |
Vladimir Marko | 0f98205 | 2014-01-21 19:08:16 +0000 | [diff] [blame] | 73 | inline bool MethodVerifier::HasFailures() const { |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 74 | return !failure_messages_.empty(); |
| 75 | } |
| 76 | |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 77 | inline const RegType& MethodVerifier::ResolveCheckedClass(dex::TypeIndex class_idx) { |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 78 | DCHECK(!HasFailures()); |
Ian Rogers | d8f69b0 | 2014-09-10 21:43:52 +0000 | [diff] [blame] | 79 | const RegType& result = ResolveClassAndCheckAccess(class_idx); |
Vladimir Marko | 2b5eaa2 | 2013-12-13 13:59:30 +0000 | [diff] [blame] | 80 | DCHECK(!HasFailures()); |
| 81 | return result; |
| 82 | } |
| 83 | |
| 84 | } // namespace verifier |
| 85 | } // namespace art |
| 86 | |
| 87 | #endif // ART_RUNTIME_VERIFIER_METHOD_VERIFIER_INL_H_ |