blob: 840b0adf492b329af881c4e3e1acdf45ce0c94ec [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
2 * Copyright (C) 2013 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
17#include "dex_compilation_unit.h"
18
19#include "base/stringprintf.h"
20#include "dex/compiler_ir.h"
21#include "dex/mir_graph.h"
22#include "utils.h"
23
24namespace art {
25
26DexCompilationUnit::DexCompilationUnit(CompilationUnit* cu)
27 : cu_(cu),
28 class_loader_(cu->class_loader),
29 class_linker_(cu->class_linker),
30 dex_file_(cu->dex_file),
31 code_item_(cu->code_item),
32 class_def_idx_(cu->class_def_idx),
33 dex_method_idx_(cu->method_idx),
Vladimir Marko2730db02014-01-27 11:15:17 +000034 access_flags_(cu->access_flags),
35 verified_method_(cu_->compiler_driver->GetVerifiedMethod(cu->dex_file, cu->method_idx)) {
Brian Carlstrom7940e442013-07-12 13:46:57 -070036}
37
38DexCompilationUnit::DexCompilationUnit(CompilationUnit* cu,
39 jobject class_loader,
40 ClassLinker* class_linker,
41 const DexFile& dex_file,
42 const DexFile::CodeItem* code_item,
Ian Rogersee39a102013-09-19 02:56:49 -070043 uint16_t class_def_idx,
Brian Carlstrom7940e442013-07-12 13:46:57 -070044 uint32_t method_idx,
Vladimir Marko2730db02014-01-27 11:15:17 +000045 uint32_t access_flags,
46 const VerifiedMethod* verified_method)
Brian Carlstrom7940e442013-07-12 13:46:57 -070047 : cu_(cu),
48 class_loader_(class_loader),
49 class_linker_(class_linker),
50 dex_file_(&dex_file),
51 code_item_(code_item),
52 class_def_idx_(class_def_idx),
53 dex_method_idx_(method_idx),
Vladimir Marko2730db02014-01-27 11:15:17 +000054 access_flags_(access_flags),
55 verified_method_(verified_method) {
Brian Carlstrom7940e442013-07-12 13:46:57 -070056}
57
58const std::string& DexCompilationUnit::GetSymbol() {
59 if (symbol_.empty()) {
60 symbol_ = "dex_";
61 symbol_ += MangleForJni(PrettyMethod(dex_method_idx_, *dex_file_));
62 }
63 return symbol_;
64}
65
Brian Carlstrom7934ac22013-07-26 10:54:15 -070066} // namespace art