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