blob: 3dfad767bd545db0a442112919c7c0f34e309706 [file] [log] [blame]
Shih-wei Liao2d831012011-09-28 22:06:53 -07001/*
Elliott Hughes0f3c5532012-03-30 14:51:51 -07002 * Copyright (C) 2012 The Android Open Source Project
Shih-wei Liao2d831012011-09-28 22:06:53 -07003 *
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
Ian Rogers7655f292013-07-29 11:07:13 -070017#include "entrypoints/entrypoint_utils.h"
Shih-wei Liao2d831012011-09-28 22:06:53 -070018
Mathieu Chartierc7853442015-03-27 14:35:38 -070019#include "art_field-inl.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070020#include "art_method-inl.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070021#include "base/mutex.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080022#include "class_linker-inl.h"
Ian Rogers4f6ad8a2013-03-18 15:27:28 -070023#include "dex_file-inl.h"
Nicolas Geoffray1920c102015-09-29 18:00:03 +000024#include "entrypoints/entrypoint_utils-inl.h"
25#include "entrypoints/quick/callee_save_frame.h"
26#include "entrypoints/runtime_asm_entrypoints.h"
Ian Rogers1d54e732013-05-02 21:10:01 -070027#include "gc/accounting/card_table-inl.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080028#include "mirror/class-inl.h"
Mathieu Chartierfc58af42015-04-16 18:00:39 -070029#include "mirror/method.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080030#include "mirror/object-inl.h"
31#include "mirror/object_array-inl.h"
Nicolas Geoffray1920c102015-09-29 18:00:03 +000032#include "nth_caller_visitor.h"
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +010033#include "oat_quick_method_header.h"
Ian Rogersaf6e67a2013-01-16 08:38:37 -080034#include "reflection.h"
35#include "scoped_thread_state_change.h"
Elliott Hugheseac76672012-05-24 21:56:51 -070036#include "well_known_classes.h"
TDYa1275bb86012012-04-11 05:57:28 -070037
jeffhao41005dd2012-05-09 17:58:52 -070038namespace art {
39
Brian Carlstrom34375312014-09-10 23:10:47 -070040static inline mirror::Class* CheckFilledNewArrayAlloc(uint32_t type_idx,
Brian Carlstrom34375312014-09-10 23:10:47 -070041 int32_t component_count,
Mathieu Chartiere401d142015-04-22 13:56:20 -070042 ArtMethod* referrer,
Brian Carlstrom34375312014-09-10 23:10:47 -070043 Thread* self,
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080044 bool access_check)
Mathieu Chartier90443472015-07-16 20:32:27 -070045 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogers57b86d42012-03-27 16:05:41 -070046 if (UNLIKELY(component_count < 0)) {
Ian Rogers62d6c772013-02-27 08:32:07 -080047 ThrowNegativeArraySizeException(component_count);
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080048 return nullptr; // Failure
Elliott Hughes6c8867d2011-10-03 16:34:05 -070049 }
Vladimir Marko05792b92015-08-03 11:56:49 +010050 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
51 size_t pointer_size = class_linker->GetImagePointerSize();
52 mirror::Class* klass = referrer->GetDexCacheResolvedType<false>(type_idx, pointer_size);
Mathieu Chartier2cebb242015-04-21 16:50:40 -070053 if (UNLIKELY(klass == nullptr)) { // Not in dex cache so try to resolve
Vladimir Marko05792b92015-08-03 11:56:49 +010054 klass = class_linker->ResolveType(type_idx, referrer);
Mathieu Chartier2cebb242015-04-21 16:50:40 -070055 if (klass == nullptr) { // Error
Ian Rogers50b35e22012-10-04 10:09:15 -070056 DCHECK(self->IsExceptionPending());
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080057 return nullptr; // Failure
Ian Rogers19846512012-02-24 11:42:47 -080058 }
Ian Rogersea2a11d2011-10-11 16:48:51 -070059 }
Ian Rogers57b86d42012-03-27 16:05:41 -070060 if (UNLIKELY(klass->IsPrimitive() && !klass->IsPrimitiveInt())) {
61 if (klass->IsPrimitiveLong() || klass->IsPrimitiveDouble()) {
Ian Rogers62d6c772013-02-27 08:32:07 -080062 ThrowRuntimeException("Bad filled array request for type %s",
63 PrettyDescriptor(klass).c_str());
Ian Rogers573db4a2011-12-13 15:30:50 -080064 } else {
Brian Carlstrom34375312014-09-10 23:10:47 -070065 self->ThrowNewExceptionF(
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +000066 "Ljava/lang/InternalError;",
Brian Carlstrom34375312014-09-10 23:10:47 -070067 "Found type %s; filled-new-array not implemented for anything but 'int'",
68 PrettyDescriptor(klass).c_str());
Ian Rogers573db4a2011-12-13 15:30:50 -080069 }
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080070 return nullptr; // Failure
Ian Rogers57b86d42012-03-27 16:05:41 -070071 }
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -070072 if (access_check) {
73 mirror::Class* referrer_klass = referrer->GetDeclaringClass();
74 if (UNLIKELY(!referrer_klass->CanAccess(klass))) {
75 ThrowIllegalAccessErrorClass(referrer_klass, klass);
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080076 return nullptr; // Failure
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -070077 }
78 }
79 DCHECK(klass->IsArrayClass()) << PrettyClass(klass);
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080080 return klass;
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -070081}
82
83// Helper function to allocate array for FILLED_NEW_ARRAY.
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080084mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, int32_t component_count,
Mathieu Chartiere401d142015-04-22 13:56:20 -070085 ArtMethod* referrer, Thread* self,
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080086 bool access_check,
Mathieu Chartiere6da9af2013-12-16 11:54:42 -080087 gc::AllocatorType /* allocator_type */) {
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080088 mirror::Class* klass = CheckFilledNewArrayAlloc(type_idx, component_count, referrer, self,
Mathieu Chartiercbb2d202013-11-14 17:45:16 -080089 access_check);
90 if (UNLIKELY(klass == nullptr)) {
91 return nullptr;
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -070092 }
Mathieu Chartiere6da9af2013-12-16 11:54:42 -080093 // Always go slow path for now, filled new array is not common.
94 gc::Heap* heap = Runtime::Current()->GetHeap();
95 // Use the current allocator type in case CheckFilledNewArrayAlloc caused us to suspend and then
96 // the heap switched the allocator type while we were suspended.
Hiroshi Yamauchif0edfc32014-09-25 11:46:46 -070097 return mirror::Array::Alloc<false>(self, klass, component_count,
98 klass->GetComponentSizeShift(),
Ian Rogers6fac4472014-02-25 17:01:10 -080099 heap->GetCurrentAllocator());
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700100}
101
102// Helper function to allocate array for FILLED_NEW_ARRAY.
Brian Carlstrom34375312014-09-10 23:10:47 -0700103mirror::Array* CheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx,
Brian Carlstrom34375312014-09-10 23:10:47 -0700104 int32_t component_count,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700105 ArtMethod* referrer,
Brian Carlstrom34375312014-09-10 23:10:47 -0700106 Thread* self,
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800107 bool access_check,
Mathieu Chartiere6da9af2013-12-16 11:54:42 -0800108 gc::AllocatorType /* allocator_type */) {
Andreas Gampe1cc7dba2014-12-17 18:43:01 -0800109 mirror::Class* klass = CheckFilledNewArrayAlloc(type_idx, component_count, referrer, self,
Mathieu Chartiercbb2d202013-11-14 17:45:16 -0800110 access_check);
111 if (UNLIKELY(klass == nullptr)) {
112 return nullptr;
Hiroshi Yamauchi3b4c1892013-09-12 21:33:12 -0700113 }
Mathieu Chartiere6da9af2013-12-16 11:54:42 -0800114 gc::Heap* heap = Runtime::Current()->GetHeap();
115 // Use the current allocator type in case CheckFilledNewArrayAlloc caused us to suspend and then
116 // the heap switched the allocator type while we were suspended.
Hiroshi Yamauchif0edfc32014-09-25 11:46:46 -0700117 return mirror::Array::Alloc<true>(self, klass, component_count,
118 klass->GetComponentSizeShift(),
Ian Rogers6fac4472014-02-25 17:01:10 -0800119 heap->GetCurrentAllocator());
Ian Rogers57b86d42012-03-27 16:05:41 -0700120}
121
Ian Rogerse5877a12014-07-16 12:06:35 -0700122void CheckReferenceResult(mirror::Object* o, Thread* self) {
Ian Rogersc0542af2014-09-03 16:16:56 -0700123 if (o == nullptr) {
Ian Rogerse5877a12014-07-16 12:06:35 -0700124 return;
125 }
Ian Rogerse5877a12014-07-16 12:06:35 -0700126 // Make sure that the result is an instance of the type this method was expected to return.
Vladimir Marko05792b92015-08-03 11:56:49 +0100127 mirror::Class* return_type = self->GetCurrentMethod(nullptr)->GetReturnType(true /* resolve */,
128 sizeof(void*));
Ian Rogerse5877a12014-07-16 12:06:35 -0700129
130 if (!o->InstanceOf(return_type)) {
Ian Rogersc0542af2014-09-03 16:16:56 -0700131 Runtime::Current()->GetJavaVM()->JniAbortF(nullptr,
132 "attempt to return an instance of %s from %s",
Ian Rogers68d8b422014-07-17 11:09:10 -0700133 PrettyTypeOf(o).c_str(),
Ian Rogersded66a02014-10-28 18:12:55 -0700134 PrettyMethod(self->GetCurrentMethod(nullptr)).c_str());
Ian Rogerse5877a12014-07-16 12:06:35 -0700135 }
136}
137
Mathieu Chartier2b7c4d12014-05-19 10:52:16 -0700138JValue InvokeProxyInvocationHandler(ScopedObjectAccessAlreadyRunnable& soa, const char* shorty,
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800139 jobject rcvr_jobj, jobject interface_method_jobj,
140 std::vector<jvalue>& args) {
141 DCHECK(soa.Env()->IsInstanceOf(rcvr_jobj, WellKnownClasses::java_lang_reflect_Proxy));
142
143 // Build argument array possibly triggering GC.
144 soa.Self()->AssertThreadSuspensionIsAllowable();
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700145 jobjectArray args_jobj = nullptr;
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800146 const JValue zero;
Jeff Haof00571c2014-05-29 17:29:47 -0700147 int32_t target_sdk_version = Runtime::Current()->GetTargetSdkVersion();
148 // Do not create empty arrays unless needed to maintain Dalvik bug compatibility.
149 if (args.size() > 0 || (target_sdk_version > 0 && target_sdk_version <= 21)) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700150 args_jobj = soa.Env()->NewObjectArray(args.size(), WellKnownClasses::java_lang_Object, nullptr);
151 if (args_jobj == nullptr) {
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800152 CHECK(soa.Self()->IsExceptionPending());
153 return zero;
154 }
155 for (size_t i = 0; i < args.size(); ++i) {
156 if (shorty[i + 1] == 'L') {
157 jobject val = args.at(i).l;
158 soa.Env()->SetObjectArrayElement(args_jobj, i, val);
159 } else {
160 JValue jv;
161 jv.SetJ(args.at(i).j);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800162 mirror::Object* val = BoxPrimitive(Primitive::GetType(shorty[i + 1]), jv);
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700163 if (val == nullptr) {
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800164 CHECK(soa.Self()->IsExceptionPending());
165 return zero;
166 }
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100167 soa.Decode<mirror::ObjectArray<mirror::Object>* >(args_jobj)->Set<false>(i, val);
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800168 }
169 }
170 }
171
Mathieu Chartierfc58af42015-04-16 18:00:39 -0700172 // Call Proxy.invoke(Proxy proxy, Method method, Object[] args).
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800173 jvalue invocation_args[3];
174 invocation_args[0].l = rcvr_jobj;
175 invocation_args[1].l = interface_method_jobj;
176 invocation_args[2].l = args_jobj;
177 jobject result =
Brian Carlstromea46f952013-07-30 01:26:50 -0700178 soa.Env()->CallStaticObjectMethodA(WellKnownClasses::java_lang_reflect_Proxy,
179 WellKnownClasses::java_lang_reflect_Proxy_invoke,
180 invocation_args);
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800181
182 // Unbox result and handle error conditions.
Ian Rogers62d6c772013-02-27 08:32:07 -0800183 if (LIKELY(!soa.Self()->IsExceptionPending())) {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700184 if (shorty[0] == 'V' || (shorty[0] == 'L' && result == nullptr)) {
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800185 // Do nothing.
186 return zero;
187 } else {
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700188 StackHandleScope<1> hs(soa.Self());
Mathieu Chartierfc58af42015-04-16 18:00:39 -0700189 auto h_interface_method(hs.NewHandle(soa.Decode<mirror::Method*>(interface_method_jobj)));
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700190 // This can cause thread suspension.
Vladimir Marko05792b92015-08-03 11:56:49 +0100191 size_t pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
192 mirror::Class* result_type =
193 h_interface_method->GetArtMethod()->GetReturnType(true /* resolve */, pointer_size);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800194 mirror::Object* result_ref = soa.Decode<mirror::Object*>(result);
Ian Rogers62d6c772013-02-27 08:32:07 -0800195 JValue result_unboxed;
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000196 if (!UnboxPrimitiveForResult(result_ref, result_type, &result_unboxed)) {
Ian Rogers530f71c2013-02-22 23:29:00 -0800197 DCHECK(soa.Self()->IsExceptionPending());
Ian Rogers62d6c772013-02-27 08:32:07 -0800198 return zero;
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800199 }
200 return result_unboxed;
201 }
202 } else {
203 // In the case of checked exceptions that aren't declared, the exception must be wrapped by
204 // a UndeclaredThrowableException.
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000205 mirror::Throwable* exception = soa.Self()->GetException();
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800206 if (exception->IsCheckedException()) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800207 mirror::Object* rcvr = soa.Decode<mirror::Object*>(rcvr_jobj);
Mingyao Yang98d1cc82014-05-15 17:02:16 -0700208 mirror::Class* proxy_class = rcvr->GetClass();
Mathieu Chartierfc58af42015-04-16 18:00:39 -0700209 mirror::Method* interface_method = soa.Decode<mirror::Method*>(interface_method_jobj);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700210 ArtMethod* proxy_method = rcvr->GetClass()->FindVirtualMethodForInterface(
211 interface_method->GetArtMethod(), sizeof(void*));
Alex Lighte64300b2015-12-15 15:02:47 -0800212 auto virtual_methods = proxy_class->GetVirtualMethodsSlice(sizeof(void*));
Mathieu Chartiere401d142015-04-22 13:56:20 -0700213 size_t num_virtuals = proxy_class->NumVirtualMethods();
Vladimir Marko14632852015-08-17 12:07:23 +0100214 size_t method_size = ArtMethod::Size(sizeof(void*));
Alex Lighte64300b2015-12-15 15:02:47 -0800215 // Rely on the fact that the methods are contiguous to determine the index of the method in
216 // the slice.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700217 int throws_index = (reinterpret_cast<uintptr_t>(proxy_method) -
Alex Lighte64300b2015-12-15 15:02:47 -0800218 reinterpret_cast<uintptr_t>(&virtual_methods.At(0))) / method_size;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700219 CHECK_LT(throws_index, static_cast<int>(num_virtuals));
Brian Carlstrom34375312014-09-10 23:10:47 -0700220 mirror::ObjectArray<mirror::Class>* declared_exceptions =
Nicolas Geoffray3a090922015-11-24 09:17:30 +0000221 proxy_class->GetThrows()->Get(throws_index);
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800222 mirror::Class* exception_class = exception->GetClass();
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800223 bool declares_exception = false;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700224 for (int32_t i = 0; i < declared_exceptions->GetLength() && !declares_exception; i++) {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800225 mirror::Class* declared_exception = declared_exceptions->Get(i);
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800226 declares_exception = declared_exception->IsAssignableFrom(exception_class);
227 }
228 if (!declares_exception) {
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000229 soa.Self()->ThrowNewWrappedException("Ljava/lang/reflect/UndeclaredThrowableException;",
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700230 nullptr);
Ian Rogersaf6e67a2013-01-16 08:38:37 -0800231 }
232 }
233 return zero;
234 }
235}
Ian Rogers832336b2014-10-08 15:35:22 -0700236
237bool FillArrayData(mirror::Object* obj, const Instruction::ArrayDataPayload* payload) {
238 DCHECK_EQ(payload->ident, static_cast<uint16_t>(Instruction::kArrayDataSignature));
239 if (UNLIKELY(obj == nullptr)) {
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000240 ThrowNullPointerException("null array in FILL_ARRAY_DATA");
Ian Rogers832336b2014-10-08 15:35:22 -0700241 return false;
242 }
243 mirror::Array* array = obj->AsArray();
244 DCHECK(!array->IsObjectArray());
245 if (UNLIKELY(static_cast<int32_t>(payload->element_count) > array->GetLength())) {
246 Thread* self = Thread::Current();
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000247 self->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;",
Ian Rogers832336b2014-10-08 15:35:22 -0700248 "failed FILL_ARRAY_DATA; length=%d, index=%d",
249 array->GetLength(), payload->element_count);
250 return false;
251 }
252 // Copy data from dex file to memory assuming both are little endian.
253 uint32_t size_in_bytes = payload->element_count * payload->element_width;
254 memcpy(array->GetRawData(payload->element_width, 0), payload->data, size_in_bytes);
255 return true;
256}
257
Nicolas Geoffray1920c102015-09-29 18:00:03 +0000258ArtMethod* GetCalleeSaveMethodCaller(ArtMethod** sp,
259 Runtime::CalleeSaveType type,
260 bool do_caller_check)
261 SHARED_REQUIRES(Locks::mutator_lock_) {
262 DCHECK_EQ(*sp, Runtime::Current()->GetCalleeSaveMethod(type));
263
264 const size_t callee_frame_size = GetCalleeSaveFrameSize(kRuntimeISA, type);
265 auto** caller_sp = reinterpret_cast<ArtMethod**>(
266 reinterpret_cast<uintptr_t>(sp) + callee_frame_size);
Nicolas Geoffray524e7ea2015-10-16 17:13:34 +0100267 const size_t callee_return_pc_offset = GetCalleeSaveReturnPcOffset(kRuntimeISA, type);
268 uintptr_t caller_pc = *reinterpret_cast<uintptr_t*>(
269 (reinterpret_cast<uint8_t*>(sp) + callee_return_pc_offset));
Nicolas Geoffray1920c102015-09-29 18:00:03 +0000270 ArtMethod* outer_method = *caller_sp;
271 ArtMethod* caller = outer_method;
Nicolas Geoffray63e47f42015-11-05 13:26:17 +0000272 if (LIKELY(caller_pc != reinterpret_cast<uintptr_t>(GetQuickInstrumentationExitPc()))) {
273 if (outer_method != nullptr) {
274 const OatQuickMethodHeader* current_code = outer_method->GetOatQuickMethodHeader(caller_pc);
275 if (current_code->IsOptimized()) {
Nicolas Geoffrayb331feb2016-02-05 16:51:53 +0000276 uintptr_t native_pc_offset = current_code->NativeQuickPcOffset(caller_pc);
277 CodeInfo code_info = current_code->GetOptimizedCodeInfo();
278 StackMapEncoding encoding = code_info.ExtractEncoding();
279 StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset, encoding);
280 DCHECK(stack_map.IsValid());
281 if (stack_map.HasInlineInfo(encoding)) {
282 InlineInfo inline_info = code_info.GetInlineInfoOf(stack_map, encoding);
283 caller = GetResolvedMethod(outer_method, inline_info, inline_info.GetDepth() - 1);
284 }
Nicolas Geoffray1920c102015-09-29 18:00:03 +0000285 }
286 }
Nicolas Geoffray63e47f42015-11-05 13:26:17 +0000287 if (kIsDebugBuild && do_caller_check) {
288 // Note that do_caller_check is optional, as this method can be called by
289 // stubs, and tests without a proper call stack.
290 NthCallerVisitor visitor(Thread::Current(), 1, true);
291 visitor.WalkStack();
292 CHECK_EQ(caller, visitor.caller);
293 }
294 } else {
295 // We're instrumenting, just use the StackVisitor which knows how to
296 // handle instrumented frames.
Nicolas Geoffray1920c102015-09-29 18:00:03 +0000297 NthCallerVisitor visitor(Thread::Current(), 1, true);
298 visitor.WalkStack();
Nicolas Geoffray63e47f42015-11-05 13:26:17 +0000299 caller = visitor.caller;
Nicolas Geoffray1920c102015-09-29 18:00:03 +0000300 }
301
302 return caller;
303}
304
Shih-wei Liao2d831012011-09-28 22:06:53 -0700305} // namespace art