interpreter_common.cc revision 8ca33bf04060fadd5b35fa93fa56547c62fe52e7
1/*
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"
18
19#include <cmath>
20
21#include "debugger.h"
22#include "entrypoints/runtime_asm_entrypoints.h"
23#include "jit/jit.h"
24#include "mirror/array-inl.h"
25#include "stack.h"
26#include "unstarted_runtime.h"
27#include "verifier/method_verifier.h"
28
29namespace art {
30namespace interpreter {
31
32// All lambda closures have to be a consecutive pair of virtual registers.
33static constexpr size_t kLambdaVirtualRegisterWidth = 2;
34
35void ThrowNullPointerExceptionFromInterpreter() {
36  ThrowNullPointerExceptionFromDexPC();
37}
38
39template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check>
40bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst,
41                uint16_t inst_data) {
42  const bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead);
43  const uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c();
44  ArtField* f =
45      FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self,
46                                                    Primitive::ComponentSize(field_type));
47  if (UNLIKELY(f == nullptr)) {
48    CHECK(self->IsExceptionPending());
49    return false;
50  }
51  Object* obj;
52  if (is_static) {
53    obj = f->GetDeclaringClass();
54  } else {
55    obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
56    if (UNLIKELY(obj == nullptr)) {
57      ThrowNullPointerExceptionForFieldAccess(f, true);
58      return false;
59    }
60  }
61  f->GetDeclaringClass()->AssertInitializedOrInitializingInThread(self);
62  // Report this field access to instrumentation if needed.
63  instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
64  if (UNLIKELY(instrumentation->HasFieldReadListeners())) {
65    Object* this_object = f->IsStatic() ? nullptr : obj;
66    instrumentation->FieldReadEvent(self, this_object, shadow_frame.GetMethod(),
67                                    shadow_frame.GetDexPC(), f);
68  }
69  uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data);
70  switch (field_type) {
71    case Primitive::kPrimBoolean:
72      shadow_frame.SetVReg(vregA, f->GetBoolean(obj));
73      break;
74    case Primitive::kPrimByte:
75      shadow_frame.SetVReg(vregA, f->GetByte(obj));
76      break;
77    case Primitive::kPrimChar:
78      shadow_frame.SetVReg(vregA, f->GetChar(obj));
79      break;
80    case Primitive::kPrimShort:
81      shadow_frame.SetVReg(vregA, f->GetShort(obj));
82      break;
83    case Primitive::kPrimInt:
84      shadow_frame.SetVReg(vregA, f->GetInt(obj));
85      break;
86    case Primitive::kPrimLong:
87      shadow_frame.SetVRegLong(vregA, f->GetLong(obj));
88      break;
89    case Primitive::kPrimNot:
90      shadow_frame.SetVRegReference(vregA, f->GetObject(obj));
91      break;
92    default:
93      LOG(FATAL) << "Unreachable: " << field_type;
94      UNREACHABLE();
95  }
96  return true;
97}
98
99// Explicitly instantiate all DoFieldGet functions.
100#define EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, _do_check) \
101  template bool DoFieldGet<_find_type, _field_type, _do_check>(Thread* self, \
102                                                               ShadowFrame& shadow_frame, \
103                                                               const Instruction* inst, \
104                                                               uint16_t inst_data)
105
106#define EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(_find_type, _field_type)  \
107    EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, false);  \
108    EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, true);
109
110// iget-XXX
111EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimBoolean)
112EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimByte)
113EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimChar)
114EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimShort)
115EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimInt)
116EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimLong)
117EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstanceObjectRead, Primitive::kPrimNot)
118
119// sget-XXX
120EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimBoolean)
121EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimByte)
122EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimChar)
123EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimShort)
124EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimInt)
125EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimLong)
126EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticObjectRead, Primitive::kPrimNot)
127
128#undef EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL
129#undef EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL
130
131// Handles iget-quick, iget-wide-quick and iget-object-quick instructions.
132// Returns true on success, otherwise throws an exception and returns false.
133template<Primitive::Type field_type>
134bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) {
135  Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
136  if (UNLIKELY(obj == nullptr)) {
137    // We lost the reference to the field index so we cannot get a more
138    // precised exception message.
139    ThrowNullPointerExceptionFromDexPC();
140    return false;
141  }
142  MemberOffset field_offset(inst->VRegC_22c());
143  // Report this field access to instrumentation if needed. Since we only have the offset of
144  // the field from the base of the object, we need to look for it first.
145  instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
146  if (UNLIKELY(instrumentation->HasFieldReadListeners())) {
147    ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(),
148                                                        field_offset.Uint32Value());
149    DCHECK(f != nullptr);
150    DCHECK(!f->IsStatic());
151    instrumentation->FieldReadEvent(Thread::Current(), obj, shadow_frame.GetMethod(),
152                                    shadow_frame.GetDexPC(), f);
153  }
154  // Note: iget-x-quick instructions are only for non-volatile fields.
155  const uint32_t vregA = inst->VRegA_22c(inst_data);
156  switch (field_type) {
157    case Primitive::kPrimInt:
158      shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetField32(field_offset)));
159      break;
160    case Primitive::kPrimBoolean:
161      shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldBoolean(field_offset)));
162      break;
163    case Primitive::kPrimByte:
164      shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldByte(field_offset)));
165      break;
166    case Primitive::kPrimChar:
167      shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldChar(field_offset)));
168      break;
169    case Primitive::kPrimShort:
170      shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldShort(field_offset)));
171      break;
172    case Primitive::kPrimLong:
173      shadow_frame.SetVRegLong(vregA, static_cast<int64_t>(obj->GetField64(field_offset)));
174      break;
175    case Primitive::kPrimNot:
176      shadow_frame.SetVRegReference(vregA, obj->GetFieldObject<mirror::Object>(field_offset));
177      break;
178    default:
179      LOG(FATAL) << "Unreachable: " << field_type;
180      UNREACHABLE();
181  }
182  return true;
183}
184
185// Explicitly instantiate all DoIGetQuick functions.
186#define EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(_field_type) \
187  template bool DoIGetQuick<_field_type>(ShadowFrame& shadow_frame, const Instruction* inst, \
188                                         uint16_t inst_data)
189
190EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimInt);      // iget-quick.
191EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimBoolean);  // iget-boolean-quick.
192EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimByte);     // iget-byte-quick.
193EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimChar);     // iget-char-quick.
194EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimShort);    // iget-short-quick.
195EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimLong);     // iget-wide-quick.
196EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimNot);      // iget-object-quick.
197#undef EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL
198
199template<Primitive::Type field_type>
200static JValue GetFieldValue(const ShadowFrame& shadow_frame, uint32_t vreg)
201    SHARED_REQUIRES(Locks::mutator_lock_) {
202  JValue field_value;
203  switch (field_type) {
204    case Primitive::kPrimBoolean:
205      field_value.SetZ(static_cast<uint8_t>(shadow_frame.GetVReg(vreg)));
206      break;
207    case Primitive::kPrimByte:
208      field_value.SetB(static_cast<int8_t>(shadow_frame.GetVReg(vreg)));
209      break;
210    case Primitive::kPrimChar:
211      field_value.SetC(static_cast<uint16_t>(shadow_frame.GetVReg(vreg)));
212      break;
213    case Primitive::kPrimShort:
214      field_value.SetS(static_cast<int16_t>(shadow_frame.GetVReg(vreg)));
215      break;
216    case Primitive::kPrimInt:
217      field_value.SetI(shadow_frame.GetVReg(vreg));
218      break;
219    case Primitive::kPrimLong:
220      field_value.SetJ(shadow_frame.GetVRegLong(vreg));
221      break;
222    case Primitive::kPrimNot:
223      field_value.SetL(shadow_frame.GetVRegReference(vreg));
224      break;
225    default:
226      LOG(FATAL) << "Unreachable: " << field_type;
227      UNREACHABLE();
228  }
229  return field_value;
230}
231
232template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check,
233         bool transaction_active>
234bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst,
235                uint16_t inst_data) {
236  bool do_assignability_check = do_access_check;
237  bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite);
238  uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c();
239  ArtField* f =
240      FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self,
241                                                    Primitive::ComponentSize(field_type));
242  if (UNLIKELY(f == nullptr)) {
243    CHECK(self->IsExceptionPending());
244    return false;
245  }
246  Object* obj;
247  if (is_static) {
248    obj = f->GetDeclaringClass();
249  } else {
250    obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
251    if (UNLIKELY(obj == nullptr)) {
252      ThrowNullPointerExceptionForFieldAccess(f, false);
253      return false;
254    }
255  }
256  f->GetDeclaringClass()->AssertInitializedOrInitializingInThread(self);
257  uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data);
258  // Report this field access to instrumentation if needed. Since we only have the offset of
259  // the field from the base of the object, we need to look for it first.
260  instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
261  if (UNLIKELY(instrumentation->HasFieldWriteListeners())) {
262    JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA);
263    Object* this_object = f->IsStatic() ? nullptr : obj;
264    instrumentation->FieldWriteEvent(self, this_object, shadow_frame.GetMethod(),
265                                     shadow_frame.GetDexPC(), f, field_value);
266  }
267  switch (field_type) {
268    case Primitive::kPrimBoolean:
269      f->SetBoolean<transaction_active>(obj, shadow_frame.GetVReg(vregA));
270      break;
271    case Primitive::kPrimByte:
272      f->SetByte<transaction_active>(obj, shadow_frame.GetVReg(vregA));
273      break;
274    case Primitive::kPrimChar:
275      f->SetChar<transaction_active>(obj, shadow_frame.GetVReg(vregA));
276      break;
277    case Primitive::kPrimShort:
278      f->SetShort<transaction_active>(obj, shadow_frame.GetVReg(vregA));
279      break;
280    case Primitive::kPrimInt:
281      f->SetInt<transaction_active>(obj, shadow_frame.GetVReg(vregA));
282      break;
283    case Primitive::kPrimLong:
284      f->SetLong<transaction_active>(obj, shadow_frame.GetVRegLong(vregA));
285      break;
286    case Primitive::kPrimNot: {
287      Object* reg = shadow_frame.GetVRegReference(vregA);
288      if (do_assignability_check && reg != nullptr) {
289        // FieldHelper::GetType can resolve classes, use a handle wrapper which will restore the
290        // object in the destructor.
291        Class* field_class;
292        {
293          StackHandleScope<2> hs(self);
294          HandleWrapper<mirror::Object> h_reg(hs.NewHandleWrapper(&reg));
295          HandleWrapper<mirror::Object> h_obj(hs.NewHandleWrapper(&obj));
296          field_class = f->GetType<true>();
297        }
298        if (!reg->VerifierInstanceOf(field_class)) {
299          // This should never happen.
300          std::string temp1, temp2, temp3;
301          self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
302                                   "Put '%s' that is not instance of field '%s' in '%s'",
303                                   reg->GetClass()->GetDescriptor(&temp1),
304                                   field_class->GetDescriptor(&temp2),
305                                   f->GetDeclaringClass()->GetDescriptor(&temp3));
306          return false;
307        }
308      }
309      f->SetObj<transaction_active>(obj, reg);
310      break;
311    }
312    default:
313      LOG(FATAL) << "Unreachable: " << field_type;
314      UNREACHABLE();
315  }
316  return true;
317}
318
319// Explicitly instantiate all DoFieldPut functions.
320#define EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, _do_check, _transaction_active) \
321  template bool DoFieldPut<_find_type, _field_type, _do_check, _transaction_active>(Thread* self, \
322      const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data)
323
324#define EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(_find_type, _field_type)  \
325    EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, false);  \
326    EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, false);  \
327    EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, true);  \
328    EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, true);
329
330// iput-XXX
331EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimBoolean)
332EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimByte)
333EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimChar)
334EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimShort)
335EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimInt)
336EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimLong)
337EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstanceObjectWrite, Primitive::kPrimNot)
338
339// sput-XXX
340EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimBoolean)
341EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimByte)
342EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimChar)
343EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimShort)
344EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimInt)
345EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimLong)
346EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticObjectWrite, Primitive::kPrimNot)
347
348#undef EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL
349#undef EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL
350
351template<Primitive::Type field_type, bool transaction_active>
352bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) {
353  Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data));
354  if (UNLIKELY(obj == nullptr)) {
355    // We lost the reference to the field index so we cannot get a more
356    // precised exception message.
357    ThrowNullPointerExceptionFromDexPC();
358    return false;
359  }
360  MemberOffset field_offset(inst->VRegC_22c());
361  const uint32_t vregA = inst->VRegA_22c(inst_data);
362  // Report this field modification to instrumentation if needed. Since we only have the offset of
363  // the field from the base of the object, we need to look for it first.
364  instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
365  if (UNLIKELY(instrumentation->HasFieldWriteListeners())) {
366    ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(),
367                                                        field_offset.Uint32Value());
368    DCHECK(f != nullptr);
369    DCHECK(!f->IsStatic());
370    JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA);
371    instrumentation->FieldWriteEvent(Thread::Current(), obj, shadow_frame.GetMethod(),
372                                     shadow_frame.GetDexPC(), f, field_value);
373  }
374  // Note: iput-x-quick instructions are only for non-volatile fields.
375  switch (field_type) {
376    case Primitive::kPrimBoolean:
377      obj->SetFieldBoolean<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
378      break;
379    case Primitive::kPrimByte:
380      obj->SetFieldByte<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
381      break;
382    case Primitive::kPrimChar:
383      obj->SetFieldChar<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
384      break;
385    case Primitive::kPrimShort:
386      obj->SetFieldShort<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
387      break;
388    case Primitive::kPrimInt:
389      obj->SetField32<transaction_active>(field_offset, shadow_frame.GetVReg(vregA));
390      break;
391    case Primitive::kPrimLong:
392      obj->SetField64<transaction_active>(field_offset, shadow_frame.GetVRegLong(vregA));
393      break;
394    case Primitive::kPrimNot:
395      obj->SetFieldObject<transaction_active>(field_offset, shadow_frame.GetVRegReference(vregA));
396      break;
397    default:
398      LOG(FATAL) << "Unreachable: " << field_type;
399      UNREACHABLE();
400  }
401  return true;
402}
403
404// Explicitly instantiate all DoIPutQuick functions.
405#define EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, _transaction_active) \
406  template bool DoIPutQuick<_field_type, _transaction_active>(const ShadowFrame& shadow_frame, \
407                                                              const Instruction* inst, \
408                                                              uint16_t inst_data)
409
410#define EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(_field_type)   \
411  EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, false);     \
412  EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, true);
413
414EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimInt)      // iput-quick.
415EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimBoolean)  // iput-boolean-quick.
416EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimByte)     // iput-byte-quick.
417EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimChar)     // iput-char-quick.
418EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimShort)    // iput-short-quick.
419EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimLong)     // iput-wide-quick.
420EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimNot)      // iput-object-quick.
421#undef EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL
422#undef EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL
423
424// We accept a null Instrumentation* meaning we must not report anything to the instrumentation.
425uint32_t FindNextInstructionFollowingException(
426    Thread* self, ShadowFrame& shadow_frame, uint32_t dex_pc,
427    const instrumentation::Instrumentation* instrumentation) {
428  self->VerifyStack();
429  StackHandleScope<2> hs(self);
430  Handle<mirror::Throwable> exception(hs.NewHandle(self->GetException()));
431  if (instrumentation != nullptr && instrumentation->HasExceptionCaughtListeners()
432      && self->IsExceptionThrownByCurrentMethod(exception.Get())) {
433    instrumentation->ExceptionCaughtEvent(self, exception.Get());
434  }
435  bool clear_exception = false;
436  uint32_t found_dex_pc = shadow_frame.GetMethod()->FindCatchBlock(
437      hs.NewHandle(exception->GetClass()), dex_pc, &clear_exception);
438  if (found_dex_pc == DexFile::kDexNoIndex && instrumentation != nullptr) {
439    // Exception is not caught by the current method. We will unwind to the
440    // caller. Notify any instrumentation listener.
441    instrumentation->MethodUnwindEvent(self, shadow_frame.GetThisObject(),
442                                       shadow_frame.GetMethod(), dex_pc);
443  } else {
444    // Exception is caught in the current method. We will jump to the found_dex_pc.
445    if (clear_exception) {
446      self->ClearException();
447    }
448  }
449  return found_dex_pc;
450}
451
452void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame) {
453  LOG(FATAL) << "Unexpected instruction: "
454             << inst->DumpString(shadow_frame.GetMethod()->GetDexFile());
455  UNREACHABLE();
456}
457
458// Assign register 'src_reg' from shadow_frame to register 'dest_reg' into new_shadow_frame.
459static inline void AssignRegister(ShadowFrame* new_shadow_frame, const ShadowFrame& shadow_frame,
460                                  size_t dest_reg, size_t src_reg)
461    SHARED_REQUIRES(Locks::mutator_lock_) {
462  // Uint required, so that sign extension does not make this wrong on 64b systems
463  uint32_t src_value = shadow_frame.GetVReg(src_reg);
464  mirror::Object* o = shadow_frame.GetVRegReference<kVerifyNone>(src_reg);
465
466  // If both register locations contains the same value, the register probably holds a reference.
467  // Note: As an optimization, non-moving collectors leave a stale reference value
468  // in the references array even after the original vreg was overwritten to a non-reference.
469  if (src_value == reinterpret_cast<uintptr_t>(o)) {
470    new_shadow_frame->SetVRegReference(dest_reg, o);
471  } else {
472    new_shadow_frame->SetVReg(dest_reg, src_value);
473  }
474}
475
476void AbortTransactionF(Thread* self, const char* fmt, ...) {
477  va_list args;
478  va_start(args, fmt);
479  AbortTransactionV(self, fmt, args);
480  va_end(args);
481}
482
483void AbortTransactionV(Thread* self, const char* fmt, va_list args) {
484  CHECK(Runtime::Current()->IsActiveTransaction());
485  // Constructs abort message.
486  std::string abort_msg;
487  StringAppendV(&abort_msg, fmt, args);
488  // Throws an exception so we can abort the transaction and rollback every change.
489  Runtime::Current()->AbortTransactionAndThrowAbortError(self, abort_msg);
490}
491
492// Separate declaration is required solely for the attributes.
493template <bool is_range,
494          bool do_assignability_check,
495          size_t kVarArgMax>
496    SHARED_REQUIRES(Locks::mutator_lock_)
497static inline bool DoCallCommon(ArtMethod* called_method,
498                                Thread* self,
499                                ShadowFrame& shadow_frame,
500                                JValue* result,
501                                uint16_t number_of_inputs,
502                                uint32_t (&arg)[kVarArgMax],
503                                uint32_t vregC) ALWAYS_INLINE;
504
505void ArtInterpreterToCompiledCodeBridge(Thread* self,
506                                        ArtMethod* caller,
507                                        const DexFile::CodeItem* code_item,
508                                        ShadowFrame* shadow_frame,
509                                        JValue* result)
510    SHARED_REQUIRES(Locks::mutator_lock_) {
511  ArtMethod* method = shadow_frame->GetMethod();
512  // Ensure static methods are initialized.
513  if (method->IsStatic()) {
514    mirror::Class* declaringClass = method->GetDeclaringClass();
515    if (UNLIKELY(!declaringClass->IsInitialized())) {
516      self->PushShadowFrame(shadow_frame);
517      StackHandleScope<1> hs(self);
518      Handle<mirror::Class> h_class(hs.NewHandle(declaringClass));
519      if (UNLIKELY(!Runtime::Current()->GetClassLinker()->EnsureInitialized(self, h_class, true,
520                                                                            true))) {
521        self->PopShadowFrame();
522        DCHECK(self->IsExceptionPending());
523        return;
524      }
525      self->PopShadowFrame();
526      CHECK(h_class->IsInitializing());
527      // Reload from shadow frame in case the method moved, this is faster than adding a handle.
528      method = shadow_frame->GetMethod();
529    }
530  }
531  uint16_t arg_offset = (code_item == nullptr)
532                            ? 0
533                            : code_item->registers_size_ - code_item->ins_size_;
534  jit::Jit* jit = Runtime::Current()->GetJit();
535  if (jit != nullptr && caller != nullptr) {
536    jit->NotifyInterpreterToCompiledCodeTransition(self, caller);
537  }
538  method->Invoke(self, shadow_frame->GetVRegArgs(arg_offset),
539                 (shadow_frame->NumberOfVRegs() - arg_offset) * sizeof(uint32_t),
540                 result, method->GetInterfaceMethodIfProxy(sizeof(void*))->GetShorty());
541}
542
543void SetStringInitValueToAllAliases(ShadowFrame* shadow_frame,
544                                    uint16_t this_obj_vreg,
545                                    JValue result)
546    SHARED_REQUIRES(Locks::mutator_lock_) {
547  Object* existing = shadow_frame->GetVRegReference(this_obj_vreg);
548  if (existing == nullptr) {
549    // If it's null, we come from compiled code that was deoptimized. Nothing to do,
550    // as the compiler verified there was no alias.
551    // Set the new string result of the StringFactory.
552    shadow_frame->SetVRegReference(this_obj_vreg, result.GetL());
553    return;
554  }
555  // Set the string init result into all aliases.
556  for (uint32_t i = 0, e = shadow_frame->NumberOfVRegs(); i < e; ++i) {
557    if (shadow_frame->GetVRegReference(i) == existing) {
558      DCHECK_EQ(shadow_frame->GetVRegReference(i),
559                reinterpret_cast<mirror::Object*>(shadow_frame->GetVReg(i)));
560      shadow_frame->SetVRegReference(i, result.GetL());
561      DCHECK_EQ(shadow_frame->GetVRegReference(i),
562                reinterpret_cast<mirror::Object*>(shadow_frame->GetVReg(i)));
563    }
564  }
565}
566
567template <bool is_range,
568          bool do_assignability_check,
569          size_t kVarArgMax>
570static inline bool DoCallCommon(ArtMethod* called_method,
571                                Thread* self,
572                                ShadowFrame& shadow_frame,
573                                JValue* result,
574                                uint16_t number_of_inputs,
575                                uint32_t (&arg)[kVarArgMax],
576                                uint32_t vregC) {
577  bool string_init = false;
578  // Replace calls to String.<init> with equivalent StringFactory call.
579  if (UNLIKELY(called_method->GetDeclaringClass()->IsStringClass()
580               && called_method->IsConstructor())) {
581    ScopedObjectAccessUnchecked soa(self);
582    jmethodID mid = soa.EncodeMethod(called_method);
583    called_method = soa.DecodeMethod(WellKnownClasses::StringInitToStringFactoryMethodID(mid));
584    string_init = true;
585  }
586
587  // Compute method information.
588  const DexFile::CodeItem* code_item = called_method->GetCodeItem();
589
590  // Number of registers for the callee's call frame.
591  uint16_t num_regs;
592  if (LIKELY(code_item != nullptr)) {
593    num_regs = code_item->registers_size_;
594    DCHECK_EQ(string_init ? number_of_inputs - 1 : number_of_inputs, code_item->ins_size_);
595  } else {
596    DCHECK(called_method->IsNative() || called_method->IsProxyMethod());
597    num_regs = number_of_inputs;
598  }
599
600  // Hack for String init:
601  //
602  // Rewrite invoke-x java.lang.String.<init>(this, a, b, c, ...) into:
603  //         invoke-x StringFactory(a, b, c, ...)
604  // by effectively dropping the first virtual register from the invoke.
605  //
606  // (at this point the ArtMethod has already been replaced,
607  // so we just need to fix-up the arguments)
608  //
609  // Note that FindMethodFromCode in entrypoint_utils-inl.h was also special-cased
610  // to handle the compiler optimization of replacing `this` with null without
611  // throwing NullPointerException.
612  uint32_t string_init_vreg_this = is_range ? vregC : arg[0];
613  if (UNLIKELY(string_init)) {
614    DCHECK_GT(num_regs, 0u);  // As the method is an instance method, there should be at least 1.
615
616    // The new StringFactory call is static and has one fewer argument.
617    if (code_item == nullptr) {
618      DCHECK(called_method->IsNative() || called_method->IsProxyMethod());
619      num_regs--;
620    }  // else ... don't need to change num_regs since it comes up from the string_init's code item
621    number_of_inputs--;
622
623    // Rewrite the var-args, dropping the 0th argument ("this")
624    for (uint32_t i = 1; i < arraysize(arg); ++i) {
625      arg[i - 1] = arg[i];
626    }
627    arg[arraysize(arg) - 1] = 0;
628
629    // Rewrite the non-var-arg case
630    vregC++;  // Skips the 0th vreg in the range ("this").
631  }
632
633  // Parameter registers go at the end of the shadow frame.
634  DCHECK_GE(num_regs, number_of_inputs);
635  size_t first_dest_reg = num_regs - number_of_inputs;
636  DCHECK_NE(first_dest_reg, (size_t)-1);
637
638  // Allocate shadow frame on the stack.
639  const char* old_cause = self->StartAssertNoThreadSuspension("DoCallCommon");
640  ShadowFrameAllocaUniquePtr shadow_frame_unique_ptr =
641      CREATE_SHADOW_FRAME(num_regs, &shadow_frame, called_method, /* dex pc */ 0);
642  ShadowFrame* new_shadow_frame = shadow_frame_unique_ptr.get();
643
644  // Initialize new shadow frame by copying the registers from the callee shadow frame.
645  if (do_assignability_check) {
646    // Slow path.
647    // We might need to do class loading, which incurs a thread state change to kNative. So
648    // register the shadow frame as under construction and allow suspension again.
649    ScopedStackedShadowFramePusher pusher(
650        self, new_shadow_frame, StackedShadowFrameType::kShadowFrameUnderConstruction);
651    self->EndAssertNoThreadSuspension(old_cause);
652
653    // ArtMethod here is needed to check type information of the call site against the callee.
654    // Type information is retrieved from a DexFile/DexCache for that respective declared method.
655    //
656    // As a special case for proxy methods, which are not dex-backed,
657    // we have to retrieve type information from the proxy's method
658    // interface method instead (which is dex backed since proxies are never interfaces).
659    ArtMethod* method = new_shadow_frame->GetMethod()->GetInterfaceMethodIfProxy(sizeof(void*));
660
661    // We need to do runtime check on reference assignment. We need to load the shorty
662    // to get the exact type of each reference argument.
663    const DexFile::TypeList* params = method->GetParameterTypeList();
664    uint32_t shorty_len = 0;
665    const char* shorty = method->GetShorty(&shorty_len);
666
667    // Handle receiver apart since it's not part of the shorty.
668    size_t dest_reg = first_dest_reg;
669    size_t arg_offset = 0;
670
671    if (!method->IsStatic()) {
672      size_t receiver_reg = is_range ? vregC : arg[0];
673      new_shadow_frame->SetVRegReference(dest_reg, shadow_frame.GetVRegReference(receiver_reg));
674      ++dest_reg;
675      ++arg_offset;
676      DCHECK(!string_init);  // All StringFactory methods are static.
677    }
678
679    // Copy the caller's invoke-* arguments into the callee's parameter registers.
680    for (uint32_t shorty_pos = 0; dest_reg < num_regs; ++shorty_pos, ++dest_reg, ++arg_offset) {
681      // Skip the 0th 'shorty' type since it represents the return type.
682      DCHECK_LT(shorty_pos + 1, shorty_len) << "for shorty '" << shorty << "'";
683      const size_t src_reg = (is_range) ? vregC + arg_offset : arg[arg_offset];
684      switch (shorty[shorty_pos + 1]) {
685        // Handle Object references. 1 virtual register slot.
686        case 'L': {
687          Object* o = shadow_frame.GetVRegReference(src_reg);
688          if (do_assignability_check && o != nullptr) {
689            size_t pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
690            Class* arg_type =
691                method->GetClassFromTypeIndex(
692                    params->GetTypeItem(shorty_pos).type_idx_, true /* resolve */, pointer_size);
693            if (arg_type == nullptr) {
694              CHECK(self->IsExceptionPending());
695              return false;
696            }
697            if (!o->VerifierInstanceOf(arg_type)) {
698              // This should never happen.
699              std::string temp1, temp2;
700              self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;",
701                                       "Invoking %s with bad arg %d, type '%s' not instance of '%s'",
702                                       new_shadow_frame->GetMethod()->GetName(), shorty_pos,
703                                       o->GetClass()->GetDescriptor(&temp1),
704                                       arg_type->GetDescriptor(&temp2));
705              return false;
706            }
707          }
708          new_shadow_frame->SetVRegReference(dest_reg, o);
709          break;
710        }
711        // Handle doubles and longs. 2 consecutive virtual register slots.
712        case 'J': case 'D': {
713          uint64_t wide_value =
714              (static_cast<uint64_t>(shadow_frame.GetVReg(src_reg + 1)) << BitSizeOf<uint32_t>()) |
715               static_cast<uint32_t>(shadow_frame.GetVReg(src_reg));
716          new_shadow_frame->SetVRegLong(dest_reg, wide_value);
717          // Skip the next virtual register slot since we already used it.
718          ++dest_reg;
719          ++arg_offset;
720          break;
721        }
722        // Handle all other primitives that are always 1 virtual register slot.
723        default:
724          new_shadow_frame->SetVReg(dest_reg, shadow_frame.GetVReg(src_reg));
725          break;
726      }
727    }
728  } else {
729    size_t arg_index = 0;
730
731    // Fast path: no extra checks.
732    if (is_range) {
733      // TODO: Implement the range version of invoke-lambda
734      uint16_t first_src_reg = vregC;
735
736      for (size_t src_reg = first_src_reg, dest_reg = first_dest_reg; dest_reg < num_regs;
737          ++dest_reg, ++src_reg) {
738        AssignRegister(new_shadow_frame, shadow_frame, dest_reg, src_reg);
739      }
740    } else {
741      DCHECK_LE(number_of_inputs, arraysize(arg));
742
743      for (; arg_index < number_of_inputs; ++arg_index) {
744        AssignRegister(new_shadow_frame, shadow_frame, first_dest_reg + arg_index, arg[arg_index]);
745      }
746    }
747    self->EndAssertNoThreadSuspension(old_cause);
748  }
749
750  // Do the call now.
751  if (LIKELY(Runtime::Current()->IsStarted())) {
752    ArtMethod* target = new_shadow_frame->GetMethod();
753    if (ClassLinker::ShouldUseInterpreterEntrypoint(
754        target,
755        target->GetEntryPointFromQuickCompiledCode())) {
756      ArtInterpreterToInterpreterBridge(self, code_item, new_shadow_frame, result);
757    } else {
758      ArtInterpreterToCompiledCodeBridge(
759          self, shadow_frame.GetMethod(), code_item, new_shadow_frame, result);
760    }
761  } else {
762    UnstartedRuntime::Invoke(self, code_item, new_shadow_frame, result, first_dest_reg);
763  }
764
765  if (string_init && !self->IsExceptionPending()) {
766    SetStringInitValueToAllAliases(&shadow_frame, string_init_vreg_this, *result);
767  }
768
769  return !self->IsExceptionPending();
770}
771
772template<bool is_range, bool do_assignability_check>
773bool DoLambdaCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame,
774                  const Instruction* inst, uint16_t inst_data ATTRIBUTE_UNUSED, JValue* result) {
775  const uint4_t num_additional_registers = inst->VRegB_25x();
776  // Argument word count.
777  const uint16_t number_of_inputs = num_additional_registers + kLambdaVirtualRegisterWidth;
778  // The lambda closure register is always present and is not encoded in the count.
779  // Furthermore, the lambda closure register is always wide, so it counts as 2 inputs.
780
781  // TODO: find a cleaner way to separate non-range and range information without duplicating
782  //       code.
783  uint32_t arg[Instruction::kMaxVarArgRegs25x];  // only used in invoke-XXX.
784  uint32_t vregC = 0;   // only used in invoke-XXX-range.
785  if (is_range) {
786    vregC = inst->VRegC_3rc();
787  } else {
788    // TODO(iam): See if it's possible to remove inst_data dependency from 35x to avoid this path
789    inst->GetAllArgs25x(arg);
790  }
791
792  // TODO: if there's an assignability check, throw instead?
793  DCHECK(called_method->IsStatic());
794
795  return DoCallCommon<is_range, do_assignability_check>(
796      called_method, self, shadow_frame,
797      result, number_of_inputs, arg, vregC);
798}
799
800template<bool is_range, bool do_assignability_check>
801bool DoCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame,
802            const Instruction* inst, uint16_t inst_data, JValue* result) {
803  // Argument word count.
804  const uint16_t number_of_inputs =
805      (is_range) ? inst->VRegA_3rc(inst_data) : inst->VRegA_35c(inst_data);
806
807  // TODO: find a cleaner way to separate non-range and range information without duplicating
808  //       code.
809  uint32_t arg[Instruction::kMaxVarArgRegs] = {};  // only used in invoke-XXX.
810  uint32_t vregC = 0;
811  if (is_range) {
812    vregC = inst->VRegC_3rc();
813  } else {
814    vregC = inst->VRegC_35c();
815    inst->GetVarArgs(arg, inst_data);
816  }
817
818  return DoCallCommon<is_range, do_assignability_check>(
819      called_method, self, shadow_frame,
820      result, number_of_inputs, arg, vregC);
821}
822
823template <bool is_range, bool do_access_check, bool transaction_active>
824bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame,
825                      Thread* self, JValue* result) {
826  DCHECK(inst->Opcode() == Instruction::FILLED_NEW_ARRAY ||
827         inst->Opcode() == Instruction::FILLED_NEW_ARRAY_RANGE);
828  const int32_t length = is_range ? inst->VRegA_3rc() : inst->VRegA_35c();
829  if (!is_range) {
830    // Checks FILLED_NEW_ARRAY's length does not exceed 5 arguments.
831    CHECK_LE(length, 5);
832  }
833  if (UNLIKELY(length < 0)) {
834    ThrowNegativeArraySizeException(length);
835    return false;
836  }
837  uint16_t type_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c();
838  Class* array_class = ResolveVerifyAndClinit(type_idx, shadow_frame.GetMethod(),
839                                              self, false, do_access_check);
840  if (UNLIKELY(array_class == nullptr)) {
841    DCHECK(self->IsExceptionPending());
842    return false;
843  }
844  CHECK(array_class->IsArrayClass());
845  Class* component_class = array_class->GetComponentType();
846  const bool is_primitive_int_component = component_class->IsPrimitiveInt();
847  if (UNLIKELY(component_class->IsPrimitive() && !is_primitive_int_component)) {
848    if (component_class->IsPrimitiveLong() || component_class->IsPrimitiveDouble()) {
849      ThrowRuntimeException("Bad filled array request for type %s",
850                            PrettyDescriptor(component_class).c_str());
851    } else {
852      self->ThrowNewExceptionF("Ljava/lang/InternalError;",
853                               "Found type %s; filled-new-array not implemented for anything but 'int'",
854                               PrettyDescriptor(component_class).c_str());
855    }
856    return false;
857  }
858  Object* new_array = Array::Alloc<true>(self, array_class, length,
859                                         array_class->GetComponentSizeShift(),
860                                         Runtime::Current()->GetHeap()->GetCurrentAllocator());
861  if (UNLIKELY(new_array == nullptr)) {
862    self->AssertPendingOOMException();
863    return false;
864  }
865  uint32_t arg[Instruction::kMaxVarArgRegs];  // only used in filled-new-array.
866  uint32_t vregC = 0;   // only used in filled-new-array-range.
867  if (is_range) {
868    vregC = inst->VRegC_3rc();
869  } else {
870    inst->GetVarArgs(arg);
871  }
872  for (int32_t i = 0; i < length; ++i) {
873    size_t src_reg = is_range ? vregC + i : arg[i];
874    if (is_primitive_int_component) {
875      new_array->AsIntArray()->SetWithoutChecks<transaction_active>(
876          i, shadow_frame.GetVReg(src_reg));
877    } else {
878      new_array->AsObjectArray<Object>()->SetWithoutChecks<transaction_active>(
879          i, shadow_frame.GetVRegReference(src_reg));
880    }
881  }
882
883  result->SetL(new_array);
884  return true;
885}
886
887// TODO fix thread analysis: should be SHARED_REQUIRES(Locks::mutator_lock_).
888template<typename T>
889static void RecordArrayElementsInTransactionImpl(mirror::PrimitiveArray<T>* array, int32_t count)
890    NO_THREAD_SAFETY_ANALYSIS {
891  Runtime* runtime = Runtime::Current();
892  for (int32_t i = 0; i < count; ++i) {
893    runtime->RecordWriteArray(array, i, array->GetWithoutChecks(i));
894  }
895}
896
897void RecordArrayElementsInTransaction(mirror::Array* array, int32_t count)
898    SHARED_REQUIRES(Locks::mutator_lock_) {
899  DCHECK(Runtime::Current()->IsActiveTransaction());
900  DCHECK(array != nullptr);
901  DCHECK_LE(count, array->GetLength());
902  Primitive::Type primitive_component_type = array->GetClass()->GetComponentType()->GetPrimitiveType();
903  switch (primitive_component_type) {
904    case Primitive::kPrimBoolean:
905      RecordArrayElementsInTransactionImpl(array->AsBooleanArray(), count);
906      break;
907    case Primitive::kPrimByte:
908      RecordArrayElementsInTransactionImpl(array->AsByteArray(), count);
909      break;
910    case Primitive::kPrimChar:
911      RecordArrayElementsInTransactionImpl(array->AsCharArray(), count);
912      break;
913    case Primitive::kPrimShort:
914      RecordArrayElementsInTransactionImpl(array->AsShortArray(), count);
915      break;
916    case Primitive::kPrimInt:
917      RecordArrayElementsInTransactionImpl(array->AsIntArray(), count);
918      break;
919    case Primitive::kPrimFloat:
920      RecordArrayElementsInTransactionImpl(array->AsFloatArray(), count);
921      break;
922    case Primitive::kPrimLong:
923      RecordArrayElementsInTransactionImpl(array->AsLongArray(), count);
924      break;
925    case Primitive::kPrimDouble:
926      RecordArrayElementsInTransactionImpl(array->AsDoubleArray(), count);
927      break;
928    default:
929      LOG(FATAL) << "Unsupported primitive type " << primitive_component_type
930                 << " in fill-array-data";
931      break;
932  }
933}
934
935// Explicit DoCall template function declarations.
936#define EXPLICIT_DO_CALL_TEMPLATE_DECL(_is_range, _do_assignability_check)                      \
937  template SHARED_REQUIRES(Locks::mutator_lock_)                                                \
938  bool DoCall<_is_range, _do_assignability_check>(ArtMethod* method, Thread* self,              \
939                                                  ShadowFrame& shadow_frame,                    \
940                                                  const Instruction* inst, uint16_t inst_data,  \
941                                                  JValue* result)
942EXPLICIT_DO_CALL_TEMPLATE_DECL(false, false);
943EXPLICIT_DO_CALL_TEMPLATE_DECL(false, true);
944EXPLICIT_DO_CALL_TEMPLATE_DECL(true, false);
945EXPLICIT_DO_CALL_TEMPLATE_DECL(true, true);
946#undef EXPLICIT_DO_CALL_TEMPLATE_DECL
947
948// Explicit DoLambdaCall template function declarations.
949#define EXPLICIT_DO_LAMBDA_CALL_TEMPLATE_DECL(_is_range, _do_assignability_check)               \
950  template SHARED_REQUIRES(Locks::mutator_lock_)                                                \
951  bool DoLambdaCall<_is_range, _do_assignability_check>(ArtMethod* method, Thread* self,        \
952                                                        ShadowFrame& shadow_frame,              \
953                                                        const Instruction* inst,                \
954                                                        uint16_t inst_data,                     \
955                                                        JValue* result)
956EXPLICIT_DO_LAMBDA_CALL_TEMPLATE_DECL(false, false);
957EXPLICIT_DO_LAMBDA_CALL_TEMPLATE_DECL(false, true);
958EXPLICIT_DO_LAMBDA_CALL_TEMPLATE_DECL(true, false);
959EXPLICIT_DO_LAMBDA_CALL_TEMPLATE_DECL(true, true);
960#undef EXPLICIT_DO_LAMBDA_CALL_TEMPLATE_DECL
961
962// Explicit DoFilledNewArray template function declarations.
963#define EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(_is_range_, _check, _transaction_active)       \
964  template SHARED_REQUIRES(Locks::mutator_lock_)                                                  \
965  bool DoFilledNewArray<_is_range_, _check, _transaction_active>(const Instruction* inst,         \
966                                                                 const ShadowFrame& shadow_frame, \
967                                                                 Thread* self, JValue* result)
968#define EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(_transaction_active)       \
969  EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, false, _transaction_active);  \
970  EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, true, _transaction_active);   \
971  EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, false, _transaction_active);   \
972  EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, true, _transaction_active)
973EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(false);
974EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(true);
975#undef EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL
976#undef EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL
977
978}  // namespace interpreter
979}  // namespace art
980