blob: 7eac3223a32d658f6b527d9abdf6a4db3f41c2c3 [file] [log] [blame]
Logan Chien4dd96f52012-02-29 01:26:58 +08001/*
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 Chien4eb953f2012-03-01 13:16:52 +080017#ifndef ART_SRC_OAT_COMPILATION_UNIT_H_
18#define ART_SRC_OAT_COMPILATION_UNIT_H_
Logan Chien4dd96f52012-02-29 01:26:58 +080019
Logan Chien61c65dc2012-02-29 03:22:30 +080020#include "dex_file.h"
21
Logan Chien4dd96f52012-02-29 01:26:58 +080022#include <stdint.h>
23
24namespace art {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080025namespace mirror {
Logan Chien4dd96f52012-02-29 01:26:58 +080026class ClassLoader;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080027class DexCache;
28} // namespace mirror
Logan Chien4dd96f52012-02-29 01:26:58 +080029class ClassLinker;
30class DexFile;
Logan Chien4dd96f52012-02-29 01:26:58 +080031
32class OatCompilationUnit {
33 public:
Ian Rogers00f7d0e2012-07-19 15:28:27 -070034 OatCompilationUnit(jobject class_loader, ClassLinker* class_linker, const DexFile& dex_file,
TDYa127dc5daa02013-01-09 21:31:37 +080035 const DexFile::CodeItem* code_item, uint32_t class_def_idx,
36 uint32_t method_idx, uint32_t access_flags)
Ian Rogers00f7d0e2012-07-19 15:28:27 -070037 : class_loader_(class_loader), class_linker_(class_linker), dex_file_(&dex_file),
TDYa127dc5daa02013-01-09 21:31:37 +080038 code_item_(code_item), class_def_idx_(class_def_idx), method_idx_(method_idx),
39 access_flags_(access_flags) {
Logan Chien4dd96f52012-02-29 01:26:58 +080040 }
41
Logan Chien61c65dc2012-02-29 03:22:30 +080042 OatCompilationUnit* GetCallee(uint32_t callee_method_idx,
Logan Chienbfe4ea42012-03-01 13:24:17 +080043 uint32_t callee_access_flags) {
Ian Rogers00f7d0e2012-07-19 15:28:27 -070044 return new OatCompilationUnit(class_loader_, class_linker_, *dex_file_, NULL,
TDYa127dc5daa02013-01-09 21:31:37 +080045 0, callee_method_idx, callee_access_flags);
Logan Chien61c65dc2012-02-29 03:22:30 +080046 }
47
Ian Rogers00f7d0e2012-07-19 15:28:27 -070048 jobject GetClassLoader() const {
Logan Chiendd361c92012-04-10 23:40:37 +080049 return class_loader_;
50 }
51
52 ClassLinker* GetClassLinker() const {
53 return class_linker_;
54 }
55
56 const DexFile* GetDexFile() const {
57 return dex_file_;
58 }
59
TDYa127dc5daa02013-01-09 21:31:37 +080060 uint32_t GetClassDefIndex() const {
61 return class_def_idx_;
62 }
63
Logan Chiendd361c92012-04-10 23:40:37 +080064 uint32_t GetDexMethodIndex() const {
65 return method_idx_;
66 }
67
68 const DexFile::CodeItem* GetCodeItem() const {
69 return code_item_;
70 }
71
Logan Chienbfe4ea42012-03-01 13:24:17 +080072 const char* GetShorty() const {
73 const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_);
Logan Chien61c65dc2012-02-29 03:22:30 +080074 return dex_file_->GetMethodShorty(method_id);
75 }
76
Logan Chienbfe4ea42012-03-01 13:24:17 +080077 const char* GetShorty(uint32_t* shorty_len) const {
78 const DexFile::MethodId& method_id = dex_file_->GetMethodId(method_idx_);
Logan Chien61c65dc2012-02-29 03:22:30 +080079 return dex_file_->GetMethodShorty(method_id, shorty_len);
80 }
81
Logan Chiendd361c92012-04-10 23:40:37 +080082 bool IsStatic() const {
83 return ((access_flags_ & kAccStatic) != 0);
84 }
85
Logan Chien4dd96f52012-02-29 01:26:58 +080086 public:
Ian Rogers00f7d0e2012-07-19 15:28:27 -070087 jobject class_loader_;
88 ClassLinker* const class_linker_;
Logan Chien4dd96f52012-02-29 01:26:58 +080089
Ian Rogers00f7d0e2012-07-19 15:28:27 -070090 const DexFile* const dex_file_;
Logan Chien4dd96f52012-02-29 01:26:58 +080091
Ian Rogers00f7d0e2012-07-19 15:28:27 -070092 const DexFile::CodeItem* const code_item_;
TDYa127dc5daa02013-01-09 21:31:37 +080093 const uint32_t class_def_idx_;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070094 const uint32_t method_idx_;
95 const uint32_t access_flags_;
Logan Chien4dd96f52012-02-29 01:26:58 +080096};
97
98} // namespace art
99
Logan Chien4eb953f2012-03-01 13:16:52 +0800100#endif // ART_SRC_OAT_COMPILATION_UNIT_H_