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