blob: eeece90be52a52af04d7ede632a070825f6bf926 [file] [log] [blame]
Ian Rogers2dd0e2c2013-01-24 12:42:14 -08001/*
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
Brian Carlstromea46f952013-07-30 01:26:50 -070017#include "art_method.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080018
Andreas Gampe479b1de2016-07-19 18:27:17 -070019#include <cstddef>
20
Ian Rogerse63db272014-07-15 15:36:11 -070021#include "arch/context.h"
Ian Rogers62f05122014-03-21 11:21:29 -070022#include "art_field-inl.h"
Brian Carlstromea46f952013-07-30 01:26:50 -070023#include "art_method-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080024#include "base/stringpiece.h"
Hiroshi Yamauchi00370822015-08-18 14:47:25 -070025#include "class_linker-inl.h"
Andreas Gampe2a5c4682015-08-14 08:22:54 -070026#include "debugger.h"
Ian Rogers4f6ad8a2013-03-18 15:27:28 -070027#include "dex_file-inl.h"
David Sehr9323e6e2016-09-13 08:58:35 -070028#include "dex_file_annotations.h"
Ian Rogersc449aa82013-07-29 14:35:46 -070029#include "dex_instruction.h"
Ian Rogers6f3dbba2014-10-14 17:41:57 -070030#include "entrypoints/runtime_asm_entrypoints.h"
Ian Rogers1d54e732013-05-02 21:10:01 -070031#include "gc/accounting/card_table-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080032#include "interpreter/interpreter.h"
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080033#include "jit/jit.h"
34#include "jit/jit_code_cache.h"
Nicolas Geoffray5550ca82015-08-21 18:38:30 +010035#include "jit/profiling_info.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080036#include "jni_internal.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070037#include "mirror/class-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080038#include "mirror/class_ext.h"
Neil Fuller0e844392016-09-08 13:43:31 +010039#include "mirror/executable.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070040#include "mirror/object_array-inl.h"
41#include "mirror/object-inl.h"
42#include "mirror/string.h"
Nicolas Geoffray9523a3e2015-07-17 11:51:28 +000043#include "oat_file-inl.h"
Mathieu Chartier0795f232016-09-27 18:43:30 -070044#include "scoped_thread_state_change-inl.h"
Ian Rogers62f05122014-03-21 11:21:29 -070045#include "well_known_classes.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080046
47namespace art {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080048
Ian Rogers0177e532014-02-11 16:30:46 -080049extern "C" void art_quick_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*,
50 const char*);
Ian Rogers936b37f2014-02-14 00:52:24 -080051extern "C" void art_quick_invoke_static_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*,
52 const char*);
Jeff Hao5d917302013-02-27 17:57:33 -080053
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -070054ArtMethod* ArtMethod::FromReflectedMethod(const ScopedObjectAccessAlreadyRunnable& soa,
55 jobject jlr_method) {
Mathieu Chartier0795f232016-09-27 18:43:30 -070056 ObjPtr<mirror::Executable> executable = soa.Decode<mirror::Executable>(jlr_method);
Neil Fuller0e844392016-09-08 13:43:31 +010057 DCHECK(executable != nullptr);
58 return executable->GetArtMethod();
Ian Rogers62f05122014-03-21 11:21:29 -070059}
60
Alex Lighta01de592016-11-15 10:43:06 -080061mirror::DexCache* ArtMethod::GetObsoleteDexCache() {
62 DCHECK(!Runtime::Current()->IsAotCompiler()) << PrettyMethod();
63 DCHECK(IsObsolete());
64 ObjPtr<mirror::ClassExt> ext(GetDeclaringClass()->GetExtData());
65 CHECK(!ext.IsNull());
66 ObjPtr<mirror::PointerArray> obsolete_methods(ext->GetObsoleteMethods());
67 CHECK(!obsolete_methods.IsNull());
68 DCHECK(ext->GetObsoleteDexCaches() != nullptr);
69 int32_t len = obsolete_methods->GetLength();
70 DCHECK_EQ(len, ext->GetObsoleteDexCaches()->GetLength());
71 // TODO I think this is fine since images should never have obsolete methods in them.
72 PointerSize pointer_size = kRuntimePointerSize;
73 DCHECK_EQ(kRuntimePointerSize, Runtime::Current()->GetClassLinker()->GetImagePointerSize());
74 for (int32_t i = 0; i < len; i++) {
75 if (this == obsolete_methods->GetElementPtrSize<ArtMethod*>(i, pointer_size)) {
76 return ext->GetObsoleteDexCaches()->Get(i);
77 }
78 }
79 LOG(FATAL) << "This method does not appear in the obsolete map of its class!";
80 UNREACHABLE();
81}
82
Ian Rogers6b14d552014-10-28 21:50:58 -070083mirror::String* ArtMethod::GetNameAsString(Thread* self) {
Mathieu Chartiere401d142015-04-22 13:56:20 -070084 CHECK(!IsProxyMethod());
Ian Rogers6b14d552014-10-28 21:50:58 -070085 StackHandleScope<1> hs(self);
Mathieu Chartiere401d142015-04-22 13:56:20 -070086 Handle<mirror::DexCache> dex_cache(hs.NewHandle(GetDexCache()));
87 auto* dex_file = dex_cache->GetDexFile();
88 uint32_t dex_method_idx = GetDexMethodIndex();
89 const DexFile::MethodId& method_id = dex_file->GetMethodId(dex_method_idx);
Ian Rogers6b14d552014-10-28 21:50:58 -070090 return Runtime::Current()->GetClassLinker()->ResolveString(*dex_file, method_id.name_idx_,
91 dex_cache);
92}
93
Alex Light9139e002015-10-09 15:59:48 -070094void ArtMethod::ThrowInvocationTimeError() {
95 DCHECK(!IsInvokable());
96 // NOTE: IsDefaultConflicting must be first since the actual method might or might not be abstract
97 // due to the way we select it.
98 if (IsDefaultConflicting()) {
99 ThrowIncompatibleClassChangeErrorForMethodConflict(this);
100 } else {
101 DCHECK(IsAbstract());
102 ThrowAbstractMethodError(this);
103 }
104}
105
Ian Rogersef7d42f2014-01-06 12:55:46 -0800106InvokeType ArtMethod::GetInvokeType() {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800107 // TODO: kSuper?
Nicolas Geoffray3aaf9642016-06-07 14:14:37 +0000108 if (IsStatic()) {
Nicolas Geoffray12abcbd2016-06-06 15:51:58 +0000109 return kStatic;
Nicolas Geoffray3aaf9642016-06-07 14:14:37 +0000110 } else if (GetDeclaringClass()->IsInterface()) {
111 return kInterface;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800112 } else if (IsDirect()) {
113 return kDirect;
114 } else {
115 return kVirtual;
116 }
117}
118
Brian Carlstromea46f952013-07-30 01:26:50 -0700119size_t ArtMethod::NumArgRegisters(const StringPiece& shorty) {
Ian Rogers6b604a12014-09-25 15:35:37 -0700120 CHECK_LE(1U, shorty.length());
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800121 uint32_t num_registers = 0;
Ian Rogers6b604a12014-09-25 15:35:37 -0700122 for (size_t i = 1; i < shorty.length(); ++i) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800123 char ch = shorty[i];
124 if (ch == 'D' || ch == 'J') {
125 num_registers += 2;
126 } else {
127 num_registers += 1;
128 }
129 }
130 return num_registers;
131}
132
Alex Light6c8467f2015-11-20 15:03:26 -0800133bool ArtMethod::HasSameNameAndSignature(ArtMethod* other) {
Mathieu Chartier268764d2016-09-13 12:09:38 -0700134 ScopedAssertNoThreadSuspension ants("HasSameNameAndSignature");
Alex Light6c8467f2015-11-20 15:03:26 -0800135 const DexFile* dex_file = GetDexFile();
136 const DexFile::MethodId& mid = dex_file->GetMethodId(GetDexMethodIndex());
137 if (GetDexCache() == other->GetDexCache()) {
138 const DexFile::MethodId& mid2 = dex_file->GetMethodId(other->GetDexMethodIndex());
Ian Rogersf2247512014-12-02 16:17:08 -0800139 return mid.name_idx_ == mid2.name_idx_ && mid.proto_idx_ == mid2.proto_idx_;
140 }
Alex Light6c8467f2015-11-20 15:03:26 -0800141 const DexFile* dex_file2 = other->GetDexFile();
142 const DexFile::MethodId& mid2 = dex_file2->GetMethodId(other->GetDexMethodIndex());
Ian Rogersf2247512014-12-02 16:17:08 -0800143 if (!DexFileStringEquals(dex_file, mid.name_idx_, dex_file2, mid2.name_idx_)) {
144 return false; // Name mismatch.
145 }
146 return dex_file->GetMethodSignature(mid) == dex_file2->GetMethodSignature(mid2);
147}
148
Andreas Gampe542451c2016-07-26 09:02:02 -0700149ArtMethod* ArtMethod::FindOverriddenMethod(PointerSize pointer_size) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800150 if (IsStatic()) {
Ian Rogersf2247512014-12-02 16:17:08 -0800151 return nullptr;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800152 }
Mathieu Chartiere401d142015-04-22 13:56:20 -0700153 mirror::Class* declaring_class = GetDeclaringClass();
154 mirror::Class* super_class = declaring_class->GetSuperClass();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800155 uint16_t method_index = GetMethodIndex();
Ian Rogersf2247512014-12-02 16:17:08 -0800156 ArtMethod* result = nullptr;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800157 // Did this method override a super class method? If so load the result from the super class'
158 // vtable
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700159 if (super_class->HasVTable() && method_index < super_class->GetVTableLength()) {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700160 result = super_class->GetVTableEntry(method_index, pointer_size);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800161 } else {
162 // Method didn't override superclass method so search interfaces
163 if (IsProxyMethod()) {
Vladimir Marko05792b92015-08-03 11:56:49 +0100164 result = mirror::DexCache::GetElementPtrSize(GetDexCacheResolvedMethods(pointer_size),
165 GetDexMethodIndex(),
166 pointer_size);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800167 CHECK_EQ(result,
168 Runtime::Current()->GetClassLinker()->FindMethodForProxy(GetDeclaringClass(), this));
169 } else {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700170 mirror::IfTable* iftable = GetDeclaringClass()->GetIfTable();
Ian Rogersf2247512014-12-02 16:17:08 -0800171 for (size_t i = 0; i < iftable->Count() && result == nullptr; i++) {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700172 mirror::Class* interface = iftable->GetInterface(i);
Alex Light51a64d52015-12-17 13:55:59 -0800173 for (ArtMethod& interface_method : interface->GetVirtualMethods(pointer_size)) {
174 if (HasSameNameAndSignature(interface_method.GetInterfaceMethodIfProxy(pointer_size))) {
175 result = &interface_method;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800176 break;
177 }
178 }
179 }
180 }
181 }
Alex Light6c8467f2015-11-20 15:03:26 -0800182 DCHECK(result == nullptr ||
Alex Light51a64d52015-12-17 13:55:59 -0800183 GetInterfaceMethodIfProxy(pointer_size)->HasSameNameAndSignature(
184 result->GetInterfaceMethodIfProxy(pointer_size)));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800185 return result;
186}
187
Ian Rogerse0a02da2014-12-02 14:10:53 -0800188uint32_t ArtMethod::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfile,
189 uint32_t name_and_signature_idx) {
190 const DexFile* dexfile = GetDexFile();
191 const uint32_t dex_method_idx = GetDexMethodIndex();
192 const DexFile::MethodId& mid = dexfile->GetMethodId(dex_method_idx);
193 const DexFile::MethodId& name_and_sig_mid = other_dexfile.GetMethodId(name_and_signature_idx);
194 DCHECK_STREQ(dexfile->GetMethodName(mid), other_dexfile.GetMethodName(name_and_sig_mid));
195 DCHECK_EQ(dexfile->GetMethodSignature(mid), other_dexfile.GetMethodSignature(name_and_sig_mid));
196 if (dexfile == &other_dexfile) {
197 return dex_method_idx;
198 }
199 const char* mid_declaring_class_descriptor = dexfile->StringByTypeIdx(mid.class_idx_);
Mathieu Chartier9507fa22015-10-29 15:08:57 -0700200 const DexFile::TypeId* other_type_id = other_dexfile.FindTypeId(mid_declaring_class_descriptor);
201 if (other_type_id != nullptr) {
202 const DexFile::MethodId* other_mid = other_dexfile.FindMethodId(
203 *other_type_id, other_dexfile.GetStringId(name_and_sig_mid.name_idx_),
204 other_dexfile.GetProtoId(name_and_sig_mid.proto_idx_));
205 if (other_mid != nullptr) {
206 return other_dexfile.GetIndexForMethodId(*other_mid);
Ian Rogerse0a02da2014-12-02 14:10:53 -0800207 }
208 }
209 return DexFile::kDexNoIndex;
210}
211
Mathieu Chartiere401d142015-04-22 13:56:20 -0700212uint32_t ArtMethod::FindCatchBlock(Handle<mirror::Class> exception_type,
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700213 uint32_t dex_pc, bool* has_no_move_exception) {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700214 const DexFile::CodeItem* code_item = GetCodeItem();
Jeff Haoaa961912014-04-22 13:54:32 -0700215 // Set aside the exception while we resolve its type.
216 Thread* self = Thread::Current();
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700217 StackHandleScope<1> hs(self);
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000218 Handle<mirror::Throwable> exception(hs.NewHandle(self->GetException()));
Jeff Haoaa961912014-04-22 13:54:32 -0700219 self->ClearException();
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700220 // Default to handler not found.
221 uint32_t found_dex_pc = DexFile::kDexNoIndex;
222 // Iterate over the catch handlers associated with dex_pc.
Andreas Gampe542451c2016-07-26 09:02:02 -0700223 PointerSize pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800224 for (CatchHandlerIterator it(*code_item, dex_pc); it.HasNext(); it.Next()) {
Andreas Gampea5b09a62016-11-17 15:21:22 -0800225 dex::TypeIndex iter_type_idx = it.GetHandlerTypeIndex();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800226 // Catch all case
Andreas Gampea5b09a62016-11-17 15:21:22 -0800227 if (!iter_type_idx.IsValid()) {
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700228 found_dex_pc = it.GetHandlerAddress();
229 break;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800230 }
231 // Does this catch exception type apply?
Vladimir Marko05792b92015-08-03 11:56:49 +0100232 mirror::Class* iter_exception_type = GetClassFromTypeIndex(iter_type_idx,
233 true /* resolve */,
234 pointer_size);
Ian Rogers822266b2014-05-29 16:55:06 -0700235 if (UNLIKELY(iter_exception_type == nullptr)) {
236 // Now have a NoClassDefFoundError as exception. Ignore in case the exception class was
237 // removed by a pro-guard like tool.
Andreas Gampe72b3e432014-05-13 21:42:05 -0700238 // Note: this is not RI behavior. RI would have failed when loading the class.
Ian Rogers822266b2014-05-29 16:55:06 -0700239 self->ClearException();
240 // Delete any long jump context as this routine is called during a stack walk which will
241 // release its in use context at the end.
242 delete self->GetLongJumpContext();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800243 LOG(WARNING) << "Unresolved exception class when finding catch block: "
Mathieu Chartiere401d142015-04-22 13:56:20 -0700244 << DescriptorToDot(GetTypeDescriptorFromTypeIdx(iter_type_idx));
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700245 } else if (iter_exception_type->IsAssignableFrom(exception_type.Get())) {
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700246 found_dex_pc = it.GetHandlerAddress();
247 break;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800248 }
249 }
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700250 if (found_dex_pc != DexFile::kDexNoIndex) {
251 const Instruction* first_catch_instr =
Jeff Haoaa961912014-04-22 13:54:32 -0700252 Instruction::At(&code_item->insns_[found_dex_pc]);
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700253 *has_no_move_exception = (first_catch_instr->Opcode() != Instruction::MOVE_EXCEPTION);
254 }
Jeff Haoaa961912014-04-22 13:54:32 -0700255 // Put the exception back.
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700256 if (exception.Get() != nullptr) {
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000257 self->SetException(exception.Get());
Jeff Haoaa961912014-04-22 13:54:32 -0700258 }
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700259 return found_dex_pc;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800260}
261
Brian Carlstromea46f952013-07-30 01:26:50 -0700262void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result,
Ian Rogers0177e532014-02-11 16:30:46 -0800263 const char* shorty) {
Dave Allison648d7112014-07-25 16:15:27 -0700264 if (UNLIKELY(__builtin_frame_address(0) < self->GetStackEnd())) {
265 ThrowStackOverflowError(self);
266 return;
267 }
268
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800269 if (kIsDebugBuild) {
270 self->AssertThreadSuspensionIsAllowable();
271 CHECK_EQ(kRunnable, self->GetState());
Andreas Gampe542451c2016-07-26 09:02:02 -0700272 CHECK_STREQ(GetInterfaceMethodIfProxy(kRuntimePointerSize)->GetShorty(), shorty);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800273 }
274
275 // Push a transition back into managed code onto the linked list in thread.
276 ManagedStack fragment;
277 self->PushManagedStackFragment(&fragment);
278
Ian Rogers62d6c772013-02-27 08:32:07 -0800279 Runtime* runtime = Runtime::Current();
Jeff Hao74180ca2013-03-27 15:29:11 -0700280 // Call the invoke stub, passing everything as arguments.
Daniel Mihalyieb076692014-08-22 17:33:31 +0200281 // If the runtime is not yet started or it is required by the debugger, then perform the
Aart Bik01223202016-05-05 15:10:42 -0700282 // Invocation by the interpreter, explicitly forcing interpretation over JIT to prevent
283 // cycling around the various JIT/Interpreter methods that handle method invocation.
Daniel Mihalyieb076692014-08-22 17:33:31 +0200284 if (UNLIKELY(!runtime->IsStarted() || Dbg::IsForcedInterpreterNeededForCalling(self, this))) {
Ian Rogers5d27faf2014-05-02 17:17:18 -0700285 if (IsStatic()) {
Aart Bik01223202016-05-05 15:10:42 -0700286 art::interpreter::EnterInterpreterFromInvoke(
287 self, this, nullptr, args, result, /*stay_in_interpreter*/ true);
Ian Rogers5d27faf2014-05-02 17:17:18 -0700288 } else {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700289 mirror::Object* receiver =
290 reinterpret_cast<StackReference<mirror::Object>*>(&args[0])->AsMirrorPtr();
Aart Bik01223202016-05-05 15:10:42 -0700291 art::interpreter::EnterInterpreterFromInvoke(
292 self, this, receiver, args + 1, result, /*stay_in_interpreter*/ true);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800293 }
294 } else {
Andreas Gampe542451c2016-07-26 09:02:02 -0700295 DCHECK_EQ(runtime->GetClassLinker()->GetImagePointerSize(), kRuntimePointerSize);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700296
297 constexpr bool kLogInvocationStartAndReturn = false;
Ian Rogersef7d42f2014-01-06 12:55:46 -0800298 bool have_quick_code = GetEntryPointFromQuickCompiledCode() != nullptr;
Elliott Hughes956af0f2014-12-11 14:34:28 -0800299 if (LIKELY(have_quick_code)) {
Jeff Hao790ad902013-05-22 15:02:08 -0700300 if (kLogInvocationStartAndReturn) {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700301 LOG(INFO) << StringPrintf(
David Sehr709b0702016-10-13 09:12:37 -0700302 "Invoking '%s' quick code=%p static=%d", PrettyMethod().c_str(),
Mathieu Chartiere401d142015-04-22 13:56:20 -0700303 GetEntryPointFromQuickCompiledCode(), static_cast<int>(IsStatic() ? 1 : 0));
Jeff Hao790ad902013-05-22 15:02:08 -0700304 }
Hiroshi Yamauchi9bdec882014-08-15 17:11:12 -0700305
Elliott Hughes956af0f2014-12-11 14:34:28 -0800306 // Ensure that we won't be accidentally calling quick compiled code when -Xint.
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800307 if (kIsDebugBuild && runtime->GetInstrumentation()->IsForcedInterpretOnly()) {
Calin Juravleffc87072016-04-20 14:22:09 +0100308 CHECK(!runtime->UseJitCompilation());
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100309 const void* oat_quick_code = (IsNative() || !IsInvokable() || IsProxyMethod())
310 ? nullptr
311 : GetOatMethodQuickCode(runtime->GetClassLinker()->GetImagePointerSize());
Nicolas Geoffray6bc43742015-10-12 18:11:10 +0100312 CHECK(oat_quick_code == nullptr || oat_quick_code != GetEntryPointFromQuickCompiledCode())
David Sehr709b0702016-10-13 09:12:37 -0700313 << "Don't call compiled code when -Xint " << PrettyMethod();
Hiroshi Yamauchi9bdec882014-08-15 17:11:12 -0700314 }
315
Elliott Hughes956af0f2014-12-11 14:34:28 -0800316 if (!IsStatic()) {
Ian Rogers0177e532014-02-11 16:30:46 -0800317 (*art_quick_invoke_stub)(this, args, args_size, self, result, shorty);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800318 } else {
Elliott Hughes956af0f2014-12-11 14:34:28 -0800319 (*art_quick_invoke_static_stub)(this, args, args_size, self, result, shorty);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800320 }
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000321 if (UNLIKELY(self->GetException() == Thread::GetDeoptimizationException())) {
Sebastien Hertzfd3077e2014-04-23 10:32:43 +0200322 // Unusual case where we were running generated code and an
Jeff Hao790ad902013-05-22 15:02:08 -0700323 // exception was thrown to force the activations to be removed from the
324 // stack. Continue execution in the interpreter.
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000325 self->DeoptimizeWithDeoptimizationException(result);
Jeff Hao790ad902013-05-22 15:02:08 -0700326 }
327 if (kLogInvocationStartAndReturn) {
David Sehr709b0702016-10-13 09:12:37 -0700328 LOG(INFO) << StringPrintf("Returned '%s' quick code=%p", PrettyMethod().c_str(),
Elliott Hughes956af0f2014-12-11 14:34:28 -0800329 GetEntryPointFromQuickCompiledCode());
Jeff Hao5d917302013-02-27 17:57:33 -0800330 }
331 } else {
David Sehr709b0702016-10-13 09:12:37 -0700332 LOG(INFO) << "Not invoking '" << PrettyMethod() << "' code=null";
Ian Rogersf2247512014-12-02 16:17:08 -0800333 if (result != nullptr) {
Jeff Hao5d917302013-02-27 17:57:33 -0800334 result->SetJ(0);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800335 }
336 }
337 }
338
339 // Pop transition.
340 self->PopManagedStackFragment(fragment);
341}
342
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700343void ArtMethod::RegisterNative(const void* native_method, bool is_fast) {
David Sehr709b0702016-10-13 09:12:37 -0700344 CHECK(IsNative()) << PrettyMethod();
345 CHECK(!IsFastNative()) << PrettyMethod();
346 CHECK(native_method != nullptr) << PrettyMethod();
Ian Rogers987560f2014-04-22 11:42:59 -0700347 if (is_fast) {
348 SetAccessFlags(GetAccessFlags() | kAccFastNative);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800349 }
Mathieu Chartier2d721012014-11-10 11:08:06 -0800350 SetEntryPointFromJni(native_method);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800351}
352
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700353void ArtMethod::UnregisterNative() {
David Sehr709b0702016-10-13 09:12:37 -0700354 CHECK(IsNative() && !IsFastNative()) << PrettyMethod();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800355 // restore stub to lookup native pointer via dlsym
Ian Rogers6f3dbba2014-10-14 17:41:57 -0700356 RegisterNative(GetJniDlsymLookupStub(), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800357}
358
Alex Light9139e002015-10-09 15:59:48 -0700359bool ArtMethod::IsOverridableByDefaultMethod() {
360 return GetDeclaringClass()->IsInterface();
361}
362
Igor Murashkin9d4b6da2016-07-29 09:51:58 -0700363bool ArtMethod::IsAnnotatedWithFastNative() {
Igor Murashkin367f3dd2016-09-01 17:00:24 -0700364 return IsAnnotatedWith(WellKnownClasses::dalvik_annotation_optimization_FastNative,
365 DexFile::kDexVisibilityBuild);
366}
367
368bool ArtMethod::IsAnnotatedWithCriticalNative() {
369 return IsAnnotatedWith(WellKnownClasses::dalvik_annotation_optimization_CriticalNative,
370 DexFile::kDexVisibilityBuild);
371}
372
373bool ArtMethod::IsAnnotatedWith(jclass klass, uint32_t visibility) {
Igor Murashkin9d4b6da2016-07-29 09:51:58 -0700374 Thread* self = Thread::Current();
375 ScopedObjectAccess soa(self);
376 StackHandleScope<1> shs(self);
377
Mathieu Chartier0795f232016-09-27 18:43:30 -0700378 ObjPtr<mirror::Class> annotation = soa.Decode<mirror::Class>(klass);
Igor Murashkin367f3dd2016-09-01 17:00:24 -0700379 DCHECK(annotation->IsAnnotation());
380 Handle<mirror::Class> annotation_handle(shs.NewHandle(annotation));
Igor Murashkin9d4b6da2016-07-29 09:51:58 -0700381
382 // Note: Resolves any method annotations' classes as a side-effect.
383 // -- This seems allowed by the spec since it says we can preload any classes
384 // referenced by another classes's constant pool table.
David Sehr9323e6e2016-09-13 08:58:35 -0700385 return annotations::IsMethodAnnotationPresent(this, annotation_handle, visibility);
Igor Murashkin9d4b6da2016-07-29 09:51:58 -0700386}
387
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100388static uint32_t GetOatMethodIndexFromMethodIndex(const DexFile& dex_file,
389 uint16_t class_def_idx,
390 uint32_t method_idx) {
391 const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_idx);
392 const uint8_t* class_data = dex_file.GetClassData(class_def);
393 CHECK(class_data != nullptr);
394 ClassDataItemIterator it(dex_file, class_data);
395 // Skip fields
396 while (it.HasNextStaticField()) {
397 it.Next();
398 }
399 while (it.HasNextInstanceField()) {
400 it.Next();
401 }
402 // Process methods
403 size_t class_def_method_index = 0;
404 while (it.HasNextDirectMethod()) {
405 if (it.GetMemberIndex() == method_idx) {
406 return class_def_method_index;
407 }
408 class_def_method_index++;
409 it.Next();
410 }
411 while (it.HasNextVirtualMethod()) {
412 if (it.GetMemberIndex() == method_idx) {
413 return class_def_method_index;
414 }
415 class_def_method_index++;
416 it.Next();
417 }
418 DCHECK(!it.HasNext());
419 LOG(FATAL) << "Failed to find method index " << method_idx << " in " << dex_file.GetLocation();
420 UNREACHABLE();
421}
422
423static const OatFile::OatMethod FindOatMethodFor(ArtMethod* method,
424 PointerSize pointer_size,
425 bool* found)
426 REQUIRES_SHARED(Locks::mutator_lock_) {
427 // Although we overwrite the trampoline of non-static methods, we may get here via the resolution
428 // method for direct methods (or virtual methods made direct).
429 mirror::Class* declaring_class = method->GetDeclaringClass();
430 size_t oat_method_index;
431 if (method->IsStatic() || method->IsDirect()) {
432 // Simple case where the oat method index was stashed at load time.
433 oat_method_index = method->GetMethodIndex();
434 } else {
435 // Compute the oat_method_index by search for its position in the declared virtual methods.
436 oat_method_index = declaring_class->NumDirectMethods();
437 bool found_virtual = false;
438 for (ArtMethod& art_method : declaring_class->GetVirtualMethods(pointer_size)) {
439 // Check method index instead of identity in case of duplicate method definitions.
440 if (method->GetDexMethodIndex() == art_method.GetDexMethodIndex()) {
441 found_virtual = true;
442 break;
443 }
444 oat_method_index++;
445 }
446 CHECK(found_virtual) << "Didn't find oat method index for virtual method: "
David Sehr709b0702016-10-13 09:12:37 -0700447 << method->PrettyMethod();
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100448 }
449 DCHECK_EQ(oat_method_index,
450 GetOatMethodIndexFromMethodIndex(*declaring_class->GetDexCache()->GetDexFile(),
451 method->GetDeclaringClass()->GetDexClassDefIndex(),
452 method->GetDexMethodIndex()));
453 OatFile::OatClass oat_class = OatFile::FindOatClass(*declaring_class->GetDexCache()->GetDexFile(),
454 declaring_class->GetDexClassDefIndex(),
455 found);
456 if (!(*found)) {
457 return OatFile::OatMethod::Invalid();
458 }
459 return oat_class.GetOatMethod(oat_method_index);
460}
461
Mathieu Chartierfc58af42015-04-16 18:00:39 -0700462bool ArtMethod::EqualParameters(Handle<mirror::ObjectArray<mirror::Class>> params) {
463 auto* dex_cache = GetDexCache();
464 auto* dex_file = dex_cache->GetDexFile();
465 const auto& method_id = dex_file->GetMethodId(GetDexMethodIndex());
466 const auto& proto_id = dex_file->GetMethodPrototype(method_id);
467 const DexFile::TypeList* proto_params = dex_file->GetProtoParameters(proto_id);
468 auto count = proto_params != nullptr ? proto_params->Size() : 0u;
469 auto param_len = params.Get() != nullptr ? params->GetLength() : 0u;
470 if (param_len != count) {
471 return false;
472 }
473 auto* cl = Runtime::Current()->GetClassLinker();
474 for (size_t i = 0; i < count; ++i) {
475 auto type_idx = proto_params->GetTypeItem(i).type_idx_;
476 auto* type = cl->ResolveType(type_idx, this);
477 if (type == nullptr) {
478 Thread::Current()->AssertPendingException();
479 return false;
480 }
481 if (type != params->GetWithoutChecks(i)) {
482 return false;
483 }
484 }
485 return true;
486}
487
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100488const uint8_t* ArtMethod::GetQuickenedInfo(PointerSize pointer_size) {
Nicolas Geoffray6bc43742015-10-12 18:11:10 +0100489 bool found = false;
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100490 OatFile::OatMethod oat_method = FindOatMethodFor(this, pointer_size, &found);
Nicolas Geoffray6bc43742015-10-12 18:11:10 +0100491 if (!found || (oat_method.GetQuickCode() != nullptr)) {
492 return nullptr;
493 }
Nicolas Geoffray4acefd32016-10-24 13:14:58 +0100494 if (kIsVdexEnabled) {
495 const OatQuickMethodHeader* header = oat_method.GetOatQuickMethodHeader();
496 // OatMethod without a header: no quickening table.
497 if (header == nullptr) {
498 return nullptr;
499 }
500 // The table is in the .vdex file.
501 const OatFile::OatDexFile* oat_dex_file = GetDexCache()->GetDexFile()->GetOatDexFile();
Mathieu Chartier1b868492016-11-16 16:22:37 -0800502 const OatFile* oat_file = oat_dex_file->GetOatFile();
503 if (oat_file == nullptr) {
504 return nullptr;
505 }
506 return oat_file->DexBegin() + header->vmap_table_offset_;
Nicolas Geoffray4acefd32016-10-24 13:14:58 +0100507 } else {
508 return oat_method.GetVmapTable();
509 }
Nicolas Geoffray6bc43742015-10-12 18:11:10 +0100510}
511
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +0100512const OatQuickMethodHeader* ArtMethod::GetOatQuickMethodHeader(uintptr_t pc) {
Nicolas Geoffray5a23d2e2015-11-03 18:58:57 +0000513 // Our callers should make sure they don't pass the instrumentation exit pc,
514 // as this method does not look at the side instrumentation stack.
515 DCHECK_NE(pc, reinterpret_cast<uintptr_t>(GetQuickInstrumentationExitPc()));
516
Nicolas Geoffray22cf3d32015-11-02 11:57:11 +0000517 if (IsRuntimeMethod()) {
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +0100518 return nullptr;
519 }
520
521 Runtime* runtime = Runtime::Current();
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100522 const void* existing_entry_point = GetEntryPointFromQuickCompiledCode();
David Sehr709b0702016-10-13 09:12:37 -0700523 CHECK(existing_entry_point != nullptr) << PrettyMethod() << "@" << this;
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100524 ClassLinker* class_linker = runtime->GetClassLinker();
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +0100525
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100526 if (class_linker->IsQuickGenericJniStub(existing_entry_point)) {
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +0100527 // The generic JNI does not have any method header.
528 return nullptr;
529 }
530
Nicolas Geoffray22cf3d32015-11-02 11:57:11 +0000531 if (existing_entry_point == GetQuickProxyInvokeHandler()) {
532 DCHECK(IsProxyMethod() && !IsConstructor());
533 // The proxy entry point does not have any method header.
534 return nullptr;
535 }
536
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100537 // Check whether the current entry point contains this pc.
538 if (!class_linker->IsQuickResolutionStub(existing_entry_point) &&
539 !class_linker->IsQuickToInterpreterBridge(existing_entry_point)) {
540 OatQuickMethodHeader* method_header =
541 OatQuickMethodHeader::FromEntryPoint(existing_entry_point);
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +0100542
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100543 if (method_header->Contains(pc)) {
544 return method_header;
545 }
546 }
547
548 // Check whether the pc is in the JIT code cache.
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100549 jit::Jit* jit = runtime->GetJit();
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100550 if (jit != nullptr) {
551 jit::JitCodeCache* code_cache = jit->GetCodeCache();
552 OatQuickMethodHeader* method_header = code_cache->LookupMethodHeader(pc, this);
553 if (method_header != nullptr) {
554 DCHECK(method_header->Contains(pc));
555 return method_header;
556 } else {
Nicolas Geoffray2a524bd2016-03-01 12:18:47 +0000557 DCHECK(!code_cache->ContainsPc(reinterpret_cast<const void*>(pc)))
David Sehr709b0702016-10-13 09:12:37 -0700558 << PrettyMethod()
Nicolas Geoffray2a524bd2016-03-01 12:18:47 +0000559 << ", pc=" << std::hex << pc
560 << ", entry_point=" << std::hex << reinterpret_cast<uintptr_t>(existing_entry_point)
561 << ", copy=" << std::boolalpha << IsCopied()
562 << ", proxy=" << std::boolalpha << IsProxyMethod();
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100563 }
564 }
565
566 // The code has to be in an oat file.
567 bool found;
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100568 OatFile::OatMethod oat_method =
569 FindOatMethodFor(this, class_linker->GetImagePointerSize(), &found);
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100570 if (!found) {
Nicolas Geoffray49e43962015-10-28 16:16:16 +0000571 if (class_linker->IsQuickResolutionStub(existing_entry_point)) {
572 // We are running the generic jni stub, but the entry point of the method has not
573 // been updated yet.
Nicolas Geoffray703c2822015-10-30 12:23:16 +0000574 DCHECK_EQ(pc, 0u) << "Should be a downcall";
575 DCHECK(IsNative());
576 return nullptr;
577 }
578 if (existing_entry_point == GetQuickInstrumentationEntryPoint()) {
579 // We are running the generic jni stub, but the method is being instrumented.
580 DCHECK_EQ(pc, 0u) << "Should be a downcall";
Nicolas Geoffray49e43962015-10-28 16:16:16 +0000581 DCHECK(IsNative());
582 return nullptr;
583 }
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100584 // Only for unit tests.
585 // TODO(ngeoffray): Update these tests to pass the right pc?
586 return OatQuickMethodHeader::FromEntryPoint(existing_entry_point);
587 }
588 const void* oat_entry_point = oat_method.GetQuickCode();
589 if (oat_entry_point == nullptr || class_linker->IsQuickGenericJniStub(oat_entry_point)) {
David Sehr709b0702016-10-13 09:12:37 -0700590 DCHECK(IsNative()) << PrettyMethod();
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100591 return nullptr;
592 }
593
594 OatQuickMethodHeader* method_header = OatQuickMethodHeader::FromEntryPoint(oat_entry_point);
595 if (pc == 0) {
596 // This is a downcall, it can only happen for a native method.
597 DCHECK(IsNative());
598 return method_header;
599 }
600
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100601 DCHECK(method_header->Contains(pc))
David Sehr709b0702016-10-13 09:12:37 -0700602 << PrettyMethod()
Roland Levillain0b671c02016-08-19 12:02:34 +0100603 << " " << std::hex << pc << " " << oat_entry_point
Nicolas Geoffray1dad3f62015-10-23 14:59:54 +0100604 << " " << (uintptr_t)(method_header->code_ + method_header->code_size_);
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +0100605 return method_header;
606}
607
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100608const void* ArtMethod::GetOatMethodQuickCode(PointerSize pointer_size) {
609 bool found;
610 OatFile::OatMethod oat_method = FindOatMethodFor(this, pointer_size, &found);
611 if (found) {
612 return oat_method.GetQuickCode();
613 }
614 return nullptr;
615}
616
Nicolas Geoffraya5891e82015-11-06 14:18:27 +0000617bool ArtMethod::HasAnyCompiledCode() {
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100618 if (IsNative() || !IsInvokable() || IsProxyMethod()) {
619 return false;
620 }
621
Nicolas Geoffraya5891e82015-11-06 14:18:27 +0000622 // Check whether the JIT has compiled it.
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100623 Runtime* runtime = Runtime::Current();
624 jit::Jit* jit = runtime->GetJit();
Nicolas Geoffraya5891e82015-11-06 14:18:27 +0000625 if (jit != nullptr && jit->GetCodeCache()->ContainsMethod(this)) {
626 return true;
627 }
628
629 // Check whether we have AOT code.
Vladimir Marko97d7e1c2016-10-04 14:44:28 +0100630 return GetOatMethodQuickCode(runtime->GetClassLinker()->GetImagePointerSize()) != nullptr;
Nicolas Geoffraya5891e82015-11-06 14:18:27 +0000631}
Nicolas Geoffray22cf3d32015-11-02 11:57:11 +0000632
Andreas Gampe542451c2016-07-26 09:02:02 -0700633void ArtMethod::CopyFrom(ArtMethod* src, PointerSize image_pointer_size) {
Nicolas Geoffray22cf3d32015-11-02 11:57:11 +0000634 memcpy(reinterpret_cast<void*>(this), reinterpret_cast<const void*>(src),
635 Size(image_pointer_size));
636 declaring_class_ = GcRoot<mirror::Class>(const_cast<ArtMethod*>(src)->GetDeclaringClass());
637
638 // If the entry point of the method we are copying from is from JIT code, we just
639 // put the entry point of the new method to interpreter. We could set the entry point
640 // to the JIT code, but this would require taking the JIT code cache lock to notify
641 // it, which we do not want at this level.
642 Runtime* runtime = Runtime::Current();
Calin Juravleffc87072016-04-20 14:22:09 +0100643 if (runtime->UseJitCompilation()) {
Nicolas Geoffray22cf3d32015-11-02 11:57:11 +0000644 if (runtime->GetJit()->GetCodeCache()->ContainsPc(GetEntryPointFromQuickCompiledCode())) {
645 SetEntryPointFromQuickCompiledCodePtrSize(GetQuickToInterpreterBridge(), image_pointer_size);
646 }
647 }
648 // Clear the profiling info for the same reasons as the JIT code.
649 if (!src->IsNative()) {
650 SetProfilingInfoPtrSize(nullptr, image_pointer_size);
651 }
652 // Clear hotness to let the JIT properly decide when to compile this method.
653 hotness_count_ = 0;
654}
655
Andreas Gampe542451c2016-07-26 09:02:02 -0700656bool ArtMethod::IsImagePointerSize(PointerSize pointer_size) {
Andreas Gampe479b1de2016-07-19 18:27:17 -0700657 // Hijack this function to get access to PtrSizedFieldsOffset.
658 //
659 // Ensure that PrtSizedFieldsOffset is correct. We rely here on usually having both 32-bit and
660 // 64-bit builds.
661 static_assert(std::is_standard_layout<ArtMethod>::value, "ArtMethod is not standard layout.");
Andreas Gampe542451c2016-07-26 09:02:02 -0700662 static_assert(
663 (sizeof(void*) != 4) ||
664 (offsetof(ArtMethod, ptr_sized_fields_) == PtrSizedFieldsOffset(PointerSize::k32)),
665 "Unexpected 32-bit class layout.");
666 static_assert(
667 (sizeof(void*) != 8) ||
668 (offsetof(ArtMethod, ptr_sized_fields_) == PtrSizedFieldsOffset(PointerSize::k64)),
669 "Unexpected 64-bit class layout.");
Andreas Gampe479b1de2016-07-19 18:27:17 -0700670
Andreas Gampe75f08852016-07-19 08:06:07 -0700671 Runtime* runtime = Runtime::Current();
672 if (runtime == nullptr) {
673 return true;
674 }
675 return runtime->GetClassLinker()->GetImagePointerSize() == pointer_size;
676}
677
David Sehr709b0702016-10-13 09:12:37 -0700678std::string ArtMethod::PrettyMethod(ArtMethod* m, bool with_signature) {
679 if (m == nullptr) {
680 return "null";
681 }
682 return m->PrettyMethod(with_signature);
683}
684
685std::string ArtMethod::PrettyMethod(bool with_signature) {
686 ArtMethod* m = this;
687 if (!m->IsRuntimeMethod()) {
688 m = m->GetInterfaceMethodIfProxy(Runtime::Current()->GetClassLinker()->GetImagePointerSize());
689 }
690 std::string result(PrettyDescriptor(m->GetDeclaringClassDescriptor()));
691 result += '.';
692 result += m->GetName();
693 if (UNLIKELY(m->IsFastNative())) {
694 result += "!";
695 }
696 if (with_signature) {
697 const Signature signature = m->GetSignature();
698 std::string sig_as_string(signature.ToString());
699 if (signature == Signature::NoSignature()) {
700 return result + sig_as_string;
701 }
702 result = PrettyReturnType(sig_as_string.c_str()) + " " + result +
703 PrettyArguments(sig_as_string.c_str());
704 }
705 return result;
706}
707
708std::string ArtMethod::JniShortName() {
709 std::string class_name(GetDeclaringClassDescriptor());
710 // Remove the leading 'L' and trailing ';'...
711 CHECK_EQ(class_name[0], 'L') << class_name;
712 CHECK_EQ(class_name[class_name.size() - 1], ';') << class_name;
713 class_name.erase(0, 1);
714 class_name.erase(class_name.size() - 1, 1);
715
716 std::string method_name(GetName());
717
718 std::string short_name;
719 short_name += "Java_";
720 short_name += MangleForJni(class_name);
721 short_name += "_";
722 short_name += MangleForJni(method_name);
723 return short_name;
724}
725
726std::string ArtMethod::JniLongName() {
727 std::string long_name;
728 long_name += JniShortName();
729 long_name += "__";
730
731 std::string signature(GetSignature().ToString());
732 signature.erase(0, 1);
733 signature.erase(signature.begin() + signature.find(')'), signature.end());
734
735 long_name += MangleForJni(signature);
736
737 return long_name;
738}
739
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800740} // namespace art