blob: fdefb9f74c59b4e455ca63bf9dc4632bd8d5875b [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"
21
22#include <math.h>
23
Ian Rogerscf7f1912014-10-22 22:06:39 -070024#include <iostream>
Ian Rogersc7dd2952014-10-21 23:31:19 -070025#include <sstream>
26
Mathieu Chartierc7853442015-03-27 14:35:38 -070027#include "art_field-inl.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070028#include "art_method-inl.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020029#include "base/logging.h"
Andreas Gampe794ad762015-02-23 08:12:24 -080030#include "base/macros.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020031#include "class_linker-inl.h"
32#include "common_throws.h"
33#include "dex_file-inl.h"
34#include "dex_instruction-inl.h"
Mingyao Yang98d1cc82014-05-15 17:02:16 -070035#include "entrypoints/entrypoint_utils-inl.h"
Mathieu Chartier0cd81352014-05-22 16:48:55 -070036#include "handle_scope-inl.h"
Igor Murashkine2facc52015-07-10 13:49:08 -070037#include "lambda/box_table.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020038#include "mirror/class-inl.h"
Igor Murashkin2ee54e22015-06-18 10:05:11 -070039#include "mirror/method.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020040#include "mirror/object-inl.h"
41#include "mirror/object_array-inl.h"
Douglas Leung4965c022014-06-11 11:41:11 -070042#include "mirror/string-inl.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020043#include "thread.h"
44#include "well_known_classes.h"
45
Mathieu Chartiere401d142015-04-22 13:56:20 -070046using ::art::ArtMethod;
Sebastien Hertz8ece0502013-08-07 11:26:41 +020047using ::art::mirror::Array;
48using ::art::mirror::BooleanArray;
49using ::art::mirror::ByteArray;
50using ::art::mirror::CharArray;
51using ::art::mirror::Class;
52using ::art::mirror::ClassLoader;
53using ::art::mirror::IntArray;
54using ::art::mirror::LongArray;
55using ::art::mirror::Object;
56using ::art::mirror::ObjectArray;
57using ::art::mirror::ShortArray;
58using ::art::mirror::String;
59using ::art::mirror::Throwable;
60
61namespace art {
62namespace interpreter {
63
64// External references to both interpreter implementations.
65
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010066template<bool do_access_check, bool transaction_active>
Ian Rogerse94652f2014-12-02 11:13:19 -080067extern JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item,
Sebastien Hertzc6714852013-09-30 16:42:32 +020068 ShadowFrame& shadow_frame, JValue result_register);
Sebastien Hertz8ece0502013-08-07 11:26:41 +020069
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010070template<bool do_access_check, bool transaction_active>
Ian Rogerse94652f2014-12-02 11:13:19 -080071extern JValue ExecuteGotoImpl(Thread* self, const DexFile::CodeItem* code_item,
Sebastien Hertzc6714852013-09-30 16:42:32 +020072 ShadowFrame& shadow_frame, JValue result_register);
Sebastien Hertz8ece0502013-08-07 11:26:41 +020073
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +000074void ThrowNullPointerExceptionFromInterpreter()
Mathieu Chartier90443472015-07-16 20:32:27 -070075 SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertzda843e12014-05-28 19:28:31 +020076
Sebastien Hertz8ece0502013-08-07 11:26:41 +020077static inline void DoMonitorEnter(Thread* self, Object* ref) NO_THREAD_SAFETY_ANALYSIS {
78 ref->MonitorEnter(self);
79}
80
81static inline void DoMonitorExit(Thread* self, Object* ref) NO_THREAD_SAFETY_ANALYSIS {
82 ref->MonitorExit(self);
83}
84
Sebastien Hertz45b15972015-04-03 16:07:05 +020085void AbortTransactionF(Thread* self, const char* fmt, ...)
86 __attribute__((__format__(__printf__, 2, 3)))
Mathieu Chartier90443472015-07-16 20:32:27 -070087 SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz45b15972015-04-03 16:07:05 +020088
89void AbortTransactionV(Thread* self, const char* fmt, va_list args)
Mathieu Chartier90443472015-07-16 20:32:27 -070090 SHARED_REQUIRES(Locks::mutator_lock_);
Mathieu Chartierb2c7ead2014-04-29 11:13:16 -070091
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010092void RecordArrayElementsInTransaction(mirror::Array* array, int32_t count)
Mathieu Chartier90443472015-07-16 20:32:27 -070093 SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010094
Sebastien Hertzc6714852013-09-30 16:42:32 +020095// Invokes the given method. This is part of the invocation support and is used by DoInvoke and
96// DoInvokeVirtualQuick functions.
97// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzc61124b2013-09-10 11:44:19 +020098template<bool is_range, bool do_assignability_check>
Ian Rogerse94652f2014-12-02 11:13:19 -080099bool DoCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame,
Sebastien Hertzc6714852013-09-30 16:42:32 +0200100 const Instruction* inst, uint16_t inst_data, JValue* result);
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200101
Igor Murashkin158f35c2015-06-10 15:55:30 -0700102// Invokes the given lambda closure. This is part of the invocation support and is used by
103// DoLambdaInvoke functions.
104// Returns true on success, otherwise throws an exception and returns false.
105template<bool is_range, bool do_assignability_check>
106bool DoLambdaCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame,
107 const Instruction* inst, uint16_t inst_data, JValue* result);
108
109// Validates that the art method corresponding to a lambda method target
110// is semantically valid:
111//
112// Must be ACC_STATIC and ACC_LAMBDA. Must be a concrete managed implementation
113// (i.e. not native, not proxy, not abstract, ...).
114//
115// If the validation fails, return false and raise an exception.
116static inline bool IsValidLambdaTargetOrThrow(ArtMethod* called_method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700117 SHARED_REQUIRES(Locks::mutator_lock_) {
Igor Murashkin158f35c2015-06-10 15:55:30 -0700118 bool success = false;
119
120 if (UNLIKELY(called_method == nullptr)) {
121 // The shadow frame should already be pushed, so we don't need to update it.
122 } else if (UNLIKELY(called_method->IsAbstract())) {
123 ThrowAbstractMethodError(called_method);
124 // TODO(iam): Also handle the case when the method is non-static, what error do we throw?
125 // TODO(iam): Also make sure that ACC_LAMBDA is set.
126 } else if (UNLIKELY(called_method->GetCodeItem() == nullptr)) {
127 // Method could be native, proxy method, etc. Lambda targets have to be concrete impls,
128 // so don't allow this.
129 } else {
130 success = true;
131 }
132
133 return success;
134}
135
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700136// Write out the 'ArtMethod*' into vreg and vreg+1
137static inline void WriteLambdaClosureIntoVRegs(ShadowFrame& shadow_frame,
138 const ArtMethod& called_method,
139 uint32_t vreg) {
140 // Split the method into a lo and hi 32 bits so we can encode them into 2 virtual registers.
141 uint32_t called_method_lo = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&called_method));
142 uint32_t called_method_hi = static_cast<uint32_t>(reinterpret_cast<uint64_t>(&called_method)
143 >> BitSizeOf<uint32_t>());
144 // Use uint64_t instead of uintptr_t to allow shifting past the max on 32-bit.
145 static_assert(sizeof(uint64_t) >= sizeof(uintptr_t), "Impossible");
146
147 DCHECK_NE(called_method_lo | called_method_hi, 0u);
148
149 shadow_frame.SetVReg(vreg, called_method_lo);
150 shadow_frame.SetVReg(vreg + 1, called_method_hi);
151}
152
Igor Murashkin158f35c2015-06-10 15:55:30 -0700153// Handles create-lambda instructions.
154// Returns true on success, otherwise throws an exception and returns false.
155// (Exceptions are thrown by creating a new exception and then being put in the thread TLS)
156//
157// As a work-in-progress implementation, this shoves the ArtMethod object corresponding
158// to the target dex method index into the target register vA and vA + 1.
159template<bool do_access_check>
160static inline bool DoCreateLambda(Thread* self, ShadowFrame& shadow_frame,
161 const Instruction* inst) {
162 /*
163 * create-lambda is opcode 0x21c
164 * - vA is the target register where the closure will be stored into
165 * (also stores into vA + 1)
166 * - vB is the method index which will be the target for a later invoke-lambda
167 */
168 const uint32_t method_idx = inst->VRegB_21c();
169 mirror::Object* receiver = nullptr; // Always static. (see 'kStatic')
170 ArtMethod* sf_method = shadow_frame.GetMethod();
171 ArtMethod* const called_method = FindMethodFromCode<kStatic, do_access_check>(
Andreas Gampe3a357142015-08-07 17:20:11 -0700172 method_idx, &receiver, sf_method, self);
Igor Murashkin158f35c2015-06-10 15:55:30 -0700173
174 uint32_t vregA = inst->VRegA_21c();
175
176 if (UNLIKELY(!IsValidLambdaTargetOrThrow(called_method))) {
177 CHECK(self->IsExceptionPending());
178 shadow_frame.SetVReg(vregA, 0u);
179 shadow_frame.SetVReg(vregA + 1, 0u);
180 return false;
181 }
182
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700183 WriteLambdaClosureIntoVRegs(shadow_frame, *called_method, vregA);
Igor Murashkin158f35c2015-06-10 15:55:30 -0700184 return true;
185}
186
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700187// Reads out the 'ArtMethod*' stored inside of vreg and vreg+1
188//
189// Validates that the art method points to a valid lambda function, otherwise throws
190// an exception and returns null.
191// (Exceptions are thrown by creating a new exception and then being put in the thread TLS)
192static inline ArtMethod* ReadLambdaClosureFromVRegsOrThrow(ShadowFrame& shadow_frame,
193 uint32_t vreg)
Mathieu Chartier90443472015-07-16 20:32:27 -0700194 SHARED_REQUIRES(Locks::mutator_lock_) {
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700195 // TODO(iam): Introduce a closure abstraction that will contain the captured variables
196 // instead of just an ArtMethod.
197 // This is temporarily using 2 vregs because a native ArtMethod can be up to 64-bit,
198 // but once proper variable capture is implemented it will only use 1 vreg.
199 uint32_t vc_value_lo = shadow_frame.GetVReg(vreg);
200 uint32_t vc_value_hi = shadow_frame.GetVReg(vreg + 1);
201
202 uint64_t vc_value_ptr = (static_cast<uint64_t>(vc_value_hi) << BitSizeOf<uint32_t>())
203 | vc_value_lo;
204
205 // Use uint64_t instead of uintptr_t to allow left-shifting past the max on 32-bit.
206 static_assert(sizeof(uint64_t) >= sizeof(uintptr_t), "Impossible");
207 ArtMethod* const called_method = reinterpret_cast<ArtMethod* const>(vc_value_ptr);
208
209 // Guard against the user passing a null closure, which is odd but (sadly) semantically valid.
210 if (UNLIKELY(called_method == nullptr)) {
211 ThrowNullPointerExceptionFromInterpreter();
212 return nullptr;
213 } else if (UNLIKELY(!IsValidLambdaTargetOrThrow(called_method))) {
214 return nullptr;
215 }
216
217 return called_method;
218}
219
Igor Murashkin158f35c2015-06-10 15:55:30 -0700220template<bool do_access_check>
221static inline bool DoInvokeLambda(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst,
222 uint16_t inst_data, JValue* result) {
223 /*
224 * invoke-lambda is opcode 0x25
225 *
226 * - vC is the closure register (both vC and vC + 1 will be used to store the closure).
227 * - vB is the number of additional registers up to |{vD,vE,vF,vG}| (4)
228 * - the rest of the registers are always var-args
229 *
230 * - reading var-args for 0x25 gets us vD,vE,vF,vG (but not vB)
231 */
232 uint32_t vC = inst->VRegC_25x();
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700233 ArtMethod* const called_method = ReadLambdaClosureFromVRegsOrThrow(shadow_frame, vC);
Igor Murashkin158f35c2015-06-10 15:55:30 -0700234
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700235 // Failed lambda target runtime check, an exception was raised.
Igor Murashkin158f35c2015-06-10 15:55:30 -0700236 if (UNLIKELY(called_method == nullptr)) {
Igor Murashkin158f35c2015-06-10 15:55:30 -0700237 CHECK(self->IsExceptionPending());
238 result->SetJ(0);
239 return false;
Igor Murashkin158f35c2015-06-10 15:55:30 -0700240 }
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700241
242 // Invoke a non-range lambda
243 return DoLambdaCall<false, do_access_check>(called_method, self, shadow_frame, inst, inst_data,
244 result);
Igor Murashkin158f35c2015-06-10 15:55:30 -0700245}
246
Sebastien Hertzc6714852013-09-30 16:42:32 +0200247// Handles invoke-XXX/range instructions.
248// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200249template<InvokeType type, bool is_range, bool do_access_check>
250static inline bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst,
251 uint16_t inst_data, JValue* result) {
252 const uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c();
253 const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c();
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700254 Object* receiver = (type == kStatic) ? nullptr : shadow_frame.GetVRegReference(vregC);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700255 ArtMethod* sf_method = shadow_frame.GetMethod();
Ian Rogerse94652f2014-12-02 11:13:19 -0800256 ArtMethod* const called_method = FindMethodFromCode<type, do_access_check>(
Andreas Gampe3a357142015-08-07 17:20:11 -0700257 method_idx, &receiver, sf_method, self);
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700258 // The shadow frame should already be pushed, so we don't need to update it.
Ian Rogerse94652f2014-12-02 11:13:19 -0800259 if (UNLIKELY(called_method == nullptr)) {
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200260 CHECK(self->IsExceptionPending());
261 result->SetJ(0);
262 return false;
Ian Rogerse94652f2014-12-02 11:13:19 -0800263 } else if (UNLIKELY(called_method->IsAbstract())) {
264 ThrowAbstractMethodError(called_method);
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200265 result->SetJ(0);
266 return false;
267 } else {
Ian Rogerse94652f2014-12-02 11:13:19 -0800268 return DoCall<is_range, do_access_check>(called_method, self, shadow_frame, inst, inst_data,
269 result);
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200270 }
271}
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200272
Sebastien Hertzc6714852013-09-30 16:42:32 +0200273// Handles invoke-virtual-quick and invoke-virtual-quick-range instructions.
274// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200275template<bool is_range>
276static inline bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame,
277 const Instruction* inst, uint16_t inst_data,
278 JValue* result) {
279 const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c();
280 Object* const receiver = shadow_frame.GetVRegReference(vregC);
Sebastien Hertzd4beb6b2013-10-02 17:07:20 +0200281 if (UNLIKELY(receiver == nullptr)) {
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200282 // We lost the reference to the method index so we cannot get a more
283 // precised exception message.
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000284 ThrowNullPointerExceptionFromDexPC();
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200285 return false;
286 }
287 const uint32_t vtable_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c();
Mingyao Yang2cdbad72014-07-16 10:44:41 -0700288 CHECK(receiver->GetClass()->ShouldHaveEmbeddedImtAndVTable());
Mathieu Chartiere401d142015-04-22 13:56:20 -0700289 ArtMethod* const called_method = receiver->GetClass()->GetEmbeddedVTableEntry(
290 vtable_idx, sizeof(void*));
Ian Rogerse94652f2014-12-02 11:13:19 -0800291 if (UNLIKELY(called_method == nullptr)) {
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200292 CHECK(self->IsExceptionPending());
293 result->SetJ(0);
294 return false;
Ian Rogerse94652f2014-12-02 11:13:19 -0800295 } else if (UNLIKELY(called_method->IsAbstract())) {
296 ThrowAbstractMethodError(called_method);
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200297 result->SetJ(0);
298 return false;
299 } else {
300 // No need to check since we've been quickened.
Ian Rogerse94652f2014-12-02 11:13:19 -0800301 return DoCall<is_range, false>(called_method, self, shadow_frame, inst, inst_data, result);
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200302 }
303}
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200304
Sebastien Hertzc6714852013-09-30 16:42:32 +0200305// Handles iget-XXX and sget-XXX instructions.
306// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200307template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check>
Ian Rogers54874942014-06-10 16:31:03 -0700308bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst,
Mathieu Chartier90443472015-07-16 20:32:27 -0700309 uint16_t inst_data) SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200310
Sebastien Hertzc6714852013-09-30 16:42:32 +0200311// Handles iget-quick, iget-wide-quick and iget-object-quick instructions.
312// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200313template<Primitive::Type field_type>
Ian Rogers54874942014-06-10 16:31:03 -0700314bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data)
Mathieu Chartier90443472015-07-16 20:32:27 -0700315 SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz479fc1e2014-04-04 17:51:34 +0200316
Sebastien Hertzc6714852013-09-30 16:42:32 +0200317// Handles iput-XXX and sput-XXX instructions.
318// Returns true on success, otherwise throws an exception and returns false.
Ian Rogers54874942014-06-10 16:31:03 -0700319template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check,
320 bool transaction_active>
321bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst,
Mathieu Chartier90443472015-07-16 20:32:27 -0700322 uint16_t inst_data) SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200323
Sebastien Hertzc6714852013-09-30 16:42:32 +0200324// Handles iput-quick, iput-wide-quick and iput-object-quick instructions.
325// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100326template<Primitive::Type field_type, bool transaction_active>
Ian Rogers54874942014-06-10 16:31:03 -0700327bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data)
Mathieu Chartier90443472015-07-16 20:32:27 -0700328 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers54874942014-06-10 16:31:03 -0700329
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200330
Sebastien Hertzc6714852013-09-30 16:42:32 +0200331// Handles string resolution for const-string and const-string-jumbo instructions. Also ensures the
332// java.lang.String class is initialized.
Ian Rogers6786a582014-10-28 12:49:06 -0700333static inline String* ResolveString(Thread* self, ShadowFrame& shadow_frame, uint32_t string_idx)
Mathieu Chartier90443472015-07-16 20:32:27 -0700334 SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200335 Class* java_lang_string_class = String::GetJavaLangString();
336 if (UNLIKELY(!java_lang_string_class->IsInitialized())) {
337 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700338 StackHandleScope<1> hs(self);
339 Handle<mirror::Class> h_class(hs.NewHandle(java_lang_string_class));
Ian Rogers7b078e82014-09-10 14:44:24 -0700340 if (UNLIKELY(!class_linker->EnsureInitialized(self, h_class, true, true))) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200341 DCHECK(self->IsExceptionPending());
Mathieu Chartierc528dba2013-11-26 12:00:11 -0800342 return nullptr;
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200343 }
344 }
Mathieu Chartiere401d142015-04-22 13:56:20 -0700345 ArtMethod* method = shadow_frame.GetMethod();
Mathieu Chartiereace4582014-11-24 18:29:54 -0800346 mirror::Class* declaring_class = method->GetDeclaringClass();
Vladimir Marko05792b92015-08-03 11:56:49 +0100347 // MethodVerifier refuses methods with string_idx out of bounds.
348 DCHECK_LT(string_idx, declaring_class->GetDexCache()->NumStrings());
349 mirror::String* s = declaring_class->GetDexCacheStrings()[string_idx].Read();
Ian Rogers6786a582014-10-28 12:49:06 -0700350 if (UNLIKELY(s == nullptr)) {
351 StackHandleScope<1> hs(self);
Mathieu Chartiereace4582014-11-24 18:29:54 -0800352 Handle<mirror::DexCache> dex_cache(hs.NewHandle(declaring_class->GetDexCache()));
Ian Rogers6786a582014-10-28 12:49:06 -0700353 s = Runtime::Current()->GetClassLinker()->ResolveString(*method->GetDexFile(), string_idx,
354 dex_cache);
355 }
356 return s;
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200357}
358
Sebastien Hertzc6714852013-09-30 16:42:32 +0200359// Handles div-int, div-int/2addr, div-int/li16 and div-int/lit8 instructions.
360// Returns true on success, otherwise throws a java.lang.ArithmeticException and return false.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200361static inline bool DoIntDivide(ShadowFrame& shadow_frame, size_t result_reg,
362 int32_t dividend, int32_t divisor)
Mathieu Chartier90443472015-07-16 20:32:27 -0700363 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogersf72a11d2014-10-30 15:41:08 -0700364 constexpr int32_t kMinInt = std::numeric_limits<int32_t>::min();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200365 if (UNLIKELY(divisor == 0)) {
366 ThrowArithmeticExceptionDivideByZero();
367 return false;
368 }
369 if (UNLIKELY(dividend == kMinInt && divisor == -1)) {
370 shadow_frame.SetVReg(result_reg, kMinInt);
371 } else {
372 shadow_frame.SetVReg(result_reg, dividend / divisor);
373 }
374 return true;
375}
376
Sebastien Hertzc6714852013-09-30 16:42:32 +0200377// Handles rem-int, rem-int/2addr, rem-int/li16 and rem-int/lit8 instructions.
378// Returns true on success, otherwise throws a java.lang.ArithmeticException and return false.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200379static inline bool DoIntRemainder(ShadowFrame& shadow_frame, size_t result_reg,
380 int32_t dividend, int32_t divisor)
Mathieu Chartier90443472015-07-16 20:32:27 -0700381 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogersf72a11d2014-10-30 15:41:08 -0700382 constexpr int32_t kMinInt = std::numeric_limits<int32_t>::min();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200383 if (UNLIKELY(divisor == 0)) {
384 ThrowArithmeticExceptionDivideByZero();
385 return false;
386 }
387 if (UNLIKELY(dividend == kMinInt && divisor == -1)) {
388 shadow_frame.SetVReg(result_reg, 0);
389 } else {
390 shadow_frame.SetVReg(result_reg, dividend % divisor);
391 }
392 return true;
393}
394
Sebastien Hertzc6714852013-09-30 16:42:32 +0200395// Handles div-long and div-long-2addr instructions.
396// Returns true on success, otherwise throws a java.lang.ArithmeticException and return false.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200397static inline bool DoLongDivide(ShadowFrame& shadow_frame, size_t result_reg,
398 int64_t dividend, int64_t divisor)
Mathieu Chartier90443472015-07-16 20:32:27 -0700399 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogers2e2deeb2013-09-23 11:58:57 -0700400 const int64_t kMinLong = std::numeric_limits<int64_t>::min();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200401 if (UNLIKELY(divisor == 0)) {
402 ThrowArithmeticExceptionDivideByZero();
403 return false;
404 }
405 if (UNLIKELY(dividend == kMinLong && divisor == -1)) {
406 shadow_frame.SetVRegLong(result_reg, kMinLong);
407 } else {
408 shadow_frame.SetVRegLong(result_reg, dividend / divisor);
409 }
410 return true;
411}
412
Sebastien Hertzc6714852013-09-30 16:42:32 +0200413// Handles rem-long and rem-long-2addr instructions.
414// Returns true on success, otherwise throws a java.lang.ArithmeticException and return false.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200415static inline bool DoLongRemainder(ShadowFrame& shadow_frame, size_t result_reg,
416 int64_t dividend, int64_t divisor)
Mathieu Chartier90443472015-07-16 20:32:27 -0700417 SHARED_REQUIRES(Locks::mutator_lock_) {
Ian Rogers2e2deeb2013-09-23 11:58:57 -0700418 const int64_t kMinLong = std::numeric_limits<int64_t>::min();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200419 if (UNLIKELY(divisor == 0)) {
420 ThrowArithmeticExceptionDivideByZero();
421 return false;
422 }
423 if (UNLIKELY(dividend == kMinLong && divisor == -1)) {
424 shadow_frame.SetVRegLong(result_reg, 0);
425 } else {
426 shadow_frame.SetVRegLong(result_reg, dividend % divisor);
427 }
428 return true;
429}
430
Sebastien Hertzc6714852013-09-30 16:42:32 +0200431// Handles filled-new-array and filled-new-array-range instructions.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200432// Returns true on success, otherwise throws an exception and returns false.
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100433template <bool is_range, bool do_access_check, bool transaction_active>
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200434bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame,
Sebastien Hertzc6714852013-09-30 16:42:32 +0200435 Thread* self, JValue* result);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200436
Sebastien Hertzc6714852013-09-30 16:42:32 +0200437// Handles packed-switch instruction.
438// Returns the branch offset to the next instruction to execute.
Sebastien Hertz3b588e02013-09-11 14:33:18 +0200439static inline int32_t DoPackedSwitch(const Instruction* inst, const ShadowFrame& shadow_frame,
440 uint16_t inst_data)
Mathieu Chartier90443472015-07-16 20:32:27 -0700441 SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200442 DCHECK(inst->Opcode() == Instruction::PACKED_SWITCH);
443 const uint16_t* switch_data = reinterpret_cast<const uint16_t*>(inst) + inst->VRegB_31t();
Sebastien Hertz3b588e02013-09-11 14:33:18 +0200444 int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data));
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200445 DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kPackedSwitchSignature));
446 uint16_t size = switch_data[1];
David Brazdil2ef645b2015-06-17 18:20:52 +0100447 if (size == 0) {
448 // Empty packed switch, move forward by 3 (size of PACKED_SWITCH).
449 return 3;
450 }
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200451 const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]);
Roland Levillain14d90572015-07-16 10:52:26 +0100452 DCHECK_ALIGNED(keys, 4);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200453 int32_t first_key = keys[0];
454 const int32_t* targets = reinterpret_cast<const int32_t*>(&switch_data[4]);
Roland Levillain14d90572015-07-16 10:52:26 +0100455 DCHECK_ALIGNED(targets, 4);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200456 int32_t index = test_val - first_key;
457 if (index >= 0 && index < size) {
458 return targets[index];
459 } else {
460 // No corresponding value: move forward by 3 (size of PACKED_SWITCH).
461 return 3;
462 }
463}
464
Sebastien Hertzc6714852013-09-30 16:42:32 +0200465// Handles sparse-switch instruction.
466// Returns the branch offset to the next instruction to execute.
Sebastien Hertz3b588e02013-09-11 14:33:18 +0200467static inline int32_t DoSparseSwitch(const Instruction* inst, const ShadowFrame& shadow_frame,
468 uint16_t inst_data)
Mathieu Chartier90443472015-07-16 20:32:27 -0700469 SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200470 DCHECK(inst->Opcode() == Instruction::SPARSE_SWITCH);
471 const uint16_t* switch_data = reinterpret_cast<const uint16_t*>(inst) + inst->VRegB_31t();
Sebastien Hertz3b588e02013-09-11 14:33:18 +0200472 int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data));
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200473 DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kSparseSwitchSignature));
474 uint16_t size = switch_data[1];
Jeff Hao935e01a2015-03-20 19:44:35 -0700475 // Return length of SPARSE_SWITCH if size is 0.
476 if (size == 0) {
477 return 3;
478 }
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200479 const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]);
Roland Levillain14d90572015-07-16 10:52:26 +0100480 DCHECK_ALIGNED(keys, 4);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200481 const int32_t* entries = keys + size;
Roland Levillain14d90572015-07-16 10:52:26 +0100482 DCHECK_ALIGNED(entries, 4);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200483 int lo = 0;
484 int hi = size - 1;
485 while (lo <= hi) {
486 int mid = (lo + hi) / 2;
487 int32_t foundVal = keys[mid];
488 if (test_val < foundVal) {
489 hi = mid - 1;
490 } else if (test_val > foundVal) {
491 lo = mid + 1;
492 } else {
493 return entries[mid];
494 }
495 }
496 // No corresponding value: move forward by 3 (size of SPARSE_SWITCH).
497 return 3;
498}
499
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700500template <bool _do_check>
501static inline bool DoBoxLambda(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst,
Mathieu Chartier90443472015-07-16 20:32:27 -0700502 uint16_t inst_data) SHARED_REQUIRES(Locks::mutator_lock_) {
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700503 /*
504 * box-lambda vA, vB /// opcode 0xf8, format 22x
505 * - vA is the target register where the Object representation of the closure will be stored into
506 * - vB is a closure (made by create-lambda)
507 * (also reads vB + 1)
508 */
509 uint32_t vreg_target_object = inst->VRegA_22x(inst_data);
510 uint32_t vreg_source_closure = inst->VRegB_22x();
511
Igor Murashkine2facc52015-07-10 13:49:08 -0700512 ArtMethod* closure_method = ReadLambdaClosureFromVRegsOrThrow(shadow_frame,
513 vreg_source_closure);
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700514
515 // Failed lambda target runtime check, an exception was raised.
516 if (UNLIKELY(closure_method == nullptr)) {
517 CHECK(self->IsExceptionPending());
518 return false;
519 }
520
Igor Murashkine2facc52015-07-10 13:49:08 -0700521 mirror::Object* closure_as_object =
522 Runtime::Current()->GetLambdaBoxTable()->BoxLambda(closure_method);
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700523
Igor Murashkine2facc52015-07-10 13:49:08 -0700524 // Failed to box the lambda, an exception was raised.
525 if (UNLIKELY(closure_as_object == nullptr)) {
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700526 CHECK(self->IsExceptionPending());
527 return false;
528 }
529
Igor Murashkine2facc52015-07-10 13:49:08 -0700530 shadow_frame.SetVRegReference(vreg_target_object, closure_as_object);
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700531 return true;
532}
533
Mathieu Chartier90443472015-07-16 20:32:27 -0700534template <bool _do_check> SHARED_REQUIRES(Locks::mutator_lock_)
Igor Murashkine2facc52015-07-10 13:49:08 -0700535static inline bool DoUnboxLambda(Thread* self,
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700536 ShadowFrame& shadow_frame,
537 const Instruction* inst,
538 uint16_t inst_data) {
539 /*
540 * unbox-lambda vA, vB, [type id] /// opcode 0xf9, format 22c
541 * - vA is the target register where the closure will be written into
542 * (also writes vA + 1)
543 * - vB is the Object representation of the closure (made by box-lambda)
544 */
545 uint32_t vreg_target_closure = inst->VRegA_22c(inst_data);
546 uint32_t vreg_source_object = inst->VRegB_22c();
547
548 // Raise NullPointerException if object is null
549 mirror::Object* boxed_closure_object = shadow_frame.GetVRegReference(vreg_source_object);
550 if (UNLIKELY(boxed_closure_object == nullptr)) {
551 ThrowNullPointerExceptionFromInterpreter();
552 return false;
553 }
554
Igor Murashkine2facc52015-07-10 13:49:08 -0700555 ArtMethod* unboxed_closure = nullptr;
556 // Raise an exception if unboxing fails.
557 if (!Runtime::Current()->GetLambdaBoxTable()->UnboxLambda(boxed_closure_object,
Igor Murashkinb1d8c312015-08-04 11:18:43 -0700558 &unboxed_closure)) {
Igor Murashkine2facc52015-07-10 13:49:08 -0700559 CHECK(self->IsExceptionPending());
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700560 return false;
561 }
562
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700563 DCHECK(unboxed_closure != nullptr);
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700564 WriteLambdaClosureIntoVRegs(shadow_frame, *unboxed_closure, vreg_target_closure);
565 return true;
566}
567
Ian Rogers54874942014-06-10 16:31:03 -0700568uint32_t FindNextInstructionFollowingException(Thread* self, ShadowFrame& shadow_frame,
Sebastien Hertz9f102032014-05-23 08:59:42 +0200569 uint32_t dex_pc, const instrumentation::Instrumentation* instrumentation)
Mathieu Chartier90443472015-07-16 20:32:27 -0700570 SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200571
Andreas Gampe794ad762015-02-23 08:12:24 -0800572NO_RETURN void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame)
573 __attribute__((cold))
Mathieu Chartier90443472015-07-16 20:32:27 -0700574 SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200575
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200576static inline void TraceExecution(const ShadowFrame& shadow_frame, const Instruction* inst,
Ian Rogerse94652f2014-12-02 11:13:19 -0800577 const uint32_t dex_pc)
Mathieu Chartier90443472015-07-16 20:32:27 -0700578 SHARED_REQUIRES(Locks::mutator_lock_) {
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700579 constexpr bool kTracing = false;
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200580 if (kTracing) {
581#define TRACE_LOG std::cerr
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700582 std::ostringstream oss;
583 oss << PrettyMethod(shadow_frame.GetMethod())
584 << StringPrintf("\n0x%x: ", dex_pc)
Ian Rogerse94652f2014-12-02 11:13:19 -0800585 << inst->DumpString(shadow_frame.GetMethod()->GetDexFile()) << "\n";
Ian Rogersef7d42f2014-01-06 12:55:46 -0800586 for (uint32_t i = 0; i < shadow_frame.NumberOfVRegs(); ++i) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200587 uint32_t raw_value = shadow_frame.GetVReg(i);
588 Object* ref_value = shadow_frame.GetVRegReference(i);
Ian Rogersef7d42f2014-01-06 12:55:46 -0800589 oss << StringPrintf(" vreg%u=0x%08X", i, raw_value);
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700590 if (ref_value != nullptr) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200591 if (ref_value->GetClass()->IsStringClass() &&
Jeff Hao848f70a2014-01-15 13:49:50 -0800592 ref_value->AsString()->GetValue() != nullptr) {
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700593 oss << "/java.lang.String \"" << ref_value->AsString()->ToModifiedUtf8() << "\"";
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200594 } else {
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700595 oss << "/" << PrettyTypeOf(ref_value);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200596 }
597 }
598 }
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700599 TRACE_LOG << oss.str() << "\n";
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200600#undef TRACE_LOG
601 }
602}
603
Sebastien Hertz1eda2262013-09-09 16:53:14 +0200604static inline bool IsBackwardBranch(int32_t branch_offset) {
605 return branch_offset <= 0;
606}
607
Sebastien Hertzc6714852013-09-30 16:42:32 +0200608// Explicitly instantiate all DoInvoke functions.
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100609#define EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, _is_range, _do_check) \
Mathieu Chartier90443472015-07-16 20:32:27 -0700610 template SHARED_REQUIRES(Locks::mutator_lock_) \
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100611 bool DoInvoke<_type, _is_range, _do_check>(Thread* self, ShadowFrame& shadow_frame, \
612 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
Sebastien Hertzc6714852013-09-30 16:42:32 +0200629// Explicitly instantiate all DoInvokeVirtualQuick functions.
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100630#define EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(_is_range) \
Mathieu Chartier90443472015-07-16 20:32:27 -0700631 template SHARED_REQUIRES(Locks::mutator_lock_) \
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100632 bool DoInvokeVirtualQuick<_is_range>(Thread* self, ShadowFrame& shadow_frame, \
633 const Instruction* inst, uint16_t inst_data, \
634 JValue* result)
Sebastien Hertzc6714852013-09-30 16:42:32 +0200635
636EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(false); // invoke-virtual-quick.
637EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(true); // invoke-virtual-quick-range.
638#undef EXPLICIT_INSTANTIATION_DO_INVOKE_VIRTUAL_QUICK
639
Igor Murashkin158f35c2015-06-10 15:55:30 -0700640// Explicitly instantiate all DoCreateLambda functions.
641#define EXPLICIT_DO_CREATE_LAMBDA_DECL(_do_check) \
Mathieu Chartier90443472015-07-16 20:32:27 -0700642template SHARED_REQUIRES(Locks::mutator_lock_) \
Igor Murashkin158f35c2015-06-10 15:55:30 -0700643bool DoCreateLambda<_do_check>(Thread* self, ShadowFrame& shadow_frame, \
644 const Instruction* inst)
645
646EXPLICIT_DO_CREATE_LAMBDA_DECL(false); // create-lambda
647EXPLICIT_DO_CREATE_LAMBDA_DECL(true); // create-lambda
648#undef EXPLICIT_DO_CREATE_LAMBDA_DECL
649
650// Explicitly instantiate all DoInvokeLambda functions.
651#define EXPLICIT_DO_INVOKE_LAMBDA_DECL(_do_check) \
Mathieu Chartier90443472015-07-16 20:32:27 -0700652template SHARED_REQUIRES(Locks::mutator_lock_) \
Igor Murashkin158f35c2015-06-10 15:55:30 -0700653bool DoInvokeLambda<_do_check>(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, \
654 uint16_t inst_data, JValue* result);
655
656EXPLICIT_DO_INVOKE_LAMBDA_DECL(false); // invoke-lambda
657EXPLICIT_DO_INVOKE_LAMBDA_DECL(true); // invoke-lambda
658#undef EXPLICIT_DO_INVOKE_LAMBDA_DECL
659
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700660// Explicitly instantiate all DoBoxLambda functions.
661#define EXPLICIT_DO_BOX_LAMBDA_DECL(_do_check) \
Mathieu Chartier90443472015-07-16 20:32:27 -0700662template SHARED_REQUIRES(Locks::mutator_lock_) \
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700663bool DoBoxLambda<_do_check>(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, \
664 uint16_t inst_data);
665
666EXPLICIT_DO_BOX_LAMBDA_DECL(false); // box-lambda
667EXPLICIT_DO_BOX_LAMBDA_DECL(true); // box-lambda
668#undef EXPLICIT_DO_BOX_LAMBDA_DECL
669
670// Explicitly instantiate all DoUnBoxLambda functions.
671#define EXPLICIT_DO_UNBOX_LAMBDA_DECL(_do_check) \
Mathieu Chartier90443472015-07-16 20:32:27 -0700672template SHARED_REQUIRES(Locks::mutator_lock_) \
Igor Murashkin2ee54e22015-06-18 10:05:11 -0700673bool DoUnboxLambda<_do_check>(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, \
674 uint16_t inst_data);
675
676EXPLICIT_DO_UNBOX_LAMBDA_DECL(false); // unbox-lambda
677EXPLICIT_DO_UNBOX_LAMBDA_DECL(true); // unbox-lambda
678#undef EXPLICIT_DO_BOX_LAMBDA_DECL
679
Sebastien Hertzc6714852013-09-30 16:42:32 +0200680
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200681} // namespace interpreter
682} // namespace art
683
684#endif // ART_RUNTIME_INTERPRETER_INTERPRETER_COMMON_H_