blob: c90c37d54a5f0a99103dd37801b884a7efcdc7d7 [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
David Sehrc431b9d2018-03-02 12:01:51 -080019#include "base/utils.h"
David Sehr9e734c72018-01-04 17:56:19 -080020#include "dex/code_item_accessors-inl.h"
David Sehrb2ec9f52018-02-21 13:20:31 -080021#include "dex/descriptors_names.h"
Mathieu Chartier736b5602015-09-02 14:54:11 -070022#include "mirror/dex_cache.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070023
24namespace art {
25
Vladimir Marko8d6768d2017-03-14 10:13:21 +000026DexCompilationUnit::DexCompilationUnit(Handle<mirror::ClassLoader> class_loader,
Brian Carlstrom7940e442013-07-12 13:46:57 -070027 ClassLinker* class_linker,
28 const DexFile& dex_file,
29 const DexFile::CodeItem* code_item,
Ian Rogersee39a102013-09-19 02:56:49 -070030 uint16_t class_def_idx,
Brian Carlstrom7940e442013-07-12 13:46:57 -070031 uint32_t method_idx,
Vladimir Marko2730db02014-01-27 11:15:17 +000032 uint32_t access_flags,
Mathieu Chartier736b5602015-09-02 14:54:11 -070033 const VerifiedMethod* verified_method,
34 Handle<mirror::DexCache> dex_cache)
Vladimir Markodf739842016-03-23 16:59:07 +000035 : class_loader_(class_loader),
Brian Carlstrom7940e442013-07-12 13:46:57 -070036 class_linker_(class_linker),
37 dex_file_(&dex_file),
38 code_item_(code_item),
39 class_def_idx_(class_def_idx),
40 dex_method_idx_(method_idx),
Vladimir Marko2730db02014-01-27 11:15:17 +000041 access_flags_(access_flags),
Mathieu Chartier736b5602015-09-02 14:54:11 -070042 verified_method_(verified_method),
Mathieu Chartier73f21d42018-01-02 14:26:50 -080043 dex_cache_(dex_cache),
Mathieu Chartier698ebbc2018-01-05 11:00:42 -080044 code_item_accessor_(dex_file, code_item) {}
Brian Carlstrom7940e442013-07-12 13:46:57 -070045
46const std::string& DexCompilationUnit::GetSymbol() {
47 if (symbol_.empty()) {
48 symbol_ = "dex_";
David Sehr709b0702016-10-13 09:12:37 -070049 symbol_ += MangleForJni(dex_file_->PrettyMethod(dex_method_idx_));
Brian Carlstrom7940e442013-07-12 13:46:57 -070050 }
51 return symbol_;
52}
53
Brian Carlstrom7934ac22013-07-26 10:54:15 -070054} // namespace art