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