blob: 34ccc13432aee516bdd0266d9c23fcee2a6f3ccf [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#include "interpreter_common.h"
Ian Rogers22d5e732014-07-15 22:23:51 -070018
Andreas Gampef0e128a2015-02-27 20:08:34 -080019#include <cmath>
20
Andreas Gampe542451c2016-07-26 09:02:02 -070021#include "base/enums.h"
Daniel Mihalyieb076692014-08-22 17:33:31 +020022#include "debugger.h"
Nicolas Geoffray7bf2b4f2015-07-08 10:11:59 +000023#include "entrypoints/runtime_asm_entrypoints.h"
Tamas Berghammerdd5e5e92016-02-12 16:29:00 +000024#include "jit/jit.h"
Narayan Kamath9823e782016-08-03 12:46:58 +010025#include "jvalue.h"
26#include "method_handles.h"
Narayan Kamath208f8572016-08-03 12:46:58 +010027#include "method_handles-inl.h"
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010028#include "mirror/array-inl.h"
Narayan Kamath9823e782016-08-03 12:46:58 +010029#include "mirror/class.h"
Narayan Kamath000e1882016-10-24 17:14:25 +010030#include "mirror/emulated_stack_frame.h"
Narayan Kamath9823e782016-08-03 12:46:58 +010031#include "mirror/method_handle_impl.h"
32#include "reflection.h"
33#include "reflection-inl.h"
Andreas Gampeb3025922015-09-01 14:45:00 -070034#include "stack.h"
Andreas Gampe2969bcd2015-03-09 12:57:41 -070035#include "unstarted_runtime.h"
Jeff Hao848f70a2014-01-15 13:49:50 -080036#include "verifier/method_verifier.h"
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +010037#include "well_known_classes.h"
Sebastien Hertz8ece0502013-08-07 11:26:41 +020038
39namespace art {
40namespace interpreter {
41
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +000042void ThrowNullPointerExceptionFromInterpreter() {
43 ThrowNullPointerExceptionFromDexPC();
Ian Rogers54874942014-06-10 16:31:03 -070044}
45
46template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check>
47bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst,
48 uint16_t inst_data) {
49 const bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead);
50 const uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c();
Roland Levillain4b8f1ec2015-08-26 18:34:03 +010051 ArtField* f =
52 FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self,
53 Primitive::ComponentSize(field_type));
Ian Rogers54874942014-06-10 16:31:03 -070054 if (UNLIKELY(f == nullptr)) {
55 CHECK(self->IsExceptionPending());
56 return false;
57 }
Mathieu Chartieref41db72016-10-25 15:08:01 -070058 ObjPtr<mirror::Object> obj;
Ian Rogers54874942014-06-10 16:31:03 -070059 if (is_static) {
60 obj = f->GetDeclaringClass();
61 } else {
62 obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
63 if (UNLIKELY(obj == nullptr)) {
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +000064 ThrowNullPointerExceptionForFieldAccess(f, true);
Ian Rogers54874942014-06-10 16:31:03 -070065 return false;
66 }
67 }
Sebastien Hertz1edbd8e2014-07-16 20:00:11 +020068 f->GetDeclaringClass()->AssertInitializedOrInitializingInThread(self);
Ian Rogers54874942014-06-10 16:31:03 -070069 // Report this field access to instrumentation if needed.
70 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
71 if (UNLIKELY(instrumentation->HasFieldReadListeners())) {
Mathieu Chartier0715c0b2016-10-03 22:49:46 -070072 StackHandleScope<1> hs(self);
73 // Wrap in handle wrapper in case the listener does thread suspension.
74 HandleWrapperObjPtr<mirror::Object> h(hs.NewHandleWrapper(&obj));
Mathieu Chartieref41db72016-10-25 15:08:01 -070075 ObjPtr<mirror::Object> this_object;
Mathieu Chartier3398c782016-09-30 10:27:43 -070076 if (!f->IsStatic()) {
77 this_object = obj;
78 }
79 instrumentation->FieldReadEvent(self,
Mathieu Chartier1cc62e42016-10-03 18:01:28 -070080 this_object.Ptr(),
Mathieu Chartier3398c782016-09-30 10:27:43 -070081 shadow_frame.GetMethod(),
82 shadow_frame.GetDexPC(),
83 f);
Ian Rogers54874942014-06-10 16:31:03 -070084 }
85 uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data);
86 switch (field_type) {
87 case Primitive::kPrimBoolean:
88 shadow_frame.SetVReg(vregA, f->GetBoolean(obj));
89 break;
90 case Primitive::kPrimByte:
91 shadow_frame.SetVReg(vregA, f->GetByte(obj));
92 break;
93 case Primitive::kPrimChar:
94 shadow_frame.SetVReg(vregA, f->GetChar(obj));
95 break;
96 case Primitive::kPrimShort:
97 shadow_frame.SetVReg(vregA, f->GetShort(obj));
98 break;
99 case Primitive::kPrimInt:
100 shadow_frame.SetVReg(vregA, f->GetInt(obj));
101 break;
102 case Primitive::kPrimLong:
103 shadow_frame.SetVRegLong(vregA, f->GetLong(obj));
104 break;
105 case Primitive::kPrimNot:
Mathieu Chartier1cc62e42016-10-03 18:01:28 -0700106 shadow_frame.SetVRegReference(vregA, f->GetObject(obj).Ptr());
Ian Rogers54874942014-06-10 16:31:03 -0700107 break;
108 default:
109 LOG(FATAL) << "Unreachable: " << field_type;
Ian Rogers2c4257b2014-10-24 14:20:06 -0700110 UNREACHABLE();
Ian Rogers54874942014-06-10 16:31:03 -0700111 }
112 return true;
113}
114
115// Explicitly instantiate all DoFieldGet functions.
116#define EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, _do_check) \
117 template bool DoFieldGet<_find_type, _field_type, _do_check>(Thread* self, \
118 ShadowFrame& shadow_frame, \
119 const Instruction* inst, \
120 uint16_t inst_data)
121
122#define EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(_find_type, _field_type) \
123 EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, false); \
124 EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, true);
125
126// iget-XXX
Andreas Gampec8ccf682014-09-29 20:07:43 -0700127EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimBoolean)
128EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimByte)
129EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimChar)
130EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimShort)
131EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimInt)
132EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimLong)
133EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstanceObjectRead, Primitive::kPrimNot)
Ian Rogers54874942014-06-10 16:31:03 -0700134
135// sget-XXX
Andreas Gampec8ccf682014-09-29 20:07:43 -0700136EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimBoolean)
137EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimByte)
138EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimChar)
139EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimShort)
140EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimInt)
141EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimLong)
142EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticObjectRead, Primitive::kPrimNot)
Ian Rogers54874942014-06-10 16:31:03 -0700143
144#undef EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL
145#undef EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL
146
147// Handles iget-quick, iget-wide-quick and iget-object-quick instructions.
148// Returns true on success, otherwise throws an exception and returns false.
149template<Primitive::Type field_type>
150bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) {
Mathieu Chartieref41db72016-10-25 15:08:01 -0700151 ObjPtr<mirror::Object> obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
Ian Rogers54874942014-06-10 16:31:03 -0700152 if (UNLIKELY(obj == nullptr)) {
153 // We lost the reference to the field index so we cannot get a more
154 // precised exception message.
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000155 ThrowNullPointerExceptionFromDexPC();
Ian Rogers54874942014-06-10 16:31:03 -0700156 return false;
157 }
158 MemberOffset field_offset(inst->VRegC_22c());
159 // Report this field access to instrumentation if needed. Since we only have the offset of
160 // the field from the base of the object, we need to look for it first.
161 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
162 if (UNLIKELY(instrumentation->HasFieldReadListeners())) {
163 ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(),
164 field_offset.Uint32Value());
165 DCHECK(f != nullptr);
166 DCHECK(!f->IsStatic());
Mathieu Chartiera3147732016-10-26 22:57:02 -0700167 StackHandleScope<1> hs(Thread::Current());
168 // Save obj in case the instrumentation event has thread suspension.
169 HandleWrapperObjPtr<mirror::Object> h = hs.NewHandleWrapper(&obj);
Mathieu Chartieref41db72016-10-25 15:08:01 -0700170 instrumentation->FieldReadEvent(Thread::Current(),
171 obj.Ptr(),
172 shadow_frame.GetMethod(),
173 shadow_frame.GetDexPC(),
174 f);
Ian Rogers54874942014-06-10 16:31:03 -0700175 }
176 // Note: iget-x-quick instructions are only for non-volatile fields.
177 const uint32_t vregA = inst->VRegA_22c(inst_data);
178 switch (field_type) {
179 case Primitive::kPrimInt:
180 shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetField32(field_offset)));
181 break;
Mathieu Chartierffc605c2014-12-10 10:35:44 -0800182 case Primitive::kPrimBoolean:
183 shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldBoolean(field_offset)));
184 break;
185 case Primitive::kPrimByte:
186 shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldByte(field_offset)));
187 break;
188 case Primitive::kPrimChar:
189 shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldChar(field_offset)));
190 break;
191 case Primitive::kPrimShort:
192 shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldShort(field_offset)));
193 break;
Ian Rogers54874942014-06-10 16:31:03 -0700194 case Primitive::kPrimLong:
195 shadow_frame.SetVRegLong(vregA, static_cast<int64_t>(obj->GetField64(field_offset)));
196 break;
197 case Primitive::kPrimNot:
198 shadow_frame.SetVRegReference(vregA, obj->GetFieldObject<mirror::Object>(field_offset));
199 break;
200 default:
201 LOG(FATAL) << "Unreachable: " << field_type;
Ian Rogers2c4257b2014-10-24 14:20:06 -0700202 UNREACHABLE();
Ian Rogers54874942014-06-10 16:31:03 -0700203 }
204 return true;
205}
206
207// Explicitly instantiate all DoIGetQuick functions.
208#define EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(_field_type) \
209 template bool DoIGetQuick<_field_type>(ShadowFrame& shadow_frame, const Instruction* inst, \
210 uint16_t inst_data)
211
Mathieu Chartierffc605c2014-12-10 10:35:44 -0800212EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimInt); // iget-quick.
213EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimBoolean); // iget-boolean-quick.
214EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimByte); // iget-byte-quick.
215EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimChar); // iget-char-quick.
216EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimShort); // iget-short-quick.
217EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimLong); // iget-wide-quick.
218EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimNot); // iget-object-quick.
Ian Rogers54874942014-06-10 16:31:03 -0700219#undef EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL
220
221template<Primitive::Type field_type>
222static JValue GetFieldValue(const ShadowFrame& shadow_frame, uint32_t vreg)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700223 REQUIRES_SHARED(Locks::mutator_lock_) {
Ian Rogers54874942014-06-10 16:31:03 -0700224 JValue field_value;
225 switch (field_type) {
226 case Primitive::kPrimBoolean:
227 field_value.SetZ(static_cast<uint8_t>(shadow_frame.GetVReg(vreg)));
228 break;
229 case Primitive::kPrimByte:
230 field_value.SetB(static_cast<int8_t>(shadow_frame.GetVReg(vreg)));
231 break;
232 case Primitive::kPrimChar:
233 field_value.SetC(static_cast<uint16_t>(shadow_frame.GetVReg(vreg)));
234 break;
235 case Primitive::kPrimShort:
236 field_value.SetS(static_cast<int16_t>(shadow_frame.GetVReg(vreg)));
237 break;
238 case Primitive::kPrimInt:
239 field_value.SetI(shadow_frame.GetVReg(vreg));
240 break;
241 case Primitive::kPrimLong:
242 field_value.SetJ(shadow_frame.GetVRegLong(vreg));
243 break;
244 case Primitive::kPrimNot:
245 field_value.SetL(shadow_frame.GetVRegReference(vreg));
246 break;
247 default:
248 LOG(FATAL) << "Unreachable: " << field_type;
Ian Rogers2c4257b2014-10-24 14:20:06 -0700249 UNREACHABLE();
Ian Rogers54874942014-06-10 16:31:03 -0700250 }
251 return field_value;
252}
253
254template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check,
255 bool transaction_active>
256bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst,
257 uint16_t inst_data) {
258 bool do_assignability_check = do_access_check;
259 bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite);
260 uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c();
Roland Levillain4b8f1ec2015-08-26 18:34:03 +0100261 ArtField* f =
262 FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self,
263 Primitive::ComponentSize(field_type));
Ian Rogers54874942014-06-10 16:31:03 -0700264 if (UNLIKELY(f == nullptr)) {
265 CHECK(self->IsExceptionPending());
266 return false;
267 }
Mathieu Chartieref41db72016-10-25 15:08:01 -0700268 ObjPtr<mirror::Object> obj;
Ian Rogers54874942014-06-10 16:31:03 -0700269 if (is_static) {
270 obj = f->GetDeclaringClass();
271 } else {
272 obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
273 if (UNLIKELY(obj == nullptr)) {
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000274 ThrowNullPointerExceptionForFieldAccess(f, false);
Ian Rogers54874942014-06-10 16:31:03 -0700275 return false;
276 }
277 }
Sebastien Hertz1edbd8e2014-07-16 20:00:11 +0200278 f->GetDeclaringClass()->AssertInitializedOrInitializingInThread(self);
Ian Rogers54874942014-06-10 16:31:03 -0700279 uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data);
280 // Report this field access to instrumentation if needed. Since we only have the offset of
281 // the field from the base of the object, we need to look for it first.
282 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
283 if (UNLIKELY(instrumentation->HasFieldWriteListeners())) {
Mathieu Chartier0715c0b2016-10-03 22:49:46 -0700284 StackHandleScope<1> hs(self);
285 // Wrap in handle wrapper in case the listener does thread suspension.
286 HandleWrapperObjPtr<mirror::Object> h(hs.NewHandleWrapper(&obj));
Ian Rogers54874942014-06-10 16:31:03 -0700287 JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA);
Mathieu Chartieref41db72016-10-25 15:08:01 -0700288 ObjPtr<mirror::Object> this_object = f->IsStatic() ? nullptr : obj;
Mathieu Chartier1cc62e42016-10-03 18:01:28 -0700289 instrumentation->FieldWriteEvent(self, this_object.Ptr(),
Mathieu Chartier3398c782016-09-30 10:27:43 -0700290 shadow_frame.GetMethod(),
291 shadow_frame.GetDexPC(),
292 f,
293 field_value);
Ian Rogers54874942014-06-10 16:31:03 -0700294 }
295 switch (field_type) {
296 case Primitive::kPrimBoolean:
297 f->SetBoolean<transaction_active>(obj, shadow_frame.GetVReg(vregA));
298 break;
299 case Primitive::kPrimByte:
300 f->SetByte<transaction_active>(obj, shadow_frame.GetVReg(vregA));
301 break;
302 case Primitive::kPrimChar:
303 f->SetChar<transaction_active>(obj, shadow_frame.GetVReg(vregA));
304 break;
305 case Primitive::kPrimShort:
306 f->SetShort<transaction_active>(obj, shadow_frame.GetVReg(vregA));
307 break;
308 case Primitive::kPrimInt:
309 f->SetInt<transaction_active>(obj, shadow_frame.GetVReg(vregA));
310 break;
311 case Primitive::kPrimLong:
312 f->SetLong<transaction_active>(obj, shadow_frame.GetVRegLong(vregA));
313 break;
314 case Primitive::kPrimNot: {
Mathieu Chartieref41db72016-10-25 15:08:01 -0700315 ObjPtr<mirror::Object> reg = shadow_frame.GetVRegReference(vregA);
Ian Rogers54874942014-06-10 16:31:03 -0700316 if (do_assignability_check && reg != nullptr) {
317 // FieldHelper::GetType can resolve classes, use a handle wrapper which will restore the
318 // object in the destructor.
Mathieu Chartieref41db72016-10-25 15:08:01 -0700319 ObjPtr<mirror::Class> field_class;
Ian Rogers54874942014-06-10 16:31:03 -0700320 {
Mathieu Chartierc7853442015-03-27 14:35:38 -0700321 StackHandleScope<2> hs(self);
Mathieu Chartieref41db72016-10-25 15:08:01 -0700322 HandleWrapperObjPtr<mirror::Object> h_reg(hs.NewHandleWrapper(&reg));
Mathieu Chartier3398c782016-09-30 10:27:43 -0700323 HandleWrapperObjPtr<mirror::Object> h_obj(hs.NewHandleWrapper(&obj));
Mathieu Chartierc7853442015-03-27 14:35:38 -0700324 field_class = f->GetType<true>();
Ian Rogers54874942014-06-10 16:31:03 -0700325 }
Mathieu Chartier1cc62e42016-10-03 18:01:28 -0700326 if (!reg->VerifierInstanceOf(field_class.Ptr())) {
Ian Rogers54874942014-06-10 16:31:03 -0700327 // This should never happen.
Ian Rogers1ff3c982014-08-12 02:30:58 -0700328 std::string temp1, temp2, temp3;
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000329 self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
Ian Rogers54874942014-06-10 16:31:03 -0700330 "Put '%s' that is not instance of field '%s' in '%s'",
Ian Rogers1ff3c982014-08-12 02:30:58 -0700331 reg->GetClass()->GetDescriptor(&temp1),
332 field_class->GetDescriptor(&temp2),
333 f->GetDeclaringClass()->GetDescriptor(&temp3));
Ian Rogers54874942014-06-10 16:31:03 -0700334 return false;
335 }
336 }
337 f->SetObj<transaction_active>(obj, reg);
338 break;
339 }
340 default:
341 LOG(FATAL) << "Unreachable: " << field_type;
Ian Rogers2c4257b2014-10-24 14:20:06 -0700342 UNREACHABLE();
Ian Rogers54874942014-06-10 16:31:03 -0700343 }
344 return true;
345}
346
347// Explicitly instantiate all DoFieldPut functions.
348#define EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, _do_check, _transaction_active) \
349 template bool DoFieldPut<_find_type, _field_type, _do_check, _transaction_active>(Thread* self, \
350 const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data)
351
352#define EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(_find_type, _field_type) \
353 EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, false); \
354 EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, false); \
355 EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, true); \
356 EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, true);
357
358// iput-XXX
Andreas Gampec8ccf682014-09-29 20:07:43 -0700359EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimBoolean)
360EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimByte)
361EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimChar)
362EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimShort)
363EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimInt)
364EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimLong)
365EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstanceObjectWrite, Primitive::kPrimNot)
Ian Rogers54874942014-06-10 16:31:03 -0700366
367// sput-XXX
Andreas Gampec8ccf682014-09-29 20:07:43 -0700368EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimBoolean)
369EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimByte)
370EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimChar)
371EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimShort)
372EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimInt)
373EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimLong)
374EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticObjectWrite, Primitive::kPrimNot)
Ian Rogers54874942014-06-10 16:31:03 -0700375
376#undef EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL
377#undef EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL
378
379template<Primitive::Type field_type, bool transaction_active>
380bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) {
Mathieu Chartieref41db72016-10-25 15:08:01 -0700381 ObjPtr<mirror::Object> obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
Ian Rogers54874942014-06-10 16:31:03 -0700382 if (UNLIKELY(obj == nullptr)) {
383 // We lost the reference to the field index so we cannot get a more
384 // precised exception message.
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +0000385 ThrowNullPointerExceptionFromDexPC();
Ian Rogers54874942014-06-10 16:31:03 -0700386 return false;
387 }
388 MemberOffset field_offset(inst->VRegC_22c());
389 const uint32_t vregA = inst->VRegA_22c(inst_data);
390 // Report this field modification to instrumentation if needed. Since we only have the offset of
391 // the field from the base of the object, we need to look for it first.
392 instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
393 if (UNLIKELY(instrumentation->HasFieldWriteListeners())) {
394 ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(),
395 field_offset.Uint32Value());
396 DCHECK(f != nullptr);
397 DCHECK(!f->IsStatic());
398 JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA);
Mathieu Chartiera3147732016-10-26 22:57:02 -0700399 StackHandleScope<1> hs(Thread::Current());
400 // Save obj in case the instrumentation event has thread suspension.
401 HandleWrapperObjPtr<mirror::Object> h = hs.NewHandleWrapper(&obj);
Mathieu Chartieref41db72016-10-25 15:08:01 -0700402 instrumentation->FieldWriteEvent(Thread::Current(),
403 obj.Ptr(),
404 shadow_frame.GetMethod(),
405 shadow_frame.GetDexPC(),
406 f,
407 field_value);
Ian Rogers54874942014-06-10 16:31:03 -0700408 }
409 // Note: iput-x-quick instructions are only for non-volatile fields.
410 switch (field_type) {
Fred Shih37f05ef2014-07-16 18:38:08 -0700411 case Primitive::kPrimBoolean:
412 obj->SetFieldBoolean<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
413 break;
414 case Primitive::kPrimByte:
415 obj->SetFieldByte<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
416 break;
417 case Primitive::kPrimChar:
418 obj->SetFieldChar<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
419 break;
420 case Primitive::kPrimShort:
421 obj->SetFieldShort<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
422 break;
Ian Rogers54874942014-06-10 16:31:03 -0700423 case Primitive::kPrimInt:
424 obj->SetField32<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
425 break;
426 case Primitive::kPrimLong:
427 obj->SetField64<transaction_active>(field_offset, shadow_frame.GetVRegLong(vregA));
428 break;
429 case Primitive::kPrimNot:
430 obj->SetFieldObject<transaction_active>(field_offset, shadow_frame.GetVRegReference(vregA));
431 break;
432 default:
433 LOG(FATAL) << "Unreachable: " << field_type;
Ian Rogers2c4257b2014-10-24 14:20:06 -0700434 UNREACHABLE();
Ian Rogers54874942014-06-10 16:31:03 -0700435 }
436 return true;
437}
438
439// Explicitly instantiate all DoIPutQuick functions.
440#define EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, _transaction_active) \
441 template bool DoIPutQuick<_field_type, _transaction_active>(const ShadowFrame& shadow_frame, \
442 const Instruction* inst, \
443 uint16_t inst_data)
444
445#define EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(_field_type) \
446 EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, false); \
447 EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, true);
448
Andreas Gampec8ccf682014-09-29 20:07:43 -0700449EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimInt) // iput-quick.
450EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimBoolean) // iput-boolean-quick.
451EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimByte) // iput-byte-quick.
452EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimChar) // iput-char-quick.
453EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimShort) // iput-short-quick.
454EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimLong) // iput-wide-quick.
455EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimNot) // iput-object-quick.
Ian Rogers54874942014-06-10 16:31:03 -0700456#undef EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL
457#undef EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL
458
Sebastien Hertz520633b2015-09-08 17:03:36 +0200459// We accept a null Instrumentation* meaning we must not report anything to the instrumentation.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700460uint32_t FindNextInstructionFollowingException(
461 Thread* self, ShadowFrame& shadow_frame, uint32_t dex_pc,
462 const instrumentation::Instrumentation* instrumentation) {
Ian Rogers54874942014-06-10 16:31:03 -0700463 self->VerifyStack();
Mathieu Chartiere401d142015-04-22 13:56:20 -0700464 StackHandleScope<2> hs(self);
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000465 Handle<mirror::Throwable> exception(hs.NewHandle(self->GetException()));
Sebastien Hertz520633b2015-09-08 17:03:36 +0200466 if (instrumentation != nullptr && instrumentation->HasExceptionCaughtListeners()
Nicolas Geoffray7642cfc2015-02-26 10:56:09 +0000467 && self->IsExceptionThrownByCurrentMethod(exception.Get())) {
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000468 instrumentation->ExceptionCaughtEvent(self, exception.Get());
Sebastien Hertz9f102032014-05-23 08:59:42 +0200469 }
Ian Rogers54874942014-06-10 16:31:03 -0700470 bool clear_exception = false;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700471 uint32_t found_dex_pc = shadow_frame.GetMethod()->FindCatchBlock(
472 hs.NewHandle(exception->GetClass()), dex_pc, &clear_exception);
Sebastien Hertz520633b2015-09-08 17:03:36 +0200473 if (found_dex_pc == DexFile::kDexNoIndex && instrumentation != nullptr) {
Nicolas Geoffray7642cfc2015-02-26 10:56:09 +0000474 // Exception is not caught by the current method. We will unwind to the
475 // caller. Notify any instrumentation listener.
Sebastien Hertz9f102032014-05-23 08:59:42 +0200476 instrumentation->MethodUnwindEvent(self, shadow_frame.GetThisObject(),
Ian Rogers54874942014-06-10 16:31:03 -0700477 shadow_frame.GetMethod(), dex_pc);
478 } else {
Nicolas Geoffray7642cfc2015-02-26 10:56:09 +0000479 // Exception is caught in the current method. We will jump to the found_dex_pc.
Ian Rogers54874942014-06-10 16:31:03 -0700480 if (clear_exception) {
481 self->ClearException();
482 }
483 }
484 return found_dex_pc;
485}
486
Ian Rogerse94652f2014-12-02 11:13:19 -0800487void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame) {
488 LOG(FATAL) << "Unexpected instruction: "
489 << inst->DumpString(shadow_frame.GetMethod()->GetDexFile());
490 UNREACHABLE();
Ian Rogers54874942014-06-10 16:31:03 -0700491}
492
Sebastien Hertz45b15972015-04-03 16:07:05 +0200493void AbortTransactionF(Thread* self, const char* fmt, ...) {
Mathieu Chartierb2c7ead2014-04-29 11:13:16 -0700494 va_list args;
495 va_start(args, fmt);
Sebastien Hertz45b15972015-04-03 16:07:05 +0200496 AbortTransactionV(self, fmt, args);
497 va_end(args);
498}
499
500void AbortTransactionV(Thread* self, const char* fmt, va_list args) {
501 CHECK(Runtime::Current()->IsActiveTransaction());
502 // Constructs abort message.
Sebastien Hertz1c80bec2015-02-03 11:58:06 +0100503 std::string abort_msg;
504 StringAppendV(&abort_msg, fmt, args);
505 // Throws an exception so we can abort the transaction and rollback every change.
Sebastien Hertz2fd7e692015-04-02 11:11:19 +0200506 Runtime::Current()->AbortTransactionAndThrowAbortError(self, abort_msg);
Mathieu Chartierb2c7ead2014-04-29 11:13:16 -0700507}
508
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100509// START DECLARATIONS :
510//
511// These additional declarations are required because clang complains
512// about ALWAYS_INLINE (-Werror, -Wgcc-compat) in definitions.
513//
514
Narayan Kamath9823e782016-08-03 12:46:58 +0100515template <bool is_range, bool do_assignability_check>
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700516 REQUIRES_SHARED(Locks::mutator_lock_)
Igor Murashkin158f35c2015-06-10 15:55:30 -0700517static inline bool DoCallCommon(ArtMethod* called_method,
518 Thread* self,
519 ShadowFrame& shadow_frame,
520 JValue* result,
521 uint16_t number_of_inputs,
Narayan Kamath370423d2016-10-03 16:51:22 +0100522 uint32_t (&arg)[Instruction::kMaxVarArgRegs],
Igor Murashkin158f35c2015-06-10 15:55:30 -0700523 uint32_t vregC) ALWAYS_INLINE;
524
Narayan Kamath208f8572016-08-03 12:46:58 +0100525template <bool is_range> REQUIRES_SHARED(Locks::mutator_lock_)
526static inline bool DoCallPolymorphic(ArtMethod* called_method,
527 Handle<mirror::MethodType> callsite_type,
528 Handle<mirror::MethodType> target_type,
529 Thread* self,
530 ShadowFrame& shadow_frame,
531 JValue* result,
532 uint32_t (&arg)[Instruction::kMaxVarArgRegs],
Narayan Kamath000e1882016-10-24 17:14:25 +0100533 uint32_t vregC,
534 const MethodHandleKind handle_kind) ALWAYS_INLINE;
Narayan Kamath208f8572016-08-03 12:46:58 +0100535
Narayan Kamath000e1882016-10-24 17:14:25 +0100536template <bool is_range> REQUIRES_SHARED(Locks::mutator_lock_)
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100537static inline bool DoCallTransform(ArtMethod* called_method,
538 Handle<mirror::MethodType> callsite_type,
Narayan Kamath000e1882016-10-24 17:14:25 +0100539 Handle<mirror::MethodType> callee_type,
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100540 Thread* self,
541 ShadowFrame& shadow_frame,
542 Handle<mirror::MethodHandleImpl> receiver,
Narayan Kamath000e1882016-10-24 17:14:25 +0100543 JValue* result,
544 uint32_t (&arg)[Instruction::kMaxVarArgRegs],
545 uint32_t vregC) ALWAYS_INLINE;
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100546
547REQUIRES_SHARED(Locks::mutator_lock_)
548inline void PerformCall(Thread* self,
549 const DexFile::CodeItem* code_item,
550 ArtMethod* caller_method,
551 const size_t first_dest_reg,
552 ShadowFrame* callee_frame,
553 JValue* result) ALWAYS_INLINE;
554
555template <bool is_range>
556REQUIRES_SHARED(Locks::mutator_lock_)
557inline void CopyRegisters(ShadowFrame& caller_frame,
558 ShadowFrame* callee_frame,
559 const uint32_t (&arg)[Instruction::kMaxVarArgRegs],
560 const size_t first_src_reg,
561 const size_t first_dest_reg,
562 const size_t num_regs) ALWAYS_INLINE;
563
564// END DECLARATIONS.
565
Siva Chandra05d24152016-01-05 17:43:17 -0800566void ArtInterpreterToCompiledCodeBridge(Thread* self,
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100567 ArtMethod* caller,
Siva Chandra05d24152016-01-05 17:43:17 -0800568 const DexFile::CodeItem* code_item,
569 ShadowFrame* shadow_frame,
570 JValue* result)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700571 REQUIRES_SHARED(Locks::mutator_lock_) {
Andreas Gampe3cfa4d02015-10-06 17:04:01 -0700572 ArtMethod* method = shadow_frame->GetMethod();
573 // Ensure static methods are initialized.
574 if (method->IsStatic()) {
Mathieu Chartieref41db72016-10-25 15:08:01 -0700575 ObjPtr<mirror::Class> declaringClass = method->GetDeclaringClass();
Andreas Gampe3cfa4d02015-10-06 17:04:01 -0700576 if (UNLIKELY(!declaringClass->IsInitialized())) {
577 self->PushShadowFrame(shadow_frame);
578 StackHandleScope<1> hs(self);
579 Handle<mirror::Class> h_class(hs.NewHandle(declaringClass));
580 if (UNLIKELY(!Runtime::Current()->GetClassLinker()->EnsureInitialized(self, h_class, true,
581 true))) {
582 self->PopShadowFrame();
583 DCHECK(self->IsExceptionPending());
584 return;
585 }
586 self->PopShadowFrame();
587 CHECK(h_class->IsInitializing());
588 // Reload from shadow frame in case the method moved, this is faster than adding a handle.
589 method = shadow_frame->GetMethod();
590 }
591 }
592 uint16_t arg_offset = (code_item == nullptr)
593 ? 0
594 : code_item->registers_size_ - code_item->ins_size_;
Nicolas Geoffray71cd50f2016-04-14 15:00:33 +0100595 jit::Jit* jit = Runtime::Current()->GetJit();
596 if (jit != nullptr && caller != nullptr) {
597 jit->NotifyInterpreterToCompiledCodeTransition(self, caller);
598 }
Andreas Gampe3cfa4d02015-10-06 17:04:01 -0700599 method->Invoke(self, shadow_frame->GetVRegArgs(arg_offset),
600 (shadow_frame->NumberOfVRegs() - arg_offset) * sizeof(uint32_t),
Andreas Gampe542451c2016-07-26 09:02:02 -0700601 result, method->GetInterfaceMethodIfProxy(kRuntimePointerSize)->GetShorty());
Andreas Gampe3cfa4d02015-10-06 17:04:01 -0700602}
603
Mingyao Yangffedec52016-05-19 10:48:40 -0700604void SetStringInitValueToAllAliases(ShadowFrame* shadow_frame,
605 uint16_t this_obj_vreg,
606 JValue result)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -0700607 REQUIRES_SHARED(Locks::mutator_lock_) {
Mathieu Chartieref41db72016-10-25 15:08:01 -0700608 ObjPtr<mirror::Object> existing = shadow_frame->GetVRegReference(this_obj_vreg);
Mingyao Yangffedec52016-05-19 10:48:40 -0700609 if (existing == nullptr) {
610 // If it's null, we come from compiled code that was deoptimized. Nothing to do,
611 // as the compiler verified there was no alias.
612 // Set the new string result of the StringFactory.
613 shadow_frame->SetVRegReference(this_obj_vreg, result.GetL());
614 return;
615 }
616 // Set the string init result into all aliases.
617 for (uint32_t i = 0, e = shadow_frame->NumberOfVRegs(); i < e; ++i) {
618 if (shadow_frame->GetVRegReference(i) == existing) {
619 DCHECK_EQ(shadow_frame->GetVRegReference(i),
620 reinterpret_cast<mirror::Object*>(shadow_frame->GetVReg(i)));
621 shadow_frame->SetVRegReference(i, result.GetL());
622 DCHECK_EQ(shadow_frame->GetVRegReference(i),
623 reinterpret_cast<mirror::Object*>(shadow_frame->GetVReg(i)));
624 }
625 }
626}
627
Narayan Kamath9823e782016-08-03 12:46:58 +0100628template<bool is_range, bool do_access_check>
Mathieu Chartieref41db72016-10-25 15:08:01 -0700629inline bool DoInvokePolymorphic(Thread* self,
630 ShadowFrame& shadow_frame,
631 const Instruction* inst,
632 uint16_t inst_data,
633 JValue* result) REQUIRES_SHARED(Locks::mutator_lock_) {
Narayan Kamath9823e782016-08-03 12:46:58 +0100634 // Invoke-polymorphic instructions always take a receiver. i.e, they are never static.
635 const uint32_t vRegC = (is_range) ? inst->VRegC_4rcc() : inst->VRegC_45cc();
636
637 // The method_idx here is the name of the signature polymorphic method that
638 // was symbolically invoked in bytecode (say MethodHandle.invoke or MethodHandle.invokeExact)
639 // and not the method that we'll dispatch to in the end.
640 //
641 // TODO(narayan) We'll have to check in the verifier that this is in fact a
642 // signature polymorphic method so that we disallow calls via invoke-polymorphic
643 // to non sig-poly methods. This would also have the side effect of verifying
644 // that vRegC really is a reference type.
Narayan Kamath208f8572016-08-03 12:46:58 +0100645 StackHandleScope<6> hs(self);
646 Handle<mirror::MethodHandleImpl> method_handle(hs.NewHandle(
Mathieu Chartieref41db72016-10-25 15:08:01 -0700647 ObjPtr<mirror::MethodHandleImpl>::DownCast(
648 MakeObjPtr(shadow_frame.GetVRegReference(vRegC)))));
Narayan Kamath208f8572016-08-03 12:46:58 +0100649 if (UNLIKELY(method_handle.Get() == nullptr)) {
Narayan Kamath9823e782016-08-03 12:46:58 +0100650 const int method_idx = (is_range) ? inst->VRegB_4rcc() : inst->VRegB_45cc();
651 // Note that the invoke type is kVirtual here because a call to a signature
652 // polymorphic method is shaped like a virtual call at the bytecode level.
653 ThrowNullPointerExceptionForMethodAccess(method_idx, InvokeType::kVirtual);
654
655 result->SetJ(0);
656 return false;
657 }
658
659 // The vRegH value gives the index of the proto_id associated with this
660 // signature polymorphic callsite.
661 const uint32_t callsite_proto_id = (is_range) ? inst->VRegH_4rcc() : inst->VRegH_45cc();
662
663 // Call through to the classlinker and ask it to resolve the static type associated
664 // with the callsite. This information is stored in the dex cache so it's
665 // guaranteed to be fast after the first resolution.
Narayan Kamath9823e782016-08-03 12:46:58 +0100666 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Narayan Kamath208f8572016-08-03 12:46:58 +0100667 Handle<mirror::Class> caller_class(hs.NewHandle(shadow_frame.GetMethod()->GetDeclaringClass()));
668 Handle<mirror::MethodType> callsite_type(hs.NewHandle(class_linker->ResolveMethodType(
Narayan Kamath9823e782016-08-03 12:46:58 +0100669 caller_class->GetDexFile(), callsite_proto_id,
670 hs.NewHandle<mirror::DexCache>(caller_class->GetDexCache()),
Narayan Kamath208f8572016-08-03 12:46:58 +0100671 hs.NewHandle<mirror::ClassLoader>(caller_class->GetClassLoader()))));
Narayan Kamath9823e782016-08-03 12:46:58 +0100672
673 // This implies we couldn't resolve one or more types in this method handle.
Narayan Kamath208f8572016-08-03 12:46:58 +0100674 if (UNLIKELY(callsite_type.Get() == nullptr)) {
Narayan Kamath9823e782016-08-03 12:46:58 +0100675 CHECK(self->IsExceptionPending());
676 result->SetJ(0);
677 return false;
678 }
679
Narayan Kamath9823e782016-08-03 12:46:58 +0100680 // Get the method we're actually invoking along with the kind of
681 // invoke that is desired. We don't need to perform access checks at this
682 // point because they would have been performed on our behalf at the point
683 // of creation of the method handle.
684 ArtMethod* called_method = method_handle->GetTargetMethod();
685 const MethodHandleKind handle_kind = method_handle->GetHandleKind();
Narayan Kamath208f8572016-08-03 12:46:58 +0100686 Handle<mirror::MethodType> handle_type(hs.NewHandle(method_handle->GetMethodType()));
Narayan Kamath9823e782016-08-03 12:46:58 +0100687 CHECK(called_method != nullptr);
Narayan Kamath208f8572016-08-03 12:46:58 +0100688 CHECK(handle_type.Get() != nullptr);
Narayan Kamath9823e782016-08-03 12:46:58 +0100689
Narayan Kamath9823e782016-08-03 12:46:58 +0100690 uint32_t arg[Instruction::kMaxVarArgRegs] = {};
Narayan Kamath000e1882016-10-24 17:14:25 +0100691 uint32_t first_src_reg = 0;
Narayan Kamath9823e782016-08-03 12:46:58 +0100692 if (is_range) {
Narayan Kamath000e1882016-10-24 17:14:25 +0100693 first_src_reg = (inst->VRegC_4rcc() + 1);
Narayan Kamath9823e782016-08-03 12:46:58 +0100694 } else {
695 inst->GetVarArgs(arg, inst_data);
696 arg[0] = arg[1];
697 arg[1] = arg[2];
698 arg[2] = arg[3];
699 arg[3] = arg[4];
700 arg[4] = 0;
Narayan Kamath000e1882016-10-24 17:14:25 +0100701 first_src_reg = arg[0];
Narayan Kamath9823e782016-08-03 12:46:58 +0100702 }
703
704 if (IsInvoke(handle_kind)) {
705 if (handle_kind == kInvokeVirtual || handle_kind == kInvokeInterface) {
Narayan Kamath000e1882016-10-24 17:14:25 +0100706 // TODO: Unfortunately, we have to postpone dynamic receiver based checks
707 // because the receiver might be cast or might come from an emulated stack
708 // frame, which means that it is unknown at this point. We perform these
709 // checks inside DoCallPolymorphic right before we do the actualy invoke.
Narayan Kamath9823e782016-08-03 12:46:58 +0100710 } else if (handle_kind == kInvokeDirect) {
Narayan Kamath9bdaeeb2016-10-20 10:57:45 +0100711 if (called_method->IsConstructor()) {
712 // TODO(narayan) : We need to handle the case where the target method is a
713 // constructor here.
714 UNIMPLEMENTED(FATAL) << "Direct invokes for constructors are not implemented yet.";
715 return false;
716 }
717
718 // Nothing special to do in the case where we're not dealing with a
719 // constructor. It's a private method, and we've already access checked at
720 // the point of creating the handle.
721 } else if (handle_kind == kInvokeSuper) {
Mathieu Chartieref41db72016-10-25 15:08:01 -0700722 ObjPtr<mirror::Class> declaring_class = called_method->GetDeclaringClass();
Narayan Kamath9bdaeeb2016-10-20 10:57:45 +0100723
724 // Note that we're not dynamically dispatching on the type of the receiver
725 // here. We use the static type of the "receiver" object that we've
726 // recorded in the method handle's type, which will be the same as the
727 // special caller that was specified at the point of lookup.
Mathieu Chartieref41db72016-10-25 15:08:01 -0700728 ObjPtr<mirror::Class> referrer_class = handle_type->GetPTypes()->Get(0);
Narayan Kamath9bdaeeb2016-10-20 10:57:45 +0100729 if (!declaring_class->IsInterface()) {
Mathieu Chartieref41db72016-10-25 15:08:01 -0700730 ObjPtr<mirror::Class> super_class = referrer_class->GetSuperClass();
Narayan Kamath9bdaeeb2016-10-20 10:57:45 +0100731 uint16_t vtable_index = called_method->GetMethodIndex();
732 DCHECK(super_class != nullptr);
733 DCHECK(super_class->HasVTable());
734 // Note that super_class is a super of referrer_class and called_method
735 // will always be declared by super_class (or one of its super classes).
736 DCHECK_LT(vtable_index, super_class->GetVTableLength());
737 called_method = super_class->GetVTableEntry(vtable_index, kRuntimePointerSize);
738 } else {
739 called_method = referrer_class->FindVirtualMethodForInterfaceSuper(
740 called_method, kRuntimePointerSize);
741 }
742
743 CHECK(called_method != nullptr);
Narayan Kamath9823e782016-08-03 12:46:58 +0100744 }
745
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100746 if (handle_kind == kInvokeTransform) {
Narayan Kamath000e1882016-10-24 17:14:25 +0100747 return DoCallTransform<is_range>(called_method,
748 callsite_type,
749 handle_type,
750 self,
751 shadow_frame,
752 method_handle /* receiver */,
753 result,
754 arg,
755 first_src_reg);
Narayan Kamath208f8572016-08-03 12:46:58 +0100756 } else {
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100757 return DoCallPolymorphic<is_range>(called_method,
758 callsite_type,
759 handle_type,
760 self,
761 shadow_frame,
762 result,
763 arg,
Narayan Kamath000e1882016-10-24 17:14:25 +0100764 first_src_reg,
765 handle_kind);
Narayan Kamath9823e782016-08-03 12:46:58 +0100766 }
Narayan Kamath9823e782016-08-03 12:46:58 +0100767 } else {
768 // TODO(narayan): Implement field getters and setters.
Narayan Kamath9823e782016-08-03 12:46:58 +0100769 UNIMPLEMENTED(FATAL) << "Field references in method handles are not implemented yet.";
770 return false;
771 }
772}
773
Narayan Kamath208f8572016-08-03 12:46:58 +0100774// Calculate the number of ins for a proxy or native method, where we
775// can't just look at the code item.
776static inline size_t GetInsForProxyOrNativeMethod(ArtMethod* method)
777 REQUIRES_SHARED(Locks::mutator_lock_) {
778 DCHECK(method->IsNative() || method->IsProxyMethod());
779
780 method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
781 size_t num_ins = 0;
782 // Separate accounting for the receiver, which isn't a part of the
783 // shorty.
784 if (!method->IsStatic()) {
785 ++num_ins;
786 }
787
788 uint32_t shorty_len = 0;
789 const char* shorty = method->GetShorty(&shorty_len);
790 for (size_t i = 1; i < shorty_len; ++i) {
791 const char c = shorty[i];
792 ++num_ins;
793 if (c == 'J' || c == 'D') {
794 ++num_ins;
795 }
796 }
797
798 return num_ins;
799}
800
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100801
802inline void PerformCall(Thread* self,
803 const DexFile::CodeItem* code_item,
804 ArtMethod* caller_method,
805 const size_t first_dest_reg,
806 ShadowFrame* callee_frame,
807 JValue* result) {
808 if (LIKELY(Runtime::Current()->IsStarted())) {
809 ArtMethod* target = callee_frame->GetMethod();
810 if (ClassLinker::ShouldUseInterpreterEntrypoint(
811 target,
812 target->GetEntryPointFromQuickCompiledCode())) {
813 ArtInterpreterToInterpreterBridge(self, code_item, callee_frame, result);
814 } else {
815 ArtInterpreterToCompiledCodeBridge(
816 self, caller_method, code_item, callee_frame, result);
817 }
818 } else {
819 UnstartedRuntime::Invoke(self, code_item, callee_frame, result, first_dest_reg);
820 }
821}
822
823template <bool is_range>
824inline void CopyRegisters(ShadowFrame& caller_frame,
825 ShadowFrame* callee_frame,
826 const uint32_t (&arg)[Instruction::kMaxVarArgRegs],
827 const size_t first_src_reg,
828 const size_t first_dest_reg,
829 const size_t num_regs) {
830 if (is_range) {
831 const size_t dest_reg_bound = first_dest_reg + num_regs;
832 for (size_t src_reg = first_src_reg, dest_reg = first_dest_reg; dest_reg < dest_reg_bound;
833 ++dest_reg, ++src_reg) {
834 AssignRegister(callee_frame, caller_frame, dest_reg, src_reg);
835 }
836 } else {
837 DCHECK_LE(num_regs, arraysize(arg));
838
839 for (size_t arg_index = 0; arg_index < num_regs; ++arg_index) {
840 AssignRegister(callee_frame, caller_frame, first_dest_reg + arg_index, arg[arg_index]);
841 }
842 }
843}
844
845// Returns true iff. the callsite type for a polymorphic invoke is transformer
846// like, i.e that it has a single input argument whose type is
847// dalvik.system.EmulatedStackFrame.
848static inline bool IsCallerTransformer(Handle<mirror::MethodType> callsite_type)
849 REQUIRES_SHARED(Locks::mutator_lock_) {
850 ObjPtr<mirror::ObjectArray<mirror::Class>> param_types(callsite_type->GetPTypes());
851 if (param_types->GetLength() == 1) {
852 ObjPtr<mirror::Class> param(param_types->GetWithoutChecks(0));
853 return param == WellKnownClasses::ToClass(WellKnownClasses::dalvik_system_EmulatedStackFrame);
854 }
855
856 return false;
857}
858
Narayan Kamath208f8572016-08-03 12:46:58 +0100859template <bool is_range>
860static inline bool DoCallPolymorphic(ArtMethod* called_method,
861 Handle<mirror::MethodType> callsite_type,
862 Handle<mirror::MethodType> target_type,
863 Thread* self,
864 ShadowFrame& shadow_frame,
865 JValue* result,
866 uint32_t (&arg)[Instruction::kMaxVarArgRegs],
Narayan Kamath000e1882016-10-24 17:14:25 +0100867 uint32_t first_src_reg,
868 const MethodHandleKind handle_kind) {
Narayan Kamath208f8572016-08-03 12:46:58 +0100869 // TODO(narayan): Wire in the String.init hacks.
870
871 // Compute method information.
872 const DexFile::CodeItem* code_item = called_method->GetCodeItem();
873
874 // Number of registers for the callee's call frame. Note that for non-exact
875 // invokes, we always derive this information from the callee method. We
876 // cannot guarantee during verification that the number of registers encoded
877 // in the invoke is equal to the number of ins for the callee. This is because
878 // some transformations (such as boxing a long -> Long or wideining an
879 // int -> long will change that number.
880 uint16_t num_regs;
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100881 size_t num_input_regs;
Narayan Kamath208f8572016-08-03 12:46:58 +0100882 size_t first_dest_reg;
883 if (LIKELY(code_item != nullptr)) {
884 num_regs = code_item->registers_size_;
885 first_dest_reg = num_regs - code_item->ins_size_;
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100886 num_input_regs = code_item->ins_size_;
Narayan Kamath208f8572016-08-03 12:46:58 +0100887 // Parameter registers go at the end of the shadow frame.
888 DCHECK_NE(first_dest_reg, (size_t)-1);
889 } else {
890 // No local regs for proxy and native methods.
891 DCHECK(called_method->IsNative() || called_method->IsProxyMethod());
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100892 num_regs = num_input_regs = GetInsForProxyOrNativeMethod(called_method);
Narayan Kamath208f8572016-08-03 12:46:58 +0100893 first_dest_reg = 0;
894 }
895
896 // Allocate shadow frame on the stack.
897 ShadowFrameAllocaUniquePtr shadow_frame_unique_ptr =
898 CREATE_SHADOW_FRAME(num_regs, &shadow_frame, called_method, /* dex pc */ 0);
899 ShadowFrame* new_shadow_frame = shadow_frame_unique_ptr.get();
900
Narayan Kamath000e1882016-10-24 17:14:25 +0100901 // Whether this polymorphic invoke was issued by a transformer method.
902 bool is_caller_transformer = false;
Narayan Kamath208f8572016-08-03 12:46:58 +0100903 // Thread might be suspended during PerformArgumentConversions due to the
904 // allocations performed during boxing.
905 {
906 ScopedStackedShadowFramePusher pusher(
907 self, new_shadow_frame, StackedShadowFrameType::kShadowFrameUnderConstruction);
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100908 if (callsite_type->IsExactMatch(target_type.Get())) {
909 // This is an exact invoke, we can take the fast path of just copying all
910 // registers without performing any argument conversions.
911 CopyRegisters<is_range>(shadow_frame,
912 new_shadow_frame,
913 arg,
914 first_src_reg,
915 first_dest_reg,
916 num_input_regs);
917 } else {
918 // This includes the case where we're entering this invoke-polymorphic
919 // from a transformer method. In that case, the callsite_type will contain
920 // a single argument of type dalvik.system.EmulatedStackFrame. In that
921 // case, we'll have to unmarshal the EmulatedStackFrame into the
922 // new_shadow_frame and perform argument conversions on it.
923 if (IsCallerTransformer(callsite_type)) {
Narayan Kamath000e1882016-10-24 17:14:25 +0100924 is_caller_transformer = true;
925 // The emulated stack frame is the first and only argument when we're coming
926 // through from a transformer.
927 ObjPtr<mirror::EmulatedStackFrame> emulated_stack_frame(
928 reinterpret_cast<mirror::EmulatedStackFrame*>(
929 shadow_frame.GetVRegReference(first_src_reg)));
930 if (!emulated_stack_frame->WriteToShadowFrame(self,
931 target_type,
932 first_dest_reg,
933 new_shadow_frame)) {
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100934 DCHECK(self->IsExceptionPending());
935 result->SetL(0);
936 return false;
937 }
938 } else if (!ConvertAndCopyArgumentsFromCallerFrame<is_range>(self,
939 callsite_type,
940 target_type,
941 shadow_frame,
942 first_src_reg,
943 first_dest_reg,
944 arg,
945 new_shadow_frame)) {
946 DCHECK(self->IsExceptionPending());
947 result->SetL(0);
948 return false;
949 }
Narayan Kamath208f8572016-08-03 12:46:58 +0100950 }
951 }
952
Narayan Kamath000e1882016-10-24 17:14:25 +0100953 // See TODO in DoInvokePolymorphic : We need to perform this dynamic, receiver
954 // based dispatch right before we perform the actual call, because the
955 // receiver isn't known very early.
956 if (handle_kind == kInvokeVirtual || handle_kind == kInvokeInterface) {
957 ObjPtr<mirror::Object> receiver(new_shadow_frame->GetVRegReference(first_dest_reg));
958 ObjPtr<mirror::Class> declaring_class(called_method->GetDeclaringClass());
959 // Verify that _vRegC is an object reference and of the type expected by
960 // the receiver.
961 if (!VerifyObjectIsClass(receiver, declaring_class)) {
962 DCHECK(self->IsExceptionPending());
963 return false;
964 }
965
966 called_method = receiver->GetClass()->FindVirtualMethodForVirtualOrInterface(
967 called_method, kRuntimePointerSize);
968 }
969
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100970 PerformCall(self, code_item, shadow_frame.GetMethod(), first_dest_reg, new_shadow_frame, result);
Narayan Kamath208f8572016-08-03 12:46:58 +0100971
972 // TODO(narayan): Perform return value conversions.
973
Narayan Kamath000e1882016-10-24 17:14:25 +0100974 // If the caller of this signature polymorphic method was a transformer,
975 // we need to copy the result back out to the emulated stack frame.
976 if (is_caller_transformer && !self->IsExceptionPending()) {
977 ObjPtr<mirror::EmulatedStackFrame> emulated_stack_frame(
978 reinterpret_cast<mirror::EmulatedStackFrame*>(
979 shadow_frame.GetVRegReference(first_src_reg)));
980
981 emulated_stack_frame->SetReturnValue(self, *result);
982 }
983
Narayan Kamath208f8572016-08-03 12:46:58 +0100984 return !self->IsExceptionPending();
985}
986
Narayan Kamath000e1882016-10-24 17:14:25 +0100987template <bool is_range>
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100988static inline bool DoCallTransform(ArtMethod* called_method,
989 Handle<mirror::MethodType> callsite_type,
Narayan Kamath000e1882016-10-24 17:14:25 +0100990 Handle<mirror::MethodType> callee_type,
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100991 Thread* self,
992 ShadowFrame& shadow_frame,
993 Handle<mirror::MethodHandleImpl> receiver,
Narayan Kamath000e1882016-10-24 17:14:25 +0100994 JValue* result,
995 uint32_t (&arg)[Instruction::kMaxVarArgRegs],
996 uint32_t first_src_reg) {
997 // This can be fixed to two, because the method we're calling here
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +0100998 // (MethodHandle.transformInternal) doesn't have any locals and the signature
999 // is known :
1000 //
1001 // private MethodHandle.transformInternal(EmulatedStackFrame sf);
1002 //
1003 // This means we need only two vregs :
1004 // - One for the receiver object.
1005 // - One for the only method argument (an EmulatedStackFrame).
1006 static constexpr size_t kNumRegsForTransform = 2;
1007
1008 const DexFile::CodeItem* code_item = called_method->GetCodeItem();
1009 DCHECK(code_item != nullptr);
1010 DCHECK_EQ(kNumRegsForTransform, code_item->registers_size_);
1011 DCHECK_EQ(kNumRegsForTransform, code_item->ins_size_);
1012
1013 ShadowFrameAllocaUniquePtr shadow_frame_unique_ptr =
1014 CREATE_SHADOW_FRAME(kNumRegsForTransform, &shadow_frame, called_method, /* dex pc */ 0);
1015 ShadowFrame* new_shadow_frame = shadow_frame_unique_ptr.get();
1016
Narayan Kamath000e1882016-10-24 17:14:25 +01001017 StackHandleScope<1> hs(self);
1018 MutableHandle<mirror::EmulatedStackFrame> sf(hs.NewHandle<mirror::EmulatedStackFrame>(nullptr));
1019 if (IsCallerTransformer(callsite_type)) {
1020 // If we're entering this transformer from another transformer, we can pass
1021 // through the handle directly to the callee, instead of having to
1022 // instantiate a new stack frame based on the shadow frame.
1023 sf.Assign(reinterpret_cast<mirror::EmulatedStackFrame*>(
1024 shadow_frame.GetVRegReference(first_src_reg)));
1025 } else {
1026 sf.Assign(mirror::EmulatedStackFrame::CreateFromShadowFrameAndArgs<is_range>(
1027 self,
1028 callsite_type,
1029 callee_type,
1030 shadow_frame,
1031 first_src_reg,
1032 arg));
1033
1034 // Something went wrong while creating the emulated stack frame, we should
1035 // throw the pending exception.
1036 if (sf.Get() == nullptr) {
1037 DCHECK(self->IsExceptionPending());
1038 return false;
1039 }
1040 }
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +01001041
1042 new_shadow_frame->SetVRegReference(0, receiver.Get());
Narayan Kamath000e1882016-10-24 17:14:25 +01001043 new_shadow_frame->SetVRegReference(1, sf.Get());
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +01001044
1045 PerformCall(self,
1046 code_item,
1047 shadow_frame.GetMethod(),
1048 0 /* first dest reg */,
1049 new_shadow_frame,
1050 result);
1051
Narayan Kamath000e1882016-10-24 17:14:25 +01001052 // If the called transformer method we called has returned a value, then we
1053 // need to copy it back to |result|.
1054 if (!self->IsExceptionPending()) {
1055 sf->GetReturnValue(self, result);
1056 }
1057
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +01001058 return !self->IsExceptionPending();
1059}
1060
Igor Murashkin6918bf12015-09-27 19:19:06 -07001061template <bool is_range,
Narayan Kamath370423d2016-10-03 16:51:22 +01001062 bool do_assignability_check>
Igor Murashkin158f35c2015-06-10 15:55:30 -07001063static inline bool DoCallCommon(ArtMethod* called_method,
1064 Thread* self,
1065 ShadowFrame& shadow_frame,
1066 JValue* result,
1067 uint16_t number_of_inputs,
Narayan Kamath370423d2016-10-03 16:51:22 +01001068 uint32_t (&arg)[Instruction::kMaxVarArgRegs],
Igor Murashkin158f35c2015-06-10 15:55:30 -07001069 uint32_t vregC) {
Jeff Hao848f70a2014-01-15 13:49:50 -08001070 bool string_init = false;
1071 // Replace calls to String.<init> with equivalent StringFactory call.
Igor Murashkin158f35c2015-06-10 15:55:30 -07001072 if (UNLIKELY(called_method->GetDeclaringClass()->IsStringClass()
1073 && called_method->IsConstructor())) {
Nicolas Geoffrayda079bb2016-09-26 17:56:07 +01001074 called_method = WellKnownClasses::StringInitToStringFactory(called_method);
Jeff Hao848f70a2014-01-15 13:49:50 -08001075 string_init = true;
1076 }
1077
Alex Lightdaf58c82016-03-16 23:00:49 +00001078 // Compute method information.
1079 const DexFile::CodeItem* code_item = called_method->GetCodeItem();
Igor Murashkin158f35c2015-06-10 15:55:30 -07001080
1081 // Number of registers for the callee's call frame.
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001082 uint16_t num_regs;
Mathieu Chartier2cebb242015-04-21 16:50:40 -07001083 if (LIKELY(code_item != nullptr)) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001084 num_regs = code_item->registers_size_;
Igor Murashkin158f35c2015-06-10 15:55:30 -07001085 DCHECK_EQ(string_init ? number_of_inputs - 1 : number_of_inputs, code_item->ins_size_);
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001086 } else {
Ian Rogerse94652f2014-12-02 11:13:19 -08001087 DCHECK(called_method->IsNative() || called_method->IsProxyMethod());
Igor Murashkin158f35c2015-06-10 15:55:30 -07001088 num_regs = number_of_inputs;
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001089 }
1090
Igor Murashkin158f35c2015-06-10 15:55:30 -07001091 // Hack for String init:
1092 //
1093 // Rewrite invoke-x java.lang.String.<init>(this, a, b, c, ...) into:
1094 // invoke-x StringFactory(a, b, c, ...)
1095 // by effectively dropping the first virtual register from the invoke.
1096 //
1097 // (at this point the ArtMethod has already been replaced,
1098 // so we just need to fix-up the arguments)
David Brazdil65902e82016-01-15 09:35:13 +00001099 //
1100 // Note that FindMethodFromCode in entrypoint_utils-inl.h was also special-cased
1101 // to handle the compiler optimization of replacing `this` with null without
1102 // throwing NullPointerException.
Igor Murashkin158f35c2015-06-10 15:55:30 -07001103 uint32_t string_init_vreg_this = is_range ? vregC : arg[0];
Igor Murashkina06b49b2015-06-25 15:18:12 -07001104 if (UNLIKELY(string_init)) {
Igor Murashkin158f35c2015-06-10 15:55:30 -07001105 DCHECK_GT(num_regs, 0u); // As the method is an instance method, there should be at least 1.
Igor Murashkina06b49b2015-06-25 15:18:12 -07001106
Igor Murashkin158f35c2015-06-10 15:55:30 -07001107 // The new StringFactory call is static and has one fewer argument.
Igor Murashkina06b49b2015-06-25 15:18:12 -07001108 if (code_item == nullptr) {
1109 DCHECK(called_method->IsNative() || called_method->IsProxyMethod());
1110 num_regs--;
1111 } // else ... don't need to change num_regs since it comes up from the string_init's code item
Igor Murashkin158f35c2015-06-10 15:55:30 -07001112 number_of_inputs--;
1113
1114 // Rewrite the var-args, dropping the 0th argument ("this")
Igor Murashkin6918bf12015-09-27 19:19:06 -07001115 for (uint32_t i = 1; i < arraysize(arg); ++i) {
Igor Murashkin158f35c2015-06-10 15:55:30 -07001116 arg[i - 1] = arg[i];
1117 }
Igor Murashkin6918bf12015-09-27 19:19:06 -07001118 arg[arraysize(arg) - 1] = 0;
Igor Murashkin158f35c2015-06-10 15:55:30 -07001119
1120 // Rewrite the non-var-arg case
1121 vregC++; // Skips the 0th vreg in the range ("this").
1122 }
1123
1124 // Parameter registers go at the end of the shadow frame.
1125 DCHECK_GE(num_regs, number_of_inputs);
1126 size_t first_dest_reg = num_regs - number_of_inputs;
1127 DCHECK_NE(first_dest_reg, (size_t)-1);
1128
Sebastien Hertzc61124b2013-09-10 11:44:19 +02001129 // Allocate shadow frame on the stack.
Igor Murashkin158f35c2015-06-10 15:55:30 -07001130 const char* old_cause = self->StartAssertNoThreadSuspension("DoCallCommon");
Andreas Gampeb3025922015-09-01 14:45:00 -07001131 ShadowFrameAllocaUniquePtr shadow_frame_unique_ptr =
Andreas Gampe03ec9302015-08-27 17:41:47 -07001132 CREATE_SHADOW_FRAME(num_regs, &shadow_frame, called_method, /* dex pc */ 0);
Andreas Gampeb3025922015-09-01 14:45:00 -07001133 ShadowFrame* new_shadow_frame = shadow_frame_unique_ptr.get();
Sebastien Hertzc61124b2013-09-10 11:44:19 +02001134
Igor Murashkin158f35c2015-06-10 15:55:30 -07001135 // Initialize new shadow frame by copying the registers from the callee shadow frame.
Jeff Haoa3faaf42013-09-03 19:07:00 -07001136 if (do_assignability_check) {
Andreas Gampe2a0d4ec2014-06-02 22:05:22 -07001137 // Slow path.
1138 // We might need to do class loading, which incurs a thread state change to kNative. So
1139 // register the shadow frame as under construction and allow suspension again.
Mingyao Yang1f2d3ba2015-05-18 12:12:50 -07001140 ScopedStackedShadowFramePusher pusher(
Sebastien Hertzf7958692015-06-09 14:09:14 +02001141 self, new_shadow_frame, StackedShadowFrameType::kShadowFrameUnderConstruction);
Andreas Gampe2a0d4ec2014-06-02 22:05:22 -07001142 self->EndAssertNoThreadSuspension(old_cause);
1143
Igor Murashkin9f95ba72016-02-01 14:21:25 -08001144 // ArtMethod here is needed to check type information of the call site against the callee.
1145 // Type information is retrieved from a DexFile/DexCache for that respective declared method.
1146 //
1147 // As a special case for proxy methods, which are not dex-backed,
1148 // we have to retrieve type information from the proxy's method
1149 // interface method instead (which is dex backed since proxies are never interfaces).
Andreas Gampe542451c2016-07-26 09:02:02 -07001150 ArtMethod* method =
1151 new_shadow_frame->GetMethod()->GetInterfaceMethodIfProxy(kRuntimePointerSize);
Igor Murashkin9f95ba72016-02-01 14:21:25 -08001152
Andreas Gampe2a0d4ec2014-06-02 22:05:22 -07001153 // We need to do runtime check on reference assignment. We need to load the shorty
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001154 // to get the exact type of each reference argument.
Igor Murashkin9f95ba72016-02-01 14:21:25 -08001155 const DexFile::TypeList* params = method->GetParameterTypeList();
Mathieu Chartierbfd9a432014-05-21 17:43:44 -07001156 uint32_t shorty_len = 0;
Igor Murashkin9f95ba72016-02-01 14:21:25 -08001157 const char* shorty = method->GetShorty(&shorty_len);
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001158
Sebastien Hertz9119c5f2013-12-16 11:31:45 +01001159 // Handle receiver apart since it's not part of the shorty.
1160 size_t dest_reg = first_dest_reg;
1161 size_t arg_offset = 0;
Igor Murashkin158f35c2015-06-10 15:55:30 -07001162
Igor Murashkin9f95ba72016-02-01 14:21:25 -08001163 if (!method->IsStatic()) {
Mathieu Chartierbfd9a432014-05-21 17:43:44 -07001164 size_t receiver_reg = is_range ? vregC : arg[0];
Sebastien Hertz9119c5f2013-12-16 11:31:45 +01001165 new_shadow_frame->SetVRegReference(dest_reg, shadow_frame.GetVRegReference(receiver_reg));
1166 ++dest_reg;
1167 ++arg_offset;
Igor Murashkina06b49b2015-06-25 15:18:12 -07001168 DCHECK(!string_init); // All StringFactory methods are static.
Sebastien Hertz9119c5f2013-12-16 11:31:45 +01001169 }
Igor Murashkin158f35c2015-06-10 15:55:30 -07001170
1171 // Copy the caller's invoke-* arguments into the callee's parameter registers.
Ian Rogersef7d42f2014-01-06 12:55:46 -08001172 for (uint32_t shorty_pos = 0; dest_reg < num_regs; ++shorty_pos, ++dest_reg, ++arg_offset) {
Igor Murashkina06b49b2015-06-25 15:18:12 -07001173 // Skip the 0th 'shorty' type since it represents the return type.
1174 DCHECK_LT(shorty_pos + 1, shorty_len) << "for shorty '" << shorty << "'";
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001175 const size_t src_reg = (is_range) ? vregC + arg_offset : arg[arg_offset];
1176 switch (shorty[shorty_pos + 1]) {
Igor Murashkin158f35c2015-06-10 15:55:30 -07001177 // Handle Object references. 1 virtual register slot.
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001178 case 'L': {
Mathieu Chartieref41db72016-10-25 15:08:01 -07001179 ObjPtr<mirror::Object> o = shadow_frame.GetVRegReference(src_reg);
Mathieu Chartier2cebb242015-04-21 16:50:40 -07001180 if (do_assignability_check && o != nullptr) {
Andreas Gampe542451c2016-07-26 09:02:02 -07001181 PointerSize pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
Mathieu Chartiere22305b2016-10-26 21:04:58 -07001182 const uint32_t type_idx = params->GetTypeItem(shorty_pos).type_idx_;
1183 ObjPtr<mirror::Class> arg_type = method->GetDexCacheResolvedType(type_idx,
1184 pointer_size);
Mathieu Chartier2cebb242015-04-21 16:50:40 -07001185 if (arg_type == nullptr) {
Mathieu Chartiere22305b2016-10-26 21:04:58 -07001186 StackHandleScope<1> hs(self);
1187 // Preserve o since it is used below and GetClassFromTypeIndex may cause thread
1188 // suspension.
1189 HandleWrapperObjPtr<mirror::Object> h = hs.NewHandleWrapper(&o);
1190 arg_type = method->GetClassFromTypeIndex(type_idx, true /* resolve */, pointer_size);
1191 if (arg_type == nullptr) {
1192 CHECK(self->IsExceptionPending());
1193 return false;
1194 }
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001195 }
1196 if (!o->VerifierInstanceOf(arg_type)) {
1197 // This should never happen.
Ian Rogers1ff3c982014-08-12 02:30:58 -07001198 std::string temp1, temp2;
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +00001199 self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001200 "Invoking %s with bad arg %d, type '%s' not instance of '%s'",
Ian Rogerse94652f2014-12-02 11:13:19 -08001201 new_shadow_frame->GetMethod()->GetName(), shorty_pos,
Ian Rogers1ff3c982014-08-12 02:30:58 -07001202 o->GetClass()->GetDescriptor(&temp1),
1203 arg_type->GetDescriptor(&temp2));
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001204 return false;
1205 }
Jeff Haoa3faaf42013-09-03 19:07:00 -07001206 }
Mathieu Chartieref41db72016-10-25 15:08:01 -07001207 new_shadow_frame->SetVRegReference(dest_reg, o.Ptr());
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001208 break;
Jeff Haoa3faaf42013-09-03 19:07:00 -07001209 }
Igor Murashkin158f35c2015-06-10 15:55:30 -07001210 // Handle doubles and longs. 2 consecutive virtual register slots.
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001211 case 'J': case 'D': {
Igor Murashkin158f35c2015-06-10 15:55:30 -07001212 uint64_t wide_value =
1213 (static_cast<uint64_t>(shadow_frame.GetVReg(src_reg + 1)) << BitSizeOf<uint32_t>()) |
1214 static_cast<uint32_t>(shadow_frame.GetVReg(src_reg));
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001215 new_shadow_frame->SetVRegLong(dest_reg, wide_value);
Igor Murashkin158f35c2015-06-10 15:55:30 -07001216 // Skip the next virtual register slot since we already used it.
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001217 ++dest_reg;
1218 ++arg_offset;
1219 break;
1220 }
Igor Murashkin158f35c2015-06-10 15:55:30 -07001221 // Handle all other primitives that are always 1 virtual register slot.
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001222 default:
1223 new_shadow_frame->SetVReg(dest_reg, shadow_frame.GetVReg(src_reg));
1224 break;
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001225 }
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001226 }
1227 } else {
Sebastien Hertz9ace87b2013-09-27 11:48:09 +02001228 if (is_range) {
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +01001229 DCHECK_EQ(num_regs, first_dest_reg + number_of_inputs);
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001230 }
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +01001231
1232 CopyRegisters<is_range>(shadow_frame,
1233 new_shadow_frame,
1234 arg,
1235 vregC,
1236 first_dest_reg,
1237 number_of_inputs);
Andreas Gampe2a0d4ec2014-06-02 22:05:22 -07001238 self->EndAssertNoThreadSuspension(old_cause);
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001239 }
1240
Narayan Kamathc3b7f1a2016-10-19 11:05:04 +01001241 PerformCall(self, code_item, shadow_frame.GetMethod(), first_dest_reg, new_shadow_frame, result);
Jeff Hao848f70a2014-01-15 13:49:50 -08001242
1243 if (string_init && !self->IsExceptionPending()) {
Mingyao Yangffedec52016-05-19 10:48:40 -07001244 SetStringInitValueToAllAliases(&shadow_frame, string_init_vreg_this, *result);
Jeff Hao848f70a2014-01-15 13:49:50 -08001245 }
1246
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001247 return !self->IsExceptionPending();
1248}
1249
Igor Murashkin158f35c2015-06-10 15:55:30 -07001250template<bool is_range, bool do_assignability_check>
Igor Murashkin158f35c2015-06-10 15:55:30 -07001251bool DoCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame,
1252 const Instruction* inst, uint16_t inst_data, JValue* result) {
1253 // Argument word count.
Roland Levillain4b8f1ec2015-08-26 18:34:03 +01001254 const uint16_t number_of_inputs =
1255 (is_range) ? inst->VRegA_3rc(inst_data) : inst->VRegA_35c(inst_data);
Igor Murashkin158f35c2015-06-10 15:55:30 -07001256
1257 // TODO: find a cleaner way to separate non-range and range information without duplicating
1258 // code.
Igor Murashkin6918bf12015-09-27 19:19:06 -07001259 uint32_t arg[Instruction::kMaxVarArgRegs] = {}; // only used in invoke-XXX.
Igor Murashkin158f35c2015-06-10 15:55:30 -07001260 uint32_t vregC = 0;
1261 if (is_range) {
1262 vregC = inst->VRegC_3rc();
1263 } else {
1264 vregC = inst->VRegC_35c();
1265 inst->GetVarArgs(arg, inst_data);
1266 }
1267
1268 return DoCallCommon<is_range, do_assignability_check>(
1269 called_method, self, shadow_frame,
1270 result, number_of_inputs, arg, vregC);
1271}
1272
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001273template <bool is_range, bool do_access_check, bool transaction_active>
Mathieu Chartieref41db72016-10-25 15:08:01 -07001274bool DoFilledNewArray(const Instruction* inst,
1275 const ShadowFrame& shadow_frame,
1276 Thread* self,
1277 JValue* result) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001278 DCHECK(inst->Opcode() == Instruction::FILLED_NEW_ARRAY ||
1279 inst->Opcode() == Instruction::FILLED_NEW_ARRAY_RANGE);
1280 const int32_t length = is_range ? inst->VRegA_3rc() : inst->VRegA_35c();
1281 if (!is_range) {
1282 // Checks FILLED_NEW_ARRAY's length does not exceed 5 arguments.
1283 CHECK_LE(length, 5);
1284 }
1285 if (UNLIKELY(length < 0)) {
1286 ThrowNegativeArraySizeException(length);
1287 return false;
1288 }
1289 uint16_t type_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c();
Mathieu Chartieref41db72016-10-25 15:08:01 -07001290 ObjPtr<mirror::Class> array_class = ResolveVerifyAndClinit(type_idx,
1291 shadow_frame.GetMethod(),
1292 self,
1293 false,
1294 do_access_check);
Mathieu Chartier52ea33b2015-06-18 16:48:52 -07001295 if (UNLIKELY(array_class == nullptr)) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001296 DCHECK(self->IsExceptionPending());
1297 return false;
1298 }
Mathieu Chartier52ea33b2015-06-18 16:48:52 -07001299 CHECK(array_class->IsArrayClass());
Mathieu Chartieref41db72016-10-25 15:08:01 -07001300 ObjPtr<mirror::Class> component_class = array_class->GetComponentType();
Mathieu Chartier52ea33b2015-06-18 16:48:52 -07001301 const bool is_primitive_int_component = component_class->IsPrimitiveInt();
1302 if (UNLIKELY(component_class->IsPrimitive() && !is_primitive_int_component)) {
1303 if (component_class->IsPrimitiveLong() || component_class->IsPrimitiveDouble()) {
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001304 ThrowRuntimeException("Bad filled array request for type %s",
David Sehr709b0702016-10-13 09:12:37 -07001305 component_class->PrettyDescriptor().c_str());
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001306 } else {
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +00001307 self->ThrowNewExceptionF("Ljava/lang/InternalError;",
Brian Carlstrom4fa0bcd2013-12-10 11:24:21 -08001308 "Found type %s; filled-new-array not implemented for anything but 'int'",
David Sehr709b0702016-10-13 09:12:37 -07001309 component_class->PrettyDescriptor().c_str());
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001310 }
1311 return false;
1312 }
Mathieu Chartieref41db72016-10-25 15:08:01 -07001313 ObjPtr<mirror::Object> new_array = mirror::Array::Alloc<true>(
1314 self,
1315 array_class,
1316 length,
1317 array_class->GetComponentSizeShift(),
1318 Runtime::Current()->GetHeap()->GetCurrentAllocator());
Mathieu Chartier52ea33b2015-06-18 16:48:52 -07001319 if (UNLIKELY(new_array == nullptr)) {
1320 self->AssertPendingOOMException();
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001321 return false;
1322 }
Igor Murashkin158f35c2015-06-10 15:55:30 -07001323 uint32_t arg[Instruction::kMaxVarArgRegs]; // only used in filled-new-array.
1324 uint32_t vregC = 0; // only used in filled-new-array-range.
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001325 if (is_range) {
Sebastien Hertzabff6432014-01-27 18:01:39 +01001326 vregC = inst->VRegC_3rc();
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001327 } else {
Ian Rogers29a26482014-05-02 15:27:29 -07001328 inst->GetVarArgs(arg);
Sebastien Hertzabff6432014-01-27 18:01:39 +01001329 }
Sebastien Hertzabff6432014-01-27 18:01:39 +01001330 for (int32_t i = 0; i < length; ++i) {
1331 size_t src_reg = is_range ? vregC + i : arg[i];
1332 if (is_primitive_int_component) {
Mathieu Chartier52ea33b2015-06-18 16:48:52 -07001333 new_array->AsIntArray()->SetWithoutChecks<transaction_active>(
1334 i, shadow_frame.GetVReg(src_reg));
Sebastien Hertzabff6432014-01-27 18:01:39 +01001335 } else {
Mathieu Chartieref41db72016-10-25 15:08:01 -07001336 new_array->AsObjectArray<mirror::Object>()->SetWithoutChecks<transaction_active>(
Mathieu Chartier52ea33b2015-06-18 16:48:52 -07001337 i, shadow_frame.GetVRegReference(src_reg));
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001338 }
1339 }
1340
Mathieu Chartier52ea33b2015-06-18 16:48:52 -07001341 result->SetL(new_array);
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001342 return true;
1343}
1344
Mathieu Chartieref41db72016-10-25 15:08:01 -07001345// TODO: Use ObjPtr here.
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001346template<typename T>
Mathieu Chartieref41db72016-10-25 15:08:01 -07001347static void RecordArrayElementsInTransactionImpl(mirror::PrimitiveArray<T>* array,
1348 int32_t count)
1349 REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001350 Runtime* runtime = Runtime::Current();
1351 for (int32_t i = 0; i < count; ++i) {
1352 runtime->RecordWriteArray(array, i, array->GetWithoutChecks(i));
1353 }
1354}
1355
Mathieu Chartieref41db72016-10-25 15:08:01 -07001356void RecordArrayElementsInTransaction(ObjPtr<mirror::Array> array, int32_t count)
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001357 REQUIRES_SHARED(Locks::mutator_lock_) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001358 DCHECK(Runtime::Current()->IsActiveTransaction());
1359 DCHECK(array != nullptr);
1360 DCHECK_LE(count, array->GetLength());
1361 Primitive::Type primitive_component_type = array->GetClass()->GetComponentType()->GetPrimitiveType();
1362 switch (primitive_component_type) {
1363 case Primitive::kPrimBoolean:
1364 RecordArrayElementsInTransactionImpl(array->AsBooleanArray(), count);
1365 break;
1366 case Primitive::kPrimByte:
1367 RecordArrayElementsInTransactionImpl(array->AsByteArray(), count);
1368 break;
1369 case Primitive::kPrimChar:
1370 RecordArrayElementsInTransactionImpl(array->AsCharArray(), count);
1371 break;
1372 case Primitive::kPrimShort:
1373 RecordArrayElementsInTransactionImpl(array->AsShortArray(), count);
1374 break;
1375 case Primitive::kPrimInt:
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001376 RecordArrayElementsInTransactionImpl(array->AsIntArray(), count);
1377 break;
Mathieu Chartiere401d142015-04-22 13:56:20 -07001378 case Primitive::kPrimFloat:
1379 RecordArrayElementsInTransactionImpl(array->AsFloatArray(), count);
1380 break;
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001381 case Primitive::kPrimLong:
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001382 RecordArrayElementsInTransactionImpl(array->AsLongArray(), count);
1383 break;
Mathieu Chartiere401d142015-04-22 13:56:20 -07001384 case Primitive::kPrimDouble:
1385 RecordArrayElementsInTransactionImpl(array->AsDoubleArray(), count);
1386 break;
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001387 default:
1388 LOG(FATAL) << "Unsupported primitive type " << primitive_component_type
1389 << " in fill-array-data";
1390 break;
1391 }
1392}
1393
Sebastien Hertzc61124b2013-09-10 11:44:19 +02001394// Explicit DoCall template function declarations.
Sebastien Hertzc6714852013-09-30 16:42:32 +02001395#define EXPLICIT_DO_CALL_TEMPLATE_DECL(_is_range, _do_assignability_check) \
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001396 template REQUIRES_SHARED(Locks::mutator_lock_) \
Sebastien Hertz9119c5f2013-12-16 11:31:45 +01001397 bool DoCall<_is_range, _do_assignability_check>(ArtMethod* method, Thread* self, \
1398 ShadowFrame& shadow_frame, \
Sebastien Hertzc6714852013-09-30 16:42:32 +02001399 const Instruction* inst, uint16_t inst_data, \
1400 JValue* result)
Sebastien Hertzc61124b2013-09-10 11:44:19 +02001401EXPLICIT_DO_CALL_TEMPLATE_DECL(false, false);
1402EXPLICIT_DO_CALL_TEMPLATE_DECL(false, true);
1403EXPLICIT_DO_CALL_TEMPLATE_DECL(true, false);
1404EXPLICIT_DO_CALL_TEMPLATE_DECL(true, true);
1405#undef EXPLICIT_DO_CALL_TEMPLATE_DECL
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001406
Narayan Kamath9823e782016-08-03 12:46:58 +01001407// Explicit DoInvokePolymorphic template function declarations.
1408#define EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(_is_range, _do_assignability_check) \
1409 template REQUIRES_SHARED(Locks::mutator_lock_) \
1410 bool DoInvokePolymorphic<_is_range, _do_assignability_check>( \
1411 Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, \
1412 uint16_t inst_data, JValue* result)
1413
1414EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(false, false);
1415EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(false, true);
1416EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(true, false);
1417EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(true, true);
1418#undef EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL
1419
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001420// Explicit DoFilledNewArray template function declarations.
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001421#define EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(_is_range_, _check, _transaction_active) \
Andreas Gampebdf7f1c2016-08-30 16:38:47 -07001422 template REQUIRES_SHARED(Locks::mutator_lock_) \
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +01001423 bool DoFilledNewArray<_is_range_, _check, _transaction_active>(const Instruction* inst, \
1424 const ShadowFrame& shadow_frame, \
1425 Thread* self, JValue* result)
1426#define EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(_transaction_active) \
1427 EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, false, _transaction_active); \
1428 EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, true, _transaction_active); \
1429 EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, false, _transaction_active); \
1430 EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, true, _transaction_active)
1431EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(false);
1432EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(true);
1433#undef EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL
Sebastien Hertz8ece0502013-08-07 11:26:41 +02001434#undef EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL
1435
1436} // namespace interpreter
1437} // namespace art