blob: 42a60896a087e23f895ecc679c8949b6eb25087b [file] [log] [blame]
Ian Rogers22d5e732014-07-15 22:23:51 -07001/*
2 * Copyright (C) 2011 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#ifndef ART_RUNTIME_METHOD_HELPER_INL_H_
18#define ART_RUNTIME_METHOD_HELPER_INL_H_
19
20#include "method_helper.h"
21
22#include "runtime.h"
23
24namespace art {
25
26inline mirror::Class* MethodHelper::GetClassFromTypeIdx(uint16_t type_idx, bool resolve) {
27 mirror::ArtMethod* method = GetMethod();
28 mirror::Class* type = method->GetDexCacheResolvedTypes()->Get(type_idx);
29 if (type == nullptr && resolve) {
30 type = Runtime::Current()->GetClassLinker()->ResolveType(type_idx, method);
31 CHECK(type != nullptr || Thread::Current()->IsExceptionPending());
32 }
33 return type;
34}
35
36inline mirror::String* MethodHelper::ResolveString(uint32_t string_idx) {
37 mirror::ArtMethod* method = GetMethod();
38 mirror::String* s = method->GetDexCacheStrings()->Get(string_idx);
39 if (UNLIKELY(s == nullptr)) {
40 StackHandleScope<1> hs(Thread::Current());
41 Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
42 s = Runtime::Current()->GetClassLinker()->ResolveString(*method->GetDexFile(), string_idx,
43 dex_cache);
44 }
45 return s;
46}
47
48} // namespace art
49
50#endif // ART_RUNTIME_METHOD_HELPER_INL_H_