Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 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" |
Ian Rogers | 22d5e73 | 2014-07-15 22:23:51 -0700 | [diff] [blame^] | 18 | |
| 19 | #include "field_helper.h" |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 20 | #include "mirror/array-inl.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 21 | |
| 22 | namespace art { |
| 23 | namespace interpreter { |
| 24 | |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 25 | void ThrowNullPointerExceptionFromInterpreter(const ShadowFrame& shadow_frame) { |
| 26 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 27 | } |
| 28 | |
| 29 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check> |
| 30 | bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, |
| 31 | uint16_t inst_data) { |
| 32 | const bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead); |
| 33 | const uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
| 34 | ArtField* f = FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self, |
| 35 | Primitive::FieldSize(field_type)); |
| 36 | if (UNLIKELY(f == nullptr)) { |
| 37 | CHECK(self->IsExceptionPending()); |
| 38 | return false; |
| 39 | } |
Sebastien Hertz | 4e99b3d | 2014-06-24 14:35:40 +0200 | [diff] [blame] | 40 | f->GetDeclaringClass()->AssertInitializedOrInitializingInThread(self); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 41 | Object* obj; |
| 42 | if (is_static) { |
| 43 | obj = f->GetDeclaringClass(); |
| 44 | } else { |
| 45 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 46 | if (UNLIKELY(obj == nullptr)) { |
| 47 | ThrowNullPointerExceptionForFieldAccess(shadow_frame.GetCurrentLocationForThrow(), f, true); |
| 48 | return false; |
| 49 | } |
| 50 | } |
| 51 | // Report this field access to instrumentation if needed. |
| 52 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 53 | if (UNLIKELY(instrumentation->HasFieldReadListeners())) { |
| 54 | Object* this_object = f->IsStatic() ? nullptr : obj; |
| 55 | instrumentation->FieldReadEvent(self, this_object, shadow_frame.GetMethod(), |
| 56 | shadow_frame.GetDexPC(), f); |
| 57 | } |
| 58 | uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data); |
| 59 | switch (field_type) { |
| 60 | case Primitive::kPrimBoolean: |
| 61 | shadow_frame.SetVReg(vregA, f->GetBoolean(obj)); |
| 62 | break; |
| 63 | case Primitive::kPrimByte: |
| 64 | shadow_frame.SetVReg(vregA, f->GetByte(obj)); |
| 65 | break; |
| 66 | case Primitive::kPrimChar: |
| 67 | shadow_frame.SetVReg(vregA, f->GetChar(obj)); |
| 68 | break; |
| 69 | case Primitive::kPrimShort: |
| 70 | shadow_frame.SetVReg(vregA, f->GetShort(obj)); |
| 71 | break; |
| 72 | case Primitive::kPrimInt: |
| 73 | shadow_frame.SetVReg(vregA, f->GetInt(obj)); |
| 74 | break; |
| 75 | case Primitive::kPrimLong: |
| 76 | shadow_frame.SetVRegLong(vregA, f->GetLong(obj)); |
| 77 | break; |
| 78 | case Primitive::kPrimNot: |
| 79 | shadow_frame.SetVRegReference(vregA, f->GetObject(obj)); |
| 80 | break; |
| 81 | default: |
| 82 | LOG(FATAL) << "Unreachable: " << field_type; |
| 83 | } |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | // Explicitly instantiate all DoFieldGet functions. |
| 88 | #define EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, _do_check) \ |
| 89 | template bool DoFieldGet<_find_type, _field_type, _do_check>(Thread* self, \ |
| 90 | ShadowFrame& shadow_frame, \ |
| 91 | const Instruction* inst, \ |
| 92 | uint16_t inst_data) |
| 93 | |
| 94 | #define EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
| 95 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, false); \ |
| 96 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, true); |
| 97 | |
| 98 | // iget-XXX |
| 99 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimBoolean); |
| 100 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimByte); |
| 101 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimChar); |
| 102 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimShort); |
| 103 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimInt); |
| 104 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimLong); |
| 105 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstanceObjectRead, Primitive::kPrimNot); |
| 106 | |
| 107 | // sget-XXX |
| 108 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimBoolean); |
| 109 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimByte); |
| 110 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimChar); |
| 111 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimShort); |
| 112 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimInt); |
| 113 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimLong); |
| 114 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticObjectRead, Primitive::kPrimNot); |
| 115 | |
| 116 | #undef EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL |
| 117 | #undef EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL |
| 118 | |
| 119 | // Handles iget-quick, iget-wide-quick and iget-object-quick instructions. |
| 120 | // Returns true on success, otherwise throws an exception and returns false. |
| 121 | template<Primitive::Type field_type> |
| 122 | bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) { |
| 123 | Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 124 | if (UNLIKELY(obj == nullptr)) { |
| 125 | // We lost the reference to the field index so we cannot get a more |
| 126 | // precised exception message. |
| 127 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 128 | return false; |
| 129 | } |
| 130 | MemberOffset field_offset(inst->VRegC_22c()); |
| 131 | // Report this field access to instrumentation if needed. Since we only have the offset of |
| 132 | // the field from the base of the object, we need to look for it first. |
| 133 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 134 | if (UNLIKELY(instrumentation->HasFieldReadListeners())) { |
| 135 | ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(), |
| 136 | field_offset.Uint32Value()); |
| 137 | DCHECK(f != nullptr); |
| 138 | DCHECK(!f->IsStatic()); |
| 139 | instrumentation->FieldReadEvent(Thread::Current(), obj, shadow_frame.GetMethod(), |
| 140 | shadow_frame.GetDexPC(), f); |
| 141 | } |
| 142 | // Note: iget-x-quick instructions are only for non-volatile fields. |
| 143 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
| 144 | switch (field_type) { |
| 145 | case Primitive::kPrimInt: |
| 146 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetField32(field_offset))); |
| 147 | break; |
| 148 | case Primitive::kPrimLong: |
| 149 | shadow_frame.SetVRegLong(vregA, static_cast<int64_t>(obj->GetField64(field_offset))); |
| 150 | break; |
| 151 | case Primitive::kPrimNot: |
| 152 | shadow_frame.SetVRegReference(vregA, obj->GetFieldObject<mirror::Object>(field_offset)); |
| 153 | break; |
| 154 | default: |
| 155 | LOG(FATAL) << "Unreachable: " << field_type; |
| 156 | } |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | // Explicitly instantiate all DoIGetQuick functions. |
| 161 | #define EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(_field_type) \ |
| 162 | template bool DoIGetQuick<_field_type>(ShadowFrame& shadow_frame, const Instruction* inst, \ |
| 163 | uint16_t inst_data) |
| 164 | |
| 165 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimInt); // iget-quick. |
| 166 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimLong); // iget-wide-quick. |
| 167 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimNot); // iget-object-quick. |
| 168 | #undef EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL |
| 169 | |
| 170 | template<Primitive::Type field_type> |
| 171 | static JValue GetFieldValue(const ShadowFrame& shadow_frame, uint32_t vreg) |
| 172 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 173 | JValue field_value; |
| 174 | switch (field_type) { |
| 175 | case Primitive::kPrimBoolean: |
| 176 | field_value.SetZ(static_cast<uint8_t>(shadow_frame.GetVReg(vreg))); |
| 177 | break; |
| 178 | case Primitive::kPrimByte: |
| 179 | field_value.SetB(static_cast<int8_t>(shadow_frame.GetVReg(vreg))); |
| 180 | break; |
| 181 | case Primitive::kPrimChar: |
| 182 | field_value.SetC(static_cast<uint16_t>(shadow_frame.GetVReg(vreg))); |
| 183 | break; |
| 184 | case Primitive::kPrimShort: |
| 185 | field_value.SetS(static_cast<int16_t>(shadow_frame.GetVReg(vreg))); |
| 186 | break; |
| 187 | case Primitive::kPrimInt: |
| 188 | field_value.SetI(shadow_frame.GetVReg(vreg)); |
| 189 | break; |
| 190 | case Primitive::kPrimLong: |
| 191 | field_value.SetJ(shadow_frame.GetVRegLong(vreg)); |
| 192 | break; |
| 193 | case Primitive::kPrimNot: |
| 194 | field_value.SetL(shadow_frame.GetVRegReference(vreg)); |
| 195 | break; |
| 196 | default: |
| 197 | LOG(FATAL) << "Unreachable: " << field_type; |
| 198 | break; |
| 199 | } |
| 200 | return field_value; |
| 201 | } |
| 202 | |
| 203 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check, |
| 204 | bool transaction_active> |
| 205 | bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst, |
| 206 | uint16_t inst_data) { |
| 207 | bool do_assignability_check = do_access_check; |
| 208 | bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite); |
| 209 | uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
| 210 | ArtField* f = FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self, |
| 211 | Primitive::FieldSize(field_type)); |
| 212 | if (UNLIKELY(f == nullptr)) { |
| 213 | CHECK(self->IsExceptionPending()); |
| 214 | return false; |
| 215 | } |
Sebastien Hertz | 4e99b3d | 2014-06-24 14:35:40 +0200 | [diff] [blame] | 216 | f->GetDeclaringClass()->AssertInitializedOrInitializingInThread(self); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 217 | Object* obj; |
| 218 | if (is_static) { |
| 219 | obj = f->GetDeclaringClass(); |
| 220 | } else { |
| 221 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 222 | if (UNLIKELY(obj == nullptr)) { |
| 223 | ThrowNullPointerExceptionForFieldAccess(shadow_frame.GetCurrentLocationForThrow(), |
| 224 | f, false); |
| 225 | return false; |
| 226 | } |
| 227 | } |
| 228 | uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data); |
| 229 | // Report this field access to instrumentation if needed. Since we only have the offset of |
| 230 | // the field from the base of the object, we need to look for it first. |
| 231 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 232 | if (UNLIKELY(instrumentation->HasFieldWriteListeners())) { |
| 233 | JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA); |
| 234 | Object* this_object = f->IsStatic() ? nullptr : obj; |
| 235 | instrumentation->FieldWriteEvent(self, this_object, shadow_frame.GetMethod(), |
| 236 | shadow_frame.GetDexPC(), f, field_value); |
| 237 | } |
| 238 | switch (field_type) { |
| 239 | case Primitive::kPrimBoolean: |
| 240 | f->SetBoolean<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 241 | break; |
| 242 | case Primitive::kPrimByte: |
| 243 | f->SetByte<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 244 | break; |
| 245 | case Primitive::kPrimChar: |
| 246 | f->SetChar<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 247 | break; |
| 248 | case Primitive::kPrimShort: |
| 249 | f->SetShort<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 250 | break; |
| 251 | case Primitive::kPrimInt: |
| 252 | f->SetInt<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 253 | break; |
| 254 | case Primitive::kPrimLong: |
| 255 | f->SetLong<transaction_active>(obj, shadow_frame.GetVRegLong(vregA)); |
| 256 | break; |
| 257 | case Primitive::kPrimNot: { |
| 258 | Object* reg = shadow_frame.GetVRegReference(vregA); |
| 259 | if (do_assignability_check && reg != nullptr) { |
| 260 | // FieldHelper::GetType can resolve classes, use a handle wrapper which will restore the |
| 261 | // object in the destructor. |
| 262 | Class* field_class; |
| 263 | { |
| 264 | StackHandleScope<3> hs(self); |
| 265 | HandleWrapper<mirror::ArtField> h_f(hs.NewHandleWrapper(&f)); |
| 266 | HandleWrapper<mirror::Object> h_reg(hs.NewHandleWrapper(®)); |
| 267 | HandleWrapper<mirror::Object> h_obj(hs.NewHandleWrapper(&obj)); |
| 268 | FieldHelper fh(h_f); |
| 269 | field_class = fh.GetType(); |
| 270 | } |
| 271 | if (!reg->VerifierInstanceOf(field_class)) { |
| 272 | // This should never happen. |
| 273 | self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(), |
| 274 | "Ljava/lang/VirtualMachineError;", |
| 275 | "Put '%s' that is not instance of field '%s' in '%s'", |
| 276 | reg->GetClass()->GetDescriptor().c_str(), |
| 277 | field_class->GetDescriptor().c_str(), |
| 278 | f->GetDeclaringClass()->GetDescriptor().c_str()); |
| 279 | return false; |
| 280 | } |
| 281 | } |
| 282 | f->SetObj<transaction_active>(obj, reg); |
| 283 | break; |
| 284 | } |
| 285 | default: |
| 286 | LOG(FATAL) << "Unreachable: " << field_type; |
| 287 | } |
| 288 | return true; |
| 289 | } |
| 290 | |
| 291 | // Explicitly instantiate all DoFieldPut functions. |
| 292 | #define EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, _do_check, _transaction_active) \ |
| 293 | template bool DoFieldPut<_find_type, _field_type, _do_check, _transaction_active>(Thread* self, \ |
| 294 | const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) |
| 295 | |
| 296 | #define EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
| 297 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, false); \ |
| 298 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, false); \ |
| 299 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, true); \ |
| 300 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, true); |
| 301 | |
| 302 | // iput-XXX |
| 303 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimBoolean); |
| 304 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimByte); |
| 305 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimChar); |
| 306 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimShort); |
| 307 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimInt); |
| 308 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimLong); |
| 309 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstanceObjectWrite, Primitive::kPrimNot); |
| 310 | |
| 311 | // sput-XXX |
| 312 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimBoolean); |
| 313 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimByte); |
| 314 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimChar); |
| 315 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimShort); |
| 316 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimInt); |
| 317 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimLong); |
| 318 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticObjectWrite, Primitive::kPrimNot); |
| 319 | |
| 320 | #undef EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL |
| 321 | #undef EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL |
| 322 | |
| 323 | template<Primitive::Type field_type, bool transaction_active> |
| 324 | bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) { |
| 325 | Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 326 | if (UNLIKELY(obj == nullptr)) { |
| 327 | // We lost the reference to the field index so we cannot get a more |
| 328 | // precised exception message. |
| 329 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 330 | return false; |
| 331 | } |
| 332 | MemberOffset field_offset(inst->VRegC_22c()); |
| 333 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
| 334 | // Report this field modification to instrumentation if needed. Since we only have the offset of |
| 335 | // the field from the base of the object, we need to look for it first. |
| 336 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 337 | if (UNLIKELY(instrumentation->HasFieldWriteListeners())) { |
| 338 | ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(), |
| 339 | field_offset.Uint32Value()); |
| 340 | DCHECK(f != nullptr); |
| 341 | DCHECK(!f->IsStatic()); |
| 342 | JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA); |
| 343 | instrumentation->FieldWriteEvent(Thread::Current(), obj, shadow_frame.GetMethod(), |
| 344 | shadow_frame.GetDexPC(), f, field_value); |
| 345 | } |
| 346 | // Note: iput-x-quick instructions are only for non-volatile fields. |
| 347 | switch (field_type) { |
| 348 | case Primitive::kPrimInt: |
| 349 | obj->SetField32<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 350 | break; |
| 351 | case Primitive::kPrimLong: |
| 352 | obj->SetField64<transaction_active>(field_offset, shadow_frame.GetVRegLong(vregA)); |
| 353 | break; |
| 354 | case Primitive::kPrimNot: |
| 355 | obj->SetFieldObject<transaction_active>(field_offset, shadow_frame.GetVRegReference(vregA)); |
| 356 | break; |
| 357 | default: |
| 358 | LOG(FATAL) << "Unreachable: " << field_type; |
| 359 | } |
| 360 | return true; |
| 361 | } |
| 362 | |
| 363 | // Explicitly instantiate all DoIPutQuick functions. |
| 364 | #define EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, _transaction_active) \ |
| 365 | template bool DoIPutQuick<_field_type, _transaction_active>(const ShadowFrame& shadow_frame, \ |
| 366 | const Instruction* inst, \ |
| 367 | uint16_t inst_data) |
| 368 | |
| 369 | #define EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(_field_type) \ |
| 370 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, false); \ |
| 371 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, true); |
| 372 | |
| 373 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimInt); // iget-quick. |
| 374 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimLong); // iget-wide-quick. |
| 375 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimNot); // iget-object-quick. |
| 376 | #undef EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL |
| 377 | #undef EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL |
| 378 | |
Sebastien Hertz | 9f10203 | 2014-05-23 08:59:42 +0200 | [diff] [blame] | 379 | /** |
| 380 | * Finds the location where this exception will be caught. We search until we reach either the top |
| 381 | * frame or a native frame, in which cases this exception is considered uncaught. |
| 382 | */ |
| 383 | class CatchLocationFinder : public StackVisitor { |
| 384 | public: |
| 385 | explicit CatchLocationFinder(Thread* self, Handle<mirror::Throwable>* exception) |
| 386 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) |
| 387 | : StackVisitor(self, nullptr), self_(self), handle_scope_(self), exception_(exception), |
| 388 | catch_method_(handle_scope_.NewHandle<mirror::ArtMethod>(nullptr)), |
| 389 | catch_dex_pc_(DexFile::kDexNoIndex), clear_exception_(false) { |
| 390 | } |
| 391 | |
| 392 | bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 393 | mirror::ArtMethod* method = GetMethod(); |
| 394 | if (method == nullptr) { |
| 395 | return true; |
| 396 | } |
| 397 | if (method->IsRuntimeMethod()) { |
| 398 | // Ignore callee save method. |
| 399 | DCHECK(method->IsCalleeSaveMethod()); |
| 400 | return true; |
| 401 | } |
| 402 | if (method->IsNative()) { |
| 403 | return false; // End stack walk. |
| 404 | } |
| 405 | DCHECK(!method->IsNative()); |
| 406 | uint32_t dex_pc = GetDexPc(); |
| 407 | if (dex_pc != DexFile::kDexNoIndex) { |
| 408 | uint32_t found_dex_pc; |
| 409 | { |
| 410 | StackHandleScope<3> hs(self_); |
| 411 | Handle<mirror::Class> exception_class(hs.NewHandle((*exception_)->GetClass())); |
| 412 | Handle<mirror::ArtMethod> h_method(hs.NewHandle(method)); |
| 413 | found_dex_pc = mirror::ArtMethod::FindCatchBlock(h_method, exception_class, dex_pc, |
| 414 | &clear_exception_); |
| 415 | } |
| 416 | if (found_dex_pc != DexFile::kDexNoIndex) { |
| 417 | catch_method_.Assign(method); |
| 418 | catch_dex_pc_ = found_dex_pc; |
| 419 | return false; // End stack walk. |
| 420 | } |
| 421 | } |
| 422 | return true; // Continue stack walk. |
| 423 | } |
| 424 | |
| 425 | ArtMethod* GetCatchMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 426 | return catch_method_.Get(); |
| 427 | } |
| 428 | |
| 429 | uint32_t GetCatchDexPc() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 430 | return catch_dex_pc_; |
| 431 | } |
| 432 | |
| 433 | bool NeedClearException() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 434 | return clear_exception_; |
| 435 | } |
| 436 | |
| 437 | private: |
| 438 | Thread* const self_; |
| 439 | StackHandleScope<1> handle_scope_; |
| 440 | Handle<mirror::Throwable>* exception_; |
| 441 | Handle<mirror::ArtMethod> catch_method_; |
| 442 | uint32_t catch_dex_pc_; |
| 443 | bool clear_exception_; |
| 444 | |
| 445 | |
| 446 | DISALLOW_COPY_AND_ASSIGN(CatchLocationFinder); |
| 447 | }; |
| 448 | |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 449 | uint32_t FindNextInstructionFollowingException(Thread* self, |
| 450 | ShadowFrame& shadow_frame, |
| 451 | uint32_t dex_pc, |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 452 | const instrumentation::Instrumentation* instrumentation) { |
| 453 | self->VerifyStack(); |
| 454 | ThrowLocation throw_location; |
Sebastien Hertz | 9f10203 | 2014-05-23 08:59:42 +0200 | [diff] [blame] | 455 | StackHandleScope<3> hs(self); |
| 456 | Handle<mirror::Throwable> exception(hs.NewHandle(self->GetException(&throw_location))); |
| 457 | if (!self->IsExceptionReportedToInstrumentation() && instrumentation->HasExceptionCaughtListeners()) { |
| 458 | CatchLocationFinder clf(self, &exception); |
| 459 | clf.WalkStack(false); |
| 460 | instrumentation->ExceptionCaughtEvent(self, throw_location, clf.GetCatchMethod(), |
| 461 | clf.GetCatchDexPc(), exception.Get()); |
| 462 | self->SetExceptionReportedToInstrumentation(true); |
| 463 | } |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 464 | bool clear_exception = false; |
| 465 | uint32_t found_dex_pc; |
| 466 | { |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 467 | Handle<mirror::Class> exception_class(hs.NewHandle(exception->GetClass())); |
| 468 | Handle<mirror::ArtMethod> h_method(hs.NewHandle(shadow_frame.GetMethod())); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 469 | found_dex_pc = mirror::ArtMethod::FindCatchBlock(h_method, exception_class, dex_pc, |
| 470 | &clear_exception); |
| 471 | } |
| 472 | if (found_dex_pc == DexFile::kDexNoIndex) { |
Sebastien Hertz | 9f10203 | 2014-05-23 08:59:42 +0200 | [diff] [blame] | 473 | instrumentation->MethodUnwindEvent(self, shadow_frame.GetThisObject(), |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 474 | shadow_frame.GetMethod(), dex_pc); |
| 475 | } else { |
Sebastien Hertz | 9f10203 | 2014-05-23 08:59:42 +0200 | [diff] [blame] | 476 | if (self->IsExceptionReportedToInstrumentation()) { |
| 477 | instrumentation->MethodUnwindEvent(self, shadow_frame.GetThisObject(), |
| 478 | shadow_frame.GetMethod(), dex_pc); |
| 479 | } |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 480 | if (clear_exception) { |
| 481 | self->ClearException(); |
| 482 | } |
| 483 | } |
| 484 | return found_dex_pc; |
| 485 | } |
| 486 | |
| 487 | void UnexpectedOpcode(const Instruction* inst, MethodHelper& mh) { |
| 488 | LOG(FATAL) << "Unexpected instruction: " << inst->DumpString(mh.GetMethod()->GetDexFile()); |
| 489 | exit(0); // Unreachable, keep GCC happy. |
| 490 | } |
| 491 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 492 | static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, |
| 493 | const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, |
| 494 | JValue* result, size_t arg_offset) |
| 495 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 496 | |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 497 | // Assign register 'src_reg' from shadow_frame to register 'dest_reg' into new_shadow_frame. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 498 | static inline void AssignRegister(ShadowFrame* new_shadow_frame, const ShadowFrame& shadow_frame, |
| 499 | size_t dest_reg, size_t src_reg) |
| 500 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 501 | // If both register locations contains the same value, the register probably holds a reference. |
Andreas Gampe | 7104cbf | 2014-03-21 11:44:43 -0700 | [diff] [blame] | 502 | // Uint required, so that sign extension does not make this wrong on 64b systems |
| 503 | uint32_t src_value = shadow_frame.GetVReg(src_reg); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 504 | mirror::Object* o = shadow_frame.GetVRegReference<kVerifyNone>(src_reg); |
Andreas Gampe | 7104cbf | 2014-03-21 11:44:43 -0700 | [diff] [blame] | 505 | if (src_value == reinterpret_cast<uintptr_t>(o)) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 506 | new_shadow_frame->SetVRegReference(dest_reg, o); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 507 | } else { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 508 | new_shadow_frame->SetVReg(dest_reg, src_value); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 509 | } |
| 510 | } |
| 511 | |
Mathieu Chartier | b2c7ead | 2014-04-29 11:13:16 -0700 | [diff] [blame] | 512 | void AbortTransaction(Thread* self, const char* fmt, ...) { |
| 513 | CHECK(Runtime::Current()->IsActiveTransaction()); |
| 514 | // Throw an exception so we can abort the transaction and undo every change. |
| 515 | va_list args; |
| 516 | va_start(args, fmt); |
| 517 | self->ThrowNewExceptionV(self->GetCurrentLocationForThrow(), "Ljava/lang/InternalError;", fmt, |
| 518 | args); |
| 519 | va_end(args); |
| 520 | } |
| 521 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 522 | template<bool is_range, bool do_assignability_check> |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 523 | bool DoCall(ArtMethod* method, Thread* self, ShadowFrame& shadow_frame, |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 524 | const Instruction* inst, uint16_t inst_data, JValue* result) { |
| 525 | // Compute method information. |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 526 | const DexFile::CodeItem* code_item = method->GetCodeItem(); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 527 | const uint16_t num_ins = (is_range) ? inst->VRegA_3rc(inst_data) : inst->VRegA_35c(inst_data); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 528 | uint16_t num_regs; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 529 | if (LIKELY(code_item != NULL)) { |
| 530 | num_regs = code_item->registers_size_; |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 531 | DCHECK_EQ(num_ins, code_item->ins_size_); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 532 | } else { |
| 533 | DCHECK(method->IsNative() || method->IsProxyMethod()); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 534 | num_regs = num_ins; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 535 | } |
| 536 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 537 | // Allocate shadow frame on the stack. |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 538 | const char* old_cause = self->StartAssertNoThreadSuspension("DoCall"); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 539 | void* memory = alloca(ShadowFrame::ComputeSize(num_regs)); |
| 540 | ShadowFrame* new_shadow_frame(ShadowFrame::Create(num_regs, &shadow_frame, method, 0, memory)); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 541 | |
| 542 | // Initialize new shadow frame. |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 543 | const size_t first_dest_reg = num_regs - num_ins; |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 544 | StackHandleScope<1> hs(self); |
| 545 | MethodHelper mh(hs.NewHandle(method)); |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 546 | if (do_assignability_check) { |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 547 | // Slow path. |
| 548 | // We might need to do class loading, which incurs a thread state change to kNative. So |
| 549 | // register the shadow frame as under construction and allow suspension again. |
| 550 | self->SetShadowFrameUnderConstruction(new_shadow_frame); |
| 551 | self->EndAssertNoThreadSuspension(old_cause); |
| 552 | |
| 553 | // We need to do runtime check on reference assignment. We need to load the shorty |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 554 | // to get the exact type of each reference argument. |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 555 | const DexFile::TypeList* params = method->GetParameterTypeList(); |
| 556 | uint32_t shorty_len = 0; |
| 557 | const char* shorty = method->GetShorty(&shorty_len); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 558 | |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 559 | // TODO: find a cleaner way to separate non-range and range information without duplicating code. |
| 560 | uint32_t arg[5]; // only used in invoke-XXX. |
| 561 | uint32_t vregC; // only used in invoke-XXX-range. |
| 562 | if (is_range) { |
| 563 | vregC = inst->VRegC_3rc(); |
| 564 | } else { |
Ian Rogers | 29a2648 | 2014-05-02 15:27:29 -0700 | [diff] [blame] | 565 | inst->GetVarArgs(arg, inst_data); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 566 | } |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 567 | |
| 568 | // Handle receiver apart since it's not part of the shorty. |
| 569 | size_t dest_reg = first_dest_reg; |
| 570 | size_t arg_offset = 0; |
| 571 | if (!method->IsStatic()) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 572 | size_t receiver_reg = is_range ? vregC : arg[0]; |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 573 | new_shadow_frame->SetVRegReference(dest_reg, shadow_frame.GetVRegReference(receiver_reg)); |
| 574 | ++dest_reg; |
| 575 | ++arg_offset; |
| 576 | } |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 577 | for (uint32_t shorty_pos = 0; dest_reg < num_regs; ++shorty_pos, ++dest_reg, ++arg_offset) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 578 | DCHECK_LT(shorty_pos + 1, shorty_len); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 579 | const size_t src_reg = (is_range) ? vregC + arg_offset : arg[arg_offset]; |
| 580 | switch (shorty[shorty_pos + 1]) { |
| 581 | case 'L': { |
| 582 | Object* o = shadow_frame.GetVRegReference(src_reg); |
| 583 | if (do_assignability_check && o != NULL) { |
| 584 | Class* arg_type = mh.GetClassFromTypeIdx(params->GetTypeItem(shorty_pos).type_idx_); |
| 585 | if (arg_type == NULL) { |
| 586 | CHECK(self->IsExceptionPending()); |
| 587 | return false; |
| 588 | } |
| 589 | if (!o->VerifierInstanceOf(arg_type)) { |
| 590 | // This should never happen. |
| 591 | self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(), |
| 592 | "Ljava/lang/VirtualMachineError;", |
| 593 | "Invoking %s with bad arg %d, type '%s' not instance of '%s'", |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 594 | method->GetName(), shorty_pos, |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 595 | o->GetClass()->GetDescriptor().c_str(), |
| 596 | arg_type->GetDescriptor().c_str()); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 597 | return false; |
| 598 | } |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 599 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 600 | new_shadow_frame->SetVRegReference(dest_reg, o); |
| 601 | break; |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 602 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 603 | case 'J': case 'D': { |
| 604 | uint64_t wide_value = (static_cast<uint64_t>(shadow_frame.GetVReg(src_reg + 1)) << 32) | |
| 605 | static_cast<uint32_t>(shadow_frame.GetVReg(src_reg)); |
| 606 | new_shadow_frame->SetVRegLong(dest_reg, wide_value); |
| 607 | ++dest_reg; |
| 608 | ++arg_offset; |
| 609 | break; |
| 610 | } |
| 611 | default: |
| 612 | new_shadow_frame->SetVReg(dest_reg, shadow_frame.GetVReg(src_reg)); |
| 613 | break; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 614 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 615 | } |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 616 | // We're done with the construction. |
| 617 | self->ClearShadowFrameUnderConstruction(); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 618 | } else { |
| 619 | // Fast path: no extra checks. |
| 620 | if (is_range) { |
| 621 | const uint16_t first_src_reg = inst->VRegC_3rc(); |
| 622 | for (size_t src_reg = first_src_reg, dest_reg = first_dest_reg; dest_reg < num_regs; |
| 623 | ++dest_reg, ++src_reg) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 624 | AssignRegister(new_shadow_frame, shadow_frame, dest_reg, src_reg); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 625 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 626 | } else { |
| 627 | DCHECK_LE(num_ins, 5U); |
| 628 | uint16_t regList = inst->Fetch16(2); |
| 629 | uint16_t count = num_ins; |
| 630 | if (count == 5) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 631 | AssignRegister(new_shadow_frame, shadow_frame, first_dest_reg + 4U, (inst_data >> 8) & 0x0f); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 632 | --count; |
| 633 | } |
| 634 | for (size_t arg_index = 0; arg_index < count; ++arg_index, regList >>= 4) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 635 | AssignRegister(new_shadow_frame, shadow_frame, first_dest_reg + arg_index, regList & 0x0f); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 636 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 637 | } |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 638 | self->EndAssertNoThreadSuspension(old_cause); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 639 | } |
| 640 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 641 | // Do the call now. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 642 | if (LIKELY(Runtime::Current()->IsStarted())) { |
Ian Rogers | 1d99e45 | 2014-01-02 17:36:41 -0800 | [diff] [blame] | 643 | if (kIsDebugBuild && method->GetEntryPointFromInterpreter() == nullptr) { |
| 644 | LOG(FATAL) << "Attempt to invoke non-executable method: " << PrettyMethod(method); |
| 645 | } |
Hiroshi Yamauchi | 563b47c | 2014-02-28 17:18:37 -0800 | [diff] [blame] | 646 | if (kIsDebugBuild && Runtime::Current()->GetInstrumentation()->IsForcedInterpretOnly() && |
| 647 | !method->IsNative() && !method->IsProxyMethod() && |
| 648 | method->GetEntryPointFromInterpreter() == artInterpreterToCompiledCodeBridge) { |
| 649 | LOG(FATAL) << "Attempt to call compiled code when -Xint: " << PrettyMethod(method); |
| 650 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 651 | (method->GetEntryPointFromInterpreter())(self, mh, code_item, new_shadow_frame, result); |
| 652 | } else { |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 653 | UnstartedRuntimeInvoke(self, mh, code_item, new_shadow_frame, result, first_dest_reg); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 654 | } |
| 655 | return !self->IsExceptionPending(); |
| 656 | } |
| 657 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 658 | template <bool is_range, bool do_access_check, bool transaction_active> |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 659 | bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame, |
| 660 | Thread* self, JValue* result) { |
| 661 | DCHECK(inst->Opcode() == Instruction::FILLED_NEW_ARRAY || |
| 662 | inst->Opcode() == Instruction::FILLED_NEW_ARRAY_RANGE); |
| 663 | const int32_t length = is_range ? inst->VRegA_3rc() : inst->VRegA_35c(); |
| 664 | if (!is_range) { |
| 665 | // Checks FILLED_NEW_ARRAY's length does not exceed 5 arguments. |
| 666 | CHECK_LE(length, 5); |
| 667 | } |
| 668 | if (UNLIKELY(length < 0)) { |
| 669 | ThrowNegativeArraySizeException(length); |
| 670 | return false; |
| 671 | } |
| 672 | uint16_t type_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c(); |
| 673 | Class* arrayClass = ResolveVerifyAndClinit(type_idx, shadow_frame.GetMethod(), |
| 674 | self, false, do_access_check); |
| 675 | if (UNLIKELY(arrayClass == NULL)) { |
| 676 | DCHECK(self->IsExceptionPending()); |
| 677 | return false; |
| 678 | } |
| 679 | CHECK(arrayClass->IsArrayClass()); |
| 680 | Class* componentClass = arrayClass->GetComponentType(); |
| 681 | if (UNLIKELY(componentClass->IsPrimitive() && !componentClass->IsPrimitiveInt())) { |
| 682 | if (componentClass->IsPrimitiveLong() || componentClass->IsPrimitiveDouble()) { |
| 683 | ThrowRuntimeException("Bad filled array request for type %s", |
| 684 | PrettyDescriptor(componentClass).c_str()); |
| 685 | } else { |
| 686 | self->ThrowNewExceptionF(shadow_frame.GetCurrentLocationForThrow(), |
| 687 | "Ljava/lang/InternalError;", |
Brian Carlstrom | 4fa0bcd | 2013-12-10 11:24:21 -0800 | [diff] [blame] | 688 | "Found type %s; filled-new-array not implemented for anything but 'int'", |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 689 | PrettyDescriptor(componentClass).c_str()); |
| 690 | } |
| 691 | return false; |
| 692 | } |
Ian Rogers | 6fac447 | 2014-02-25 17:01:10 -0800 | [diff] [blame] | 693 | Object* newArray = Array::Alloc<true>(self, arrayClass, length, arrayClass->GetComponentSize(), |
| 694 | Runtime::Current()->GetHeap()->GetCurrentAllocator()); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 695 | if (UNLIKELY(newArray == NULL)) { |
| 696 | DCHECK(self->IsExceptionPending()); |
| 697 | return false; |
| 698 | } |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 699 | uint32_t arg[5]; // only used in filled-new-array. |
| 700 | uint32_t vregC; // only used in filled-new-array-range. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 701 | if (is_range) { |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 702 | vregC = inst->VRegC_3rc(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 703 | } else { |
Ian Rogers | 29a2648 | 2014-05-02 15:27:29 -0700 | [diff] [blame] | 704 | inst->GetVarArgs(arg); |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 705 | } |
| 706 | const bool is_primitive_int_component = componentClass->IsPrimitiveInt(); |
| 707 | for (int32_t i = 0; i < length; ++i) { |
| 708 | size_t src_reg = is_range ? vregC + i : arg[i]; |
| 709 | if (is_primitive_int_component) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 710 | newArray->AsIntArray()->SetWithoutChecks<transaction_active>(i, shadow_frame.GetVReg(src_reg)); |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 711 | } else { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 712 | newArray->AsObjectArray<Object>()->SetWithoutChecks<transaction_active>(i, shadow_frame.GetVRegReference(src_reg)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 713 | } |
| 714 | } |
| 715 | |
| 716 | result->SetL(newArray); |
| 717 | return true; |
| 718 | } |
| 719 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 720 | // TODO fix thread analysis: should be SHARED_LOCKS_REQUIRED(Locks::mutator_lock_). |
| 721 | template<typename T> |
| 722 | static void RecordArrayElementsInTransactionImpl(mirror::PrimitiveArray<T>* array, int32_t count) |
| 723 | NO_THREAD_SAFETY_ANALYSIS { |
| 724 | Runtime* runtime = Runtime::Current(); |
| 725 | for (int32_t i = 0; i < count; ++i) { |
| 726 | runtime->RecordWriteArray(array, i, array->GetWithoutChecks(i)); |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | void RecordArrayElementsInTransaction(mirror::Array* array, int32_t count) |
| 731 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 732 | DCHECK(Runtime::Current()->IsActiveTransaction()); |
| 733 | DCHECK(array != nullptr); |
| 734 | DCHECK_LE(count, array->GetLength()); |
| 735 | Primitive::Type primitive_component_type = array->GetClass()->GetComponentType()->GetPrimitiveType(); |
| 736 | switch (primitive_component_type) { |
| 737 | case Primitive::kPrimBoolean: |
| 738 | RecordArrayElementsInTransactionImpl(array->AsBooleanArray(), count); |
| 739 | break; |
| 740 | case Primitive::kPrimByte: |
| 741 | RecordArrayElementsInTransactionImpl(array->AsByteArray(), count); |
| 742 | break; |
| 743 | case Primitive::kPrimChar: |
| 744 | RecordArrayElementsInTransactionImpl(array->AsCharArray(), count); |
| 745 | break; |
| 746 | case Primitive::kPrimShort: |
| 747 | RecordArrayElementsInTransactionImpl(array->AsShortArray(), count); |
| 748 | break; |
| 749 | case Primitive::kPrimInt: |
| 750 | case Primitive::kPrimFloat: |
| 751 | RecordArrayElementsInTransactionImpl(array->AsIntArray(), count); |
| 752 | break; |
| 753 | case Primitive::kPrimLong: |
| 754 | case Primitive::kPrimDouble: |
| 755 | RecordArrayElementsInTransactionImpl(array->AsLongArray(), count); |
| 756 | break; |
| 757 | default: |
| 758 | LOG(FATAL) << "Unsupported primitive type " << primitive_component_type |
| 759 | << " in fill-array-data"; |
| 760 | break; |
| 761 | } |
| 762 | } |
| 763 | |
Sebastien Hertz | 4e99b3d | 2014-06-24 14:35:40 +0200 | [diff] [blame] | 764 | // Helper function to deal with class loading in an unstarted runtime. |
| 765 | static void UnstartedRuntimeFindClass(Thread* self, Handle<mirror::String> className, |
| 766 | Handle<mirror::ClassLoader> class_loader, JValue* result, |
| 767 | const std::string& method_name, bool initialize_class, |
| 768 | bool abort_if_not_found) |
| 769 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 770 | CHECK(className.Get() != nullptr); |
| 771 | std::string descriptor(DotToDescriptor(className->ToModifiedUtf8().c_str())); |
| 772 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
| 773 | |
| 774 | Class* found = class_linker->FindClass(self, descriptor.c_str(), class_loader); |
| 775 | if (found == nullptr && abort_if_not_found) { |
| 776 | if (!self->IsExceptionPending()) { |
| 777 | AbortTransaction(self, "%s failed in un-started runtime for class: %s", |
| 778 | method_name.c_str(), PrettyDescriptor(descriptor).c_str()); |
| 779 | } |
| 780 | return; |
| 781 | } |
| 782 | if (found != nullptr && initialize_class) { |
| 783 | StackHandleScope<1> hs(self); |
| 784 | Handle<mirror::Class> h_class(hs.NewHandle(found)); |
| 785 | if (!class_linker->EnsureInitialized(h_class, true, true)) { |
| 786 | CHECK(self->IsExceptionPending()); |
| 787 | return; |
| 788 | } |
| 789 | } |
| 790 | result->SetL(found); |
| 791 | } |
| 792 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 793 | static void UnstartedRuntimeInvoke(Thread* self, MethodHelper& mh, |
| 794 | const DexFile::CodeItem* code_item, ShadowFrame* shadow_frame, |
| 795 | JValue* result, size_t arg_offset) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 796 | // In a runtime that's not started we intercept certain methods to avoid complicated dependency |
| 797 | // problems in core libraries. |
| 798 | std::string name(PrettyMethod(shadow_frame->GetMethod())); |
Sebastien Hertz | 4e99b3d | 2014-06-24 14:35:40 +0200 | [diff] [blame] | 799 | if (name == "java.lang.Class java.lang.Class.forName(java.lang.String)") { |
| 800 | // TODO: Support for the other variants that take more arguments should also be added. |
| 801 | mirror::String* class_name = shadow_frame->GetVRegReference(arg_offset)->AsString(); |
| 802 | StackHandleScope<1> hs(self); |
| 803 | Handle<mirror::String> h_class_name(hs.NewHandle(class_name)); |
| 804 | UnstartedRuntimeFindClass(self, h_class_name, NullHandle<mirror::ClassLoader>(), result, name, |
| 805 | true, true); |
| 806 | } else if (name == "java.lang.Class java.lang.VMClassLoader.loadClass(java.lang.String, boolean)") { |
| 807 | mirror::String* class_name = shadow_frame->GetVRegReference(arg_offset)->AsString(); |
| 808 | StackHandleScope<1> hs(self); |
| 809 | Handle<mirror::String> h_class_name(hs.NewHandle(class_name)); |
| 810 | UnstartedRuntimeFindClass(self, h_class_name, NullHandle<mirror::ClassLoader>(), result, name, |
| 811 | false, true); |
| 812 | } else if (name == "java.lang.Class java.lang.VMClassLoader.findLoadedClass(java.lang.ClassLoader, java.lang.String)") { |
| 813 | mirror::String* class_name = shadow_frame->GetVRegReference(arg_offset + 1)->AsString(); |
| 814 | mirror::ClassLoader* class_loader = |
| 815 | down_cast<mirror::ClassLoader*>(shadow_frame->GetVRegReference(arg_offset)); |
| 816 | StackHandleScope<2> hs(self); |
| 817 | Handle<mirror::String> h_class_name(hs.NewHandle(class_name)); |
| 818 | Handle<mirror::ClassLoader> h_class_loader(hs.NewHandle(class_loader)); |
| 819 | UnstartedRuntimeFindClass(self, h_class_name, h_class_loader, result, name, false, false); |
Ian Rogers | c45b8b5 | 2014-05-03 01:39:59 -0700 | [diff] [blame] | 820 | } else if (name == "java.lang.Class java.lang.Void.lookupType()") { |
| 821 | result->SetL(Runtime::Current()->GetClassLinker()->FindPrimitiveClass('V')); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 822 | } else if (name == "java.lang.Object java.lang.Class.newInstance()") { |
| 823 | Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); |
| 824 | ArtMethod* c = klass->FindDeclaredDirectMethod("<init>", "()V"); |
| 825 | CHECK(c != NULL); |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 826 | StackHandleScope<1> hs(self); |
| 827 | Handle<Object> obj(hs.NewHandle(klass->AllocObject(self))); |
| 828 | CHECK(obj.Get() != NULL); |
| 829 | EnterInterpreterFromInvoke(self, c, obj.Get(), NULL, NULL); |
| 830 | result->SetL(obj.Get()); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 831 | } else if (name == "java.lang.reflect.Field java.lang.Class.getDeclaredField(java.lang.String)") { |
| 832 | // Special managed code cut-out to allow field lookup in a un-started runtime that'd fail |
| 833 | // going the reflective Dex way. |
| 834 | Class* klass = shadow_frame->GetVRegReference(arg_offset)->AsClass(); |
| 835 | String* name = shadow_frame->GetVRegReference(arg_offset + 1)->AsString(); |
| 836 | ArtField* found = NULL; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 837 | ObjectArray<ArtField>* fields = klass->GetIFields(); |
| 838 | for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { |
| 839 | ArtField* f = fields->Get(i); |
Mathieu Chartier | 61c5ebc | 2014-06-05 17:42:53 -0700 | [diff] [blame] | 840 | if (name->Equals(f->GetName())) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 841 | found = f; |
| 842 | } |
| 843 | } |
| 844 | if (found == NULL) { |
| 845 | fields = klass->GetSFields(); |
| 846 | for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { |
| 847 | ArtField* f = fields->Get(i); |
Mathieu Chartier | 61c5ebc | 2014-06-05 17:42:53 -0700 | [diff] [blame] | 848 | if (name->Equals(f->GetName())) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 849 | found = f; |
| 850 | } |
| 851 | } |
| 852 | } |
| 853 | CHECK(found != NULL) |
| 854 | << "Failed to find field in Class.getDeclaredField in un-started runtime. name=" |
| 855 | << name->ToModifiedUtf8() << " class=" << PrettyDescriptor(klass); |
| 856 | // TODO: getDeclaredField calls GetType once the field is found to ensure a |
| 857 | // NoClassDefFoundError is thrown if the field's type cannot be resolved. |
| 858 | Class* jlr_Field = self->DecodeJObject(WellKnownClasses::java_lang_reflect_Field)->AsClass(); |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 859 | StackHandleScope<1> hs(self); |
| 860 | Handle<Object> field(hs.NewHandle(jlr_Field->AllocNonMovableObject(self))); |
| 861 | CHECK(field.Get() != NULL); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 862 | ArtMethod* c = jlr_Field->FindDeclaredDirectMethod("<init>", "(Ljava/lang/reflect/ArtField;)V"); |
| 863 | uint32_t args[1]; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 864 | args[0] = StackReference<mirror::Object>::FromMirrorPtr(found).AsVRegValue(); |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 865 | EnterInterpreterFromInvoke(self, c, field.Get(), args, NULL); |
| 866 | result->SetL(field.Get()); |
Ian Rogers | c45b8b5 | 2014-05-03 01:39:59 -0700 | [diff] [blame] | 867 | } else if (name == "int java.lang.Object.hashCode()") { |
| 868 | Object* obj = shadow_frame->GetVRegReference(arg_offset); |
| 869 | result->SetI(obj->IdentityHashCode()); |
| 870 | } else if (name == "java.lang.String java.lang.reflect.ArtMethod.getMethodName(java.lang.reflect.ArtMethod)") { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 871 | StackHandleScope<1> hs(self); |
| 872 | MethodHelper mh(hs.NewHandle(shadow_frame->GetVRegReference(arg_offset)->AsArtMethod())); |
| 873 | result->SetL(mh.GetNameAsString(self)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 874 | } else if (name == "void java.lang.System.arraycopy(java.lang.Object, int, java.lang.Object, int, int)" || |
| 875 | name == "void java.lang.System.arraycopy(char[], int, char[], int, int)") { |
| 876 | // Special case array copying without initializing System. |
| 877 | Class* ctype = shadow_frame->GetVRegReference(arg_offset)->GetClass()->GetComponentType(); |
| 878 | jint srcPos = shadow_frame->GetVReg(arg_offset + 1); |
| 879 | jint dstPos = shadow_frame->GetVReg(arg_offset + 3); |
| 880 | jint length = shadow_frame->GetVReg(arg_offset + 4); |
| 881 | if (!ctype->IsPrimitive()) { |
| 882 | ObjectArray<Object>* src = shadow_frame->GetVRegReference(arg_offset)->AsObjectArray<Object>(); |
| 883 | ObjectArray<Object>* dst = shadow_frame->GetVRegReference(arg_offset + 2)->AsObjectArray<Object>(); |
| 884 | for (jint i = 0; i < length; ++i) { |
| 885 | dst->Set(dstPos + i, src->Get(srcPos + i)); |
| 886 | } |
| 887 | } else if (ctype->IsPrimitiveChar()) { |
| 888 | CharArray* src = shadow_frame->GetVRegReference(arg_offset)->AsCharArray(); |
| 889 | CharArray* dst = shadow_frame->GetVRegReference(arg_offset + 2)->AsCharArray(); |
| 890 | for (jint i = 0; i < length; ++i) { |
| 891 | dst->Set(dstPos + i, src->Get(srcPos + i)); |
| 892 | } |
| 893 | } else if (ctype->IsPrimitiveInt()) { |
| 894 | IntArray* src = shadow_frame->GetVRegReference(arg_offset)->AsIntArray(); |
| 895 | IntArray* dst = shadow_frame->GetVRegReference(arg_offset + 2)->AsIntArray(); |
| 896 | for (jint i = 0; i < length; ++i) { |
| 897 | dst->Set(dstPos + i, src->Get(srcPos + i)); |
| 898 | } |
| 899 | } else { |
Ian Rogers | c45b8b5 | 2014-05-03 01:39:59 -0700 | [diff] [blame] | 900 | self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(), "Ljava/lang/InternalError;", |
| 901 | "Unimplemented System.arraycopy for type '%s'", |
| 902 | PrettyDescriptor(ctype).c_str()); |
| 903 | } |
| 904 | } else if (name == "java.lang.Object java.lang.ThreadLocal.get()") { |
| 905 | std::string caller(PrettyMethod(shadow_frame->GetLink()->GetMethod())); |
| 906 | if (caller == "java.lang.String java.lang.IntegralToString.convertInt(java.lang.AbstractStringBuilder, int)") { |
| 907 | // Allocate non-threadlocal buffer. |
| 908 | result->SetL(mirror::CharArray::Alloc(self, 11)); |
| 909 | } else { |
| 910 | self->ThrowNewException(self->GetCurrentLocationForThrow(), "Ljava/lang/InternalError;", |
| 911 | "Unimplemented ThreadLocal.get"); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 912 | } |
| 913 | } else { |
| 914 | // Not special, continue with regular interpreter execution. |
| 915 | artInterpreterToInterpreterBridge(self, mh, code_item, shadow_frame, result); |
| 916 | } |
| 917 | } |
| 918 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 919 | // Explicit DoCall template function declarations. |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 920 | #define EXPLICIT_DO_CALL_TEMPLATE_DECL(_is_range, _do_assignability_check) \ |
| 921 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) \ |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 922 | bool DoCall<_is_range, _do_assignability_check>(ArtMethod* method, Thread* self, \ |
| 923 | ShadowFrame& shadow_frame, \ |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 924 | const Instruction* inst, uint16_t inst_data, \ |
| 925 | JValue* result) |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 926 | EXPLICIT_DO_CALL_TEMPLATE_DECL(false, false); |
| 927 | EXPLICIT_DO_CALL_TEMPLATE_DECL(false, true); |
| 928 | EXPLICIT_DO_CALL_TEMPLATE_DECL(true, false); |
| 929 | EXPLICIT_DO_CALL_TEMPLATE_DECL(true, true); |
| 930 | #undef EXPLICIT_DO_CALL_TEMPLATE_DECL |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 931 | |
| 932 | // Explicit DoFilledNewArray template function declarations. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 933 | #define EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(_is_range_, _check, _transaction_active) \ |
| 934 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) \ |
| 935 | bool DoFilledNewArray<_is_range_, _check, _transaction_active>(const Instruction* inst, \ |
| 936 | const ShadowFrame& shadow_frame, \ |
| 937 | Thread* self, JValue* result) |
| 938 | #define EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(_transaction_active) \ |
| 939 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, false, _transaction_active); \ |
| 940 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, true, _transaction_active); \ |
| 941 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, false, _transaction_active); \ |
| 942 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, true, _transaction_active) |
| 943 | EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(false); |
| 944 | EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(true); |
| 945 | #undef EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 946 | #undef EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL |
| 947 | |
| 948 | } // namespace interpreter |
| 949 | } // namespace art |