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 | |
Logan Chien | 4eb953f | 2012-03-01 13:16:52 +0800 | [diff] [blame] | 17 | #ifndef ART_SRC_OAT_COMPILATION_UNIT_H_ |
| 18 | #define ART_SRC_OAT_COMPILATION_UNIT_H_ |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 19 | |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 20 | #include "dex_file.h" |
| 21 | |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 22 | #include <stdint.h> |
| 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | class ClassLoader; |
| 27 | class ClassLinker; |
| 28 | class DexFile; |
| 29 | class DexCache; |
| 30 | |
| 31 | class OatCompilationUnit { |
| 32 | public: |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 33 | OatCompilationUnit(const ClassLoader* class_loader, ClassLinker* class_linker, |
| 34 | const DexFile& dex_file, DexCache& dex_cache, |
| 35 | const DexFile::CodeItem* code_item, |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 36 | uint32_t method_idx, uint32_t access_flags) |
| 37 | : class_loader_(class_loader), class_linker_(class_linker), |
| 38 | dex_file_(&dex_file), dex_cache_(&dex_cache), code_item_(code_item), |
| 39 | method_idx_(method_idx), access_flags_(access_flags) { |
| 40 | } |
| 41 | |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 42 | OatCompilationUnit* GetCallee(uint32_t callee_method_idx, |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 43 | uint32_t callee_access_flags) { |
| 44 | return new OatCompilationUnit(class_loader_, class_linker_, *dex_file_, |
| 45 | *dex_cache_, NULL, callee_method_idx, |
| 46 | callee_access_flags); |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 47 | } |
| 48 | |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 49 | const ClassLoader* GetClassLoader() const { |
| 50 | return class_loader_; |
| 51 | } |
| 52 | |
| 53 | ClassLinker* GetClassLinker() const { |
| 54 | return class_linker_; |
| 55 | } |
| 56 | |
| 57 | const DexFile* GetDexFile() const { |
| 58 | return dex_file_; |
| 59 | } |
| 60 | |
| 61 | DexCache* GetDexCache() const { |
| 62 | return dex_cache_; |
| 63 | } |
| 64 | |
| 65 | uint32_t GetDexMethodIndex() const { |
| 66 | return method_idx_; |
| 67 | } |
| 68 | |
| 69 | const DexFile::CodeItem* GetCodeItem() const { |
| 70 | return code_item_; |
| 71 | } |
| 72 | |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 73 | const char* GetShorty() const { |
| 74 | const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_); |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 75 | return dex_file_->GetMethodShorty(method_id); |
| 76 | } |
| 77 | |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 78 | const char* GetShorty(uint32_t* shorty_len) const { |
| 79 | const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_); |
Logan Chien | 61c65dc | 2012-02-29 03:22:30 +0800 | [diff] [blame] | 80 | return dex_file_->GetMethodShorty(method_id, shorty_len); |
| 81 | } |
| 82 | |
Logan Chien | dd361c9 | 2012-04-10 23:40:37 +0800 | [diff] [blame] | 83 | bool IsStatic() const { |
| 84 | return ((access_flags_ & kAccStatic) != 0); |
| 85 | } |
| 86 | |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 87 | public: |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 88 | const ClassLoader* class_loader_; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 89 | ClassLinker* class_linker_; |
| 90 | |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 91 | const DexFile* dex_file_; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 92 | DexCache* dex_cache_; |
| 93 | |
Logan Chien | bfe4ea4 | 2012-03-01 13:24:17 +0800 | [diff] [blame] | 94 | const DexFile::CodeItem* code_item_; |
Logan Chien | 4dd96f5 | 2012-02-29 01:26:58 +0800 | [diff] [blame] | 95 | uint32_t method_idx_; |
| 96 | uint32_t access_flags_; |
| 97 | }; |
| 98 | |
| 99 | } // namespace art |
| 100 | |
Logan Chien | 4eb953f | 2012-03-01 13:16:52 +0800 | [diff] [blame] | 101 | #endif // ART_SRC_OAT_COMPILATION_UNIT_H_ |