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 | |
Andreas Gampe | f0e128a | 2015-02-27 20:08:34 -0800 | [diff] [blame] | 19 | #include <cmath> |
| 20 | |
Daniel Mihalyi | eb07669 | 2014-08-22 17:33:31 +0200 | [diff] [blame] | 21 | #include "debugger.h" |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 22 | #include "mirror/array-inl.h" |
Andreas Gampe | 2969bcd | 2015-03-09 12:57:41 -0700 | [diff] [blame] | 23 | #include "unstarted_runtime.h" |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 24 | #include "verifier/method_verifier.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 25 | |
| 26 | namespace art { |
| 27 | namespace interpreter { |
| 28 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 29 | void ThrowNullPointerExceptionFromInterpreter() { |
| 30 | ThrowNullPointerExceptionFromDexPC(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check> |
| 34 | bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, |
| 35 | uint16_t inst_data) { |
| 36 | const bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead); |
| 37 | const uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
| 38 | ArtField* f = FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self, |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 39 | Primitive::ComponentSize(field_type)); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 40 | if (UNLIKELY(f == nullptr)) { |
| 41 | CHECK(self->IsExceptionPending()); |
| 42 | return false; |
| 43 | } |
| 44 | Object* obj; |
| 45 | if (is_static) { |
| 46 | obj = f->GetDeclaringClass(); |
| 47 | } else { |
| 48 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 49 | if (UNLIKELY(obj == nullptr)) { |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 50 | ThrowNullPointerExceptionForFieldAccess(f, true); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 51 | return false; |
| 52 | } |
| 53 | } |
Sebastien Hertz | 1edbd8e | 2014-07-16 20:00:11 +0200 | [diff] [blame] | 54 | f->GetDeclaringClass()->AssertInitializedOrInitializingInThread(self); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 55 | // Report this field access to instrumentation if needed. |
| 56 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 57 | if (UNLIKELY(instrumentation->HasFieldReadListeners())) { |
| 58 | Object* this_object = f->IsStatic() ? nullptr : obj; |
| 59 | instrumentation->FieldReadEvent(self, this_object, shadow_frame.GetMethod(), |
| 60 | shadow_frame.GetDexPC(), f); |
| 61 | } |
| 62 | uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data); |
| 63 | switch (field_type) { |
| 64 | case Primitive::kPrimBoolean: |
| 65 | shadow_frame.SetVReg(vregA, f->GetBoolean(obj)); |
| 66 | break; |
| 67 | case Primitive::kPrimByte: |
| 68 | shadow_frame.SetVReg(vregA, f->GetByte(obj)); |
| 69 | break; |
| 70 | case Primitive::kPrimChar: |
| 71 | shadow_frame.SetVReg(vregA, f->GetChar(obj)); |
| 72 | break; |
| 73 | case Primitive::kPrimShort: |
| 74 | shadow_frame.SetVReg(vregA, f->GetShort(obj)); |
| 75 | break; |
| 76 | case Primitive::kPrimInt: |
| 77 | shadow_frame.SetVReg(vregA, f->GetInt(obj)); |
| 78 | break; |
| 79 | case Primitive::kPrimLong: |
| 80 | shadow_frame.SetVRegLong(vregA, f->GetLong(obj)); |
| 81 | break; |
| 82 | case Primitive::kPrimNot: |
| 83 | shadow_frame.SetVRegReference(vregA, f->GetObject(obj)); |
| 84 | break; |
| 85 | default: |
| 86 | LOG(FATAL) << "Unreachable: " << field_type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 87 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 88 | } |
| 89 | return true; |
| 90 | } |
| 91 | |
| 92 | // Explicitly instantiate all DoFieldGet functions. |
| 93 | #define EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, _do_check) \ |
| 94 | template bool DoFieldGet<_find_type, _field_type, _do_check>(Thread* self, \ |
| 95 | ShadowFrame& shadow_frame, \ |
| 96 | const Instruction* inst, \ |
| 97 | uint16_t inst_data) |
| 98 | |
| 99 | #define EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
| 100 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, false); \ |
| 101 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, true); |
| 102 | |
| 103 | // iget-XXX |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 104 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimBoolean) |
| 105 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimByte) |
| 106 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimChar) |
| 107 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimShort) |
| 108 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimInt) |
| 109 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimLong) |
| 110 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstanceObjectRead, Primitive::kPrimNot) |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 111 | |
| 112 | // sget-XXX |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 113 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimBoolean) |
| 114 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimByte) |
| 115 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimChar) |
| 116 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimShort) |
| 117 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimInt) |
| 118 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimLong) |
| 119 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticObjectRead, Primitive::kPrimNot) |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 120 | |
| 121 | #undef EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL |
| 122 | #undef EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL |
| 123 | |
| 124 | // Handles iget-quick, iget-wide-quick and iget-object-quick instructions. |
| 125 | // Returns true on success, otherwise throws an exception and returns false. |
| 126 | template<Primitive::Type field_type> |
| 127 | bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) { |
| 128 | Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 129 | if (UNLIKELY(obj == nullptr)) { |
| 130 | // We lost the reference to the field index so we cannot get a more |
| 131 | // precised exception message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 132 | ThrowNullPointerExceptionFromDexPC(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 133 | return false; |
| 134 | } |
| 135 | MemberOffset field_offset(inst->VRegC_22c()); |
| 136 | // Report this field access to instrumentation if needed. Since we only have the offset of |
| 137 | // the field from the base of the object, we need to look for it first. |
| 138 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 139 | if (UNLIKELY(instrumentation->HasFieldReadListeners())) { |
| 140 | ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(), |
| 141 | field_offset.Uint32Value()); |
| 142 | DCHECK(f != nullptr); |
| 143 | DCHECK(!f->IsStatic()); |
| 144 | instrumentation->FieldReadEvent(Thread::Current(), obj, shadow_frame.GetMethod(), |
| 145 | shadow_frame.GetDexPC(), f); |
| 146 | } |
| 147 | // Note: iget-x-quick instructions are only for non-volatile fields. |
| 148 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
| 149 | switch (field_type) { |
| 150 | case Primitive::kPrimInt: |
| 151 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetField32(field_offset))); |
| 152 | break; |
Mathieu Chartier | ffc605c | 2014-12-10 10:35:44 -0800 | [diff] [blame] | 153 | case Primitive::kPrimBoolean: |
| 154 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldBoolean(field_offset))); |
| 155 | break; |
| 156 | case Primitive::kPrimByte: |
| 157 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldByte(field_offset))); |
| 158 | break; |
| 159 | case Primitive::kPrimChar: |
| 160 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldChar(field_offset))); |
| 161 | break; |
| 162 | case Primitive::kPrimShort: |
| 163 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldShort(field_offset))); |
| 164 | break; |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 165 | case Primitive::kPrimLong: |
| 166 | shadow_frame.SetVRegLong(vregA, static_cast<int64_t>(obj->GetField64(field_offset))); |
| 167 | break; |
| 168 | case Primitive::kPrimNot: |
| 169 | shadow_frame.SetVRegReference(vregA, obj->GetFieldObject<mirror::Object>(field_offset)); |
| 170 | break; |
| 171 | default: |
| 172 | LOG(FATAL) << "Unreachable: " << field_type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 173 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 174 | } |
| 175 | return true; |
| 176 | } |
| 177 | |
| 178 | // Explicitly instantiate all DoIGetQuick functions. |
| 179 | #define EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(_field_type) \ |
| 180 | template bool DoIGetQuick<_field_type>(ShadowFrame& shadow_frame, const Instruction* inst, \ |
| 181 | uint16_t inst_data) |
| 182 | |
Mathieu Chartier | ffc605c | 2014-12-10 10:35:44 -0800 | [diff] [blame] | 183 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimInt); // iget-quick. |
| 184 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimBoolean); // iget-boolean-quick. |
| 185 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimByte); // iget-byte-quick. |
| 186 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimChar); // iget-char-quick. |
| 187 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimShort); // iget-short-quick. |
| 188 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimLong); // iget-wide-quick. |
| 189 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimNot); // iget-object-quick. |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 190 | #undef EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL |
| 191 | |
| 192 | template<Primitive::Type field_type> |
| 193 | static JValue GetFieldValue(const ShadowFrame& shadow_frame, uint32_t vreg) |
| 194 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 195 | JValue field_value; |
| 196 | switch (field_type) { |
| 197 | case Primitive::kPrimBoolean: |
| 198 | field_value.SetZ(static_cast<uint8_t>(shadow_frame.GetVReg(vreg))); |
| 199 | break; |
| 200 | case Primitive::kPrimByte: |
| 201 | field_value.SetB(static_cast<int8_t>(shadow_frame.GetVReg(vreg))); |
| 202 | break; |
| 203 | case Primitive::kPrimChar: |
| 204 | field_value.SetC(static_cast<uint16_t>(shadow_frame.GetVReg(vreg))); |
| 205 | break; |
| 206 | case Primitive::kPrimShort: |
| 207 | field_value.SetS(static_cast<int16_t>(shadow_frame.GetVReg(vreg))); |
| 208 | break; |
| 209 | case Primitive::kPrimInt: |
| 210 | field_value.SetI(shadow_frame.GetVReg(vreg)); |
| 211 | break; |
| 212 | case Primitive::kPrimLong: |
| 213 | field_value.SetJ(shadow_frame.GetVRegLong(vreg)); |
| 214 | break; |
| 215 | case Primitive::kPrimNot: |
| 216 | field_value.SetL(shadow_frame.GetVRegReference(vreg)); |
| 217 | break; |
| 218 | default: |
| 219 | LOG(FATAL) << "Unreachable: " << field_type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 220 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 221 | } |
| 222 | return field_value; |
| 223 | } |
| 224 | |
| 225 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check, |
| 226 | bool transaction_active> |
| 227 | bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst, |
| 228 | uint16_t inst_data) { |
| 229 | bool do_assignability_check = do_access_check; |
| 230 | bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite); |
| 231 | uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
| 232 | ArtField* f = FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self, |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 233 | Primitive::ComponentSize(field_type)); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 234 | if (UNLIKELY(f == nullptr)) { |
| 235 | CHECK(self->IsExceptionPending()); |
| 236 | return false; |
| 237 | } |
| 238 | Object* obj; |
| 239 | if (is_static) { |
| 240 | obj = f->GetDeclaringClass(); |
| 241 | } else { |
| 242 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 243 | if (UNLIKELY(obj == nullptr)) { |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 244 | ThrowNullPointerExceptionForFieldAccess(f, false); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 245 | return false; |
| 246 | } |
| 247 | } |
Sebastien Hertz | 1edbd8e | 2014-07-16 20:00:11 +0200 | [diff] [blame] | 248 | f->GetDeclaringClass()->AssertInitializedOrInitializingInThread(self); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 249 | uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data); |
| 250 | // Report this field access to instrumentation if needed. Since we only have the offset of |
| 251 | // the field from the base of the object, we need to look for it first. |
| 252 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 253 | if (UNLIKELY(instrumentation->HasFieldWriteListeners())) { |
| 254 | JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA); |
| 255 | Object* this_object = f->IsStatic() ? nullptr : obj; |
| 256 | instrumentation->FieldWriteEvent(self, this_object, shadow_frame.GetMethod(), |
| 257 | shadow_frame.GetDexPC(), f, field_value); |
| 258 | } |
| 259 | switch (field_type) { |
| 260 | case Primitive::kPrimBoolean: |
| 261 | f->SetBoolean<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 262 | break; |
| 263 | case Primitive::kPrimByte: |
| 264 | f->SetByte<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 265 | break; |
| 266 | case Primitive::kPrimChar: |
| 267 | f->SetChar<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 268 | break; |
| 269 | case Primitive::kPrimShort: |
| 270 | f->SetShort<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 271 | break; |
| 272 | case Primitive::kPrimInt: |
| 273 | f->SetInt<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
| 274 | break; |
| 275 | case Primitive::kPrimLong: |
| 276 | f->SetLong<transaction_active>(obj, shadow_frame.GetVRegLong(vregA)); |
| 277 | break; |
| 278 | case Primitive::kPrimNot: { |
| 279 | Object* reg = shadow_frame.GetVRegReference(vregA); |
| 280 | if (do_assignability_check && reg != nullptr) { |
| 281 | // FieldHelper::GetType can resolve classes, use a handle wrapper which will restore the |
| 282 | // object in the destructor. |
| 283 | Class* field_class; |
| 284 | { |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 285 | StackHandleScope<2> hs(self); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 286 | HandleWrapper<mirror::Object> h_reg(hs.NewHandleWrapper(®)); |
| 287 | HandleWrapper<mirror::Object> h_obj(hs.NewHandleWrapper(&obj)); |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 288 | field_class = f->GetType<true>(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 289 | } |
| 290 | if (!reg->VerifierInstanceOf(field_class)) { |
| 291 | // This should never happen. |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 292 | std::string temp1, temp2, temp3; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 293 | self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;", |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 294 | "Put '%s' that is not instance of field '%s' in '%s'", |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 295 | reg->GetClass()->GetDescriptor(&temp1), |
| 296 | field_class->GetDescriptor(&temp2), |
| 297 | f->GetDeclaringClass()->GetDescriptor(&temp3)); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 298 | return false; |
| 299 | } |
| 300 | } |
| 301 | f->SetObj<transaction_active>(obj, reg); |
| 302 | break; |
| 303 | } |
| 304 | default: |
| 305 | LOG(FATAL) << "Unreachable: " << field_type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 306 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 307 | } |
| 308 | return true; |
| 309 | } |
| 310 | |
| 311 | // Explicitly instantiate all DoFieldPut functions. |
| 312 | #define EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, _do_check, _transaction_active) \ |
| 313 | template bool DoFieldPut<_find_type, _field_type, _do_check, _transaction_active>(Thread* self, \ |
| 314 | const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) |
| 315 | |
| 316 | #define EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
| 317 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, false); \ |
| 318 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, false); \ |
| 319 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, true); \ |
| 320 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, true); |
| 321 | |
| 322 | // iput-XXX |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 323 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimBoolean) |
| 324 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimByte) |
| 325 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimChar) |
| 326 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimShort) |
| 327 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimInt) |
| 328 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimLong) |
| 329 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstanceObjectWrite, Primitive::kPrimNot) |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 330 | |
| 331 | // sput-XXX |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 332 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimBoolean) |
| 333 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimByte) |
| 334 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimChar) |
| 335 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimShort) |
| 336 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimInt) |
| 337 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimLong) |
| 338 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticObjectWrite, Primitive::kPrimNot) |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 339 | |
| 340 | #undef EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL |
| 341 | #undef EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL |
| 342 | |
| 343 | template<Primitive::Type field_type, bool transaction_active> |
| 344 | bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) { |
| 345 | Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 346 | if (UNLIKELY(obj == nullptr)) { |
| 347 | // We lost the reference to the field index so we cannot get a more |
| 348 | // precised exception message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 349 | ThrowNullPointerExceptionFromDexPC(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 350 | return false; |
| 351 | } |
| 352 | MemberOffset field_offset(inst->VRegC_22c()); |
| 353 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
| 354 | // Report this field modification to instrumentation if needed. Since we only have the offset of |
| 355 | // the field from the base of the object, we need to look for it first. |
| 356 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 357 | if (UNLIKELY(instrumentation->HasFieldWriteListeners())) { |
| 358 | ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(), |
| 359 | field_offset.Uint32Value()); |
| 360 | DCHECK(f != nullptr); |
| 361 | DCHECK(!f->IsStatic()); |
| 362 | JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA); |
| 363 | instrumentation->FieldWriteEvent(Thread::Current(), obj, shadow_frame.GetMethod(), |
| 364 | shadow_frame.GetDexPC(), f, field_value); |
| 365 | } |
| 366 | // Note: iput-x-quick instructions are only for non-volatile fields. |
| 367 | switch (field_type) { |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 368 | case Primitive::kPrimBoolean: |
| 369 | obj->SetFieldBoolean<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 370 | break; |
| 371 | case Primitive::kPrimByte: |
| 372 | obj->SetFieldByte<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 373 | break; |
| 374 | case Primitive::kPrimChar: |
| 375 | obj->SetFieldChar<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 376 | break; |
| 377 | case Primitive::kPrimShort: |
| 378 | obj->SetFieldShort<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 379 | break; |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 380 | case Primitive::kPrimInt: |
| 381 | obj->SetField32<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 382 | break; |
| 383 | case Primitive::kPrimLong: |
| 384 | obj->SetField64<transaction_active>(field_offset, shadow_frame.GetVRegLong(vregA)); |
| 385 | break; |
| 386 | case Primitive::kPrimNot: |
| 387 | obj->SetFieldObject<transaction_active>(field_offset, shadow_frame.GetVRegReference(vregA)); |
| 388 | break; |
| 389 | default: |
| 390 | LOG(FATAL) << "Unreachable: " << field_type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 391 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 392 | } |
| 393 | return true; |
| 394 | } |
| 395 | |
| 396 | // Explicitly instantiate all DoIPutQuick functions. |
| 397 | #define EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, _transaction_active) \ |
| 398 | template bool DoIPutQuick<_field_type, _transaction_active>(const ShadowFrame& shadow_frame, \ |
| 399 | const Instruction* inst, \ |
| 400 | uint16_t inst_data) |
| 401 | |
| 402 | #define EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(_field_type) \ |
| 403 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, false); \ |
| 404 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, true); |
| 405 | |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 406 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimInt) // iput-quick. |
| 407 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimBoolean) // iput-boolean-quick. |
| 408 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimByte) // iput-byte-quick. |
| 409 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimChar) // iput-char-quick. |
| 410 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimShort) // iput-short-quick. |
| 411 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimLong) // iput-wide-quick. |
| 412 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimNot) // iput-object-quick. |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 413 | #undef EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL |
| 414 | #undef EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL |
| 415 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 416 | uint32_t FindNextInstructionFollowingException( |
| 417 | Thread* self, ShadowFrame& shadow_frame, uint32_t dex_pc, |
| 418 | const instrumentation::Instrumentation* instrumentation) { |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 419 | self->VerifyStack(); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 420 | StackHandleScope<2> hs(self); |
Nicolas Geoffray | 14691c5 | 2015-03-05 10:40:17 +0000 | [diff] [blame] | 421 | Handle<mirror::Throwable> exception(hs.NewHandle(self->GetException())); |
Nicolas Geoffray | 7642cfc | 2015-02-26 10:56:09 +0000 | [diff] [blame] | 422 | if (instrumentation->HasExceptionCaughtListeners() |
| 423 | && self->IsExceptionThrownByCurrentMethod(exception.Get())) { |
Nicolas Geoffray | 14691c5 | 2015-03-05 10:40:17 +0000 | [diff] [blame] | 424 | instrumentation->ExceptionCaughtEvent(self, exception.Get()); |
Sebastien Hertz | 9f10203 | 2014-05-23 08:59:42 +0200 | [diff] [blame] | 425 | } |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 426 | bool clear_exception = false; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 427 | uint32_t found_dex_pc = shadow_frame.GetMethod()->FindCatchBlock( |
| 428 | hs.NewHandle(exception->GetClass()), dex_pc, &clear_exception); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 429 | if (found_dex_pc == DexFile::kDexNoIndex) { |
Nicolas Geoffray | 7642cfc | 2015-02-26 10:56:09 +0000 | [diff] [blame] | 430 | // Exception is not caught by the current method. We will unwind to the |
| 431 | // caller. Notify any instrumentation listener. |
Sebastien Hertz | 9f10203 | 2014-05-23 08:59:42 +0200 | [diff] [blame] | 432 | instrumentation->MethodUnwindEvent(self, shadow_frame.GetThisObject(), |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 433 | shadow_frame.GetMethod(), dex_pc); |
| 434 | } else { |
Nicolas Geoffray | 7642cfc | 2015-02-26 10:56:09 +0000 | [diff] [blame] | 435 | // Exception is caught in the current method. We will jump to the found_dex_pc. |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 436 | if (clear_exception) { |
| 437 | self->ClearException(); |
| 438 | } |
| 439 | } |
| 440 | return found_dex_pc; |
| 441 | } |
| 442 | |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 443 | void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame) { |
| 444 | LOG(FATAL) << "Unexpected instruction: " |
| 445 | << inst->DumpString(shadow_frame.GetMethod()->GetDexFile()); |
| 446 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 449 | // 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] | 450 | static inline void AssignRegister(ShadowFrame* new_shadow_frame, const ShadowFrame& shadow_frame, |
| 451 | size_t dest_reg, size_t src_reg) |
| 452 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Andreas Gampe | 7104cbf | 2014-03-21 11:44:43 -0700 | [diff] [blame] | 453 | // Uint required, so that sign extension does not make this wrong on 64b systems |
| 454 | uint32_t src_value = shadow_frame.GetVReg(src_reg); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 455 | mirror::Object* o = shadow_frame.GetVRegReference<kVerifyNone>(src_reg); |
Igor Murashkin | c449e8b | 2015-06-10 15:56:42 -0700 | [diff] [blame^] | 456 | |
| 457 | // If both register locations contains the same value, the register probably holds a reference. |
| 458 | // Note: As an optimization, non-moving collectors leave a stale reference value |
| 459 | // in the references array even after the original vreg was overwritten to a non-reference. |
Andreas Gampe | 7104cbf | 2014-03-21 11:44:43 -0700 | [diff] [blame] | 460 | if (src_value == reinterpret_cast<uintptr_t>(o)) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 461 | new_shadow_frame->SetVRegReference(dest_reg, o); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 462 | } else { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 463 | new_shadow_frame->SetVReg(dest_reg, src_value); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 464 | } |
| 465 | } |
| 466 | |
Sebastien Hertz | 45b1597 | 2015-04-03 16:07:05 +0200 | [diff] [blame] | 467 | void AbortTransactionF(Thread* self, const char* fmt, ...) { |
Mathieu Chartier | b2c7ead | 2014-04-29 11:13:16 -0700 | [diff] [blame] | 468 | va_list args; |
| 469 | va_start(args, fmt); |
Sebastien Hertz | 45b1597 | 2015-04-03 16:07:05 +0200 | [diff] [blame] | 470 | AbortTransactionV(self, fmt, args); |
| 471 | va_end(args); |
| 472 | } |
| 473 | |
| 474 | void AbortTransactionV(Thread* self, const char* fmt, va_list args) { |
| 475 | CHECK(Runtime::Current()->IsActiveTransaction()); |
| 476 | // Constructs abort message. |
Sebastien Hertz | 1c80bec | 2015-02-03 11:58:06 +0100 | [diff] [blame] | 477 | std::string abort_msg; |
| 478 | StringAppendV(&abort_msg, fmt, args); |
| 479 | // Throws an exception so we can abort the transaction and rollback every change. |
Sebastien Hertz | 2fd7e69 | 2015-04-02 11:11:19 +0200 | [diff] [blame] | 480 | Runtime::Current()->AbortTransactionAndThrowAbortError(self, abort_msg); |
Mathieu Chartier | b2c7ead | 2014-04-29 11:13:16 -0700 | [diff] [blame] | 481 | } |
| 482 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 483 | template<bool is_range, bool do_assignability_check> |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 484 | bool DoCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame, |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 485 | const Instruction* inst, uint16_t inst_data, JValue* result) { |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 486 | bool string_init = false; |
| 487 | // Replace calls to String.<init> with equivalent StringFactory call. |
| 488 | if (called_method->GetDeclaringClass()->IsStringClass() && called_method->IsConstructor()) { |
| 489 | ScopedObjectAccessUnchecked soa(self); |
| 490 | jmethodID mid = soa.EncodeMethod(called_method); |
| 491 | called_method = soa.DecodeMethod(WellKnownClasses::StringInitToStringFactoryMethodID(mid)); |
| 492 | string_init = true; |
| 493 | } |
| 494 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 495 | // Compute method information. |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 496 | const DexFile::CodeItem* code_item = called_method->GetCodeItem(); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 497 | 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] | 498 | uint16_t num_regs; |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 499 | if (LIKELY(code_item != nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 500 | num_regs = code_item->registers_size_; |
Jeff Hao | 9651d9b | 2015-04-29 15:58:17 -0700 | [diff] [blame] | 501 | DCHECK_EQ(string_init ? num_ins - 1 : num_ins, code_item->ins_size_); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 502 | } else { |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 503 | DCHECK(called_method->IsNative() || called_method->IsProxyMethod()); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 504 | num_regs = num_ins; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 505 | if (string_init) { |
| 506 | // The new StringFactory call is static and has one fewer argument. |
| 507 | num_regs--; |
| 508 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 509 | } |
| 510 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 511 | // Allocate shadow frame on the stack. |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 512 | const char* old_cause = self->StartAssertNoThreadSuspension("DoCall"); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 513 | void* memory = alloca(ShadowFrame::ComputeSize(num_regs)); |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 514 | ShadowFrame* new_shadow_frame(ShadowFrame::Create(num_regs, &shadow_frame, called_method, 0, |
| 515 | memory)); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 516 | |
| 517 | // Initialize new shadow frame. |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 518 | size_t first_dest_reg = num_regs - num_ins; |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 519 | if (do_assignability_check) { |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 520 | // Slow path. |
| 521 | // We might need to do class loading, which incurs a thread state change to kNative. So |
| 522 | // register the shadow frame as under construction and allow suspension again. |
Mingyao Yang | 1f2d3ba | 2015-05-18 12:12:50 -0700 | [diff] [blame] | 523 | ScopedStackedShadowFramePusher pusher( |
Sebastien Hertz | f795869 | 2015-06-09 14:09:14 +0200 | [diff] [blame] | 524 | self, new_shadow_frame, StackedShadowFrameType::kShadowFrameUnderConstruction); |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 525 | self->EndAssertNoThreadSuspension(old_cause); |
| 526 | |
| 527 | // 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] | 528 | // to get the exact type of each reference argument. |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 529 | const DexFile::TypeList* params = new_shadow_frame->GetMethod()->GetParameterTypeList(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 530 | uint32_t shorty_len = 0; |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 531 | const char* shorty = new_shadow_frame->GetMethod()->GetShorty(&shorty_len); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 532 | |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 533 | // TODO: find a cleaner way to separate non-range and range information without duplicating |
| 534 | // code. |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 535 | uint32_t arg[5]; // only used in invoke-XXX. |
| 536 | uint32_t vregC; // only used in invoke-XXX-range. |
| 537 | if (is_range) { |
| 538 | vregC = inst->VRegC_3rc(); |
| 539 | } else { |
Ian Rogers | 29a2648 | 2014-05-02 15:27:29 -0700 | [diff] [blame] | 540 | inst->GetVarArgs(arg, inst_data); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 541 | } |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 542 | |
| 543 | // Handle receiver apart since it's not part of the shorty. |
| 544 | size_t dest_reg = first_dest_reg; |
| 545 | size_t arg_offset = 0; |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 546 | if (!new_shadow_frame->GetMethod()->IsStatic()) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 547 | size_t receiver_reg = is_range ? vregC : arg[0]; |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 548 | new_shadow_frame->SetVRegReference(dest_reg, shadow_frame.GetVRegReference(receiver_reg)); |
| 549 | ++dest_reg; |
| 550 | ++arg_offset; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 551 | } else if (string_init) { |
| 552 | // Skip the referrer for the new static StringFactory call. |
| 553 | ++dest_reg; |
| 554 | ++arg_offset; |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 555 | } |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 556 | 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] | 557 | DCHECK_LT(shorty_pos + 1, shorty_len); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 558 | const size_t src_reg = (is_range) ? vregC + arg_offset : arg[arg_offset]; |
| 559 | switch (shorty[shorty_pos + 1]) { |
| 560 | case 'L': { |
| 561 | Object* o = shadow_frame.GetVRegReference(src_reg); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 562 | if (do_assignability_check && o != nullptr) { |
Ian Rogers | a048560 | 2014-12-02 15:48:04 -0800 | [diff] [blame] | 563 | Class* arg_type = |
| 564 | new_shadow_frame->GetMethod()->GetClassFromTypeIndex( |
| 565 | params->GetTypeItem(shorty_pos).type_idx_, true); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 566 | if (arg_type == nullptr) { |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 567 | CHECK(self->IsExceptionPending()); |
| 568 | return false; |
| 569 | } |
| 570 | if (!o->VerifierInstanceOf(arg_type)) { |
| 571 | // This should never happen. |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 572 | std::string temp1, temp2; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 573 | self->ThrowNewExceptionF("Ljava/lang/VirtualMachineError;", |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 574 | "Invoking %s with bad arg %d, type '%s' not instance of '%s'", |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 575 | new_shadow_frame->GetMethod()->GetName(), shorty_pos, |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 576 | o->GetClass()->GetDescriptor(&temp1), |
| 577 | arg_type->GetDescriptor(&temp2)); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 578 | return false; |
| 579 | } |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 580 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 581 | new_shadow_frame->SetVRegReference(dest_reg, o); |
| 582 | break; |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 583 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 584 | case 'J': case 'D': { |
| 585 | uint64_t wide_value = (static_cast<uint64_t>(shadow_frame.GetVReg(src_reg + 1)) << 32) | |
| 586 | static_cast<uint32_t>(shadow_frame.GetVReg(src_reg)); |
| 587 | new_shadow_frame->SetVRegLong(dest_reg, wide_value); |
| 588 | ++dest_reg; |
| 589 | ++arg_offset; |
| 590 | break; |
| 591 | } |
| 592 | default: |
| 593 | new_shadow_frame->SetVReg(dest_reg, shadow_frame.GetVReg(src_reg)); |
| 594 | break; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 595 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 596 | } |
| 597 | } else { |
| 598 | // Fast path: no extra checks. |
| 599 | if (is_range) { |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 600 | uint16_t first_src_reg = inst->VRegC_3rc(); |
| 601 | if (string_init) { |
| 602 | // Skip the referrer for the new static StringFactory call. |
| 603 | ++first_src_reg; |
| 604 | ++first_dest_reg; |
| 605 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 606 | for (size_t src_reg = first_src_reg, dest_reg = first_dest_reg; dest_reg < num_regs; |
| 607 | ++dest_reg, ++src_reg) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 608 | AssignRegister(new_shadow_frame, shadow_frame, dest_reg, src_reg); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 609 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 610 | } else { |
| 611 | DCHECK_LE(num_ins, 5U); |
| 612 | uint16_t regList = inst->Fetch16(2); |
| 613 | uint16_t count = num_ins; |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 614 | size_t arg_index = 0; |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 615 | if (count == 5) { |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 616 | AssignRegister(new_shadow_frame, shadow_frame, first_dest_reg + 4U, |
| 617 | (inst_data >> 8) & 0x0f); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 618 | --count; |
Kenny Root | 8c638bc | 2015-05-14 16:48:22 -0700 | [diff] [blame] | 619 | } |
| 620 | if (string_init) { |
| 621 | // Skip the referrer for the new static StringFactory call. |
| 622 | regList >>= 4; |
| 623 | ++first_dest_reg; |
| 624 | --count; |
| 625 | } |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 626 | for (; arg_index < count; ++arg_index, regList >>= 4) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 627 | 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] | 628 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 629 | } |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 630 | self->EndAssertNoThreadSuspension(old_cause); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 631 | } |
| 632 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 633 | // Do the call now. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 634 | if (LIKELY(Runtime::Current()->IsStarted())) { |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 635 | if (kIsDebugBuild && new_shadow_frame->GetMethod()->GetEntryPointFromInterpreter() == nullptr) { |
| 636 | LOG(FATAL) << "Attempt to invoke non-executable method: " |
| 637 | << PrettyMethod(new_shadow_frame->GetMethod()); |
| 638 | UNREACHABLE(); |
Ian Rogers | 1d99e45 | 2014-01-02 17:36:41 -0800 | [diff] [blame] | 639 | } |
Hiroshi Yamauchi | 563b47c | 2014-02-28 17:18:37 -0800 | [diff] [blame] | 640 | if (kIsDebugBuild && Runtime::Current()->GetInstrumentation()->IsForcedInterpretOnly() && |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 641 | !new_shadow_frame->GetMethod()->IsNative() && |
| 642 | !new_shadow_frame->GetMethod()->IsProxyMethod() && |
| 643 | new_shadow_frame->GetMethod()->GetEntryPointFromInterpreter() |
| 644 | == artInterpreterToCompiledCodeBridge) { |
| 645 | LOG(FATAL) << "Attempt to call compiled code when -Xint: " |
| 646 | << PrettyMethod(new_shadow_frame->GetMethod()); |
| 647 | UNREACHABLE(); |
Hiroshi Yamauchi | 563b47c | 2014-02-28 17:18:37 -0800 | [diff] [blame] | 648 | } |
Daniel Mihalyi | eb07669 | 2014-08-22 17:33:31 +0200 | [diff] [blame] | 649 | // Force the use of interpreter when it is required by the debugger. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 650 | EntryPointFromInterpreter* entry; |
Daniel Mihalyi | eb07669 | 2014-08-22 17:33:31 +0200 | [diff] [blame] | 651 | if (UNLIKELY(Dbg::IsForcedInterpreterNeededForCalling(self, new_shadow_frame->GetMethod()))) { |
| 652 | entry = &art::artInterpreterToInterpreterBridge; |
| 653 | } else { |
| 654 | entry = new_shadow_frame->GetMethod()->GetEntryPointFromInterpreter(); |
| 655 | } |
| 656 | entry(self, code_item, new_shadow_frame, result); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 657 | } else { |
Andreas Gampe | 799681b | 2015-05-15 19:24:12 -0700 | [diff] [blame] | 658 | UnstartedRuntime::Invoke(self, code_item, new_shadow_frame, result, first_dest_reg); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 659 | } |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 660 | |
| 661 | if (string_init && !self->IsExceptionPending()) { |
| 662 | // Set the new string result of the StringFactory. |
| 663 | uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); |
| 664 | shadow_frame.SetVRegReference(vregC, result->GetL()); |
| 665 | // Overwrite all potential copies of the original result of the new-instance of string with the |
| 666 | // new result of the StringFactory. Use the verifier to find this set of registers. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 667 | ArtMethod* method = shadow_frame.GetMethod(); |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 668 | MethodReference method_ref = method->ToMethodReference(); |
| 669 | SafeMap<uint32_t, std::set<uint32_t>> string_init_map; |
| 670 | SafeMap<uint32_t, std::set<uint32_t>>* string_init_map_ptr; |
| 671 | MethodRefToStringInitRegMap& method_to_string_init_map = Runtime::Current()->GetStringInitMap(); |
| 672 | auto it = method_to_string_init_map.find(method_ref); |
| 673 | if (it == method_to_string_init_map.end()) { |
| 674 | string_init_map = std::move(verifier::MethodVerifier::FindStringInitMap(method)); |
| 675 | method_to_string_init_map.Overwrite(method_ref, string_init_map); |
| 676 | string_init_map_ptr = &string_init_map; |
| 677 | } else { |
| 678 | string_init_map_ptr = &it->second; |
| 679 | } |
| 680 | if (string_init_map_ptr->size() != 0) { |
| 681 | uint32_t dex_pc = shadow_frame.GetDexPC(); |
| 682 | auto map_it = string_init_map_ptr->find(dex_pc); |
| 683 | if (map_it != string_init_map_ptr->end()) { |
| 684 | const std::set<uint32_t>& reg_set = map_it->second; |
| 685 | for (auto set_it = reg_set.begin(); set_it != reg_set.end(); ++set_it) { |
| 686 | shadow_frame.SetVRegReference(*set_it, result->GetL()); |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 692 | return !self->IsExceptionPending(); |
| 693 | } |
| 694 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 695 | template <bool is_range, bool do_access_check, bool transaction_active> |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 696 | bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame, |
| 697 | Thread* self, JValue* result) { |
| 698 | DCHECK(inst->Opcode() == Instruction::FILLED_NEW_ARRAY || |
| 699 | inst->Opcode() == Instruction::FILLED_NEW_ARRAY_RANGE); |
| 700 | const int32_t length = is_range ? inst->VRegA_3rc() : inst->VRegA_35c(); |
| 701 | if (!is_range) { |
| 702 | // Checks FILLED_NEW_ARRAY's length does not exceed 5 arguments. |
| 703 | CHECK_LE(length, 5); |
| 704 | } |
| 705 | if (UNLIKELY(length < 0)) { |
| 706 | ThrowNegativeArraySizeException(length); |
| 707 | return false; |
| 708 | } |
| 709 | uint16_t type_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c(); |
| 710 | Class* arrayClass = ResolveVerifyAndClinit(type_idx, shadow_frame.GetMethod(), |
| 711 | self, false, do_access_check); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 712 | if (UNLIKELY(arrayClass == nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 713 | DCHECK(self->IsExceptionPending()); |
| 714 | return false; |
| 715 | } |
| 716 | CHECK(arrayClass->IsArrayClass()); |
| 717 | Class* componentClass = arrayClass->GetComponentType(); |
| 718 | if (UNLIKELY(componentClass->IsPrimitive() && !componentClass->IsPrimitiveInt())) { |
| 719 | if (componentClass->IsPrimitiveLong() || componentClass->IsPrimitiveDouble()) { |
| 720 | ThrowRuntimeException("Bad filled array request for type %s", |
| 721 | PrettyDescriptor(componentClass).c_str()); |
| 722 | } else { |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 723 | self->ThrowNewExceptionF("Ljava/lang/InternalError;", |
Brian Carlstrom | 4fa0bcd | 2013-12-10 11:24:21 -0800 | [diff] [blame] | 724 | "Found type %s; filled-new-array not implemented for anything but 'int'", |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 725 | PrettyDescriptor(componentClass).c_str()); |
| 726 | } |
| 727 | return false; |
| 728 | } |
Hiroshi Yamauchi | f0edfc3 | 2014-09-25 11:46:46 -0700 | [diff] [blame] | 729 | Object* newArray = Array::Alloc<true>(self, arrayClass, length, |
| 730 | arrayClass->GetComponentSizeShift(), |
Ian Rogers | 6fac447 | 2014-02-25 17:01:10 -0800 | [diff] [blame] | 731 | Runtime::Current()->GetHeap()->GetCurrentAllocator()); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 732 | if (UNLIKELY(newArray == nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 733 | DCHECK(self->IsExceptionPending()); |
| 734 | return false; |
| 735 | } |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 736 | uint32_t arg[5]; // only used in filled-new-array. |
| 737 | uint32_t vregC; // only used in filled-new-array-range. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 738 | if (is_range) { |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 739 | vregC = inst->VRegC_3rc(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 740 | } else { |
Ian Rogers | 29a2648 | 2014-05-02 15:27:29 -0700 | [diff] [blame] | 741 | inst->GetVarArgs(arg); |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 742 | } |
| 743 | const bool is_primitive_int_component = componentClass->IsPrimitiveInt(); |
| 744 | for (int32_t i = 0; i < length; ++i) { |
| 745 | size_t src_reg = is_range ? vregC + i : arg[i]; |
| 746 | if (is_primitive_int_component) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 747 | newArray->AsIntArray()->SetWithoutChecks<transaction_active>(i, shadow_frame.GetVReg(src_reg)); |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 748 | } else { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 749 | newArray->AsObjectArray<Object>()->SetWithoutChecks<transaction_active>(i, shadow_frame.GetVRegReference(src_reg)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 750 | } |
| 751 | } |
| 752 | |
| 753 | result->SetL(newArray); |
| 754 | return true; |
| 755 | } |
| 756 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 757 | // TODO fix thread analysis: should be SHARED_LOCKS_REQUIRED(Locks::mutator_lock_). |
| 758 | template<typename T> |
| 759 | static void RecordArrayElementsInTransactionImpl(mirror::PrimitiveArray<T>* array, int32_t count) |
| 760 | NO_THREAD_SAFETY_ANALYSIS { |
| 761 | Runtime* runtime = Runtime::Current(); |
| 762 | for (int32_t i = 0; i < count; ++i) { |
| 763 | runtime->RecordWriteArray(array, i, array->GetWithoutChecks(i)); |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | void RecordArrayElementsInTransaction(mirror::Array* array, int32_t count) |
| 768 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 769 | DCHECK(Runtime::Current()->IsActiveTransaction()); |
| 770 | DCHECK(array != nullptr); |
| 771 | DCHECK_LE(count, array->GetLength()); |
| 772 | Primitive::Type primitive_component_type = array->GetClass()->GetComponentType()->GetPrimitiveType(); |
| 773 | switch (primitive_component_type) { |
| 774 | case Primitive::kPrimBoolean: |
| 775 | RecordArrayElementsInTransactionImpl(array->AsBooleanArray(), count); |
| 776 | break; |
| 777 | case Primitive::kPrimByte: |
| 778 | RecordArrayElementsInTransactionImpl(array->AsByteArray(), count); |
| 779 | break; |
| 780 | case Primitive::kPrimChar: |
| 781 | RecordArrayElementsInTransactionImpl(array->AsCharArray(), count); |
| 782 | break; |
| 783 | case Primitive::kPrimShort: |
| 784 | RecordArrayElementsInTransactionImpl(array->AsShortArray(), count); |
| 785 | break; |
| 786 | case Primitive::kPrimInt: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 787 | RecordArrayElementsInTransactionImpl(array->AsIntArray(), count); |
| 788 | break; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 789 | case Primitive::kPrimFloat: |
| 790 | RecordArrayElementsInTransactionImpl(array->AsFloatArray(), count); |
| 791 | break; |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 792 | case Primitive::kPrimLong: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 793 | RecordArrayElementsInTransactionImpl(array->AsLongArray(), count); |
| 794 | break; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 795 | case Primitive::kPrimDouble: |
| 796 | RecordArrayElementsInTransactionImpl(array->AsDoubleArray(), count); |
| 797 | break; |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 798 | default: |
| 799 | LOG(FATAL) << "Unsupported primitive type " << primitive_component_type |
| 800 | << " in fill-array-data"; |
| 801 | break; |
| 802 | } |
| 803 | } |
| 804 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 805 | // Explicit DoCall template function declarations. |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 806 | #define EXPLICIT_DO_CALL_TEMPLATE_DECL(_is_range, _do_assignability_check) \ |
| 807 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) \ |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 808 | bool DoCall<_is_range, _do_assignability_check>(ArtMethod* method, Thread* self, \ |
| 809 | ShadowFrame& shadow_frame, \ |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 810 | const Instruction* inst, uint16_t inst_data, \ |
| 811 | JValue* result) |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 812 | EXPLICIT_DO_CALL_TEMPLATE_DECL(false, false); |
| 813 | EXPLICIT_DO_CALL_TEMPLATE_DECL(false, true); |
| 814 | EXPLICIT_DO_CALL_TEMPLATE_DECL(true, false); |
| 815 | EXPLICIT_DO_CALL_TEMPLATE_DECL(true, true); |
| 816 | #undef EXPLICIT_DO_CALL_TEMPLATE_DECL |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 817 | |
| 818 | // Explicit DoFilledNewArray template function declarations. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 819 | #define EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(_is_range_, _check, _transaction_active) \ |
| 820 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) \ |
| 821 | bool DoFilledNewArray<_is_range_, _check, _transaction_active>(const Instruction* inst, \ |
| 822 | const ShadowFrame& shadow_frame, \ |
| 823 | Thread* self, JValue* result) |
| 824 | #define EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(_transaction_active) \ |
| 825 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, false, _transaction_active); \ |
| 826 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, true, _transaction_active); \ |
| 827 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, false, _transaction_active); \ |
| 828 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, true, _transaction_active) |
| 829 | EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(false); |
| 830 | EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(true); |
| 831 | #undef EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 832 | #undef EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL |
| 833 | |
| 834 | } // namespace interpreter |
| 835 | } // namespace art |