blob: 7814f36075c95f6a9441a61581cb8ed505f3d31b [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
Brian Carlstromea46f952013-07-30 01:26:50 -070019#include "art_method-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080020#include "base/stringpiece.h"
Ian Rogers4f6ad8a2013-03-18 15:27:28 -070021#include "class-inl.h"
22#include "dex_file-inl.h"
Ian Rogersc449aa82013-07-29 14:35:46 -070023#include "dex_instruction.h"
Ian Rogers1d54e732013-05-02 21:10:01 -070024#include "gc/accounting/card_table-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080025#include "interpreter/interpreter.h"
26#include "jni_internal.h"
Ian Rogers1809a722013-08-09 22:05:32 -070027#include "mapping_table.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080028#include "object-inl.h"
29#include "object_array.h"
30#include "object_array-inl.h"
31#include "string.h"
32#include "object_utils.h"
33
34namespace art {
35namespace mirror {
36
Brian Carlstromea46f952013-07-30 01:26:50 -070037extern "C" void art_portable_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*, char);
Ian Rogers0177e532014-02-11 16:30:46 -080038extern "C" void art_quick_invoke_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*,
39 const char*);
Stuart Monteithb95a5342014-03-12 13:32:32 +000040#ifdef __LP64__
Ian Rogers936b37f2014-02-14 00:52:24 -080041extern "C" void art_quick_invoke_static_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*,
42 const char*);
43#endif
Jeff Hao5d917302013-02-27 17:57:33 -080044
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080045// TODO: get global references for these
Brian Carlstromea46f952013-07-30 01:26:50 -070046Class* ArtMethod::java_lang_reflect_ArtMethod_ = NULL;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080047
Mathieu Chartier83c8ee02014-01-28 14:50:23 -080048void ArtMethod::VisitRoots(RootCallback* callback, void* arg) {
Mathieu Chartierc528dba2013-11-26 12:00:11 -080049 if (java_lang_reflect_ArtMethod_ != nullptr) {
Mathieu Chartier815873e2014-02-13 18:02:13 -080050 callback(reinterpret_cast<mirror::Object**>(&java_lang_reflect_ArtMethod_), arg, 0,
51 kRootStickyClass);
Mathieu Chartierc528dba2013-11-26 12:00:11 -080052 }
53}
54
Ian Rogersef7d42f2014-01-06 12:55:46 -080055InvokeType ArtMethod::GetInvokeType() {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080056 // TODO: kSuper?
57 if (GetDeclaringClass()->IsInterface()) {
58 return kInterface;
59 } else if (IsStatic()) {
60 return kStatic;
61 } else if (IsDirect()) {
62 return kDirect;
63 } else {
64 return kVirtual;
65 }
66}
67
Brian Carlstromea46f952013-07-30 01:26:50 -070068void ArtMethod::SetClass(Class* java_lang_reflect_ArtMethod) {
69 CHECK(java_lang_reflect_ArtMethod_ == NULL);
70 CHECK(java_lang_reflect_ArtMethod != NULL);
71 java_lang_reflect_ArtMethod_ = java_lang_reflect_ArtMethod;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080072}
73
Brian Carlstromea46f952013-07-30 01:26:50 -070074void ArtMethod::ResetClass() {
75 CHECK(java_lang_reflect_ArtMethod_ != NULL);
76 java_lang_reflect_ArtMethod_ = NULL;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080077}
78
Brian Carlstromea46f952013-07-30 01:26:50 -070079void ArtMethod::SetDexCacheStrings(ObjectArray<String>* new_dex_cache_strings) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010080 SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_strings_),
81 new_dex_cache_strings, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080082}
83
Brian Carlstromea46f952013-07-30 01:26:50 -070084void ArtMethod::SetDexCacheResolvedMethods(ObjectArray<ArtMethod>* new_dex_cache_methods) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010085 SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_methods_),
86 new_dex_cache_methods, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080087}
88
Brian Carlstromea46f952013-07-30 01:26:50 -070089void ArtMethod::SetDexCacheResolvedTypes(ObjectArray<Class>* new_dex_cache_classes) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010090 SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, dex_cache_resolved_types_),
91 new_dex_cache_classes, false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080092}
93
Brian Carlstromea46f952013-07-30 01:26:50 -070094size_t ArtMethod::NumArgRegisters(const StringPiece& shorty) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080095 CHECK_LE(1, shorty.length());
96 uint32_t num_registers = 0;
97 for (int i = 1; i < shorty.length(); ++i) {
98 char ch = shorty[i];
99 if (ch == 'D' || ch == 'J') {
100 num_registers += 2;
101 } else {
102 num_registers += 1;
103 }
104 }
105 return num_registers;
106}
107
Ian Rogersef7d42f2014-01-06 12:55:46 -0800108bool ArtMethod::IsProxyMethod() {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800109 return GetDeclaringClass()->IsProxyClass();
110}
111
Ian Rogersef7d42f2014-01-06 12:55:46 -0800112ArtMethod* ArtMethod::FindOverriddenMethod() {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800113 if (IsStatic()) {
114 return NULL;
115 }
116 Class* declaring_class = GetDeclaringClass();
117 Class* super_class = declaring_class->GetSuperClass();
118 uint16_t method_index = GetMethodIndex();
Brian Carlstromea46f952013-07-30 01:26:50 -0700119 ObjectArray<ArtMethod>* super_class_vtable = super_class->GetVTable();
120 ArtMethod* result = NULL;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800121 // Did this method override a super class method? If so load the result from the super class'
122 // vtable
123 if (super_class_vtable != NULL && method_index < super_class_vtable->GetLength()) {
124 result = super_class_vtable->Get(method_index);
125 } else {
126 // Method didn't override superclass method so search interfaces
127 if (IsProxyMethod()) {
128 result = GetDexCacheResolvedMethods()->Get(GetDexMethodIndex());
129 CHECK_EQ(result,
130 Runtime::Current()->GetClassLinker()->FindMethodForProxy(GetDeclaringClass(), this));
131 } else {
132 MethodHelper mh(this);
133 MethodHelper interface_mh;
134 IfTable* iftable = GetDeclaringClass()->GetIfTable();
135 for (size_t i = 0; i < iftable->Count() && result == NULL; i++) {
136 Class* interface = iftable->GetInterface(i);
137 for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) {
Brian Carlstromea46f952013-07-30 01:26:50 -0700138 ArtMethod* interface_method = interface->GetVirtualMethod(j);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800139 interface_mh.ChangeMethod(interface_method);
140 if (mh.HasSameNameAndSignature(&interface_mh)) {
141 result = interface_method;
142 break;
143 }
144 }
145 }
146 }
147 }
148#ifndef NDEBUG
149 MethodHelper result_mh(result);
150 DCHECK(result == NULL || MethodHelper(this).HasSameNameAndSignature(&result_mh));
151#endif
152 return result;
153}
154
Ian Rogersef7d42f2014-01-06 12:55:46 -0800155uintptr_t ArtMethod::NativePcOffset(const uintptr_t pc) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800156 const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this);
157 return pc - reinterpret_cast<uintptr_t>(code);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800158}
159
Dave Allisonb373e092014-02-20 16:06:36 -0800160uint32_t ArtMethod::ToDexPc(const uintptr_t pc, bool abort_on_failure) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800161 if (IsPortableCompiled()) {
162 // Portable doesn't use the machine pc, we just use dex pc instead.
163 return static_cast<uint32_t>(pc);
164 }
Ian Rogers1809a722013-08-09 22:05:32 -0700165 MappingTable table(GetMappingTable());
166 if (table.TotalSize() == 0) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800167 DCHECK(IsNative() || IsCalleeSaveMethod() || IsProxyMethod()) << PrettyMethod(this);
168 return DexFile::kDexNoIndex; // Special no mapping case
169 }
Ian Rogers62d6c772013-02-27 08:32:07 -0800170 const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this);
171 uint32_t sought_offset = pc - reinterpret_cast<uintptr_t>(code);
Ian Rogers1809a722013-08-09 22:05:32 -0700172 // Assume the caller wants a pc-to-dex mapping so check here first.
173 typedef MappingTable::PcToDexIterator It;
174 for (It cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) {
175 if (cur.NativePcOffset() == sought_offset) {
176 return cur.DexPc();
177 }
178 }
179 // Now check dex-to-pc mappings.
180 typedef MappingTable::DexToPcIterator It2;
181 for (It2 cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) {
182 if (cur.NativePcOffset() == sought_offset) {
183 return cur.DexPc();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800184 }
185 }
Dave Allisonb373e092014-02-20 16:06:36 -0800186 if (abort_on_failure) {
187 LOG(FATAL) << "Failed to find Dex offset for PC offset " << reinterpret_cast<void*>(sought_offset)
188 << "(PC " << reinterpret_cast<void*>(pc) << ", code=" << code
189 << ") in " << PrettyMethod(this);
190 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800191 return DexFile::kDexNoIndex;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800192}
193
Ian Rogersef7d42f2014-01-06 12:55:46 -0800194uintptr_t ArtMethod::ToNativePc(const uint32_t dex_pc) {
Ian Rogers1809a722013-08-09 22:05:32 -0700195 MappingTable table(GetMappingTable());
196 if (table.TotalSize() == 0) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800197 DCHECK_EQ(dex_pc, 0U);
198 return 0; // Special no mapping/pc == 0 case
199 }
Ian Rogers1809a722013-08-09 22:05:32 -0700200 // Assume the caller wants a dex-to-pc mapping so check here first.
201 typedef MappingTable::DexToPcIterator It;
202 for (It cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) {
203 if (cur.DexPc() == dex_pc) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800204 const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this);
Ian Rogers1809a722013-08-09 22:05:32 -0700205 return reinterpret_cast<uintptr_t>(code) + cur.NativePcOffset();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800206 }
207 }
Ian Rogers1809a722013-08-09 22:05:32 -0700208 // Now check pc-to-dex mappings.
209 typedef MappingTable::PcToDexIterator It2;
210 for (It2 cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) {
211 if (cur.DexPc() == dex_pc) {
212 const void* code = Runtime::Current()->GetInstrumentation()->GetQuickCodeFor(this);
213 return reinterpret_cast<uintptr_t>(code) + cur.NativePcOffset();
214 }
215 }
216 LOG(FATAL) << "Failed to find native offset for dex pc 0x" << std::hex << dex_pc
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800217 << " in " << PrettyMethod(this);
218 return 0;
219}
220
Brian Carlstromea46f952013-07-30 01:26:50 -0700221uint32_t ArtMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800222 bool* has_no_move_exception) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800223 MethodHelper mh(this);
224 const DexFile::CodeItem* code_item = mh.GetCodeItem();
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700225 // Default to handler not found.
226 uint32_t found_dex_pc = DexFile::kDexNoIndex;
227 // Iterate over the catch handlers associated with dex_pc.
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800228 for (CatchHandlerIterator it(*code_item, dex_pc); it.HasNext(); it.Next()) {
229 uint16_t iter_type_idx = it.GetHandlerTypeIndex();
230 // Catch all case
231 if (iter_type_idx == DexFile::kDexNoIndex16) {
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700232 found_dex_pc = it.GetHandlerAddress();
233 break;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800234 }
235 // Does this catch exception type apply?
236 Class* iter_exception_type = mh.GetDexCacheResolvedType(iter_type_idx);
237 if (iter_exception_type == NULL) {
238 // The verifier should take care of resolving all exception classes early
239 LOG(WARNING) << "Unresolved exception class when finding catch block: "
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700240 << mh.GetTypeDescriptorFromTypeIdx(iter_type_idx);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800241 } else if (iter_exception_type->IsAssignableFrom(exception_type)) {
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700242 found_dex_pc = it.GetHandlerAddress();
243 break;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800244 }
245 }
Ian Rogers9e8f45e2013-07-31 10:58:53 -0700246 if (found_dex_pc != DexFile::kDexNoIndex) {
247 const Instruction* first_catch_instr =
248 Instruction::At(&mh.GetCodeItem()->insns_[found_dex_pc]);
249 *has_no_move_exception = (first_catch_instr->Opcode() != Instruction::MOVE_EXCEPTION);
250 }
251 return found_dex_pc;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800252}
253
Brian Carlstromea46f952013-07-30 01:26:50 -0700254void ArtMethod::Invoke(Thread* self, uint32_t* args, uint32_t args_size, JValue* result,
Ian Rogers0177e532014-02-11 16:30:46 -0800255 const char* shorty) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800256 if (kIsDebugBuild) {
257 self->AssertThreadSuspensionIsAllowable();
258 CHECK_EQ(kRunnable, self->GetState());
Ian Rogers0177e532014-02-11 16:30:46 -0800259 CHECK_STREQ(MethodHelper(this).GetShorty(), shorty);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800260 }
261
262 // Push a transition back into managed code onto the linked list in thread.
263 ManagedStack fragment;
264 self->PushManagedStackFragment(&fragment);
265
Ian Rogers62d6c772013-02-27 08:32:07 -0800266 Runtime* runtime = Runtime::Current();
Jeff Hao74180ca2013-03-27 15:29:11 -0700267 // Call the invoke stub, passing everything as arguments.
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700268 if (UNLIKELY(!runtime->IsStarted())) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800269 LOG(INFO) << "Not invoking " << PrettyMethod(this) << " for a runtime that isn't started";
270 if (result != NULL) {
271 result->SetJ(0);
272 }
273 } else {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800274 const bool kLogInvocationStartAndReturn = false;
Ian Rogersef7d42f2014-01-06 12:55:46 -0800275 bool have_quick_code = GetEntryPointFromQuickCompiledCode() != nullptr;
276 bool have_portable_code = GetEntryPointFromPortableCompiledCode() != nullptr;
277 if (LIKELY(have_quick_code || have_portable_code)) {
Jeff Hao790ad902013-05-22 15:02:08 -0700278 if (kLogInvocationStartAndReturn) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800279 LOG(INFO) << StringPrintf("Invoking '%s' %s code=%p", PrettyMethod(this).c_str(),
280 have_quick_code ? "quick" : "portable",
281 have_quick_code ? GetEntryPointFromQuickCompiledCode()
282 : GetEntryPointFromPortableCompiledCode());
Jeff Hao790ad902013-05-22 15:02:08 -0700283 }
Ian Rogersef7d42f2014-01-06 12:55:46 -0800284 if (!IsPortableCompiled()) {
Stuart Monteithb95a5342014-03-12 13:32:32 +0000285#ifdef __LP64__
Ian Rogers936b37f2014-02-14 00:52:24 -0800286 if (!IsStatic()) {
287 (*art_quick_invoke_stub)(this, args, args_size, self, result, shorty);
288 } else {
289 (*art_quick_invoke_static_stub)(this, args, args_size, self, result, shorty);
290 }
291#else
Ian Rogers0177e532014-02-11 16:30:46 -0800292 (*art_quick_invoke_stub)(this, args, args_size, self, result, shorty);
Ian Rogers936b37f2014-02-14 00:52:24 -0800293#endif
Ian Rogersef7d42f2014-01-06 12:55:46 -0800294 } else {
Ian Rogers0177e532014-02-11 16:30:46 -0800295 (*art_portable_invoke_stub)(this, args, args_size, self, result, shorty[0]);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800296 }
297 if (UNLIKELY(reinterpret_cast<intptr_t>(self->GetException(NULL)) == -1)) {
Jeff Hao790ad902013-05-22 15:02:08 -0700298 // Unusual case where we were running LLVM generated code and an
299 // exception was thrown to force the activations to be removed from the
300 // stack. Continue execution in the interpreter.
301 self->ClearException();
302 ShadowFrame* shadow_frame = self->GetAndClearDeoptimizationShadowFrame(result);
303 self->SetTopOfStack(NULL, 0);
304 self->SetTopOfShadowStack(shadow_frame);
305 interpreter::EnterInterpreterFromDeoptimize(self, shadow_frame, result);
306 }
307 if (kLogInvocationStartAndReturn) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800308 LOG(INFO) << StringPrintf("Returned '%s' %s code=%p", PrettyMethod(this).c_str(),
309 have_quick_code ? "quick" : "portable",
310 have_quick_code ? GetEntryPointFromQuickCompiledCode()
311 : GetEntryPointFromPortableCompiledCode());
Jeff Hao5d917302013-02-27 17:57:33 -0800312 }
313 } else {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800314 LOG(INFO) << "Not invoking '" << PrettyMethod(this) << "' code=null";
Jeff Hao5d917302013-02-27 17:57:33 -0800315 if (result != NULL) {
316 result->SetJ(0);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800317 }
318 }
319 }
320
321 // Pop transition.
322 self->PopManagedStackFragment(fragment);
323}
324
Ian Rogersef7d42f2014-01-06 12:55:46 -0800325bool ArtMethod::IsRegistered() {
326 void* native_method =
327 GetFieldPtr<void*>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, entry_point_from_jni_), false);
328 CHECK(native_method != nullptr);
Jeff Hao79fe5392013-04-24 18:41:58 -0700329 void* jni_stub = GetJniDlsymLookupStub();
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800330 return native_method != jni_stub;
331}
332
Ian Rogers848871b2013-08-05 10:56:33 -0700333extern "C" void art_work_around_app_jni_bugs(JNIEnv*, jobject);
Ian Rogers1eb512d2013-10-18 15:42:20 -0700334void ArtMethod::RegisterNative(Thread* self, const void* native_method, bool is_fast) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800335 DCHECK(Thread::Current() == self);
336 CHECK(IsNative()) << PrettyMethod(this);
Ian Rogers1eb512d2013-10-18 15:42:20 -0700337 CHECK(!IsFastNative()) << PrettyMethod(this);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800338 CHECK(native_method != NULL) << PrettyMethod(this);
339 if (!self->GetJniEnv()->vm->work_around_app_jni_bugs) {
Ian Rogers1eb512d2013-10-18 15:42:20 -0700340 if (is_fast) {
341 SetAccessFlags(GetAccessFlags() | kAccFastNative);
342 }
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800343 SetNativeMethod(native_method);
344 } else {
345 // We've been asked to associate this method with the given native method but are working
346 // around JNI bugs, that include not giving Object** SIRT references to native methods. Direct
347 // the native method to runtime support and store the target somewhere runtime support will
348 // find it.
Ian Rogersef7d42f2014-01-06 12:55:46 -0800349#if defined(__i386__) || defined(__x86_64__)
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800350 UNIMPLEMENTED(FATAL);
Ian Rogers848871b2013-08-05 10:56:33 -0700351#else
352 SetNativeMethod(reinterpret_cast<void*>(art_work_around_app_jni_bugs));
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800353#endif
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100354 SetFieldPtr<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_),
355 reinterpret_cast<const uint8_t*>(native_method), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800356 }
357}
358
Brian Carlstromea46f952013-07-30 01:26:50 -0700359void ArtMethod::UnregisterNative(Thread* self) {
Ian Rogers1eb512d2013-10-18 15:42:20 -0700360 CHECK(IsNative() && !IsFastNative()) << PrettyMethod(this);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800361 // restore stub to lookup native pointer via dlsym
Ian Rogers1eb512d2013-10-18 15:42:20 -0700362 RegisterNative(self, GetJniDlsymLookupStub(), false);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800363}
364
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800365} // namespace mirror
366} // namespace art