blob: 34c75a39ff498af349a6dbab66e5c94ae0cff641 [file] [log] [blame]
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001/*
2 * Copyright (C) 2012 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_INTERPRETER_INTERPRETER_COMMON_H_
18#define ART_RUNTIME_INTERPRETER_INTERPRETER_COMMON_H_
19
20#include "interpreter.h"
buzbee78f1bdc2017-03-01 10:55:57 -080021#include "interpreter_intrinsics.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020022
23#include <math.h>
24
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070025#include <atomic>
Ian Rogerscf7f1912014-10-22 22:06:39 -070026#include <iostream>
Ian Rogersc7dd2952014-10-21 23:31:19 -070027#include <sstream>
28
Andreas Gampe57943812017-12-06 21:39:13 -080029#include <android-base/logging.h>
30#include <android-base/stringprintf.h>
Andreas Gampe46ee31b2016-12-14 10:11:49 -080031
Mathieu Chartierc7853442015-03-27 14:35:38 -070032#include "art_field-inl.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070033#include "art_method-inl.h"
Andreas Gampe542451c2016-07-26 09:02:02 -070034#include "base/enums.h"
Andreas Gampe794ad762015-02-23 08:12:24 -080035#include "base/macros.h"
Andreas Gampe57943812017-12-06 21:39:13 -080036#include "base/mutex.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020037#include "class_linker-inl.h"
Orion Hodson811bd5f2016-12-07 11:35:37 +000038#include "common_dex_operations.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020039#include "common_throws.h"
David Sehr9e734c72018-01-04 17:56:19 -080040#include "dex/dex_file-inl.h"
41#include "dex/dex_instruction-inl.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070042#include "entrypoints/entrypoint_utils-inl.h"
Mathieu Chartier0cd81352014-05-22 16:48:55 -070043#include "handle_scope-inl.h"
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +010044#include "jit/jit.h"
Orion Hodsonc069a302017-01-18 09:23:12 +000045#include "mirror/call_site.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020046#include "mirror/class-inl.h"
Christina Wadsworthbf44e0e2016-08-18 10:37:42 -070047#include "mirror/dex_cache.h"
48#include "mirror/method.h"
Orion Hodsonc069a302017-01-18 09:23:12 +000049#include "mirror/method_handles_lookup.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020050#include "mirror/object-inl.h"
51#include "mirror/object_array-inl.h"
Douglas Leung4965c022014-06-11 11:41:11 -070052#include "mirror/string-inl.h"
Mathieu Chartieref41db72016-10-25 15:08:01 -070053#include "obj_ptr.h"
Andreas Gampe03ec9302015-08-27 17:41:47 -070054#include "stack.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020055#include "thread.h"
Orion Hodson811bd5f2016-12-07 11:35:37 +000056#include "unstarted_runtime.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020057#include "well_known_classes.h"
58
Sebastien Hertz8ece0502013-08-07 11:26:41 +020059namespace art {
60namespace interpreter {
61
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +000062void ThrowNullPointerExceptionFromInterpreter()
Andreas Gampebdf7f1c2016-08-30 16:38:47 -070063 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzda843e12014-05-28 19:28:31 +020064
Andreas Gampe03ec9302015-08-27 17:41:47 -070065template <bool kMonitorCounting>
Mathieu Chartieref41db72016-10-25 15:08:01 -070066static inline void DoMonitorEnter(Thread* self, ShadowFrame* frame, ObjPtr<mirror::Object> ref)
Mathieu Chartier2d096c92015-10-12 16:18:20 -070067 NO_THREAD_SAFETY_ANALYSIS
68 REQUIRES(!Roles::uninterruptible_) {
Alex Light77fee872017-09-05 14:51:49 -070069 DCHECK(!ref.IsNull());
Mathieu Chartier2d096c92015-10-12 16:18:20 -070070 StackHandleScope<1> hs(self);
Mathieu Chartieref41db72016-10-25 15:08:01 -070071 Handle<mirror::Object> h_ref(hs.NewHandle(ref));
Mathieu Chartier2d096c92015-10-12 16:18:20 -070072 h_ref->MonitorEnter(self);
Alex Light77fee872017-09-05 14:51:49 -070073 DCHECK(self->HoldsLock(h_ref.Get()));
74 if (UNLIKELY(self->IsExceptionPending())) {
75 bool unlocked = h_ref->MonitorExit(self);
76 DCHECK(unlocked);
77 return;
78 }
Andreas Gampe56fdd0e2016-04-28 14:56:54 -070079 if (kMonitorCounting && frame->GetMethod()->MustCountLocks()) {
80 frame->GetLockCountData().AddMonitor(self, h_ref.Get());
81 }
Sebastien Hertz8ece0502013-08-07 11:26:41 +020082}
83
Andreas Gampe03ec9302015-08-27 17:41:47 -070084template <bool kMonitorCounting>
Mathieu Chartieref41db72016-10-25 15:08:01 -070085static inline void DoMonitorExit(Thread* self, ShadowFrame* frame, ObjPtr<mirror::Object> ref)
Mathieu Chartier2d096c92015-10-12 16:18:20 -070086 NO_THREAD_SAFETY_ANALYSIS
87 REQUIRES(!Roles::uninterruptible_) {
88 StackHandleScope<1> hs(self);
Mathieu Chartieref41db72016-10-25 15:08:01 -070089 Handle<mirror::Object> h_ref(hs.NewHandle(ref));
Mathieu Chartier2d096c92015-10-12 16:18:20 -070090 h_ref->MonitorExit(self);
Andreas Gampe56fdd0e2016-04-28 14:56:54 -070091 if (kMonitorCounting && frame->GetMethod()->MustCountLocks()) {
92 frame->GetLockCountData().RemoveMonitorOrThrow(self, h_ref.Get());
93 }
94}
95
96template <bool kMonitorCounting>
97static inline bool DoMonitorCheckOnExit(Thread* self, ShadowFrame* frame)
98 NO_THREAD_SAFETY_ANALYSIS
99 REQUIRES(!Roles::uninterruptible_) {
100 if (kMonitorCounting && frame->GetMethod()->MustCountLocks()) {
101 return frame->GetLockCountData().CheckAllMonitorsReleasedOrThrow(self);
102 }
103 return true;
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200104}
105
Sebastien Hertz45b15972015-04-03 16:07:05 +0200106void AbortTransactionF(Thread* self, const char* fmt, ...)
107 __attribute__((__format__(__printf__, 2, 3)))
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700108 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz45b15972015-04-03 16:07:05 +0200109
110void AbortTransactionV(Thread* self, const char* fmt, va_list args)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700111 REQUIRES_SHARED(Locks::mutator_lock_);
Mathieu Chartierb2c7ead2014-04-29 11:13:16 -0700112
Mathieu Chartieref41db72016-10-25 15:08:01 -0700113void RecordArrayElementsInTransaction(ObjPtr<mirror::Array> array, int32_t count)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700114 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100115
buzbee78f1bdc2017-03-01 10:55:57 -0800116// Invokes the given method. This is part of the invocation support and is used by DoInvoke,
117// DoFastInvoke and DoInvokeVirtualQuick functions.
Sebastien Hertzc6714852013-09-30 16:42:32 +0200118// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200119template<bool is_range, bool do_assignability_check>
Ian Rogerse94652f2014-12-02 11:13:19 -0800120bool DoCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame,
Sebastien Hertzc6714852013-09-30 16:42:32 +0200121 const Instruction* inst, uint16_t inst_data, JValue* result);
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200122
buzbee78f1bdc2017-03-01 10:55:57 -0800123// Handles streamlined non-range invoke static, direct and virtual instructions originating in
124// mterp. Access checks and instrumentation other than jit profiling are not supported, but does
125// support interpreter intrinsics if applicable.
126// Returns true on success, otherwise throws an exception and returns false.
127template<InvokeType type>
128static inline bool DoFastInvoke(Thread* self,
129 ShadowFrame& shadow_frame,
130 const Instruction* inst,
131 uint16_t inst_data,
132 JValue* result) {
133 const uint32_t method_idx = inst->VRegB_35c();
134 const uint32_t vregC = inst->VRegC_35c();
135 ObjPtr<mirror::Object> receiver = (type == kStatic)
136 ? nullptr
137 : shadow_frame.GetVRegReference(vregC);
138 ArtMethod* sf_method = shadow_frame.GetMethod();
139 ArtMethod* const called_method = FindMethodFromCode<type, false>(
140 method_idx, &receiver, sf_method, self);
141 // The shadow frame should already be pushed, so we don't need to update it.
142 if (UNLIKELY(called_method == nullptr)) {
143 CHECK(self->IsExceptionPending());
144 result->SetJ(0);
145 return false;
146 } else if (UNLIKELY(!called_method->IsInvokable())) {
147 called_method->ThrowInvocationTimeError();
148 result->SetJ(0);
149 return false;
150 } else {
buzbee78f1bdc2017-03-01 10:55:57 -0800151 jit::Jit* jit = Runtime::Current()->GetJit();
Nicolas Geoffraycecc4882017-08-09 19:14:01 +0100152 if (jit != nullptr && type == kVirtual) {
153 jit->InvokeVirtualOrInterface(receiver, sf_method, shadow_frame.GetDexPC(), called_method);
buzbee78f1bdc2017-03-01 10:55:57 -0800154 }
Nicolas Geoffrayb9bec2e2017-05-24 15:59:18 +0100155 if (called_method->IsIntrinsic()) {
156 if (MterpHandleIntrinsic(&shadow_frame, called_method, inst, inst_data,
157 shadow_frame.GetResultRegister())) {
158 return !self->IsExceptionPending();
159 }
160 }
buzbee78f1bdc2017-03-01 10:55:57 -0800161 return DoCall<false, false>(called_method, self, shadow_frame, inst, inst_data, result);
162 }
163}
164
Narayan Kamath9823e782016-08-03 12:46:58 +0100165// Handles all invoke-XXX/range instructions except for invoke-polymorphic[/range].
Sebastien Hertzc6714852013-09-30 16:42:32 +0200166// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200167template<InvokeType type, bool is_range, bool do_access_check>
Mathieu Chartieref41db72016-10-25 15:08:01 -0700168static inline bool DoInvoke(Thread* self,
169 ShadowFrame& shadow_frame,
170 const Instruction* inst,
171 uint16_t inst_data,
172 JValue* result) {
Alex Light848574c2017-09-25 16:59:39 -0700173 // Make sure to check for async exceptions before anything else.
174 if (UNLIKELY(self->ObserveAsyncException())) {
175 return false;
176 }
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200177 const uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c();
178 const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c();
Roland Levillain2ae376f2018-01-30 11:35:11 +0000179 ObjPtr<mirror::Object> receiver =
180 (type == kStatic) ? nullptr : shadow_frame.GetVRegReference(vregC);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700181 ArtMethod* sf_method = shadow_frame.GetMethod();
Ian Rogerse94652f2014-12-02 11:13:19 -0800182 ArtMethod* const called_method = FindMethodFromCode<type, do_access_check>(
Andreas Gampe3a357142015-08-07 17:20:11 -0700183 method_idx, &receiver, sf_method, self);
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700184 // The shadow frame should already be pushed, so we don't need to update it.
Ian Rogerse94652f2014-12-02 11:13:19 -0800185 if (UNLIKELY(called_method == nullptr)) {
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200186 CHECK(self->IsExceptionPending());
187 result->SetJ(0);
188 return false;
Alex Light9139e002015-10-09 15:59:48 -0700189 } else if (UNLIKELY(!called_method->IsInvokable())) {
190 called_method->ThrowInvocationTimeError();
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200191 result->SetJ(0);
192 return false;
193 } else {
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100194 jit::Jit* jit = Runtime::Current()->GetJit();
Nicolas Geoffraycecc4882017-08-09 19:14:01 +0100195 if (jit != nullptr && (type == kVirtual || type == kInterface)) {
196 jit->InvokeVirtualOrInterface(receiver, sf_method, shadow_frame.GetDexPC(), called_method);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100197 }
198 // TODO: Remove the InvokeVirtualOrInterface instrumentation, as it was only used by the JIT.
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100199 if (type == kVirtual || type == kInterface) {
200 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
201 if (UNLIKELY(instrumentation->HasInvokeVirtualOrInterfaceListeners())) {
202 instrumentation->InvokeVirtualOrInterface(
Mathieu Chartieref41db72016-10-25 15:08:01 -0700203 self, receiver.Ptr(), sf_method, shadow_frame.GetDexPC(), called_method);
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100204 }
205 }
Ian Rogerse94652f2014-12-02 11:13:19 -0800206 return DoCall<is_range, do_access_check>(called_method, self, shadow_frame, inst, inst_data,
207 result);
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200208 }
209}
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200210
Vladimir Markoaf940202017-12-08 15:01:18 +0000211static inline ObjPtr<mirror::MethodHandle> ResolveMethodHandle(Thread* self,
212 uint32_t method_handle_index,
213 ArtMethod* referrer)
Orion Hodson2e599942017-09-22 16:17:41 +0100214 REQUIRES_SHARED(Locks::mutator_lock_) {
215 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Orion Hodsone7732be2017-10-11 14:35:20 +0100216 return class_linker->ResolveMethodHandle(self, method_handle_index, referrer);
Orion Hodson2e599942017-09-22 16:17:41 +0100217}
218
Vladimir Markoaf940202017-12-08 15:01:18 +0000219static inline ObjPtr<mirror::MethodType> ResolveMethodType(Thread* self,
Orion Hodson16b2adf2018-05-14 08:53:38 +0100220 dex::ProtoIndex method_type_index,
Vladimir Markoaf940202017-12-08 15:01:18 +0000221 ArtMethod* referrer)
Orion Hodson2e599942017-09-22 16:17:41 +0100222 REQUIRES_SHARED(Locks::mutator_lock_) {
223 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Orion Hodsone7732be2017-10-11 14:35:20 +0100224 return class_linker->ResolveMethodType(self, method_type_index, referrer);
Orion Hodson2e599942017-09-22 16:17:41 +0100225}
226
Orion Hodson43f0cdb2017-10-10 14:47:32 +0100227#define DECLARE_SIGNATURE_POLYMORPHIC_HANDLER(Name, ...) \
228bool Do ## Name(Thread* self, \
229 ShadowFrame& shadow_frame, \
230 const Instruction* inst, \
231 uint16_t inst_data, \
232 JValue* result) REQUIRES_SHARED(Locks::mutator_lock_);
233#include "intrinsics_list.h"
234INTRINSICS_LIST(DECLARE_SIGNATURE_POLYMORPHIC_HANDLER)
235#undef INTRINSICS_LIST
236#undef DECLARE_SIGNATURE_POLYMORPHIC_HANDLER
237
238// Performs a invoke-polymorphic or invoke-polymorphic-range.
Orion Hodsonc069a302017-01-18 09:23:12 +0000239template<bool is_range>
Orion Hodson811bd5f2016-12-07 11:35:37 +0000240bool DoInvokePolymorphic(Thread* self,
241 ShadowFrame& shadow_frame,
242 const Instruction* inst,
243 uint16_t inst_data,
Orion Hodson20e7a6e2018-05-18 08:33:20 +0100244 JValue* result)
245 REQUIRES_SHARED(Locks::mutator_lock_);
246
247bool DoInvokeCustom(Thread* self,
248 ShadowFrame& shadow_frame,
249 uint32_t call_site_idx,
250 const InstructionOperands* operands,
251 JValue* result)
252 REQUIRES_SHARED(Locks::mutator_lock_);
Narayan Kamath9823e782016-08-03 12:46:58 +0100253
Orion Hodsonc069a302017-01-18 09:23:12 +0000254// Performs a custom invoke (invoke-custom/invoke-custom-range).
255template<bool is_range>
256bool DoInvokeCustom(Thread* self,
257 ShadowFrame& shadow_frame,
258 const Instruction* inst,
259 uint16_t inst_data,
Orion Hodson20e7a6e2018-05-18 08:33:20 +0100260 JValue* result)
261 REQUIRES_SHARED(Locks::mutator_lock_) {
262 const uint32_t call_site_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c();
263 if (is_range) {
264 RangeInstructionOperands operands(inst->VRegC_3rc(), inst->VRegA_3rc());
265 return DoInvokeCustom(self, shadow_frame, call_site_idx, &operands, result);
266 } else {
267 uint32_t args[Instruction::kMaxVarArgRegs];
268 inst->GetVarArgs(args, inst_data);
269 VarArgsInstructionOperands operands(args, inst->VRegA_35c());
270 return DoInvokeCustom(self, shadow_frame, call_site_idx, &operands, result);
271 }
272}
Orion Hodsonc069a302017-01-18 09:23:12 +0000273
Sebastien Hertzc6714852013-09-30 16:42:32 +0200274// Handles invoke-virtual-quick and invoke-virtual-quick-range instructions.
275// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200276template<bool is_range>
277static inline bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame,
278 const Instruction* inst, uint16_t inst_data,
279 JValue* result) {
280 const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c();
Mathieu Chartieref41db72016-10-25 15:08:01 -0700281 ObjPtr<mirror::Object> const receiver = shadow_frame.GetVRegReference(vregC);
Sebastien Hertzd4beb6b2013-10-02 17:07:20 +0200282 if (UNLIKELY(receiver == nullptr)) {
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200283 // We lost the reference to the method index so we cannot get a more
284 // precised exception message.
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000285 ThrowNullPointerExceptionFromDexPC();
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200286 return false;
287 }
288 const uint32_t vtable_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c();
Artem Udovichenkoa62cb9b2016-06-30 09:18:25 +0000289 CHECK(receiver->GetClass()->ShouldHaveEmbeddedVTable());
Mathieu Chartiere401d142015-04-22 13:56:20 -0700290 ArtMethod* const called_method = receiver->GetClass()->GetEmbeddedVTableEntry(
Chang Xingfef27c22017-07-11 09:57:44 -0700291 vtable_idx, Runtime::Current()->GetClassLinker()->GetImagePointerSize());
Ian Rogerse94652f2014-12-02 11:13:19 -0800292 if (UNLIKELY(called_method == nullptr)) {
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200293 CHECK(self->IsExceptionPending());
294 result->SetJ(0);
295 return false;
Alex Light9139e002015-10-09 15:59:48 -0700296 } else if (UNLIKELY(!called_method->IsInvokable())) {
297 called_method->ThrowInvocationTimeError();
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200298 result->SetJ(0);
299 return false;
300 } else {
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100301 jit::Jit* jit = Runtime::Current()->GetJit();
302 if (jit != nullptr) {
303 jit->InvokeVirtualOrInterface(
Mathieu Chartier268764d2016-09-13 12:09:38 -0700304 receiver, shadow_frame.GetMethod(), shadow_frame.GetDexPC(), called_method);
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100305 jit->AddSamples(self, shadow_frame.GetMethod(), 1, /*with_backedges*/false);
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100306 }
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100307 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
Nicolas Geoffray274fe4a2016-04-12 16:33:24 +0100308 // TODO: Remove the InvokeVirtualOrInterface instrumentation, as it was only used by the JIT.
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100309 if (UNLIKELY(instrumentation->HasInvokeVirtualOrInterfaceListeners())) {
310 instrumentation->InvokeVirtualOrInterface(
Mathieu Chartieref41db72016-10-25 15:08:01 -0700311 self, receiver.Ptr(), shadow_frame.GetMethod(), shadow_frame.GetDexPC(), called_method);
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100312 }
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200313 // No need to check since we've been quickened.
Ian Rogerse94652f2014-12-02 11:13:19 -0800314 return DoCall<is_range, false>(called_method, self, shadow_frame, inst, inst_data, result);
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200315 }
316}
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200317
Sebastien Hertzc6714852013-09-30 16:42:32 +0200318// Handles iget-XXX and sget-XXX instructions.
319// Returns true on success, otherwise throws an exception and returns false.
Chang Xingbd208d82017-07-12 14:53:17 -0700320template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check,
321 bool transaction_active = false>
Ian Rogers54874942014-06-10 16:31:03 -0700322bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst,
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700323 uint16_t inst_data) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200324
Sebastien Hertzc6714852013-09-30 16:42:32 +0200325// Handles iget-quick, iget-wide-quick and iget-object-quick instructions.
326// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200327template<Primitive::Type field_type>
Ian Rogers54874942014-06-10 16:31:03 -0700328bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700329 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz479fc1e2014-04-04 17:51:34 +0200330
Sebastien Hertzc6714852013-09-30 16:42:32 +0200331// Handles iput-XXX and sput-XXX instructions.
332// Returns true on success, otherwise throws an exception and returns false.
Ian Rogers54874942014-06-10 16:31:03 -0700333template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check,
334 bool transaction_active>
335bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst,
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700336 uint16_t inst_data) REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200337
Sebastien Hertzc6714852013-09-30 16:42:32 +0200338// Handles iput-quick, iput-wide-quick and iput-object-quick instructions.
339// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100340template<Primitive::Type field_type, bool transaction_active>
Ian Rogers54874942014-06-10 16:31:03 -0700341bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700342 REQUIRES_SHARED(Locks::mutator_lock_);
Ian Rogers54874942014-06-10 16:31:03 -0700343
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200344
Sebastien Hertzc6714852013-09-30 16:42:32 +0200345// Handles string resolution for const-string and const-string-jumbo instructions. Also ensures the
346// java.lang.String class is initialized.
Mathieu Chartieref41db72016-10-25 15:08:01 -0700347static inline ObjPtr<mirror::String> ResolveString(Thread* self,
348 ShadowFrame& shadow_frame,
Andreas Gampe8a0128a2016-11-28 07:38:35 -0800349 dex::StringIndex string_idx)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700350 REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartieref41db72016-10-25 15:08:01 -0700351 ObjPtr<mirror::Class> java_lang_string_class = mirror::String::GetJavaLangString();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200352 if (UNLIKELY(!java_lang_string_class->IsInitialized())) {
353 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700354 StackHandleScope<1> hs(self);
355 Handle<mirror::Class> h_class(hs.NewHandle(java_lang_string_class));
Ian Rogers7b078e82014-09-10 14:44:24 -0700356 if (UNLIKELY(!class_linker->EnsureInitialized(self, h_class, true, true))) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200357 DCHECK(self->IsExceptionPending());
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800358 return nullptr;
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200359 }
360 }
Mathieu Chartiere401d142015-04-22 13:56:20 -0700361 ArtMethod* method = shadow_frame.GetMethod();
Vladimir Markoec786222016-12-20 16:24:13 +0000362 ObjPtr<mirror::String> string_ptr = method->GetDexCache()->GetResolvedString(string_idx);
Christina Wadsworthbf44e0e2016-08-18 10:37:42 -0700363 if (UNLIKELY(string_ptr == nullptr)) {
Ian Rogers6786a582014-10-28 12:49:06 -0700364 StackHandleScope<1> hs(self);
Alex Lightdba61482016-12-21 08:20:29 -0800365 Handle<mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
Vladimir Markoa64b52d2017-12-08 16:27:49 +0000366 string_ptr = Runtime::Current()->GetClassLinker()->ResolveString(string_idx, dex_cache);
Ian Rogers6786a582014-10-28 12:49:06 -0700367 }
Christina Wadsworthbf44e0e2016-08-18 10:37:42 -0700368 return string_ptr;
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200369}
370
Sebastien Hertzc6714852013-09-30 16:42:32 +0200371// Handles div-int, div-int/2addr, div-int/li16 and div-int/lit8 instructions.
372// Returns true on success, otherwise throws a java.lang.ArithmeticException and return false.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200373static inline bool DoIntDivide(ShadowFrame& shadow_frame, size_t result_reg,
374 int32_t dividend, int32_t divisor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700375 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogersf72a11d2014-10-30 15:41:08 -0700376 constexpr int32_t kMinInt = std::numeric_limits<int32_t>::min();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200377 if (UNLIKELY(divisor == 0)) {
378 ThrowArithmeticExceptionDivideByZero();
379 return false;
380 }
381 if (UNLIKELY(dividend == kMinInt && divisor == -1)) {
382 shadow_frame.SetVReg(result_reg, kMinInt);
383 } else {
384 shadow_frame.SetVReg(result_reg, dividend / divisor);
385 }
386 return true;
387}
388
Sebastien Hertzc6714852013-09-30 16:42:32 +0200389// Handles rem-int, rem-int/2addr, rem-int/li16 and rem-int/lit8 instructions.
390// Returns true on success, otherwise throws a java.lang.ArithmeticException and return false.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200391static inline bool DoIntRemainder(ShadowFrame& shadow_frame, size_t result_reg,
392 int32_t dividend, int32_t divisor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700393 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogersf72a11d2014-10-30 15:41:08 -0700394 constexpr int32_t kMinInt = std::numeric_limits<int32_t>::min();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200395 if (UNLIKELY(divisor == 0)) {
396 ThrowArithmeticExceptionDivideByZero();
397 return false;
398 }
399 if (UNLIKELY(dividend == kMinInt && divisor == -1)) {
400 shadow_frame.SetVReg(result_reg, 0);
401 } else {
402 shadow_frame.SetVReg(result_reg, dividend % divisor);
403 }
404 return true;
405}
406
Sebastien Hertzc6714852013-09-30 16:42:32 +0200407// Handles div-long and div-long-2addr instructions.
408// Returns true on success, otherwise throws a java.lang.ArithmeticException and return false.
Mathieu Chartieref41db72016-10-25 15:08:01 -0700409static inline bool DoLongDivide(ShadowFrame& shadow_frame,
410 size_t result_reg,
411 int64_t dividend,
412 int64_t divisor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700413 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2e2deeb2013-09-23 11:58:57 -0700414 const int64_t kMinLong = std::numeric_limits<int64_t>::min();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200415 if (UNLIKELY(divisor == 0)) {
416 ThrowArithmeticExceptionDivideByZero();
417 return false;
418 }
419 if (UNLIKELY(dividend == kMinLong && divisor == -1)) {
420 shadow_frame.SetVRegLong(result_reg, kMinLong);
421 } else {
422 shadow_frame.SetVRegLong(result_reg, dividend / divisor);
423 }
424 return true;
425}
426
Sebastien Hertzc6714852013-09-30 16:42:32 +0200427// Handles rem-long and rem-long-2addr instructions.
428// Returns true on success, otherwise throws a java.lang.ArithmeticException and return false.
Mathieu Chartieref41db72016-10-25 15:08:01 -0700429static inline bool DoLongRemainder(ShadowFrame& shadow_frame,
430 size_t result_reg,
431 int64_t dividend,
432 int64_t divisor)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700433 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers2e2deeb2013-09-23 11:58:57 -0700434 const int64_t kMinLong = std::numeric_limits<int64_t>::min();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200435 if (UNLIKELY(divisor == 0)) {
436 ThrowArithmeticExceptionDivideByZero();
437 return false;
438 }
439 if (UNLIKELY(dividend == kMinLong && divisor == -1)) {
440 shadow_frame.SetVRegLong(result_reg, 0);
441 } else {
442 shadow_frame.SetVRegLong(result_reg, dividend % divisor);
443 }
444 return true;
445}
446
Sebastien Hertzc6714852013-09-30 16:42:32 +0200447// Handles filled-new-array and filled-new-array-range instructions.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200448// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100449template <bool is_range, bool do_access_check, bool transaction_active>
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200450bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame,
Sebastien Hertzc6714852013-09-30 16:42:32 +0200451 Thread* self, JValue* result);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200452
Sebastien Hertzc6714852013-09-30 16:42:32 +0200453// Handles packed-switch instruction.
454// Returns the branch offset to the next instruction to execute.
Sebastien Hertz3b588e02013-09-11 14:33:18 +0200455static inline int32_t DoPackedSwitch(const Instruction* inst, const ShadowFrame& shadow_frame,
456 uint16_t inst_data)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700457 REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200458 DCHECK(inst->Opcode() == Instruction::PACKED_SWITCH);
459 const uint16_t* switch_data = reinterpret_cast<const uint16_t*>(inst) + inst->VRegB_31t();
Sebastien Hertz3b588e02013-09-11 14:33:18 +0200460 int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data));
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200461 DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kPackedSwitchSignature));
462 uint16_t size = switch_data[1];
David Brazdil2ef645b2015-06-17 18:20:52 +0100463 if (size == 0) {
464 // Empty packed switch, move forward by 3 (size of PACKED_SWITCH).
465 return 3;
466 }
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200467 const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]);
Roland Levillain14d90572015-07-16 10:52:26 +0100468 DCHECK_ALIGNED(keys, 4);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200469 int32_t first_key = keys[0];
470 const int32_t* targets = reinterpret_cast<const int32_t*>(&switch_data[4]);
Roland Levillain14d90572015-07-16 10:52:26 +0100471 DCHECK_ALIGNED(targets, 4);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200472 int32_t index = test_val - first_key;
473 if (index >= 0 && index < size) {
474 return targets[index];
475 } else {
476 // No corresponding value: move forward by 3 (size of PACKED_SWITCH).
477 return 3;
478 }
479}
480
Sebastien Hertzc6714852013-09-30 16:42:32 +0200481// Handles sparse-switch instruction.
482// Returns the branch offset to the next instruction to execute.
Sebastien Hertz3b588e02013-09-11 14:33:18 +0200483static inline int32_t DoSparseSwitch(const Instruction* inst, const ShadowFrame& shadow_frame,
484 uint16_t inst_data)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700485 REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200486 DCHECK(inst->Opcode() == Instruction::SPARSE_SWITCH);
487 const uint16_t* switch_data = reinterpret_cast<const uint16_t*>(inst) + inst->VRegB_31t();
Sebastien Hertz3b588e02013-09-11 14:33:18 +0200488 int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data));
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200489 DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kSparseSwitchSignature));
490 uint16_t size = switch_data[1];
Jeff Hao935e01a2015-03-20 19:44:35 -0700491 // Return length of SPARSE_SWITCH if size is 0.
492 if (size == 0) {
493 return 3;
494 }
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200495 const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]);
Roland Levillain14d90572015-07-16 10:52:26 +0100496 DCHECK_ALIGNED(keys, 4);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200497 const int32_t* entries = keys + size;
Roland Levillain14d90572015-07-16 10:52:26 +0100498 DCHECK_ALIGNED(entries, 4);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200499 int lo = 0;
500 int hi = size - 1;
501 while (lo <= hi) {
502 int mid = (lo + hi) / 2;
503 int32_t foundVal = keys[mid];
504 if (test_val < foundVal) {
505 hi = mid - 1;
506 } else if (test_val > foundVal) {
507 lo = mid + 1;
508 } else {
509 return entries[mid];
510 }
511 }
512 // No corresponding value: move forward by 3 (size of SPARSE_SWITCH).
513 return 3;
514}
515
Alex Light9fb1ab12017-09-05 09:32:49 -0700516// We execute any instrumentation events triggered by throwing and/or handing the pending exception
517// and change the shadow_frames dex_pc to the appropriate exception handler if the current method
518// has one. If the exception has been handled and the shadow_frame is now pointing to a catch clause
519// we return true. If the current method is unable to handle the exception we return false.
520// This function accepts a null Instrumentation* as a way to cause instrumentation events not to be
521// reported.
522// TODO We might wish to reconsider how we cause some events to be ignored.
523bool MoveToExceptionHandler(Thread* self,
524 ShadowFrame& shadow_frame,
525 const instrumentation::Instrumentation* instrumentation)
526 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200527
Andreas Gampe794ad762015-02-23 08:12:24 -0800528NO_RETURN void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame)
529 __attribute__((cold))
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700530 REQUIRES_SHARED(Locks::mutator_lock_);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200531
Bill Buzbeed47fd902016-07-07 14:42:43 +0000532// Set true if you want TraceExecution invocation before each bytecode execution.
533constexpr bool kTraceExecutionEnabled = false;
Serguei Katkov9fb0ac72016-02-20 12:55:24 +0600534
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200535static inline void TraceExecution(const ShadowFrame& shadow_frame, const Instruction* inst,
Ian Rogerse94652f2014-12-02 11:13:19 -0800536 const uint32_t dex_pc)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700537 REQUIRES_SHARED(Locks::mutator_lock_) {
Bill Buzbeed47fd902016-07-07 14:42:43 +0000538 if (kTraceExecutionEnabled) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200539#define TRACE_LOG std::cerr
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700540 std::ostringstream oss;
David Sehr709b0702016-10-13 09:12:37 -0700541 oss << shadow_frame.GetMethod()->PrettyMethod()
Andreas Gampe46ee31b2016-12-14 10:11:49 -0800542 << android::base::StringPrintf("\n0x%x: ", dex_pc)
Ian Rogerse94652f2014-12-02 11:13:19 -0800543 << inst->DumpString(shadow_frame.GetMethod()->GetDexFile()) << "\n";
Ian Rogersef7d42f2014-01-06 12:55:46 -0800544 for (uint32_t i = 0; i < shadow_frame.NumberOfVRegs(); ++i) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200545 uint32_t raw_value = shadow_frame.GetVReg(i);
Mathieu Chartieref41db72016-10-25 15:08:01 -0700546 ObjPtr<mirror::Object> ref_value = shadow_frame.GetVRegReference(i);
Andreas Gampe46ee31b2016-12-14 10:11:49 -0800547 oss << android::base::StringPrintf(" vreg%u=0x%08X", i, raw_value);
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700548 if (ref_value != nullptr) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200549 if (ref_value->GetClass()->IsStringClass() &&
jessicahandojo3aaa37b2016-07-29 14:46:37 -0700550 !ref_value->AsString()->IsValueNull()) {
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700551 oss << "/java.lang.String \"" << ref_value->AsString()->ToModifiedUtf8() << "\"";
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200552 } else {
David Sehr709b0702016-10-13 09:12:37 -0700553 oss << "/" << ref_value->PrettyTypeOf();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200554 }
555 }
556 }
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700557 TRACE_LOG << oss.str() << "\n";
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200558#undef TRACE_LOG
559 }
560}
561
Sebastien Hertz1eda2262013-09-09 16:53:14 +0200562static inline bool IsBackwardBranch(int32_t branch_offset) {
563 return branch_offset <= 0;
564}
565
Jeff Hao5ea84132017-05-05 16:59:29 -0700566// The arg_offset is the offset to the first input register in the frame.
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100567void ArtInterpreterToCompiledCodeBridge(Thread* self,
568 ArtMethod* caller,
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100569 ShadowFrame* shadow_frame,
Jeff Hao5ea84132017-05-05 16:59:29 -0700570 uint16_t arg_offset,
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100571 JValue* result);
Siva Chandra05d24152016-01-05 17:43:17 -0800572
Mingyao Yang2ee17902017-08-30 11:37:08 -0700573static inline bool IsStringInit(const DexFile* dex_file, uint32_t method_idx)
574 REQUIRES_SHARED(Locks::mutator_lock_) {
575 const DexFile::MethodId& method_id = dex_file->GetMethodId(method_idx);
576 const char* class_name = dex_file->StringByTypeIdx(method_id.class_idx_);
577 const char* method_name = dex_file->GetMethodName(method_id);
578 // Instead of calling ResolveMethod() which has suspend point and can trigger
579 // GC, look up the method symbolically.
580 // Compare method's class name and method name against string init.
581 // It's ok since it's not allowed to create your own java/lang/String.
582 // TODO: verify that assumption.
583 if ((strcmp(class_name, "Ljava/lang/String;") == 0) &&
584 (strcmp(method_name, "<init>") == 0)) {
585 return true;
586 }
587 return false;
588}
589
590static inline bool IsStringInit(const Instruction* instr, ArtMethod* caller)
591 REQUIRES_SHARED(Locks::mutator_lock_) {
592 if (instr->Opcode() == Instruction::INVOKE_DIRECT ||
593 instr->Opcode() == Instruction::INVOKE_DIRECT_RANGE) {
594 uint16_t callee_method_idx = (instr->Opcode() == Instruction::INVOKE_DIRECT_RANGE) ?
595 instr->VRegB_3rc() : instr->VRegB_35c();
596 return IsStringInit(caller->GetDexFile(), callee_method_idx);
597 }
598 return false;
599}
600
Mingyao Yangffedec52016-05-19 10:48:40 -0700601// Set string value created from StringFactory.newStringFromXXX() into all aliases of
602// StringFactory.newEmptyString().
603void SetStringInitValueToAllAliases(ShadowFrame* shadow_frame,
604 uint16_t this_obj_vreg,
605 JValue result);
606
Sebastien Hertzc6714852013-09-30 16:42:32 +0200607// Explicitly instantiate all DoInvoke functions.
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100608#define EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, _is_range, _do_check) \
buzbee78f1bdc2017-03-01 10:55:57 -0800609 template REQUIRES_SHARED(Locks::mutator_lock_) \
610 bool DoInvoke<_type, _is_range, _do_check>(Thread* self, \
611 ShadowFrame& shadow_frame, \
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100612 const Instruction* inst, uint16_t inst_data, \
613 JValue* result)
Sebastien Hertzc6714852013-09-30 16:42:32 +0200614
615#define EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(_type) \
616 EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, false, false); \
617 EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, false, true); \
618 EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, true, false); \
619 EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, true, true);
620
Andreas Gampec8ccf682014-09-29 20:07:43 -0700621EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kStatic) // invoke-static/range.
622EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kDirect) // invoke-direct/range.
623EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kVirtual) // invoke-virtual/range.
624EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kSuper) // invoke-super/range.
625EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kInterface) // invoke-interface/range.
Sebastien Hertzc6714852013-09-30 16:42:32 +0200626#undef EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL
627#undef EXPLICIT_DO_INVOKE_TEMPLATE_DECL
628
buzbee78f1bdc2017-03-01 10:55:57 -0800629// Explicitly instantiate all DoFastInvoke functions.
630#define EXPLICIT_DO_FAST_INVOKE_TEMPLATE_DECL(_type) \
631 template REQUIRES_SHARED(Locks::mutator_lock_) \
632 bool DoFastInvoke<_type>(Thread* self, \
633 ShadowFrame& shadow_frame, \
634 const Instruction* inst, uint16_t inst_data, \
635 JValue* result)
636
637EXPLICIT_DO_FAST_INVOKE_TEMPLATE_DECL(kStatic); // invoke-static
638EXPLICIT_DO_FAST_INVOKE_TEMPLATE_DECL(kDirect); // invoke-direct
639EXPLICIT_DO_FAST_INVOKE_TEMPLATE_DECL(kVirtual); // invoke-virtual
640#undef EXPLICIT_DO_FAST_INVOKE_TEMPLATE_DECL
641
Sebastien Hertzc6714852013-09-30 16:42:32 +0200642// Explicitly instantiate all DoInvokeVirtualQuick functions.
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100643#define EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(_is_range) \
Roland Levillain2ae376f2018-01-30 11:35:11 +0000644 template REQUIRES_SHARED(Locks::mutator_lock_) \
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100645 bool DoInvokeVirtualQuick<_is_range>(Thread* self, ShadowFrame& shadow_frame, \
646 const Instruction* inst, uint16_t inst_data, \
647 JValue* result)
Sebastien Hertzc6714852013-09-30 16:42:32 +0200648
649EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(false); // invoke-virtual-quick.
650EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(true); // invoke-virtual-quick-range.
651#undef EXPLICIT_INSTANTIATION_DO_INVOKE_VIRTUAL_QUICK
652
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200653} // namespace interpreter
654} // namespace art
655
656#endif // ART_RUNTIME_INTERPRETER_INTERPRETER_COMMON_H_