Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_ |
| 18 | #define ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_ |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | |
Vladimir Marko | c91df2d | 2015-04-23 09:29:21 +0000 | [diff] [blame] | 22 | #include "base/arena_object.h" |
Mathieu Chartier | 736b560 | 2015-09-02 14:54:11 -0700 | [diff] [blame] | 23 | #include "dex_file.h" |
| 24 | #include "handle.h" |
| 25 | #include "jni.h" |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 26 | |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 27 | namespace art { |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 28 | namespace mirror { |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 29 | class ClassLoader; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 30 | class DexCache; |
| 31 | } // namespace mirror |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 32 | class ClassLinker; |
Vladimir Marko | 2730db0 | 2014-01-27 11:15:17 +0000 | [diff] [blame] | 33 | class VerifiedMethod; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 34 | |
Vladimir Marko | c91df2d | 2015-04-23 09:29:21 +0000 | [diff] [blame] | 35 | class DexCompilationUnit : public DeletableArenaObject<kArenaAllocMisc> { |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 36 | public: |
Vladimir Marko | df73984 | 2016-03-23 16:59:07 +0000 | [diff] [blame] | 37 | DexCompilationUnit(jobject class_loader, |
Mathieu Chartier | 736b560 | 2015-09-02 14:54:11 -0700 | [diff] [blame] | 38 | ClassLinker* class_linker, |
| 39 | const DexFile& dex_file, |
| 40 | const DexFile::CodeItem* code_item, |
| 41 | uint16_t class_def_idx, |
| 42 | uint32_t method_idx, |
| 43 | uint32_t access_flags, |
| 44 | const VerifiedMethod* verified_method, |
| 45 | Handle<mirror::DexCache> dex_cache); |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 46 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 47 | jobject GetClassLoader() const { |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 48 | return class_loader_; |
| 49 | } |
| 50 | |
| 51 | ClassLinker* GetClassLinker() const { |
| 52 | return class_linker_; |
| 53 | } |
| 54 | |
| 55 | const DexFile* GetDexFile() const { |
| 56 | return dex_file_; |
| 57 | } |
| 58 | |
Ian Rogers | ee39a10 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 59 | uint16_t GetClassDefIndex() const { |
TDYa127 | dc5daa0 | 2013-01-09 21:31:37 +0800 | [diff] [blame] | 60 | return class_def_idx_; |
| 61 | } |
| 62 | |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 63 | uint32_t GetDexMethodIndex() const { |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 64 | return dex_method_idx_; |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | const DexFile::CodeItem* GetCodeItem() const { |
| 68 | return code_item_; |
| 69 | } |
| 70 | |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 71 | const char* GetShorty() const { |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 72 | const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 73 | return dex_file_->GetMethodShorty(method_id); |
| 74 | } |
| 75 | |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 76 | const char* GetShorty(uint32_t* shorty_len) const { |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 77 | const DexFile::MethodId& method_id = dex_file_->GetMethodId(dex_method_idx_); |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 78 | return dex_file_->GetMethodShorty(method_id, shorty_len); |
| 79 | } |
| 80 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 81 | uint32_t GetAccessFlags() const { |
| 82 | return access_flags_; |
| 83 | } |
| 84 | |
Ian Rogers | a49bdff | 2013-07-31 14:49:16 -0700 | [diff] [blame] | 85 | bool IsConstructor() const { |
| 86 | return ((access_flags_ & kAccConstructor) != 0); |
| 87 | } |
| 88 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 89 | bool IsNative() const { |
| 90 | return ((access_flags_ & kAccNative) != 0); |
| 91 | } |
| 92 | |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 93 | bool IsStatic() const { |
| 94 | return ((access_flags_ & kAccStatic) != 0); |
| 95 | } |
| 96 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 97 | bool IsSynchronized() const { |
| 98 | return ((access_flags_ & kAccSynchronized) != 0); |
| 99 | } |
| 100 | |
Vladimir Marko | 2730db0 | 2014-01-27 11:15:17 +0000 | [diff] [blame] | 101 | const VerifiedMethod* GetVerifiedMethod() const { |
| 102 | return verified_method_; |
| 103 | } |
| 104 | |
Mathieu Chartier | ab972ef | 2014-12-03 17:38:22 -0800 | [diff] [blame] | 105 | void ClearVerifiedMethod() { |
| 106 | verified_method_ = nullptr; |
| 107 | } |
| 108 | |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 109 | const std::string& GetSymbol(); |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 110 | |
Mathieu Chartier | 736b560 | 2015-09-02 14:54:11 -0700 | [diff] [blame] | 111 | Handle<mirror::DexCache> GetDexCache() const { |
| 112 | return dex_cache_; |
| 113 | } |
| 114 | |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 115 | private: |
| 116 | const jobject class_loader_; |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 117 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 118 | ClassLinker* const class_linker_; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 119 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 120 | const DexFile* const dex_file_; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 121 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 122 | const DexFile::CodeItem* const code_item_; |
Ian Rogers | ee39a10 | 2013-09-19 02:56:49 -0700 | [diff] [blame] | 123 | const uint16_t class_def_idx_; |
Ian Rogers | 89756f2 | 2013-03-04 16:40:02 -0800 | [diff] [blame] | 124 | const uint32_t dex_method_idx_; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 125 | const uint32_t access_flags_; |
Mathieu Chartier | ab972ef | 2014-12-03 17:38:22 -0800 | [diff] [blame] | 126 | const VerifiedMethod* verified_method_; |
Brian Carlstrom | 265091e | 2013-01-30 14:08:26 -0800 | [diff] [blame] | 127 | |
Mathieu Chartier | 736b560 | 2015-09-02 14:54:11 -0700 | [diff] [blame] | 128 | Handle<mirror::DexCache> dex_cache_; |
| 129 | |
Ian Rogers | 1bf8d4d | 2013-05-30 00:18:49 -0700 | [diff] [blame] | 130 | std::string symbol_; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 131 | }; |
| 132 | |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 133 | } // namespace art |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 134 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 135 | #endif // ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_ |