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 | |
Vladimir Marko | 78baed5 | 2018-10-11 10:44:58 +0100 | [diff] [blame] | 21 | #include "base/casts.h" |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 22 | #include "base/enums.h" |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 23 | #include "class_root.h" |
Daniel Mihalyi | eb07669 | 2014-08-22 17:33:31 +0200 | [diff] [blame] | 24 | #include "debugger.h" |
David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 25 | #include "dex/dex_file_types.h" |
Nicolas Geoffray | 7bf2b4f | 2015-07-08 10:11:59 +0000 | [diff] [blame] | 26 | #include "entrypoints/runtime_asm_entrypoints.h" |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 27 | #include "intrinsics_enum.h" |
Tamas Berghammer | dd5e5e9 | 2016-02-12 16:29:00 +0000 | [diff] [blame] | 28 | #include "jit/jit.h" |
Andreas Gampe | c5b7564 | 2018-05-16 15:12:11 -0700 | [diff] [blame] | 29 | #include "jvalue-inl.h" |
Narayan Kamath | 208f857 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 30 | #include "method_handles-inl.h" |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 31 | #include "method_handles.h" |
Andreas Gampe | 8e0f043 | 2018-10-24 13:38:03 -0700 | [diff] [blame] | 32 | #include "mirror/array-alloc-inl.h" |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 33 | #include "mirror/array-inl.h" |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 34 | #include "mirror/class.h" |
Narayan Kamath | 000e188 | 2016-10-24 17:14:25 +0100 | [diff] [blame] | 35 | #include "mirror/emulated_stack_frame.h" |
Andreas Gampe | c6ea7d0 | 2017-02-01 16:46:28 -0800 | [diff] [blame] | 36 | #include "mirror/method_handle_impl-inl.h" |
Andreas Gampe | 52ecb65 | 2018-10-24 15:18:21 -0700 | [diff] [blame^] | 37 | #include "mirror/object_array-alloc-inl.h" |
| 38 | #include "mirror/object_array-inl.h" |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 39 | #include "mirror/var_handle.h" |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 40 | #include "reflection-inl.h" |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 41 | #include "reflection.h" |
Vladimir Marko | 6ec2a1b | 2018-05-22 15:33:48 +0100 | [diff] [blame] | 42 | #include "shadow_frame-inl.h" |
Andreas Gampe | b302592 | 2015-09-01 14:45:00 -0700 | [diff] [blame] | 43 | #include "stack.h" |
Andreas Gampe | 513061a | 2017-06-01 09:17:34 -0700 | [diff] [blame] | 44 | #include "thread-inl.h" |
Chang Xing | bd208d8 | 2017-07-12 14:53:17 -0700 | [diff] [blame] | 45 | #include "transaction.h" |
Orion Hodson | 537a4fe | 2018-05-15 13:57:58 +0100 | [diff] [blame] | 46 | #include "var_handles.h" |
Narayan Kamath | c3b7f1a | 2016-10-19 11:05:04 +0100 | [diff] [blame] | 47 | #include "well_known_classes.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 48 | |
| 49 | namespace art { |
| 50 | namespace interpreter { |
| 51 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 52 | void ThrowNullPointerExceptionFromInterpreter() { |
| 53 | ThrowNullPointerExceptionFromDexPC(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 54 | } |
| 55 | |
David Srbecky | 960327b | 2018-10-25 10:11:59 +0000 | [diff] [blame] | 56 | bool CheckStackOverflow(Thread* self, size_t frame_size) |
| 57 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 58 | bool implicit_check = !Runtime::Current()->ExplicitStackOverflowChecks(); |
| 59 | uint8_t* stack_end = self->GetStackEndForInterpreter(implicit_check); |
| 60 | if (UNLIKELY(__builtin_frame_address(0) < stack_end + frame_size)) { |
| 61 | ThrowStackOverflowError(self); |
| 62 | return false; |
| 63 | } |
| 64 | return true; |
| 65 | } |
| 66 | |
Chang Xing | bd208d8 | 2017-07-12 14:53:17 -0700 | [diff] [blame] | 67 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check, |
| 68 | bool transaction_active> |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 69 | bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, |
| 70 | uint16_t inst_data) { |
| 71 | const bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead); |
| 72 | const uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 73 | ArtField* f = |
| 74 | FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self, |
| 75 | Primitive::ComponentSize(field_type)); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 76 | if (UNLIKELY(f == nullptr)) { |
| 77 | CHECK(self->IsExceptionPending()); |
| 78 | return false; |
| 79 | } |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 80 | ObjPtr<mirror::Object> obj; |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 81 | if (is_static) { |
| 82 | obj = f->GetDeclaringClass(); |
Chang Xing | bd208d8 | 2017-07-12 14:53:17 -0700 | [diff] [blame] | 83 | if (transaction_active) { |
| 84 | if (Runtime::Current()->GetTransaction()->ReadConstraint(obj.Ptr(), f)) { |
| 85 | Runtime::Current()->AbortTransactionAndThrowAbortError(self, "Can't read static fields of " |
| 86 | + obj->PrettyTypeOf() + " since it does not belong to clinit's class."); |
| 87 | return false; |
| 88 | } |
| 89 | } |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 90 | } else { |
| 91 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 92 | if (UNLIKELY(obj == nullptr)) { |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 93 | ThrowNullPointerExceptionForFieldAccess(f, true); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 94 | return false; |
| 95 | } |
| 96 | } |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 97 | |
| 98 | JValue result; |
Alex Light | 084fa37 | 2017-06-16 08:58:34 -0700 | [diff] [blame] | 99 | if (UNLIKELY(!DoFieldGetCommon<field_type>(self, shadow_frame, obj, f, &result))) { |
| 100 | // Instrumentation threw an error! |
| 101 | CHECK(self->IsExceptionPending()); |
| 102 | return false; |
| 103 | } |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 104 | uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data); |
| 105 | switch (field_type) { |
| 106 | case Primitive::kPrimBoolean: |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 107 | shadow_frame.SetVReg(vregA, result.GetZ()); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 108 | break; |
| 109 | case Primitive::kPrimByte: |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 110 | shadow_frame.SetVReg(vregA, result.GetB()); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 111 | break; |
| 112 | case Primitive::kPrimChar: |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 113 | shadow_frame.SetVReg(vregA, result.GetC()); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 114 | break; |
| 115 | case Primitive::kPrimShort: |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 116 | shadow_frame.SetVReg(vregA, result.GetS()); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 117 | break; |
| 118 | case Primitive::kPrimInt: |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 119 | shadow_frame.SetVReg(vregA, result.GetI()); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 120 | break; |
| 121 | case Primitive::kPrimLong: |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 122 | shadow_frame.SetVRegLong(vregA, result.GetJ()); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 123 | break; |
| 124 | case Primitive::kPrimNot: |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 125 | shadow_frame.SetVRegReference(vregA, result.GetL()); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 126 | break; |
| 127 | default: |
| 128 | LOG(FATAL) << "Unreachable: " << field_type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 129 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 130 | } |
| 131 | return true; |
| 132 | } |
| 133 | |
| 134 | // Explicitly instantiate all DoFieldGet functions. |
Chang Xing | bd208d8 | 2017-07-12 14:53:17 -0700 | [diff] [blame] | 135 | #define EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, _do_check, _transaction_active) \ |
| 136 | template bool DoFieldGet<_find_type, _field_type, _do_check, _transaction_active>(Thread* self, \ |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 137 | ShadowFrame& shadow_frame, \ |
| 138 | const Instruction* inst, \ |
| 139 | uint16_t inst_data) |
| 140 | |
| 141 | #define EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
Chang Xing | bd208d8 | 2017-07-12 14:53:17 -0700 | [diff] [blame] | 142 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, false, true); \ |
| 143 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, false, false); \ |
| 144 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, true, true); \ |
| 145 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, true, false); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 146 | |
| 147 | // iget-XXX |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 148 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimBoolean) |
| 149 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimByte) |
| 150 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimChar) |
| 151 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimShort) |
| 152 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimInt) |
| 153 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimLong) |
| 154 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstanceObjectRead, Primitive::kPrimNot) |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 155 | |
| 156 | // sget-XXX |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 157 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimBoolean) |
| 158 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimByte) |
| 159 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimChar) |
| 160 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimShort) |
| 161 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimInt) |
| 162 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimLong) |
| 163 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticObjectRead, Primitive::kPrimNot) |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 164 | |
| 165 | #undef EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL |
| 166 | #undef EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL |
| 167 | |
| 168 | // Handles iget-quick, iget-wide-quick and iget-object-quick instructions. |
| 169 | // Returns true on success, otherwise throws an exception and returns false. |
| 170 | template<Primitive::Type field_type> |
| 171 | bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) { |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 172 | ObjPtr<mirror::Object> obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 173 | if (UNLIKELY(obj == nullptr)) { |
| 174 | // We lost the reference to the field index so we cannot get a more |
| 175 | // precised exception message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 176 | ThrowNullPointerExceptionFromDexPC(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 177 | return false; |
| 178 | } |
| 179 | MemberOffset field_offset(inst->VRegC_22c()); |
| 180 | // Report this field access to instrumentation if needed. Since we only have the offset of |
| 181 | // the field from the base of the object, we need to look for it first. |
| 182 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 183 | if (UNLIKELY(instrumentation->HasFieldReadListeners())) { |
| 184 | ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(), |
| 185 | field_offset.Uint32Value()); |
| 186 | DCHECK(f != nullptr); |
| 187 | DCHECK(!f->IsStatic()); |
Alex Light | 084fa37 | 2017-06-16 08:58:34 -0700 | [diff] [blame] | 188 | Thread* self = Thread::Current(); |
| 189 | StackHandleScope<1> hs(self); |
Mathieu Chartier | a314773 | 2016-10-26 22:57:02 -0700 | [diff] [blame] | 190 | // Save obj in case the instrumentation event has thread suspension. |
| 191 | HandleWrapperObjPtr<mirror::Object> h = hs.NewHandleWrapper(&obj); |
Alex Light | 084fa37 | 2017-06-16 08:58:34 -0700 | [diff] [blame] | 192 | instrumentation->FieldReadEvent(self, |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 193 | obj.Ptr(), |
| 194 | shadow_frame.GetMethod(), |
| 195 | shadow_frame.GetDexPC(), |
| 196 | f); |
Alex Light | 084fa37 | 2017-06-16 08:58:34 -0700 | [diff] [blame] | 197 | if (UNLIKELY(self->IsExceptionPending())) { |
| 198 | return false; |
| 199 | } |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 200 | } |
| 201 | // Note: iget-x-quick instructions are only for non-volatile fields. |
| 202 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
| 203 | switch (field_type) { |
| 204 | case Primitive::kPrimInt: |
| 205 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetField32(field_offset))); |
| 206 | break; |
Mathieu Chartier | ffc605c | 2014-12-10 10:35:44 -0800 | [diff] [blame] | 207 | case Primitive::kPrimBoolean: |
| 208 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldBoolean(field_offset))); |
| 209 | break; |
| 210 | case Primitive::kPrimByte: |
| 211 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldByte(field_offset))); |
| 212 | break; |
| 213 | case Primitive::kPrimChar: |
| 214 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldChar(field_offset))); |
| 215 | break; |
| 216 | case Primitive::kPrimShort: |
| 217 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetFieldShort(field_offset))); |
| 218 | break; |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 219 | case Primitive::kPrimLong: |
| 220 | shadow_frame.SetVRegLong(vregA, static_cast<int64_t>(obj->GetField64(field_offset))); |
| 221 | break; |
| 222 | case Primitive::kPrimNot: |
| 223 | shadow_frame.SetVRegReference(vregA, obj->GetFieldObject<mirror::Object>(field_offset)); |
| 224 | break; |
| 225 | default: |
| 226 | LOG(FATAL) << "Unreachable: " << field_type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 227 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 228 | } |
| 229 | return true; |
| 230 | } |
| 231 | |
| 232 | // Explicitly instantiate all DoIGetQuick functions. |
| 233 | #define EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(_field_type) \ |
| 234 | template bool DoIGetQuick<_field_type>(ShadowFrame& shadow_frame, const Instruction* inst, \ |
| 235 | uint16_t inst_data) |
| 236 | |
Mathieu Chartier | ffc605c | 2014-12-10 10:35:44 -0800 | [diff] [blame] | 237 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimInt); // iget-quick. |
| 238 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimBoolean); // iget-boolean-quick. |
| 239 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimByte); // iget-byte-quick. |
| 240 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimChar); // iget-char-quick. |
| 241 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimShort); // iget-short-quick. |
| 242 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimLong); // iget-wide-quick. |
| 243 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimNot); // iget-object-quick. |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 244 | #undef EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL |
| 245 | |
| 246 | template<Primitive::Type field_type> |
| 247 | static JValue GetFieldValue(const ShadowFrame& shadow_frame, uint32_t vreg) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 248 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 249 | JValue field_value; |
| 250 | switch (field_type) { |
| 251 | case Primitive::kPrimBoolean: |
| 252 | field_value.SetZ(static_cast<uint8_t>(shadow_frame.GetVReg(vreg))); |
| 253 | break; |
| 254 | case Primitive::kPrimByte: |
| 255 | field_value.SetB(static_cast<int8_t>(shadow_frame.GetVReg(vreg))); |
| 256 | break; |
| 257 | case Primitive::kPrimChar: |
| 258 | field_value.SetC(static_cast<uint16_t>(shadow_frame.GetVReg(vreg))); |
| 259 | break; |
| 260 | case Primitive::kPrimShort: |
| 261 | field_value.SetS(static_cast<int16_t>(shadow_frame.GetVReg(vreg))); |
| 262 | break; |
| 263 | case Primitive::kPrimInt: |
| 264 | field_value.SetI(shadow_frame.GetVReg(vreg)); |
| 265 | break; |
| 266 | case Primitive::kPrimLong: |
| 267 | field_value.SetJ(shadow_frame.GetVRegLong(vreg)); |
| 268 | break; |
| 269 | case Primitive::kPrimNot: |
| 270 | field_value.SetL(shadow_frame.GetVRegReference(vreg)); |
| 271 | break; |
| 272 | default: |
| 273 | LOG(FATAL) << "Unreachable: " << field_type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 274 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 275 | } |
| 276 | return field_value; |
| 277 | } |
| 278 | |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 279 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check, |
| 280 | bool transaction_active> |
| 281 | bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst, |
| 282 | uint16_t inst_data) { |
| 283 | const bool do_assignability_check = do_access_check; |
| 284 | bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite); |
| 285 | uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
| 286 | ArtField* f = |
| 287 | FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self, |
| 288 | Primitive::ComponentSize(field_type)); |
| 289 | if (UNLIKELY(f == nullptr)) { |
| 290 | CHECK(self->IsExceptionPending()); |
| 291 | return false; |
| 292 | } |
| 293 | ObjPtr<mirror::Object> obj; |
| 294 | if (is_static) { |
| 295 | obj = f->GetDeclaringClass(); |
Chang Xing | bd208d8 | 2017-07-12 14:53:17 -0700 | [diff] [blame] | 296 | if (transaction_active) { |
| 297 | if (Runtime::Current()->GetTransaction()->WriteConstraint(obj.Ptr(), f)) { |
| 298 | Runtime::Current()->AbortTransactionAndThrowAbortError( |
| 299 | self, "Can't set fields of " + obj->PrettyTypeOf()); |
| 300 | return false; |
| 301 | } |
| 302 | } |
| 303 | |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 304 | } else { |
| 305 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
| 306 | if (UNLIKELY(obj == nullptr)) { |
| 307 | ThrowNullPointerExceptionForFieldAccess(f, false); |
| 308 | return false; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data); |
Orion Hodson | ba28f9f | 2016-10-26 10:56:25 +0100 | [diff] [blame] | 313 | JValue value = GetFieldValue<field_type>(shadow_frame, vregA); |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 314 | return DoFieldPutCommon<field_type, do_assignability_check, transaction_active>(self, |
| 315 | shadow_frame, |
| 316 | obj, |
| 317 | f, |
Orion Hodson | ba28f9f | 2016-10-26 10:56:25 +0100 | [diff] [blame] | 318 | value); |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 319 | } |
| 320 | |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 321 | // Explicitly instantiate all DoFieldPut functions. |
| 322 | #define EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, _do_check, _transaction_active) \ |
| 323 | template bool DoFieldPut<_find_type, _field_type, _do_check, _transaction_active>(Thread* self, \ |
| 324 | const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) |
| 325 | |
| 326 | #define EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
| 327 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, false); \ |
| 328 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, false); \ |
| 329 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, true); \ |
| 330 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, true); |
| 331 | |
| 332 | // iput-XXX |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 333 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimBoolean) |
| 334 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimByte) |
| 335 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimChar) |
| 336 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimShort) |
| 337 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimInt) |
| 338 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimLong) |
| 339 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstanceObjectWrite, Primitive::kPrimNot) |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 340 | |
| 341 | // sput-XXX |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 342 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimBoolean) |
| 343 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimByte) |
| 344 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimChar) |
| 345 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimShort) |
| 346 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimInt) |
| 347 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimLong) |
| 348 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticObjectWrite, Primitive::kPrimNot) |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 349 | |
| 350 | #undef EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL |
| 351 | #undef EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL |
| 352 | |
| 353 | template<Primitive::Type field_type, bool transaction_active> |
| 354 | bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) { |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 355 | ObjPtr<mirror::Object> obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 356 | if (UNLIKELY(obj == nullptr)) { |
| 357 | // We lost the reference to the field index so we cannot get a more |
| 358 | // precised exception message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 359 | ThrowNullPointerExceptionFromDexPC(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 360 | return false; |
| 361 | } |
| 362 | MemberOffset field_offset(inst->VRegC_22c()); |
| 363 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
| 364 | // Report this field modification to instrumentation if needed. Since we only have the offset of |
| 365 | // the field from the base of the object, we need to look for it first. |
| 366 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 367 | if (UNLIKELY(instrumentation->HasFieldWriteListeners())) { |
| 368 | ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(), |
| 369 | field_offset.Uint32Value()); |
| 370 | DCHECK(f != nullptr); |
| 371 | DCHECK(!f->IsStatic()); |
| 372 | JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA); |
Alex Light | 084fa37 | 2017-06-16 08:58:34 -0700 | [diff] [blame] | 373 | Thread* self = Thread::Current(); |
| 374 | StackHandleScope<2> hs(self); |
Mathieu Chartier | a314773 | 2016-10-26 22:57:02 -0700 | [diff] [blame] | 375 | // Save obj in case the instrumentation event has thread suspension. |
| 376 | HandleWrapperObjPtr<mirror::Object> h = hs.NewHandleWrapper(&obj); |
Alex Light | 084fa37 | 2017-06-16 08:58:34 -0700 | [diff] [blame] | 377 | mirror::Object* fake_root = nullptr; |
| 378 | HandleWrapper<mirror::Object> ret(hs.NewHandleWrapper<mirror::Object>( |
| 379 | field_type == Primitive::kPrimNot ? field_value.GetGCRoot() : &fake_root)); |
| 380 | instrumentation->FieldWriteEvent(self, |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 381 | obj.Ptr(), |
| 382 | shadow_frame.GetMethod(), |
| 383 | shadow_frame.GetDexPC(), |
| 384 | f, |
| 385 | field_value); |
Alex Light | 084fa37 | 2017-06-16 08:58:34 -0700 | [diff] [blame] | 386 | if (UNLIKELY(self->IsExceptionPending())) { |
| 387 | return false; |
| 388 | } |
Alex Light | 0aa7a5a | 2018-10-10 15:58:14 +0000 | [diff] [blame] | 389 | if (UNLIKELY(shadow_frame.GetForcePopFrame())) { |
| 390 | // Don't actually set the field. The next instruction will force us to pop. |
| 391 | DCHECK(Runtime::Current()->AreNonStandardExitsEnabled()); |
| 392 | DCHECK(PrevFrameWillRetry(self, shadow_frame)); |
| 393 | return true; |
| 394 | } |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 395 | } |
| 396 | // Note: iput-x-quick instructions are only for non-volatile fields. |
| 397 | switch (field_type) { |
Fred Shih | 37f05ef | 2014-07-16 18:38:08 -0700 | [diff] [blame] | 398 | case Primitive::kPrimBoolean: |
| 399 | obj->SetFieldBoolean<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 400 | break; |
| 401 | case Primitive::kPrimByte: |
| 402 | obj->SetFieldByte<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 403 | break; |
| 404 | case Primitive::kPrimChar: |
| 405 | obj->SetFieldChar<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 406 | break; |
| 407 | case Primitive::kPrimShort: |
| 408 | obj->SetFieldShort<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 409 | break; |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 410 | case Primitive::kPrimInt: |
| 411 | obj->SetField32<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
| 412 | break; |
| 413 | case Primitive::kPrimLong: |
| 414 | obj->SetField64<transaction_active>(field_offset, shadow_frame.GetVRegLong(vregA)); |
| 415 | break; |
| 416 | case Primitive::kPrimNot: |
| 417 | obj->SetFieldObject<transaction_active>(field_offset, shadow_frame.GetVRegReference(vregA)); |
| 418 | break; |
| 419 | default: |
| 420 | LOG(FATAL) << "Unreachable: " << field_type; |
Ian Rogers | 2c4257b | 2014-10-24 14:20:06 -0700 | [diff] [blame] | 421 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 422 | } |
| 423 | return true; |
| 424 | } |
| 425 | |
| 426 | // Explicitly instantiate all DoIPutQuick functions. |
| 427 | #define EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, _transaction_active) \ |
| 428 | template bool DoIPutQuick<_field_type, _transaction_active>(const ShadowFrame& shadow_frame, \ |
| 429 | const Instruction* inst, \ |
| 430 | uint16_t inst_data) |
| 431 | |
| 432 | #define EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(_field_type) \ |
| 433 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, false); \ |
| 434 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, true); |
| 435 | |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 436 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimInt) // iput-quick. |
| 437 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimBoolean) // iput-boolean-quick. |
| 438 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimByte) // iput-byte-quick. |
| 439 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimChar) // iput-char-quick. |
| 440 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimShort) // iput-short-quick. |
| 441 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimLong) // iput-wide-quick. |
| 442 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimNot) // iput-object-quick. |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 443 | #undef EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL |
| 444 | #undef EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL |
| 445 | |
Alex Light | 9fb1ab1 | 2017-09-05 09:32:49 -0700 | [diff] [blame] | 446 | // We execute any instrumentation events that are triggered by this exception and change the |
| 447 | // shadow_frame's dex_pc to that of the exception handler if there is one in the current method. |
| 448 | // Return true if we should continue executing in the current method and false if we need to go up |
| 449 | // the stack to find an exception handler. |
Sebastien Hertz | 520633b | 2015-09-08 17:03:36 +0200 | [diff] [blame] | 450 | // We accept a null Instrumentation* meaning we must not report anything to the instrumentation. |
Alex Light | 9fb1ab1 | 2017-09-05 09:32:49 -0700 | [diff] [blame] | 451 | // TODO We should have a better way to skip instrumentation reporting or possibly rethink that |
| 452 | // behavior. |
| 453 | bool MoveToExceptionHandler(Thread* self, |
| 454 | ShadowFrame& shadow_frame, |
| 455 | const instrumentation::Instrumentation* instrumentation) { |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 456 | self->VerifyStack(); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 457 | StackHandleScope<2> hs(self); |
Nicolas Geoffray | 14691c5 | 2015-03-05 10:40:17 +0000 | [diff] [blame] | 458 | Handle<mirror::Throwable> exception(hs.NewHandle(self->GetException())); |
Alex Light | 9fb1ab1 | 2017-09-05 09:32:49 -0700 | [diff] [blame] | 459 | if (instrumentation != nullptr && |
| 460 | instrumentation->HasExceptionThrownListeners() && |
| 461 | self->IsExceptionThrownByCurrentMethod(exception.Get())) { |
| 462 | // See b/65049545 for why we don't need to check to see if the exception has changed. |
Alex Light | 6e1607e | 2017-08-23 10:06:18 -0700 | [diff] [blame] | 463 | instrumentation->ExceptionThrownEvent(self, exception.Get()); |
Alex Light | 0aa7a5a | 2018-10-10 15:58:14 +0000 | [diff] [blame] | 464 | if (shadow_frame.GetForcePopFrame()) { |
| 465 | // We will check in the caller for GetForcePopFrame again. We need to bail out early to |
| 466 | // prevent an ExceptionHandledEvent from also being sent before popping. |
| 467 | return true; |
| 468 | } |
Sebastien Hertz | 9f10203 | 2014-05-23 08:59:42 +0200 | [diff] [blame] | 469 | } |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 470 | bool clear_exception = false; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 471 | uint32_t found_dex_pc = shadow_frame.GetMethod()->FindCatchBlock( |
Alex Light | 9fb1ab1 | 2017-09-05 09:32:49 -0700 | [diff] [blame] | 472 | hs.NewHandle(exception->GetClass()), shadow_frame.GetDexPC(), &clear_exception); |
Andreas Gampe | e2abbc6 | 2017-09-15 11:59:26 -0700 | [diff] [blame] | 473 | if (found_dex_pc == dex::kDexNoIndex) { |
Alex Light | 9fb1ab1 | 2017-09-05 09:32:49 -0700 | [diff] [blame] | 474 | if (instrumentation != nullptr) { |
| 475 | if (shadow_frame.NeedsNotifyPop()) { |
| 476 | instrumentation->WatchedFramePopped(self, shadow_frame); |
| 477 | } |
| 478 | // Exception is not caught by the current method. We will unwind to the |
| 479 | // caller. Notify any instrumentation listener. |
| 480 | instrumentation->MethodUnwindEvent(self, |
| 481 | shadow_frame.GetThisObject(), |
| 482 | shadow_frame.GetMethod(), |
| 483 | shadow_frame.GetDexPC()); |
Alex Light | e814f9d | 2017-07-31 16:14:39 -0700 | [diff] [blame] | 484 | } |
Alex Light | 9fb1ab1 | 2017-09-05 09:32:49 -0700 | [diff] [blame] | 485 | return false; |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 486 | } else { |
Alex Light | 9fb1ab1 | 2017-09-05 09:32:49 -0700 | [diff] [blame] | 487 | shadow_frame.SetDexPC(found_dex_pc); |
| 488 | if (instrumentation != nullptr && instrumentation->HasExceptionHandledListeners()) { |
| 489 | self->ClearException(); |
| 490 | instrumentation->ExceptionHandledEvent(self, exception.Get()); |
| 491 | if (UNLIKELY(self->IsExceptionPending())) { |
| 492 | // Exception handled event threw an exception. Try to find the handler for this one. |
| 493 | return MoveToExceptionHandler(self, shadow_frame, instrumentation); |
| 494 | } else if (!clear_exception) { |
| 495 | self->SetException(exception.Get()); |
| 496 | } |
| 497 | } else if (clear_exception) { |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 498 | self->ClearException(); |
| 499 | } |
Alex Light | 9fb1ab1 | 2017-09-05 09:32:49 -0700 | [diff] [blame] | 500 | return true; |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 501 | } |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 502 | } |
| 503 | |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 504 | void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame) { |
| 505 | LOG(FATAL) << "Unexpected instruction: " |
| 506 | << inst->DumpString(shadow_frame.GetMethod()->GetDexFile()); |
| 507 | UNREACHABLE(); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 508 | } |
| 509 | |
Sebastien Hertz | 45b1597 | 2015-04-03 16:07:05 +0200 | [diff] [blame] | 510 | void AbortTransactionF(Thread* self, const char* fmt, ...) { |
Mathieu Chartier | b2c7ead | 2014-04-29 11:13:16 -0700 | [diff] [blame] | 511 | va_list args; |
| 512 | va_start(args, fmt); |
Sebastien Hertz | 45b1597 | 2015-04-03 16:07:05 +0200 | [diff] [blame] | 513 | AbortTransactionV(self, fmt, args); |
| 514 | va_end(args); |
| 515 | } |
| 516 | |
| 517 | void AbortTransactionV(Thread* self, const char* fmt, va_list args) { |
| 518 | CHECK(Runtime::Current()->IsActiveTransaction()); |
| 519 | // Constructs abort message. |
Sebastien Hertz | 1c80bec | 2015-02-03 11:58:06 +0100 | [diff] [blame] | 520 | std::string abort_msg; |
Andreas Gampe | 46ee31b | 2016-12-14 10:11:49 -0800 | [diff] [blame] | 521 | android::base::StringAppendV(&abort_msg, fmt, args); |
Sebastien Hertz | 1c80bec | 2015-02-03 11:58:06 +0100 | [diff] [blame] | 522 | // 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] | 523 | Runtime::Current()->AbortTransactionAndThrowAbortError(self, abort_msg); |
Mathieu Chartier | b2c7ead | 2014-04-29 11:13:16 -0700 | [diff] [blame] | 524 | } |
| 525 | |
Narayan Kamath | c3b7f1a | 2016-10-19 11:05:04 +0100 | [diff] [blame] | 526 | // START DECLARATIONS : |
| 527 | // |
| 528 | // These additional declarations are required because clang complains |
| 529 | // about ALWAYS_INLINE (-Werror, -Wgcc-compat) in definitions. |
| 530 | // |
| 531 | |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 532 | template <bool is_range, bool do_assignability_check> |
Vladimir Marko | d16363a | 2017-02-01 14:09:13 +0000 | [diff] [blame] | 533 | static ALWAYS_INLINE bool DoCallCommon(ArtMethod* called_method, |
| 534 | Thread* self, |
| 535 | ShadowFrame& shadow_frame, |
| 536 | JValue* result, |
| 537 | uint16_t number_of_inputs, |
| 538 | uint32_t (&arg)[Instruction::kMaxVarArgRegs], |
| 539 | uint32_t vregC) REQUIRES_SHARED(Locks::mutator_lock_); |
Narayan Kamath | c3b7f1a | 2016-10-19 11:05:04 +0100 | [diff] [blame] | 540 | |
| 541 | template <bool is_range> |
Narayan Kamath | 2cb856c | 2016-11-02 12:01:26 +0000 | [diff] [blame] | 542 | ALWAYS_INLINE void CopyRegisters(ShadowFrame& caller_frame, |
| 543 | ShadowFrame* callee_frame, |
| 544 | const uint32_t (&arg)[Instruction::kMaxVarArgRegs], |
| 545 | const size_t first_src_reg, |
| 546 | const size_t first_dest_reg, |
| 547 | const size_t num_regs) REQUIRES_SHARED(Locks::mutator_lock_); |
Narayan Kamath | c3b7f1a | 2016-10-19 11:05:04 +0100 | [diff] [blame] | 548 | |
| 549 | // END DECLARATIONS. |
| 550 | |
Siva Chandra | 05d2415 | 2016-01-05 17:43:17 -0800 | [diff] [blame] | 551 | void ArtInterpreterToCompiledCodeBridge(Thread* self, |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 552 | ArtMethod* caller, |
Siva Chandra | 05d2415 | 2016-01-05 17:43:17 -0800 | [diff] [blame] | 553 | ShadowFrame* shadow_frame, |
Jeff Hao | 5ea8413 | 2017-05-05 16:59:29 -0700 | [diff] [blame] | 554 | uint16_t arg_offset, |
Siva Chandra | 05d2415 | 2016-01-05 17:43:17 -0800 | [diff] [blame] | 555 | JValue* result) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 556 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Andreas Gampe | 3cfa4d0 | 2015-10-06 17:04:01 -0700 | [diff] [blame] | 557 | ArtMethod* method = shadow_frame->GetMethod(); |
| 558 | // Ensure static methods are initialized. |
| 559 | if (method->IsStatic()) { |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 560 | ObjPtr<mirror::Class> declaringClass = method->GetDeclaringClass(); |
Andreas Gampe | 3cfa4d0 | 2015-10-06 17:04:01 -0700 | [diff] [blame] | 561 | if (UNLIKELY(!declaringClass->IsInitialized())) { |
| 562 | self->PushShadowFrame(shadow_frame); |
| 563 | StackHandleScope<1> hs(self); |
| 564 | Handle<mirror::Class> h_class(hs.NewHandle(declaringClass)); |
Nicolas Geoffray | 0182229 | 2017-03-09 09:03:19 +0000 | [diff] [blame] | 565 | if (UNLIKELY(!Runtime::Current()->GetClassLinker()->EnsureInitialized(self, h_class, true, |
| 566 | true))) { |
Andreas Gampe | 3cfa4d0 | 2015-10-06 17:04:01 -0700 | [diff] [blame] | 567 | self->PopShadowFrame(); |
| 568 | DCHECK(self->IsExceptionPending()); |
| 569 | return; |
| 570 | } |
| 571 | self->PopShadowFrame(); |
| 572 | CHECK(h_class->IsInitializing()); |
Nicolas Geoffray | 0182229 | 2017-03-09 09:03:19 +0000 | [diff] [blame] | 573 | // Reload from shadow frame in case the method moved, this is faster than adding a handle. |
| 574 | method = shadow_frame->GetMethod(); |
Andreas Gampe | 3cfa4d0 | 2015-10-06 17:04:01 -0700 | [diff] [blame] | 575 | } |
| 576 | } |
Jeff Hao | 5ea8413 | 2017-05-05 16:59:29 -0700 | [diff] [blame] | 577 | // Basic checks for the arg_offset. If there's no code item, the arg_offset must be 0. Otherwise, |
| 578 | // check that the arg_offset isn't greater than the number of registers. A stronger check is |
| 579 | // difficult since the frame may contain space for all the registers in the method, or only enough |
| 580 | // space for the arguments. |
| 581 | if (kIsDebugBuild) { |
| 582 | if (method->GetCodeItem() == nullptr) { |
| 583 | DCHECK_EQ(0u, arg_offset) << method->PrettyMethod(); |
| 584 | } else { |
| 585 | DCHECK_LE(arg_offset, shadow_frame->NumberOfVRegs()); |
| 586 | } |
| 587 | } |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 588 | jit::Jit* jit = Runtime::Current()->GetJit(); |
| 589 | if (jit != nullptr && caller != nullptr) { |
| 590 | jit->NotifyInterpreterToCompiledCodeTransition(self, caller); |
| 591 | } |
Andreas Gampe | 3cfa4d0 | 2015-10-06 17:04:01 -0700 | [diff] [blame] | 592 | method->Invoke(self, shadow_frame->GetVRegArgs(arg_offset), |
| 593 | (shadow_frame->NumberOfVRegs() - arg_offset) * sizeof(uint32_t), |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 594 | result, method->GetInterfaceMethodIfProxy(kRuntimePointerSize)->GetShorty()); |
Andreas Gampe | 3cfa4d0 | 2015-10-06 17:04:01 -0700 | [diff] [blame] | 595 | } |
| 596 | |
Mingyao Yang | ffedec5 | 2016-05-19 10:48:40 -0700 | [diff] [blame] | 597 | void SetStringInitValueToAllAliases(ShadowFrame* shadow_frame, |
| 598 | uint16_t this_obj_vreg, |
| 599 | JValue result) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 600 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 601 | ObjPtr<mirror::Object> existing = shadow_frame->GetVRegReference(this_obj_vreg); |
Mingyao Yang | ffedec5 | 2016-05-19 10:48:40 -0700 | [diff] [blame] | 602 | if (existing == nullptr) { |
| 603 | // If it's null, we come from compiled code that was deoptimized. Nothing to do, |
| 604 | // as the compiler verified there was no alias. |
| 605 | // Set the new string result of the StringFactory. |
| 606 | shadow_frame->SetVRegReference(this_obj_vreg, result.GetL()); |
| 607 | return; |
| 608 | } |
| 609 | // Set the string init result into all aliases. |
| 610 | for (uint32_t i = 0, e = shadow_frame->NumberOfVRegs(); i < e; ++i) { |
| 611 | if (shadow_frame->GetVRegReference(i) == existing) { |
| 612 | DCHECK_EQ(shadow_frame->GetVRegReference(i), |
Vladimir Marko | 78baed5 | 2018-10-11 10:44:58 +0100 | [diff] [blame] | 613 | reinterpret_cast32<mirror::Object*>(shadow_frame->GetVReg(i))); |
Mingyao Yang | ffedec5 | 2016-05-19 10:48:40 -0700 | [diff] [blame] | 614 | shadow_frame->SetVRegReference(i, result.GetL()); |
| 615 | DCHECK_EQ(shadow_frame->GetVRegReference(i), |
Vladimir Marko | 78baed5 | 2018-10-11 10:44:58 +0100 | [diff] [blame] | 616 | reinterpret_cast32<mirror::Object*>(shadow_frame->GetVReg(i))); |
Mingyao Yang | ffedec5 | 2016-05-19 10:48:40 -0700 | [diff] [blame] | 617 | } |
| 618 | } |
| 619 | } |
| 620 | |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 621 | template<bool is_range> |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 622 | static bool DoMethodHandleInvokeCommon(Thread* self, |
| 623 | ShadowFrame& shadow_frame, |
| 624 | bool invoke_exact, |
| 625 | const Instruction* inst, |
| 626 | uint16_t inst_data, |
| 627 | JValue* result) |
Orion Hodson | ba28f9f | 2016-10-26 10:56:25 +0100 | [diff] [blame] | 628 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Alex Light | 848574c | 2017-09-25 16:59:39 -0700 | [diff] [blame] | 629 | // Make sure to check for async exceptions |
| 630 | if (UNLIKELY(self->ObserveAsyncException())) { |
| 631 | return false; |
| 632 | } |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 633 | // Invoke-polymorphic instructions always take a receiver. i.e, they are never static. |
| 634 | const uint32_t vRegC = (is_range) ? inst->VRegC_4rcc() : inst->VRegC_45cc(); |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 635 | const int invoke_method_idx = (is_range) ? inst->VRegB_4rcc() : inst->VRegB_45cc(); |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 636 | |
Orion Hodson | 1a06f9f | 2016-11-09 08:32:42 +0000 | [diff] [blame] | 637 | // Initialize |result| to 0 as this is the default return value for |
| 638 | // polymorphic invocations of method handle types with void return |
| 639 | // and provides sane return result in error cases. |
| 640 | result->SetJ(0); |
| 641 | |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 642 | // The invoke_method_idx here is the name of the signature polymorphic method that |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 643 | // was symbolically invoked in bytecode (say MethodHandle.invoke or MethodHandle.invokeExact) |
| 644 | // and not the method that we'll dispatch to in the end. |
Orion Hodson | e7732be | 2017-10-11 14:35:20 +0100 | [diff] [blame] | 645 | StackHandleScope<2> hs(self); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 646 | Handle<mirror::MethodHandle> method_handle(hs.NewHandle( |
| 647 | ObjPtr<mirror::MethodHandle>::DownCast( |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 648 | MakeObjPtr(shadow_frame.GetVRegReference(vRegC))))); |
Andreas Gampe | fa4333d | 2017-02-14 11:10:34 -0800 | [diff] [blame] | 649 | if (UNLIKELY(method_handle == nullptr)) { |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 650 | // Note that the invoke type is kVirtual here because a call to a signature |
| 651 | // polymorphic method is shaped like a virtual call at the bytecode level. |
Orion Hodson | 3d617ac | 2016-10-19 14:00:46 +0100 | [diff] [blame] | 652 | ThrowNullPointerExceptionForMethodAccess(invoke_method_idx, InvokeType::kVirtual); |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 653 | return false; |
| 654 | } |
| 655 | |
| 656 | // The vRegH value gives the index of the proto_id associated with this |
Orion Hodson | 811bd5f | 2016-12-07 11:35:37 +0000 | [diff] [blame] | 657 | // signature polymorphic call site. |
Orion Hodson | 06d10a7 | 2018-05-14 08:53:38 +0100 | [diff] [blame] | 658 | const uint16_t vRegH = (is_range) ? inst->VRegH_4rcc() : inst->VRegH_45cc(); |
| 659 | const dex::ProtoIndex callsite_proto_id(vRegH); |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 660 | |
| 661 | // Call through to the classlinker and ask it to resolve the static type associated |
| 662 | // with the callsite. This information is stored in the dex cache so it's |
| 663 | // guaranteed to be fast after the first resolution. |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 664 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Orion Hodson | e7732be | 2017-10-11 14:35:20 +0100 | [diff] [blame] | 665 | Handle<mirror::MethodType> callsite_type(hs.NewHandle( |
| 666 | class_linker->ResolveMethodType(self, callsite_proto_id, shadow_frame.GetMethod()))); |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 667 | |
| 668 | // This implies we couldn't resolve one or more types in this method handle. |
Andreas Gampe | fa4333d | 2017-02-14 11:10:34 -0800 | [diff] [blame] | 669 | if (UNLIKELY(callsite_type == nullptr)) { |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 670 | CHECK(self->IsExceptionPending()); |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 671 | return false; |
| 672 | } |
| 673 | |
Orion Hodson | 811bd5f | 2016-12-07 11:35:37 +0000 | [diff] [blame] | 674 | // There is a common dispatch method for method handles that takes |
| 675 | // arguments either from a range or an array of arguments depending |
| 676 | // on whether the DEX instruction is invoke-polymorphic/range or |
| 677 | // invoke-polymorphic. The array here is for the latter. |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 678 | if (UNLIKELY(is_range)) { |
Orion Hodson | 811bd5f | 2016-12-07 11:35:37 +0000 | [diff] [blame] | 679 | // VRegC is the register holding the method handle. Arguments passed |
| 680 | // to the method handle's target do not include the method handle. |
Orion Hodson | 960d4f7 | 2017-11-10 15:32:38 +0000 | [diff] [blame] | 681 | RangeInstructionOperands operands(inst->VRegC_4rcc() + 1, inst->VRegA_4rcc() - 1); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 682 | if (invoke_exact) { |
Orion Hodson | 960d4f7 | 2017-11-10 15:32:38 +0000 | [diff] [blame] | 683 | return MethodHandleInvokeExact(self, |
| 684 | shadow_frame, |
| 685 | method_handle, |
| 686 | callsite_type, |
| 687 | &operands, |
| 688 | result); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 689 | } else { |
Orion Hodson | 960d4f7 | 2017-11-10 15:32:38 +0000 | [diff] [blame] | 690 | return MethodHandleInvoke(self, |
| 691 | shadow_frame, |
| 692 | method_handle, |
| 693 | callsite_type, |
| 694 | &operands, |
| 695 | result); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 696 | } |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 697 | } else { |
Orion Hodson | 811bd5f | 2016-12-07 11:35:37 +0000 | [diff] [blame] | 698 | // Get the register arguments for the invoke. |
Orion Hodson | 960d4f7 | 2017-11-10 15:32:38 +0000 | [diff] [blame] | 699 | uint32_t args[Instruction::kMaxVarArgRegs] = {}; |
Orion Hodson | 811bd5f | 2016-12-07 11:35:37 +0000 | [diff] [blame] | 700 | inst->GetVarArgs(args, inst_data); |
| 701 | // Drop the first register which is the method handle performing the invoke. |
Alexey Frunze | 8631a46 | 2017-01-19 19:07:37 -0800 | [diff] [blame] | 702 | memmove(args, args + 1, sizeof(args[0]) * (Instruction::kMaxVarArgRegs - 1)); |
Orion Hodson | 811bd5f | 2016-12-07 11:35:37 +0000 | [diff] [blame] | 703 | args[Instruction::kMaxVarArgRegs - 1] = 0; |
Orion Hodson | 960d4f7 | 2017-11-10 15:32:38 +0000 | [diff] [blame] | 704 | VarArgsInstructionOperands operands(args, inst->VRegA_45cc() - 1); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 705 | if (invoke_exact) { |
Orion Hodson | 960d4f7 | 2017-11-10 15:32:38 +0000 | [diff] [blame] | 706 | return MethodHandleInvokeExact(self, |
| 707 | shadow_frame, |
| 708 | method_handle, |
| 709 | callsite_type, |
| 710 | &operands, |
| 711 | result); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 712 | } else { |
Orion Hodson | 960d4f7 | 2017-11-10 15:32:38 +0000 | [diff] [blame] | 713 | return MethodHandleInvoke(self, |
| 714 | shadow_frame, |
| 715 | method_handle, |
| 716 | callsite_type, |
| 717 | &operands, |
| 718 | result); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 719 | } |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | bool DoMethodHandleInvokeExact(Thread* self, |
| 724 | ShadowFrame& shadow_frame, |
| 725 | const Instruction* inst, |
| 726 | uint16_t inst_data, |
| 727 | JValue* result) REQUIRES_SHARED(Locks::mutator_lock_) { |
| 728 | if (inst->Opcode() == Instruction::INVOKE_POLYMORPHIC) { |
| 729 | static const bool kIsRange = false; |
| 730 | return DoMethodHandleInvokeCommon<kIsRange>( |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 731 | self, shadow_frame, /* invoke_exact= */ true, inst, inst_data, result); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 732 | } else { |
| 733 | DCHECK_EQ(inst->Opcode(), Instruction::INVOKE_POLYMORPHIC_RANGE); |
| 734 | static const bool kIsRange = true; |
| 735 | return DoMethodHandleInvokeCommon<kIsRange>( |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 736 | self, shadow_frame, /* invoke_exact= */ true, inst, inst_data, result); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 737 | } |
| 738 | } |
| 739 | |
| 740 | bool DoMethodHandleInvoke(Thread* self, |
| 741 | ShadowFrame& shadow_frame, |
| 742 | const Instruction* inst, |
| 743 | uint16_t inst_data, |
| 744 | JValue* result) REQUIRES_SHARED(Locks::mutator_lock_) { |
| 745 | if (inst->Opcode() == Instruction::INVOKE_POLYMORPHIC) { |
| 746 | static const bool kIsRange = false; |
| 747 | return DoMethodHandleInvokeCommon<kIsRange>( |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 748 | self, shadow_frame, /* invoke_exact= */ false, inst, inst_data, result); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 749 | } else { |
| 750 | DCHECK_EQ(inst->Opcode(), Instruction::INVOKE_POLYMORPHIC_RANGE); |
| 751 | static const bool kIsRange = true; |
| 752 | return DoMethodHandleInvokeCommon<kIsRange>( |
Andreas Gampe | 98ea9d9 | 2018-10-19 14:06:15 -0700 | [diff] [blame] | 753 | self, shadow_frame, /* invoke_exact= */ false, inst, inst_data, result); |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 754 | } |
| 755 | } |
| 756 | |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 757 | static bool DoVarHandleInvokeCommon(Thread* self, |
| 758 | ShadowFrame& shadow_frame, |
| 759 | const Instruction* inst, |
| 760 | uint16_t inst_data, |
| 761 | JValue* result, |
| 762 | mirror::VarHandle::AccessMode access_mode) |
| 763 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 764 | // Make sure to check for async exceptions |
| 765 | if (UNLIKELY(self->ObserveAsyncException())) { |
| 766 | return false; |
| 767 | } |
| 768 | |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 769 | StackHandleScope<2> hs(self); |
Orion Hodson | 537a4fe | 2018-05-15 13:57:58 +0100 | [diff] [blame] | 770 | bool is_var_args = inst->HasVarArgs(); |
Orion Hodson | 06d10a7 | 2018-05-14 08:53:38 +0100 | [diff] [blame] | 771 | const uint16_t vRegH = is_var_args ? inst->VRegH_45cc() : inst->VRegH_4rcc(); |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 772 | ClassLinker* const class_linker = Runtime::Current()->GetClassLinker(); |
| 773 | Handle<mirror::MethodType> callsite_type(hs.NewHandle( |
Orion Hodson | 06d10a7 | 2018-05-14 08:53:38 +0100 | [diff] [blame] | 774 | class_linker->ResolveMethodType(self, dex::ProtoIndex(vRegH), shadow_frame.GetMethod()))); |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 775 | // This implies we couldn't resolve one or more types in this VarHandle. |
| 776 | if (UNLIKELY(callsite_type == nullptr)) { |
| 777 | CHECK(self->IsExceptionPending()); |
| 778 | return false; |
| 779 | } |
| 780 | |
Orion Hodson | 537a4fe | 2018-05-15 13:57:58 +0100 | [diff] [blame] | 781 | const uint32_t vRegC = is_var_args ? inst->VRegC_45cc() : inst->VRegC_4rcc(); |
| 782 | ObjPtr<mirror::Object> receiver(shadow_frame.GetVRegReference(vRegC)); |
| 783 | Handle<mirror::VarHandle> var_handle(hs.NewHandle(down_cast<mirror::VarHandle*>(receiver.Ptr()))); |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 784 | if (is_var_args) { |
| 785 | uint32_t args[Instruction::kMaxVarArgRegs]; |
| 786 | inst->GetVarArgs(args, inst_data); |
| 787 | VarArgsInstructionOperands all_operands(args, inst->VRegA_45cc()); |
| 788 | NoReceiverInstructionOperands operands(&all_operands); |
Orion Hodson | 537a4fe | 2018-05-15 13:57:58 +0100 | [diff] [blame] | 789 | return VarHandleInvokeAccessor(self, |
| 790 | shadow_frame, |
| 791 | var_handle, |
| 792 | callsite_type, |
| 793 | access_mode, |
| 794 | &operands, |
| 795 | result); |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 796 | } else { |
| 797 | RangeInstructionOperands all_operands(inst->VRegC_4rcc(), inst->VRegA_4rcc()); |
| 798 | NoReceiverInstructionOperands operands(&all_operands); |
Orion Hodson | 537a4fe | 2018-05-15 13:57:58 +0100 | [diff] [blame] | 799 | return VarHandleInvokeAccessor(self, |
| 800 | shadow_frame, |
| 801 | var_handle, |
| 802 | callsite_type, |
| 803 | access_mode, |
| 804 | &operands, |
| 805 | result); |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 806 | } |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 807 | } |
| 808 | |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 809 | #define DO_VAR_HANDLE_ACCESSOR(_access_mode) \ |
| 810 | bool DoVarHandle ## _access_mode(Thread* self, \ |
| 811 | ShadowFrame& shadow_frame, \ |
| 812 | const Instruction* inst, \ |
| 813 | uint16_t inst_data, \ |
| 814 | JValue* result) REQUIRES_SHARED(Locks::mutator_lock_) { \ |
| 815 | const auto access_mode = mirror::VarHandle::AccessMode::k ## _access_mode; \ |
| 816 | return DoVarHandleInvokeCommon(self, shadow_frame, inst, inst_data, result, access_mode); \ |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 817 | } |
| 818 | |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 819 | DO_VAR_HANDLE_ACCESSOR(CompareAndExchange) |
| 820 | DO_VAR_HANDLE_ACCESSOR(CompareAndExchangeAcquire) |
| 821 | DO_VAR_HANDLE_ACCESSOR(CompareAndExchangeRelease) |
| 822 | DO_VAR_HANDLE_ACCESSOR(CompareAndSet) |
| 823 | DO_VAR_HANDLE_ACCESSOR(Get) |
| 824 | DO_VAR_HANDLE_ACCESSOR(GetAcquire) |
| 825 | DO_VAR_HANDLE_ACCESSOR(GetAndAdd) |
| 826 | DO_VAR_HANDLE_ACCESSOR(GetAndAddAcquire) |
| 827 | DO_VAR_HANDLE_ACCESSOR(GetAndAddRelease) |
| 828 | DO_VAR_HANDLE_ACCESSOR(GetAndBitwiseAnd) |
| 829 | DO_VAR_HANDLE_ACCESSOR(GetAndBitwiseAndAcquire) |
| 830 | DO_VAR_HANDLE_ACCESSOR(GetAndBitwiseAndRelease) |
| 831 | DO_VAR_HANDLE_ACCESSOR(GetAndBitwiseOr) |
| 832 | DO_VAR_HANDLE_ACCESSOR(GetAndBitwiseOrAcquire) |
| 833 | DO_VAR_HANDLE_ACCESSOR(GetAndBitwiseOrRelease) |
| 834 | DO_VAR_HANDLE_ACCESSOR(GetAndBitwiseXor) |
| 835 | DO_VAR_HANDLE_ACCESSOR(GetAndBitwiseXorAcquire) |
| 836 | DO_VAR_HANDLE_ACCESSOR(GetAndBitwiseXorRelease) |
| 837 | DO_VAR_HANDLE_ACCESSOR(GetAndSet) |
| 838 | DO_VAR_HANDLE_ACCESSOR(GetAndSetAcquire) |
| 839 | DO_VAR_HANDLE_ACCESSOR(GetAndSetRelease) |
| 840 | DO_VAR_HANDLE_ACCESSOR(GetOpaque) |
| 841 | DO_VAR_HANDLE_ACCESSOR(GetVolatile) |
| 842 | DO_VAR_HANDLE_ACCESSOR(Set) |
| 843 | DO_VAR_HANDLE_ACCESSOR(SetOpaque) |
| 844 | DO_VAR_HANDLE_ACCESSOR(SetRelease) |
| 845 | DO_VAR_HANDLE_ACCESSOR(SetVolatile) |
| 846 | DO_VAR_HANDLE_ACCESSOR(WeakCompareAndSet) |
| 847 | DO_VAR_HANDLE_ACCESSOR(WeakCompareAndSetAcquire) |
| 848 | DO_VAR_HANDLE_ACCESSOR(WeakCompareAndSetPlain) |
| 849 | DO_VAR_HANDLE_ACCESSOR(WeakCompareAndSetRelease) |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 850 | |
Orion Hodson | 928033d | 2018-02-07 05:30:54 +0000 | [diff] [blame] | 851 | #undef DO_VAR_HANDLE_ACCESSOR |
Orion Hodson | 43f0cdb | 2017-10-10 14:47:32 +0100 | [diff] [blame] | 852 | |
| 853 | template<bool is_range> |
| 854 | bool DoInvokePolymorphic(Thread* self, |
| 855 | ShadowFrame& shadow_frame, |
| 856 | const Instruction* inst, |
| 857 | uint16_t inst_data, |
| 858 | JValue* result) { |
| 859 | const int invoke_method_idx = inst->VRegB(); |
| 860 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
| 861 | ArtMethod* invoke_method = |
| 862 | class_linker->ResolveMethod<ClassLinker::ResolveMode::kCheckICCEAndIAE>( |
| 863 | self, invoke_method_idx, shadow_frame.GetMethod(), kVirtual); |
| 864 | |
| 865 | // Ensure intrinsic identifiers are initialized. |
| 866 | DCHECK(invoke_method->IsIntrinsic()); |
| 867 | |
| 868 | // Dispatch based on intrinsic identifier associated with method. |
| 869 | switch (static_cast<art::Intrinsics>(invoke_method->GetIntrinsic())) { |
| 870 | #define CASE_SIGNATURE_POLYMORPHIC_INTRINSIC(Name, ...) \ |
| 871 | case Intrinsics::k##Name: \ |
| 872 | return Do ## Name(self, shadow_frame, inst, inst_data, result); |
| 873 | #include "intrinsics_list.h" |
| 874 | SIGNATURE_POLYMORPHIC_INTRINSICS_LIST(CASE_SIGNATURE_POLYMORPHIC_INTRINSIC) |
| 875 | #undef INTRINSICS_LIST |
| 876 | #undef SIGNATURE_POLYMORPHIC_INTRINSICS_LIST |
| 877 | #undef CASE_SIGNATURE_POLYMORPHIC_INTRINSIC |
| 878 | default: |
| 879 | LOG(FATAL) << "Unreachable: " << invoke_method->GetIntrinsic(); |
| 880 | UNREACHABLE(); |
| 881 | return false; |
Narayan Kamath | c3b7f1a | 2016-10-19 11:05:04 +0100 | [diff] [blame] | 882 | } |
| 883 | } |
| 884 | |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 885 | static JValue ConvertScalarBootstrapArgument(jvalue value) { |
| 886 | // value either contains a primitive scalar value if it corresponds |
| 887 | // to a primitive type, or it contains an integer value if it |
| 888 | // corresponds to an object instance reference id (e.g. a string id). |
| 889 | return JValue::FromPrimitive(value.j); |
| 890 | } |
| 891 | |
| 892 | static ObjPtr<mirror::Class> GetClassForBootstrapArgument(EncodedArrayValueIterator::ValueType type) |
| 893 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 894 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 895 | ObjPtr<mirror::ObjectArray<mirror::Class>> class_roots = class_linker->GetClassRoots(); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 896 | switch (type) { |
| 897 | case EncodedArrayValueIterator::ValueType::kBoolean: |
| 898 | case EncodedArrayValueIterator::ValueType::kByte: |
| 899 | case EncodedArrayValueIterator::ValueType::kChar: |
| 900 | case EncodedArrayValueIterator::ValueType::kShort: |
| 901 | // These types are disallowed by JVMS. Treat as integers. This |
| 902 | // will result in CCE's being raised if the BSM has one of these |
| 903 | // types. |
| 904 | case EncodedArrayValueIterator::ValueType::kInt: |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 905 | return GetClassRoot(ClassRoot::kPrimitiveInt, class_roots); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 906 | case EncodedArrayValueIterator::ValueType::kLong: |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 907 | return GetClassRoot(ClassRoot::kPrimitiveLong, class_roots); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 908 | case EncodedArrayValueIterator::ValueType::kFloat: |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 909 | return GetClassRoot(ClassRoot::kPrimitiveFloat, class_roots); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 910 | case EncodedArrayValueIterator::ValueType::kDouble: |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 911 | return GetClassRoot(ClassRoot::kPrimitiveDouble, class_roots); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 912 | case EncodedArrayValueIterator::ValueType::kMethodType: |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 913 | return GetClassRoot<mirror::MethodType>(class_roots); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 914 | case EncodedArrayValueIterator::ValueType::kMethodHandle: |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 915 | return GetClassRoot<mirror::MethodHandle>(class_roots); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 916 | case EncodedArrayValueIterator::ValueType::kString: |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 917 | return GetClassRoot<mirror::String>(); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 918 | case EncodedArrayValueIterator::ValueType::kType: |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 919 | return GetClassRoot<mirror::Class>(); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 920 | case EncodedArrayValueIterator::ValueType::kField: |
| 921 | case EncodedArrayValueIterator::ValueType::kMethod: |
| 922 | case EncodedArrayValueIterator::ValueType::kEnum: |
| 923 | case EncodedArrayValueIterator::ValueType::kArray: |
| 924 | case EncodedArrayValueIterator::ValueType::kAnnotation: |
| 925 | case EncodedArrayValueIterator::ValueType::kNull: |
| 926 | return nullptr; |
| 927 | } |
| 928 | } |
| 929 | |
| 930 | static bool GetArgumentForBootstrapMethod(Thread* self, |
| 931 | ArtMethod* referrer, |
| 932 | EncodedArrayValueIterator::ValueType type, |
| 933 | const JValue* encoded_value, |
| 934 | JValue* decoded_value) |
| 935 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 936 | // The encoded_value contains either a scalar value (IJDF) or a |
| 937 | // scalar DEX file index to a reference type to be materialized. |
| 938 | switch (type) { |
| 939 | case EncodedArrayValueIterator::ValueType::kInt: |
| 940 | case EncodedArrayValueIterator::ValueType::kFloat: |
| 941 | decoded_value->SetI(encoded_value->GetI()); |
| 942 | return true; |
| 943 | case EncodedArrayValueIterator::ValueType::kLong: |
| 944 | case EncodedArrayValueIterator::ValueType::kDouble: |
| 945 | decoded_value->SetJ(encoded_value->GetJ()); |
| 946 | return true; |
| 947 | case EncodedArrayValueIterator::ValueType::kMethodType: { |
| 948 | StackHandleScope<2> hs(self); |
| 949 | Handle<mirror::ClassLoader> class_loader(hs.NewHandle(referrer->GetClassLoader())); |
| 950 | Handle<mirror::DexCache> dex_cache(hs.NewHandle(referrer->GetDexCache())); |
Orion Hodson | 06d10a7 | 2018-05-14 08:53:38 +0100 | [diff] [blame] | 951 | dex::ProtoIndex proto_idx(encoded_value->GetC()); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 952 | ClassLinker* cl = Runtime::Current()->GetClassLinker(); |
Orion Hodson | 06d10a7 | 2018-05-14 08:53:38 +0100 | [diff] [blame] | 953 | ObjPtr<mirror::MethodType> o = |
| 954 | cl->ResolveMethodType(self, proto_idx, dex_cache, class_loader); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 955 | if (UNLIKELY(o.IsNull())) { |
| 956 | DCHECK(self->IsExceptionPending()); |
| 957 | return false; |
| 958 | } |
| 959 | decoded_value->SetL(o); |
| 960 | return true; |
| 961 | } |
| 962 | case EncodedArrayValueIterator::ValueType::kMethodHandle: { |
| 963 | uint32_t index = static_cast<uint32_t>(encoded_value->GetI()); |
| 964 | ClassLinker* cl = Runtime::Current()->GetClassLinker(); |
| 965 | ObjPtr<mirror::MethodHandle> o = cl->ResolveMethodHandle(self, index, referrer); |
| 966 | if (UNLIKELY(o.IsNull())) { |
| 967 | DCHECK(self->IsExceptionPending()); |
| 968 | return false; |
| 969 | } |
| 970 | decoded_value->SetL(o); |
| 971 | return true; |
| 972 | } |
| 973 | case EncodedArrayValueIterator::ValueType::kString: { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 974 | dex::StringIndex index(static_cast<uint32_t>(encoded_value->GetI())); |
| 975 | ClassLinker* cl = Runtime::Current()->GetClassLinker(); |
Vladimir Marko | 18090d1 | 2018-06-01 16:53:12 +0100 | [diff] [blame] | 976 | ObjPtr<mirror::String> o = cl->ResolveString(index, referrer); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 977 | if (UNLIKELY(o.IsNull())) { |
| 978 | DCHECK(self->IsExceptionPending()); |
| 979 | return false; |
| 980 | } |
| 981 | decoded_value->SetL(o); |
| 982 | return true; |
| 983 | } |
| 984 | case EncodedArrayValueIterator::ValueType::kType: { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 985 | dex::TypeIndex index(static_cast<uint32_t>(encoded_value->GetI())); |
| 986 | ClassLinker* cl = Runtime::Current()->GetClassLinker(); |
Vladimir Marko | 09c5ca4 | 2018-05-31 15:15:31 +0100 | [diff] [blame] | 987 | ObjPtr<mirror::Class> o = cl->ResolveType(index, referrer); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 988 | if (UNLIKELY(o.IsNull())) { |
| 989 | DCHECK(self->IsExceptionPending()); |
| 990 | return false; |
| 991 | } |
| 992 | decoded_value->SetL(o); |
| 993 | return true; |
| 994 | } |
| 995 | case EncodedArrayValueIterator::ValueType::kBoolean: |
| 996 | case EncodedArrayValueIterator::ValueType::kByte: |
| 997 | case EncodedArrayValueIterator::ValueType::kChar: |
| 998 | case EncodedArrayValueIterator::ValueType::kShort: |
| 999 | case EncodedArrayValueIterator::ValueType::kField: |
| 1000 | case EncodedArrayValueIterator::ValueType::kMethod: |
| 1001 | case EncodedArrayValueIterator::ValueType::kEnum: |
| 1002 | case EncodedArrayValueIterator::ValueType::kArray: |
| 1003 | case EncodedArrayValueIterator::ValueType::kAnnotation: |
| 1004 | case EncodedArrayValueIterator::ValueType::kNull: |
| 1005 | // Unreachable - unsupported types that have been checked when |
| 1006 | // determining the effect call site type based on the bootstrap |
| 1007 | // argument types. |
| 1008 | UNREACHABLE(); |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | static bool PackArgumentForBootstrapMethod(Thread* self, |
| 1013 | ArtMethod* referrer, |
| 1014 | CallSiteArrayValueIterator* it, |
| 1015 | ShadowFrameSetter* setter) |
| 1016 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 1017 | auto type = it->GetValueType(); |
| 1018 | const JValue encoded_value = ConvertScalarBootstrapArgument(it->GetJavaValue()); |
| 1019 | JValue decoded_value; |
| 1020 | if (!GetArgumentForBootstrapMethod(self, referrer, type, &encoded_value, &decoded_value)) { |
| 1021 | return false; |
| 1022 | } |
| 1023 | switch (it->GetValueType()) { |
| 1024 | case EncodedArrayValueIterator::ValueType::kInt: |
| 1025 | case EncodedArrayValueIterator::ValueType::kFloat: |
| 1026 | setter->Set(static_cast<uint32_t>(decoded_value.GetI())); |
| 1027 | return true; |
| 1028 | case EncodedArrayValueIterator::ValueType::kLong: |
| 1029 | case EncodedArrayValueIterator::ValueType::kDouble: |
| 1030 | setter->SetLong(decoded_value.GetJ()); |
| 1031 | return true; |
| 1032 | case EncodedArrayValueIterator::ValueType::kMethodType: |
| 1033 | case EncodedArrayValueIterator::ValueType::kMethodHandle: |
| 1034 | case EncodedArrayValueIterator::ValueType::kString: |
| 1035 | case EncodedArrayValueIterator::ValueType::kType: |
| 1036 | setter->SetReference(decoded_value.GetL()); |
| 1037 | return true; |
| 1038 | case EncodedArrayValueIterator::ValueType::kBoolean: |
| 1039 | case EncodedArrayValueIterator::ValueType::kByte: |
| 1040 | case EncodedArrayValueIterator::ValueType::kChar: |
| 1041 | case EncodedArrayValueIterator::ValueType::kShort: |
| 1042 | case EncodedArrayValueIterator::ValueType::kField: |
| 1043 | case EncodedArrayValueIterator::ValueType::kMethod: |
| 1044 | case EncodedArrayValueIterator::ValueType::kEnum: |
| 1045 | case EncodedArrayValueIterator::ValueType::kArray: |
| 1046 | case EncodedArrayValueIterator::ValueType::kAnnotation: |
| 1047 | case EncodedArrayValueIterator::ValueType::kNull: |
| 1048 | // Unreachable - unsupported types that have been checked when |
| 1049 | // determining the effect call site type based on the bootstrap |
| 1050 | // argument types. |
| 1051 | UNREACHABLE(); |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | static bool PackCollectorArrayForBootstrapMethod(Thread* self, |
| 1056 | ArtMethod* referrer, |
| 1057 | ObjPtr<mirror::Class> array_type, |
| 1058 | int32_t array_length, |
| 1059 | CallSiteArrayValueIterator* it, |
| 1060 | ShadowFrameSetter* setter) |
| 1061 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 1062 | StackHandleScope<1> hs(self); |
| 1063 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
| 1064 | JValue decoded_value; |
| 1065 | |
| 1066 | #define COLLECT_PRIMITIVE_ARRAY(Descriptor, Type) \ |
| 1067 | Handle<mirror::Type ## Array> array = \ |
| 1068 | hs.NewHandle(mirror::Type ## Array::Alloc(self, array_length)); \ |
| 1069 | if (array.IsNull()) { \ |
| 1070 | return false; \ |
| 1071 | } \ |
| 1072 | for (int32_t i = 0; it->HasNext(); it->Next(), ++i) { \ |
| 1073 | auto type = it->GetValueType(); \ |
| 1074 | DCHECK_EQ(type, EncodedArrayValueIterator::ValueType::k ## Type); \ |
| 1075 | const JValue encoded_value = \ |
| 1076 | ConvertScalarBootstrapArgument(it->GetJavaValue()); \ |
| 1077 | GetArgumentForBootstrapMethod(self, \ |
| 1078 | referrer, \ |
| 1079 | type, \ |
| 1080 | &encoded_value, \ |
| 1081 | &decoded_value); \ |
| 1082 | array->Set(i, decoded_value.Get ## Descriptor()); \ |
| 1083 | } \ |
| 1084 | setter->SetReference(array.Get()); \ |
| 1085 | return true; |
| 1086 | |
| 1087 | #define COLLECT_REFERENCE_ARRAY(T, Type) \ |
Andreas Gampe | 584771b | 2018-10-18 13:22:23 -0700 | [diff] [blame] | 1088 | Handle<mirror::ObjectArray<T>> array = /* NOLINT */ \ |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1089 | hs.NewHandle(mirror::ObjectArray<T>::Alloc(self, \ |
| 1090 | array_type, \ |
| 1091 | array_length)); \ |
| 1092 | if (array.IsNull()) { \ |
| 1093 | return false; \ |
| 1094 | } \ |
| 1095 | for (int32_t i = 0; it->HasNext(); it->Next(), ++i) { \ |
| 1096 | auto type = it->GetValueType(); \ |
| 1097 | DCHECK_EQ(type, EncodedArrayValueIterator::ValueType::k ## Type); \ |
| 1098 | const JValue encoded_value = \ |
| 1099 | ConvertScalarBootstrapArgument(it->GetJavaValue()); \ |
| 1100 | if (!GetArgumentForBootstrapMethod(self, \ |
| 1101 | referrer, \ |
| 1102 | type, \ |
| 1103 | &encoded_value, \ |
| 1104 | &decoded_value)) { \ |
| 1105 | return false; \ |
| 1106 | } \ |
| 1107 | ObjPtr<mirror::Object> o = decoded_value.GetL(); \ |
| 1108 | if (Runtime::Current()->IsActiveTransaction()) { \ |
| 1109 | array->Set<true>(i, ObjPtr<T>::DownCast(o)); \ |
| 1110 | } else { \ |
| 1111 | array->Set<false>(i, ObjPtr<T>::DownCast(o)); \ |
| 1112 | } \ |
| 1113 | } \ |
| 1114 | setter->SetReference(array.Get()); \ |
| 1115 | return true; |
| 1116 | |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1117 | ObjPtr<mirror::ObjectArray<mirror::Class>> class_roots = class_linker->GetClassRoots(); |
| 1118 | ObjPtr<mirror::Class> component_type = array_type->GetComponentType(); |
| 1119 | if (component_type == GetClassRoot(ClassRoot::kPrimitiveInt, class_roots)) { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1120 | COLLECT_PRIMITIVE_ARRAY(I, Int); |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1121 | } else if (component_type == GetClassRoot(ClassRoot::kPrimitiveLong, class_roots)) { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1122 | COLLECT_PRIMITIVE_ARRAY(J, Long); |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1123 | } else if (component_type == GetClassRoot(ClassRoot::kPrimitiveFloat, class_roots)) { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1124 | COLLECT_PRIMITIVE_ARRAY(F, Float); |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1125 | } else if (component_type == GetClassRoot(ClassRoot::kPrimitiveDouble, class_roots)) { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1126 | COLLECT_PRIMITIVE_ARRAY(D, Double); |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1127 | } else if (component_type == GetClassRoot<mirror::MethodType>()) { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1128 | COLLECT_REFERENCE_ARRAY(mirror::MethodType, MethodType); |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1129 | } else if (component_type == GetClassRoot<mirror::MethodHandle>()) { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1130 | COLLECT_REFERENCE_ARRAY(mirror::MethodHandle, MethodHandle); |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1131 | } else if (component_type == GetClassRoot<mirror::String>(class_roots)) { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1132 | COLLECT_REFERENCE_ARRAY(mirror::String, String); |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1133 | } else if (component_type == GetClassRoot<mirror::Class>()) { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1134 | COLLECT_REFERENCE_ARRAY(mirror::Class, Type); |
| 1135 | } else { |
| 1136 | UNREACHABLE(); |
| 1137 | } |
| 1138 | #undef COLLECT_PRIMITIVE_ARRAY |
| 1139 | #undef COLLECT_REFERENCE_ARRAY |
| 1140 | } |
| 1141 | |
| 1142 | static ObjPtr<mirror::MethodType> BuildCallSiteForBootstrapMethod(Thread* self, |
| 1143 | const DexFile* dex_file, |
| 1144 | uint32_t call_site_idx) |
| 1145 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 1146 | const DexFile::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx); |
| 1147 | CallSiteArrayValueIterator it(*dex_file, csi); |
| 1148 | DCHECK_GE(it.Size(), 1u); |
| 1149 | |
| 1150 | StackHandleScope<2> hs(self); |
| 1151 | // Create array for parameter types. |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1152 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Vladimir Marko | a8bba7d | 2018-05-30 15:18:48 +0100 | [diff] [blame] | 1153 | ObjPtr<mirror::Class> class_array_type = |
| 1154 | GetClassRoot<mirror::ObjectArray<mirror::Class>>(class_linker); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1155 | Handle<mirror::ObjectArray<mirror::Class>> ptypes = hs.NewHandle( |
| 1156 | mirror::ObjectArray<mirror::Class>::Alloc(self, |
| 1157 | class_array_type, |
| 1158 | static_cast<int>(it.Size()))); |
| 1159 | if (ptypes.IsNull()) { |
| 1160 | DCHECK(self->IsExceptionPending()); |
| 1161 | return nullptr; |
| 1162 | } |
| 1163 | |
| 1164 | // Populate the first argument with an instance of j.l.i.MethodHandles.Lookup |
| 1165 | // that the runtime will construct. |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1166 | ptypes->Set(0, GetClassRoot<mirror::MethodHandlesLookup>(class_linker)); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1167 | it.Next(); |
| 1168 | |
| 1169 | // The remaining parameter types are derived from the types of |
| 1170 | // arguments present in the DEX file. |
| 1171 | int index = 1; |
| 1172 | while (it.HasNext()) { |
| 1173 | ObjPtr<mirror::Class> ptype = GetClassForBootstrapArgument(it.GetValueType()); |
| 1174 | if (ptype.IsNull()) { |
| 1175 | ThrowClassCastException("Unsupported bootstrap argument type"); |
| 1176 | return nullptr; |
| 1177 | } |
| 1178 | ptypes->Set(index, ptype); |
| 1179 | index++; |
| 1180 | it.Next(); |
| 1181 | } |
| 1182 | DCHECK_EQ(static_cast<size_t>(index), it.Size()); |
| 1183 | |
| 1184 | // By definition, the return type is always a j.l.i.CallSite. |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1185 | Handle<mirror::Class> rtype = hs.NewHandle(GetClassRoot<mirror::CallSite>()); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1186 | return mirror::MethodType::Create(self, rtype, ptypes); |
| 1187 | } |
| 1188 | |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1189 | static ObjPtr<mirror::CallSite> InvokeBootstrapMethod(Thread* self, |
| 1190 | ShadowFrame& shadow_frame, |
| 1191 | uint32_t call_site_idx) |
| 1192 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1193 | StackHandleScope<5> hs(self); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1194 | // There are three mandatory arguments expected from the call site |
| 1195 | // value array in the DEX file: the bootstrap method handle, the |
| 1196 | // method name to pass to the bootstrap method, and the method type |
| 1197 | // to pass to the bootstrap method. |
| 1198 | static constexpr size_t kMandatoryArgumentsCount = 3; |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1199 | ArtMethod* referrer = shadow_frame.GetMethod(); |
| 1200 | const DexFile* dex_file = referrer->GetDexFile(); |
| 1201 | const DexFile::CallSiteIdItem& csi = dex_file->GetCallSiteId(call_site_idx); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1202 | CallSiteArrayValueIterator it(*dex_file, csi); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1203 | if (it.Size() < kMandatoryArgumentsCount) { |
| 1204 | ThrowBootstrapMethodError("Truncated bootstrap arguments (%zu < %zu)", |
| 1205 | it.Size(), kMandatoryArgumentsCount); |
| 1206 | return nullptr; |
| 1207 | } |
| 1208 | |
| 1209 | if (it.GetValueType() != EncodedArrayValueIterator::ValueType::kMethodHandle) { |
| 1210 | ThrowBootstrapMethodError("First bootstrap argument is not a method handle"); |
| 1211 | return nullptr; |
| 1212 | } |
| 1213 | |
| 1214 | uint32_t bsm_index = static_cast<uint32_t>(it.GetJavaValue().i); |
| 1215 | it.Next(); |
| 1216 | |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1217 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1218 | Handle<mirror::MethodHandle> bsm = |
| 1219 | hs.NewHandle(class_linker->ResolveMethodHandle(self, bsm_index, referrer)); |
| 1220 | if (bsm.IsNull()) { |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1221 | DCHECK(self->IsExceptionPending()); |
| 1222 | return nullptr; |
| 1223 | } |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1224 | |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1225 | if (bsm->GetHandleKind() != mirror::MethodHandle::Kind::kInvokeStatic) { |
| 1226 | // JLS suggests also accepting constructors. This is currently |
| 1227 | // hard as constructor invocations happen via transformers in ART |
| 1228 | // today. The constructor would need to be a class derived from java.lang.invoke.CallSite. |
| 1229 | ThrowBootstrapMethodError("Unsupported bootstrap method invocation kind"); |
| 1230 | return nullptr; |
| 1231 | } |
| 1232 | |
| 1233 | // Construct the local call site type information based on the 3 |
| 1234 | // mandatory arguments provided by the runtime and the static arguments |
| 1235 | // in the DEX file. We will use these arguments to build a shadow frame. |
| 1236 | MutableHandle<mirror::MethodType> call_site_type = |
| 1237 | hs.NewHandle(BuildCallSiteForBootstrapMethod(self, dex_file, call_site_idx)); |
| 1238 | if (call_site_type.IsNull()) { |
| 1239 | DCHECK(self->IsExceptionPending()); |
| 1240 | return nullptr; |
| 1241 | } |
| 1242 | |
| 1243 | // Check if this BSM is targeting a variable arity method. If so, |
| 1244 | // we'll need to collect the trailing arguments into an array. |
| 1245 | Handle<mirror::Array> collector_arguments; |
| 1246 | int32_t collector_arguments_length; |
| 1247 | if (bsm->GetTargetMethod()->IsVarargs()) { |
| 1248 | int number_of_bsm_parameters = bsm->GetMethodType()->GetNumberOfPTypes(); |
| 1249 | if (number_of_bsm_parameters == 0) { |
| 1250 | ThrowBootstrapMethodError("Variable arity BSM does not have any arguments"); |
| 1251 | return nullptr; |
| 1252 | } |
| 1253 | Handle<mirror::Class> collector_array_class = |
| 1254 | hs.NewHandle(bsm->GetMethodType()->GetPTypes()->Get(number_of_bsm_parameters - 1)); |
| 1255 | if (!collector_array_class->IsArrayClass()) { |
| 1256 | ThrowBootstrapMethodError("Variable arity BSM does not have array as final argument"); |
| 1257 | return nullptr; |
| 1258 | } |
| 1259 | // The call site may include no arguments to be collected. In this |
| 1260 | // case the number of arguments must be at least the number of BSM |
| 1261 | // parameters less the collector array. |
| 1262 | if (call_site_type->GetNumberOfPTypes() < number_of_bsm_parameters - 1) { |
| 1263 | ThrowWrongMethodTypeException(bsm->GetMethodType(), call_site_type.Get()); |
| 1264 | return nullptr; |
| 1265 | } |
| 1266 | // Check all the arguments to be collected match the collector array component type. |
| 1267 | for (int i = number_of_bsm_parameters - 1; i < call_site_type->GetNumberOfPTypes(); ++i) { |
| 1268 | if (call_site_type->GetPTypes()->Get(i) != collector_array_class->GetComponentType()) { |
| 1269 | ThrowClassCastException(collector_array_class->GetComponentType(), |
| 1270 | call_site_type->GetPTypes()->Get(i)); |
| 1271 | return nullptr; |
| 1272 | } |
| 1273 | } |
| 1274 | // Update the call site method type so it now includes the collector array. |
| 1275 | int32_t collector_arguments_start = number_of_bsm_parameters - 1; |
| 1276 | collector_arguments_length = call_site_type->GetNumberOfPTypes() - number_of_bsm_parameters + 1; |
| 1277 | call_site_type.Assign( |
| 1278 | mirror::MethodType::CollectTrailingArguments(self, |
| 1279 | call_site_type.Get(), |
| 1280 | collector_array_class.Get(), |
| 1281 | collector_arguments_start)); |
| 1282 | if (call_site_type.IsNull()) { |
| 1283 | DCHECK(self->IsExceptionPending()); |
| 1284 | return nullptr; |
| 1285 | } |
| 1286 | } else { |
| 1287 | collector_arguments_length = 0; |
| 1288 | } |
| 1289 | |
| 1290 | if (call_site_type->GetNumberOfPTypes() != bsm->GetMethodType()->GetNumberOfPTypes()) { |
| 1291 | ThrowWrongMethodTypeException(bsm->GetMethodType(), call_site_type.Get()); |
| 1292 | return nullptr; |
| 1293 | } |
| 1294 | |
| 1295 | // BSM invocation has a different set of exceptions that |
| 1296 | // j.l.i.MethodHandle.invoke(). Scan arguments looking for CCE |
| 1297 | // "opportunities". Unfortunately we cannot just leave this to the |
| 1298 | // method handle invocation as this might generate a WMTE. |
| 1299 | for (int32_t i = 0; i < call_site_type->GetNumberOfPTypes(); ++i) { |
| 1300 | ObjPtr<mirror::Class> from = call_site_type->GetPTypes()->Get(i); |
| 1301 | ObjPtr<mirror::Class> to = bsm->GetMethodType()->GetPTypes()->Get(i); |
| 1302 | if (!IsParameterTypeConvertible(from, to)) { |
| 1303 | ThrowClassCastException(from, to); |
| 1304 | return nullptr; |
| 1305 | } |
| 1306 | } |
| 1307 | if (!IsReturnTypeConvertible(call_site_type->GetRType(), bsm->GetMethodType()->GetRType())) { |
| 1308 | ThrowClassCastException(bsm->GetMethodType()->GetRType(), call_site_type->GetRType()); |
| 1309 | return nullptr; |
| 1310 | } |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1311 | |
| 1312 | // Set-up a shadow frame for invoking the bootstrap method handle. |
| 1313 | ShadowFrameAllocaUniquePtr bootstrap_frame = |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1314 | CREATE_SHADOW_FRAME(call_site_type->NumberOfVRegs(), |
| 1315 | nullptr, |
| 1316 | referrer, |
| 1317 | shadow_frame.GetDexPC()); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1318 | ScopedStackedShadowFramePusher pusher( |
| 1319 | self, bootstrap_frame.get(), StackedShadowFrameType::kShadowFrameUnderConstruction); |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1320 | ShadowFrameSetter setter(bootstrap_frame.get(), 0u); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1321 | |
| 1322 | // The first parameter is a MethodHandles lookup instance. |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1323 | Handle<mirror::Class> lookup_class = |
| 1324 | hs.NewHandle(shadow_frame.GetMethod()->GetDeclaringClass()); |
| 1325 | ObjPtr<mirror::MethodHandlesLookup> lookup = |
| 1326 | mirror::MethodHandlesLookup::Create(self, lookup_class); |
| 1327 | if (lookup.IsNull()) { |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1328 | DCHECK(self->IsExceptionPending()); |
| 1329 | return nullptr; |
| 1330 | } |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1331 | setter.SetReference(lookup); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1332 | |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1333 | // Pack the remaining arguments into the frame. |
| 1334 | int number_of_arguments = call_site_type->GetNumberOfPTypes(); |
| 1335 | int argument_index; |
| 1336 | for (argument_index = 1; argument_index < number_of_arguments; ++argument_index) { |
| 1337 | if (argument_index == number_of_arguments - 1 && |
| 1338 | call_site_type->GetPTypes()->Get(argument_index)->IsArrayClass()) { |
| 1339 | ObjPtr<mirror::Class> array_type = call_site_type->GetPTypes()->Get(argument_index); |
| 1340 | if (!PackCollectorArrayForBootstrapMethod(self, |
| 1341 | referrer, |
| 1342 | array_type, |
| 1343 | collector_arguments_length, |
| 1344 | &it, |
| 1345 | &setter)) { |
| 1346 | DCHECK(self->IsExceptionPending()); |
| 1347 | return nullptr; |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1348 | } |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1349 | } else if (!PackArgumentForBootstrapMethod(self, referrer, &it, &setter)) { |
| 1350 | DCHECK(self->IsExceptionPending()); |
| 1351 | return nullptr; |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1352 | } |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1353 | it.Next(); |
| 1354 | } |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1355 | DCHECK(!it.HasNext()); |
| 1356 | DCHECK(setter.Done()); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1357 | |
| 1358 | // Invoke the bootstrap method handle. |
| 1359 | JValue result; |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1360 | RangeInstructionOperands operands(0, bootstrap_frame->NumberOfVRegs()); |
| 1361 | bool invoke_success = MethodHandleInvoke(self, |
| 1362 | *bootstrap_frame, |
| 1363 | bsm, |
| 1364 | call_site_type, |
| 1365 | &operands, |
| 1366 | &result); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1367 | if (!invoke_success) { |
| 1368 | DCHECK(self->IsExceptionPending()); |
| 1369 | return nullptr; |
| 1370 | } |
| 1371 | |
| 1372 | Handle<mirror::Object> object(hs.NewHandle(result.GetL())); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1373 | if (UNLIKELY(object.IsNull())) { |
Orion Hodson | da1cdd0 | 2018-01-31 18:08:28 +0000 | [diff] [blame] | 1374 | // This will typically be for LambdaMetafactory which is not supported. |
Orion Hodson | 76e6adb | 2018-02-23 13:15:55 +0000 | [diff] [blame] | 1375 | ThrowClassCastException("Bootstrap method returned null"); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1376 | return nullptr; |
| 1377 | } |
| 1378 | |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1379 | // Check the result type is a subclass of j.l.i.CallSite. |
Vladimir Marko | c7aa87e | 2018-05-24 15:19:52 +0100 | [diff] [blame] | 1380 | ObjPtr<mirror::Class> call_site_class = GetClassRoot<mirror::CallSite>(class_linker); |
| 1381 | if (UNLIKELY(!object->InstanceOf(call_site_class))) { |
| 1382 | ThrowClassCastException(object->GetClass(), call_site_class); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1383 | return nullptr; |
| 1384 | } |
| 1385 | |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1386 | // Check the call site target is not null as we're going to invoke it. |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1387 | ObjPtr<mirror::CallSite> call_site = |
| 1388 | ObjPtr<mirror::CallSite>::DownCast(ObjPtr<mirror::Object>(result.GetL())); |
| 1389 | ObjPtr<mirror::MethodHandle> target = call_site->GetTarget(); |
| 1390 | if (UNLIKELY(target == nullptr)) { |
Orion Hodson | a5dca52 | 2018-02-27 12:42:11 +0000 | [diff] [blame] | 1391 | ThrowClassCastException("Bootstrap method returned a CallSite with a null target"); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1392 | return nullptr; |
| 1393 | } |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1394 | return call_site; |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1395 | } |
| 1396 | |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1397 | namespace { |
| 1398 | |
| 1399 | ObjPtr<mirror::CallSite> DoResolveCallSite(Thread* self, |
| 1400 | ShadowFrame& shadow_frame, |
| 1401 | uint32_t call_site_idx) |
| 1402 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 1403 | StackHandleScope<1> hs(self); |
| 1404 | Handle<mirror::DexCache> dex_cache(hs.NewHandle(shadow_frame.GetMethod()->GetDexCache())); |
| 1405 | |
| 1406 | // Get the call site from the DexCache if present. |
| 1407 | ObjPtr<mirror::CallSite> call_site = dex_cache->GetResolvedCallSite(call_site_idx); |
| 1408 | if (LIKELY(call_site != nullptr)) { |
| 1409 | return call_site; |
| 1410 | } |
| 1411 | |
| 1412 | // Invoke the bootstrap method to get a candidate call site. |
| 1413 | call_site = InvokeBootstrapMethod(self, shadow_frame, call_site_idx); |
| 1414 | if (UNLIKELY(call_site == nullptr)) { |
| 1415 | if (!self->GetException()->IsError()) { |
| 1416 | // Use a BootstrapMethodError if the exception is not an instance of java.lang.Error. |
| 1417 | ThrowWrappedBootstrapMethodError("Exception from call site #%u bootstrap method", |
| 1418 | call_site_idx); |
| 1419 | } |
| 1420 | return nullptr; |
| 1421 | } |
| 1422 | |
| 1423 | // Attempt to place the candidate call site into the DexCache, return the winning call site. |
| 1424 | return dex_cache->SetResolvedCallSite(call_site_idx, call_site); |
| 1425 | } |
| 1426 | |
| 1427 | } // namespace |
| 1428 | |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1429 | bool DoInvokeCustom(Thread* self, |
| 1430 | ShadowFrame& shadow_frame, |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1431 | uint32_t call_site_idx, |
| 1432 | const InstructionOperands* operands, |
| 1433 | JValue* result) { |
Alex Light | 848574c | 2017-09-25 16:59:39 -0700 | [diff] [blame] | 1434 | // Make sure to check for async exceptions |
| 1435 | if (UNLIKELY(self->ObserveAsyncException())) { |
| 1436 | return false; |
| 1437 | } |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1438 | |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1439 | // invoke-custom is not supported in transactions. In transactions |
| 1440 | // there is a limited set of types supported. invoke-custom allows |
| 1441 | // running arbitrary code and instantiating arbitrary types. |
| 1442 | CHECK(!Runtime::Current()->IsActiveTransaction()); |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1443 | |
| 1444 | ObjPtr<mirror::CallSite> call_site = DoResolveCallSite(self, shadow_frame, call_site_idx); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1445 | if (call_site.IsNull()) { |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1446 | DCHECK(self->IsExceptionPending()); |
| 1447 | return false; |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1448 | } |
| 1449 | |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1450 | StackHandleScope<2> hs(self); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1451 | Handle<mirror::MethodHandle> target = hs.NewHandle(call_site->GetTarget()); |
| 1452 | Handle<mirror::MethodType> target_method_type = hs.NewHandle(target->GetMethodType()); |
Orion Hodson | 4c8e12e | 2018-05-18 08:33:20 +0100 | [diff] [blame] | 1453 | DCHECK_EQ(operands->GetNumberOfOperands(), target_method_type->NumberOfVRegs()) |
| 1454 | << " call_site_idx" << call_site_idx; |
| 1455 | return MethodHandleInvokeExact(self, |
| 1456 | shadow_frame, |
| 1457 | target, |
| 1458 | target_method_type, |
| 1459 | operands, |
| 1460 | result); |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1461 | } |
| 1462 | |
Vladimir Marko | 6ec2a1b | 2018-05-22 15:33:48 +0100 | [diff] [blame] | 1463 | // Assign register 'src_reg' from shadow_frame to register 'dest_reg' into new_shadow_frame. |
| 1464 | static inline void AssignRegister(ShadowFrame* new_shadow_frame, const ShadowFrame& shadow_frame, |
| 1465 | size_t dest_reg, size_t src_reg) |
| 1466 | REQUIRES_SHARED(Locks::mutator_lock_) { |
| 1467 | // Uint required, so that sign extension does not make this wrong on 64b systems |
| 1468 | uint32_t src_value = shadow_frame.GetVReg(src_reg); |
| 1469 | ObjPtr<mirror::Object> o = shadow_frame.GetVRegReference<kVerifyNone>(src_reg); |
| 1470 | |
| 1471 | // If both register locations contains the same value, the register probably holds a reference. |
| 1472 | // Note: As an optimization, non-moving collectors leave a stale reference value |
| 1473 | // in the references array even after the original vreg was overwritten to a non-reference. |
Vladimir Marko | 78baed5 | 2018-10-11 10:44:58 +0100 | [diff] [blame] | 1474 | if (src_value == reinterpret_cast32<uint32_t>(o.Ptr())) { |
Vladimir Marko | 6ec2a1b | 2018-05-22 15:33:48 +0100 | [diff] [blame] | 1475 | new_shadow_frame->SetVRegReference(dest_reg, o); |
| 1476 | } else { |
| 1477 | new_shadow_frame->SetVReg(dest_reg, src_value); |
| 1478 | } |
| 1479 | } |
| 1480 | |
Narayan Kamath | c3b7f1a | 2016-10-19 11:05:04 +0100 | [diff] [blame] | 1481 | template <bool is_range> |
| 1482 | inline void CopyRegisters(ShadowFrame& caller_frame, |
| 1483 | ShadowFrame* callee_frame, |
| 1484 | const uint32_t (&arg)[Instruction::kMaxVarArgRegs], |
| 1485 | const size_t first_src_reg, |
| 1486 | const size_t first_dest_reg, |
| 1487 | const size_t num_regs) { |
| 1488 | if (is_range) { |
| 1489 | const size_t dest_reg_bound = first_dest_reg + num_regs; |
| 1490 | for (size_t src_reg = first_src_reg, dest_reg = first_dest_reg; dest_reg < dest_reg_bound; |
| 1491 | ++dest_reg, ++src_reg) { |
| 1492 | AssignRegister(callee_frame, caller_frame, dest_reg, src_reg); |
| 1493 | } |
| 1494 | } else { |
| 1495 | DCHECK_LE(num_regs, arraysize(arg)); |
| 1496 | |
| 1497 | for (size_t arg_index = 0; arg_index < num_regs; ++arg_index) { |
| 1498 | AssignRegister(callee_frame, caller_frame, first_dest_reg + arg_index, arg[arg_index]); |
| 1499 | } |
| 1500 | } |
| 1501 | } |
| 1502 | |
Igor Murashkin | 6918bf1 | 2015-09-27 19:19:06 -0700 | [diff] [blame] | 1503 | template <bool is_range, |
Narayan Kamath | 370423d | 2016-10-03 16:51:22 +0100 | [diff] [blame] | 1504 | bool do_assignability_check> |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1505 | static inline bool DoCallCommon(ArtMethod* called_method, |
| 1506 | Thread* self, |
| 1507 | ShadowFrame& shadow_frame, |
| 1508 | JValue* result, |
| 1509 | uint16_t number_of_inputs, |
Narayan Kamath | 370423d | 2016-10-03 16:51:22 +0100 | [diff] [blame] | 1510 | uint32_t (&arg)[Instruction::kMaxVarArgRegs], |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1511 | uint32_t vregC) { |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1512 | bool string_init = false; |
| 1513 | // Replace calls to String.<init> with equivalent StringFactory call. |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1514 | if (UNLIKELY(called_method->GetDeclaringClass()->IsStringClass() |
| 1515 | && called_method->IsConstructor())) { |
Nicolas Geoffray | da079bb | 2016-09-26 17:56:07 +0100 | [diff] [blame] | 1516 | called_method = WellKnownClasses::StringInitToStringFactory(called_method); |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1517 | string_init = true; |
| 1518 | } |
| 1519 | |
Alex Light | daf58c8 | 2016-03-16 23:00:49 +0000 | [diff] [blame] | 1520 | // Compute method information. |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame] | 1521 | CodeItemDataAccessor accessor(called_method->DexInstructionData()); |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1522 | // Number of registers for the callee's call frame. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1523 | uint16_t num_regs; |
Jeff Hao | 5ea8413 | 2017-05-05 16:59:29 -0700 | [diff] [blame] | 1524 | // Test whether to use the interpreter or compiler entrypoint, and save that result to pass to |
| 1525 | // PerformCall. A deoptimization could occur at any time, and we shouldn't change which |
| 1526 | // entrypoint to use once we start building the shadow frame. |
Mathieu Chartier | 448bbcf | 2017-07-06 12:05:13 -0700 | [diff] [blame] | 1527 | |
| 1528 | // For unstarted runtimes, always use the interpreter entrypoint. This fixes the case where we are |
| 1529 | // doing cross compilation. Note that GetEntryPointFromQuickCompiledCode doesn't use the image |
| 1530 | // pointer size here and this may case an overflow if it is called from the compiler. b/62402160 |
| 1531 | const bool use_interpreter_entrypoint = !Runtime::Current()->IsStarted() || |
| 1532 | ClassLinker::ShouldUseInterpreterEntrypoint( |
| 1533 | called_method, |
| 1534 | called_method->GetEntryPointFromQuickCompiledCode()); |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 1535 | if (LIKELY(accessor.HasCodeItem())) { |
Jeff Hao | 5ea8413 | 2017-05-05 16:59:29 -0700 | [diff] [blame] | 1536 | // When transitioning to compiled code, space only needs to be reserved for the input registers. |
| 1537 | // The rest of the frame gets discarded. This also prevents accessing the called method's code |
| 1538 | // item, saving memory by keeping code items of compiled code untouched. |
Mathieu Chartier | 448bbcf | 2017-07-06 12:05:13 -0700 | [diff] [blame] | 1539 | if (!use_interpreter_entrypoint) { |
| 1540 | DCHECK(!Runtime::Current()->IsAotCompiler()) << "Compiler should use interpreter entrypoint"; |
Jeff Hao | 5ea8413 | 2017-05-05 16:59:29 -0700 | [diff] [blame] | 1541 | num_regs = number_of_inputs; |
| 1542 | } else { |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 1543 | num_regs = accessor.RegistersSize(); |
| 1544 | DCHECK_EQ(string_init ? number_of_inputs - 1 : number_of_inputs, accessor.InsSize()); |
Jeff Hao | 5ea8413 | 2017-05-05 16:59:29 -0700 | [diff] [blame] | 1545 | } |
Nicolas Geoffray | 0182229 | 2017-03-09 09:03:19 +0000 | [diff] [blame] | 1546 | } else { |
| 1547 | DCHECK(called_method->IsNative() || called_method->IsProxyMethod()); |
| 1548 | num_regs = number_of_inputs; |
Jeff Hao | df79ddb | 2017-02-27 14:47:06 -0800 | [diff] [blame] | 1549 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1550 | |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1551 | // Hack for String init: |
| 1552 | // |
| 1553 | // Rewrite invoke-x java.lang.String.<init>(this, a, b, c, ...) into: |
| 1554 | // invoke-x StringFactory(a, b, c, ...) |
| 1555 | // by effectively dropping the first virtual register from the invoke. |
| 1556 | // |
| 1557 | // (at this point the ArtMethod has already been replaced, |
| 1558 | // so we just need to fix-up the arguments) |
David Brazdil | 65902e8 | 2016-01-15 09:35:13 +0000 | [diff] [blame] | 1559 | // |
| 1560 | // Note that FindMethodFromCode in entrypoint_utils-inl.h was also special-cased |
| 1561 | // to handle the compiler optimization of replacing `this` with null without |
| 1562 | // throwing NullPointerException. |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1563 | uint32_t string_init_vreg_this = is_range ? vregC : arg[0]; |
Igor Murashkin | a06b49b | 2015-06-25 15:18:12 -0700 | [diff] [blame] | 1564 | if (UNLIKELY(string_init)) { |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1565 | DCHECK_GT(num_regs, 0u); // As the method is an instance method, there should be at least 1. |
Igor Murashkin | a06b49b | 2015-06-25 15:18:12 -0700 | [diff] [blame] | 1566 | |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1567 | // The new StringFactory call is static and has one fewer argument. |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 1568 | if (!accessor.HasCodeItem()) { |
Igor Murashkin | a06b49b | 2015-06-25 15:18:12 -0700 | [diff] [blame] | 1569 | DCHECK(called_method->IsNative() || called_method->IsProxyMethod()); |
| 1570 | num_regs--; |
| 1571 | } // else ... don't need to change num_regs since it comes up from the string_init's code item |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1572 | number_of_inputs--; |
| 1573 | |
| 1574 | // Rewrite the var-args, dropping the 0th argument ("this") |
Igor Murashkin | 6918bf1 | 2015-09-27 19:19:06 -0700 | [diff] [blame] | 1575 | for (uint32_t i = 1; i < arraysize(arg); ++i) { |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1576 | arg[i - 1] = arg[i]; |
| 1577 | } |
Igor Murashkin | 6918bf1 | 2015-09-27 19:19:06 -0700 | [diff] [blame] | 1578 | arg[arraysize(arg) - 1] = 0; |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1579 | |
| 1580 | // Rewrite the non-var-arg case |
| 1581 | vregC++; // Skips the 0th vreg in the range ("this"). |
| 1582 | } |
| 1583 | |
| 1584 | // Parameter registers go at the end of the shadow frame. |
| 1585 | DCHECK_GE(num_regs, number_of_inputs); |
| 1586 | size_t first_dest_reg = num_regs - number_of_inputs; |
| 1587 | DCHECK_NE(first_dest_reg, (size_t)-1); |
| 1588 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 1589 | // Allocate shadow frame on the stack. |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1590 | const char* old_cause = self->StartAssertNoThreadSuspension("DoCallCommon"); |
Andreas Gampe | b302592 | 2015-09-01 14:45:00 -0700 | [diff] [blame] | 1591 | ShadowFrameAllocaUniquePtr shadow_frame_unique_ptr = |
Andreas Gampe | 03ec930 | 2015-08-27 17:41:47 -0700 | [diff] [blame] | 1592 | CREATE_SHADOW_FRAME(num_regs, &shadow_frame, called_method, /* dex pc */ 0); |
Andreas Gampe | b302592 | 2015-09-01 14:45:00 -0700 | [diff] [blame] | 1593 | ShadowFrame* new_shadow_frame = shadow_frame_unique_ptr.get(); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 1594 | |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1595 | // Initialize new shadow frame by copying the registers from the callee shadow frame. |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 1596 | if (do_assignability_check) { |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 1597 | // Slow path. |
| 1598 | // We might need to do class loading, which incurs a thread state change to kNative. So |
| 1599 | // register the shadow frame as under construction and allow suspension again. |
Mingyao Yang | 1f2d3ba | 2015-05-18 12:12:50 -0700 | [diff] [blame] | 1600 | ScopedStackedShadowFramePusher pusher( |
Sebastien Hertz | f795869 | 2015-06-09 14:09:14 +0200 | [diff] [blame] | 1601 | self, new_shadow_frame, StackedShadowFrameType::kShadowFrameUnderConstruction); |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 1602 | self->EndAssertNoThreadSuspension(old_cause); |
| 1603 | |
Igor Murashkin | 9f95ba7 | 2016-02-01 14:21:25 -0800 | [diff] [blame] | 1604 | // ArtMethod here is needed to check type information of the call site against the callee. |
| 1605 | // Type information is retrieved from a DexFile/DexCache for that respective declared method. |
| 1606 | // |
| 1607 | // As a special case for proxy methods, which are not dex-backed, |
| 1608 | // we have to retrieve type information from the proxy's method |
| 1609 | // interface method instead (which is dex backed since proxies are never interfaces). |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 1610 | ArtMethod* method = |
| 1611 | new_shadow_frame->GetMethod()->GetInterfaceMethodIfProxy(kRuntimePointerSize); |
Igor Murashkin | 9f95ba7 | 2016-02-01 14:21:25 -0800 | [diff] [blame] | 1612 | |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 1613 | // 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] | 1614 | // to get the exact type of each reference argument. |
Igor Murashkin | 9f95ba7 | 2016-02-01 14:21:25 -0800 | [diff] [blame] | 1615 | const DexFile::TypeList* params = method->GetParameterTypeList(); |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 1616 | uint32_t shorty_len = 0; |
Igor Murashkin | 9f95ba7 | 2016-02-01 14:21:25 -0800 | [diff] [blame] | 1617 | const char* shorty = method->GetShorty(&shorty_len); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1618 | |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 1619 | // Handle receiver apart since it's not part of the shorty. |
| 1620 | size_t dest_reg = first_dest_reg; |
| 1621 | size_t arg_offset = 0; |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1622 | |
Igor Murashkin | 9f95ba7 | 2016-02-01 14:21:25 -0800 | [diff] [blame] | 1623 | if (!method->IsStatic()) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 1624 | size_t receiver_reg = is_range ? vregC : arg[0]; |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 1625 | new_shadow_frame->SetVRegReference(dest_reg, shadow_frame.GetVRegReference(receiver_reg)); |
| 1626 | ++dest_reg; |
| 1627 | ++arg_offset; |
Igor Murashkin | a06b49b | 2015-06-25 15:18:12 -0700 | [diff] [blame] | 1628 | DCHECK(!string_init); // All StringFactory methods are static. |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 1629 | } |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1630 | |
| 1631 | // Copy the caller's invoke-* arguments into the callee's parameter registers. |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 1632 | for (uint32_t shorty_pos = 0; dest_reg < num_regs; ++shorty_pos, ++dest_reg, ++arg_offset) { |
Igor Murashkin | a06b49b | 2015-06-25 15:18:12 -0700 | [diff] [blame] | 1633 | // Skip the 0th 'shorty' type since it represents the return type. |
| 1634 | DCHECK_LT(shorty_pos + 1, shorty_len) << "for shorty '" << shorty << "'"; |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1635 | const size_t src_reg = (is_range) ? vregC + arg_offset : arg[arg_offset]; |
| 1636 | switch (shorty[shorty_pos + 1]) { |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1637 | // Handle Object references. 1 virtual register slot. |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1638 | case 'L': { |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 1639 | ObjPtr<mirror::Object> o = shadow_frame.GetVRegReference(src_reg); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 1640 | if (do_assignability_check && o != nullptr) { |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 1641 | const dex::TypeIndex type_idx = params->GetTypeItem(shorty_pos).type_idx_; |
Vladimir Marko | 942fd31 | 2017-01-16 20:52:19 +0000 | [diff] [blame] | 1642 | ObjPtr<mirror::Class> arg_type = method->GetDexCache()->GetResolvedType(type_idx); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 1643 | if (arg_type == nullptr) { |
Mathieu Chartier | e22305b | 2016-10-26 21:04:58 -0700 | [diff] [blame] | 1644 | StackHandleScope<1> hs(self); |
| 1645 | // Preserve o since it is used below and GetClassFromTypeIndex may cause thread |
| 1646 | // suspension. |
| 1647 | HandleWrapperObjPtr<mirror::Object> h = hs.NewHandleWrapper(&o); |
Vladimir Marko | b45528c | 2017-07-27 14:14:28 +0100 | [diff] [blame] | 1648 | arg_type = method->ResolveClassFromTypeIndex(type_idx); |
Mathieu Chartier | e22305b | 2016-10-26 21:04:58 -0700 | [diff] [blame] | 1649 | if (arg_type == nullptr) { |
| 1650 | CHECK(self->IsExceptionPending()); |
| 1651 | return false; |
| 1652 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1653 | } |
| 1654 | if (!o->VerifierInstanceOf(arg_type)) { |
| 1655 | // This should never happen. |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 1656 | std::string temp1, temp2; |
Orion Hodson | fef0664 | 2016-11-25 16:07:11 +0000 | [diff] [blame] | 1657 | self->ThrowNewExceptionF("Ljava/lang/InternalError;", |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1658 | "Invoking %s with bad arg %d, type '%s' not instance of '%s'", |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 1659 | new_shadow_frame->GetMethod()->GetName(), shorty_pos, |
Ian Rogers | 1ff3c98 | 2014-08-12 02:30:58 -0700 | [diff] [blame] | 1660 | o->GetClass()->GetDescriptor(&temp1), |
| 1661 | arg_type->GetDescriptor(&temp2)); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1662 | return false; |
| 1663 | } |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 1664 | } |
Vladimir Marko | 6ec2a1b | 2018-05-22 15:33:48 +0100 | [diff] [blame] | 1665 | new_shadow_frame->SetVRegReference(dest_reg, o); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1666 | break; |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 1667 | } |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1668 | // Handle doubles and longs. 2 consecutive virtual register slots. |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1669 | case 'J': case 'D': { |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1670 | uint64_t wide_value = |
| 1671 | (static_cast<uint64_t>(shadow_frame.GetVReg(src_reg + 1)) << BitSizeOf<uint32_t>()) | |
| 1672 | static_cast<uint32_t>(shadow_frame.GetVReg(src_reg)); |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1673 | new_shadow_frame->SetVRegLong(dest_reg, wide_value); |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1674 | // Skip the next virtual register slot since we already used it. |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1675 | ++dest_reg; |
| 1676 | ++arg_offset; |
| 1677 | break; |
| 1678 | } |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1679 | // Handle all other primitives that are always 1 virtual register slot. |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1680 | default: |
| 1681 | new_shadow_frame->SetVReg(dest_reg, shadow_frame.GetVReg(src_reg)); |
| 1682 | break; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1683 | } |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1684 | } |
| 1685 | } else { |
Sebastien Hertz | 9ace87b | 2013-09-27 11:48:09 +0200 | [diff] [blame] | 1686 | if (is_range) { |
Narayan Kamath | c3b7f1a | 2016-10-19 11:05:04 +0100 | [diff] [blame] | 1687 | DCHECK_EQ(num_regs, first_dest_reg + number_of_inputs); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1688 | } |
Narayan Kamath | c3b7f1a | 2016-10-19 11:05:04 +0100 | [diff] [blame] | 1689 | |
| 1690 | CopyRegisters<is_range>(shadow_frame, |
| 1691 | new_shadow_frame, |
| 1692 | arg, |
| 1693 | vregC, |
| 1694 | first_dest_reg, |
| 1695 | number_of_inputs); |
Andreas Gampe | 2a0d4ec | 2014-06-02 22:05:22 -0700 | [diff] [blame] | 1696 | self->EndAssertNoThreadSuspension(old_cause); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1697 | } |
| 1698 | |
Jeff Hao | 5ea8413 | 2017-05-05 16:59:29 -0700 | [diff] [blame] | 1699 | PerformCall(self, |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 1700 | accessor, |
Jeff Hao | 5ea8413 | 2017-05-05 16:59:29 -0700 | [diff] [blame] | 1701 | shadow_frame.GetMethod(), |
| 1702 | first_dest_reg, |
| 1703 | new_shadow_frame, |
| 1704 | result, |
| 1705 | use_interpreter_entrypoint); |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1706 | |
| 1707 | if (string_init && !self->IsExceptionPending()) { |
Mingyao Yang | ffedec5 | 2016-05-19 10:48:40 -0700 | [diff] [blame] | 1708 | SetStringInitValueToAllAliases(&shadow_frame, string_init_vreg_this, *result); |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 1709 | } |
| 1710 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1711 | return !self->IsExceptionPending(); |
| 1712 | } |
| 1713 | |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1714 | template<bool is_range, bool do_assignability_check> |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1715 | bool DoCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame, |
| 1716 | const Instruction* inst, uint16_t inst_data, JValue* result) { |
| 1717 | // Argument word count. |
Roland Levillain | 4b8f1ec | 2015-08-26 18:34:03 +0100 | [diff] [blame] | 1718 | const uint16_t number_of_inputs = |
| 1719 | (is_range) ? inst->VRegA_3rc(inst_data) : inst->VRegA_35c(inst_data); |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1720 | |
| 1721 | // TODO: find a cleaner way to separate non-range and range information without duplicating |
| 1722 | // code. |
Igor Murashkin | 6918bf1 | 2015-09-27 19:19:06 -0700 | [diff] [blame] | 1723 | uint32_t arg[Instruction::kMaxVarArgRegs] = {}; // only used in invoke-XXX. |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1724 | uint32_t vregC = 0; |
| 1725 | if (is_range) { |
| 1726 | vregC = inst->VRegC_3rc(); |
| 1727 | } else { |
| 1728 | vregC = inst->VRegC_35c(); |
| 1729 | inst->GetVarArgs(arg, inst_data); |
| 1730 | } |
| 1731 | |
| 1732 | return DoCallCommon<is_range, do_assignability_check>( |
| 1733 | called_method, self, shadow_frame, |
| 1734 | result, number_of_inputs, arg, vregC); |
| 1735 | } |
| 1736 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1737 | template <bool is_range, bool do_access_check, bool transaction_active> |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 1738 | bool DoFilledNewArray(const Instruction* inst, |
| 1739 | const ShadowFrame& shadow_frame, |
| 1740 | Thread* self, |
| 1741 | JValue* result) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1742 | DCHECK(inst->Opcode() == Instruction::FILLED_NEW_ARRAY || |
| 1743 | inst->Opcode() == Instruction::FILLED_NEW_ARRAY_RANGE); |
| 1744 | const int32_t length = is_range ? inst->VRegA_3rc() : inst->VRegA_35c(); |
| 1745 | if (!is_range) { |
| 1746 | // Checks FILLED_NEW_ARRAY's length does not exceed 5 arguments. |
| 1747 | CHECK_LE(length, 5); |
| 1748 | } |
| 1749 | if (UNLIKELY(length < 0)) { |
| 1750 | ThrowNegativeArraySizeException(length); |
| 1751 | return false; |
| 1752 | } |
| 1753 | uint16_t type_idx = is_range ? inst->VRegB_3rc() : inst->VRegB_35c(); |
Andreas Gampe | a5b09a6 | 2016-11-17 15:21:22 -0800 | [diff] [blame] | 1754 | ObjPtr<mirror::Class> array_class = ResolveVerifyAndClinit(dex::TypeIndex(type_idx), |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 1755 | shadow_frame.GetMethod(), |
| 1756 | self, |
| 1757 | false, |
| 1758 | do_access_check); |
Mathieu Chartier | 52ea33b | 2015-06-18 16:48:52 -0700 | [diff] [blame] | 1759 | if (UNLIKELY(array_class == nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1760 | DCHECK(self->IsExceptionPending()); |
| 1761 | return false; |
| 1762 | } |
Mathieu Chartier | 52ea33b | 2015-06-18 16:48:52 -0700 | [diff] [blame] | 1763 | CHECK(array_class->IsArrayClass()); |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 1764 | ObjPtr<mirror::Class> component_class = array_class->GetComponentType(); |
Mathieu Chartier | 52ea33b | 2015-06-18 16:48:52 -0700 | [diff] [blame] | 1765 | const bool is_primitive_int_component = component_class->IsPrimitiveInt(); |
| 1766 | if (UNLIKELY(component_class->IsPrimitive() && !is_primitive_int_component)) { |
| 1767 | if (component_class->IsPrimitiveLong() || component_class->IsPrimitiveDouble()) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1768 | ThrowRuntimeException("Bad filled array request for type %s", |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 1769 | component_class->PrettyDescriptor().c_str()); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1770 | } else { |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 1771 | self->ThrowNewExceptionF("Ljava/lang/InternalError;", |
Brian Carlstrom | 4fa0bcd | 2013-12-10 11:24:21 -0800 | [diff] [blame] | 1772 | "Found type %s; filled-new-array not implemented for anything but 'int'", |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 1773 | component_class->PrettyDescriptor().c_str()); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1774 | } |
| 1775 | return false; |
| 1776 | } |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 1777 | ObjPtr<mirror::Object> new_array = mirror::Array::Alloc<true>( |
| 1778 | self, |
| 1779 | array_class, |
| 1780 | length, |
| 1781 | array_class->GetComponentSizeShift(), |
| 1782 | Runtime::Current()->GetHeap()->GetCurrentAllocator()); |
Mathieu Chartier | 52ea33b | 2015-06-18 16:48:52 -0700 | [diff] [blame] | 1783 | if (UNLIKELY(new_array == nullptr)) { |
| 1784 | self->AssertPendingOOMException(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1785 | return false; |
| 1786 | } |
Igor Murashkin | 158f35c | 2015-06-10 15:55:30 -0700 | [diff] [blame] | 1787 | uint32_t arg[Instruction::kMaxVarArgRegs]; // only used in filled-new-array. |
| 1788 | uint32_t vregC = 0; // only used in filled-new-array-range. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1789 | if (is_range) { |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 1790 | vregC = inst->VRegC_3rc(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1791 | } else { |
Ian Rogers | 29a2648 | 2014-05-02 15:27:29 -0700 | [diff] [blame] | 1792 | inst->GetVarArgs(arg); |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 1793 | } |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 1794 | for (int32_t i = 0; i < length; ++i) { |
| 1795 | size_t src_reg = is_range ? vregC + i : arg[i]; |
| 1796 | if (is_primitive_int_component) { |
Mathieu Chartier | 52ea33b | 2015-06-18 16:48:52 -0700 | [diff] [blame] | 1797 | new_array->AsIntArray()->SetWithoutChecks<transaction_active>( |
| 1798 | i, shadow_frame.GetVReg(src_reg)); |
Sebastien Hertz | abff643 | 2014-01-27 18:01:39 +0100 | [diff] [blame] | 1799 | } else { |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 1800 | new_array->AsObjectArray<mirror::Object>()->SetWithoutChecks<transaction_active>( |
Mathieu Chartier | 52ea33b | 2015-06-18 16:48:52 -0700 | [diff] [blame] | 1801 | i, shadow_frame.GetVRegReference(src_reg)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1802 | } |
| 1803 | } |
| 1804 | |
Mathieu Chartier | 52ea33b | 2015-06-18 16:48:52 -0700 | [diff] [blame] | 1805 | result->SetL(new_array); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1806 | return true; |
| 1807 | } |
| 1808 | |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 1809 | // TODO: Use ObjPtr here. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1810 | template<typename T> |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 1811 | static void RecordArrayElementsInTransactionImpl(mirror::PrimitiveArray<T>* array, |
| 1812 | int32_t count) |
| 1813 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1814 | Runtime* runtime = Runtime::Current(); |
| 1815 | for (int32_t i = 0; i < count; ++i) { |
| 1816 | runtime->RecordWriteArray(array, i, array->GetWithoutChecks(i)); |
| 1817 | } |
| 1818 | } |
| 1819 | |
Mathieu Chartier | ef41db7 | 2016-10-25 15:08:01 -0700 | [diff] [blame] | 1820 | void RecordArrayElementsInTransaction(ObjPtr<mirror::Array> array, int32_t count) |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1821 | REQUIRES_SHARED(Locks::mutator_lock_) { |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1822 | DCHECK(Runtime::Current()->IsActiveTransaction()); |
| 1823 | DCHECK(array != nullptr); |
| 1824 | DCHECK_LE(count, array->GetLength()); |
| 1825 | Primitive::Type primitive_component_type = array->GetClass()->GetComponentType()->GetPrimitiveType(); |
| 1826 | switch (primitive_component_type) { |
| 1827 | case Primitive::kPrimBoolean: |
| 1828 | RecordArrayElementsInTransactionImpl(array->AsBooleanArray(), count); |
| 1829 | break; |
| 1830 | case Primitive::kPrimByte: |
| 1831 | RecordArrayElementsInTransactionImpl(array->AsByteArray(), count); |
| 1832 | break; |
| 1833 | case Primitive::kPrimChar: |
| 1834 | RecordArrayElementsInTransactionImpl(array->AsCharArray(), count); |
| 1835 | break; |
| 1836 | case Primitive::kPrimShort: |
| 1837 | RecordArrayElementsInTransactionImpl(array->AsShortArray(), count); |
| 1838 | break; |
| 1839 | case Primitive::kPrimInt: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1840 | RecordArrayElementsInTransactionImpl(array->AsIntArray(), count); |
| 1841 | break; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1842 | case Primitive::kPrimFloat: |
| 1843 | RecordArrayElementsInTransactionImpl(array->AsFloatArray(), count); |
| 1844 | break; |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1845 | case Primitive::kPrimLong: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1846 | RecordArrayElementsInTransactionImpl(array->AsLongArray(), count); |
| 1847 | break; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 1848 | case Primitive::kPrimDouble: |
| 1849 | RecordArrayElementsInTransactionImpl(array->AsDoubleArray(), count); |
| 1850 | break; |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1851 | default: |
| 1852 | LOG(FATAL) << "Unsupported primitive type " << primitive_component_type |
| 1853 | << " in fill-array-data"; |
| 1854 | break; |
| 1855 | } |
| 1856 | } |
| 1857 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 1858 | // Explicit DoCall template function declarations. |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 1859 | #define EXPLICIT_DO_CALL_TEMPLATE_DECL(_is_range, _do_assignability_check) \ |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1860 | template REQUIRES_SHARED(Locks::mutator_lock_) \ |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 1861 | bool DoCall<_is_range, _do_assignability_check>(ArtMethod* method, Thread* self, \ |
| 1862 | ShadowFrame& shadow_frame, \ |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 1863 | const Instruction* inst, uint16_t inst_data, \ |
| 1864 | JValue* result) |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 1865 | EXPLICIT_DO_CALL_TEMPLATE_DECL(false, false); |
| 1866 | EXPLICIT_DO_CALL_TEMPLATE_DECL(false, true); |
| 1867 | EXPLICIT_DO_CALL_TEMPLATE_DECL(true, false); |
| 1868 | EXPLICIT_DO_CALL_TEMPLATE_DECL(true, true); |
| 1869 | #undef EXPLICIT_DO_CALL_TEMPLATE_DECL |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1870 | |
Orion Hodson | c069a30 | 2017-01-18 09:23:12 +0000 | [diff] [blame] | 1871 | // Explicit DoInvokePolymorphic template function declarations. |
| 1872 | #define EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(_is_range) \ |
| 1873 | template REQUIRES_SHARED(Locks::mutator_lock_) \ |
| 1874 | bool DoInvokePolymorphic<_is_range>( \ |
| 1875 | Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, \ |
| 1876 | uint16_t inst_data, JValue* result) |
| 1877 | EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(false); |
| 1878 | EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL(true); |
Narayan Kamath | 9823e78 | 2016-08-03 12:46:58 +0100 | [diff] [blame] | 1879 | #undef EXPLICIT_DO_INVOKE_POLYMORPHIC_TEMPLATE_DECL |
| 1880 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1881 | // Explicit DoFilledNewArray template function declarations. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1882 | #define EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(_is_range_, _check, _transaction_active) \ |
Andreas Gampe | bdf7f1c | 2016-08-30 16:38:47 -0700 | [diff] [blame] | 1883 | template REQUIRES_SHARED(Locks::mutator_lock_) \ |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 1884 | bool DoFilledNewArray<_is_range_, _check, _transaction_active>(const Instruction* inst, \ |
| 1885 | const ShadowFrame& shadow_frame, \ |
| 1886 | Thread* self, JValue* result) |
| 1887 | #define EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(_transaction_active) \ |
| 1888 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, false, _transaction_active); \ |
| 1889 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(false, true, _transaction_active); \ |
| 1890 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, false, _transaction_active); \ |
| 1891 | EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL(true, true, _transaction_active) |
| 1892 | EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(false); |
| 1893 | EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL(true); |
| 1894 | #undef EXPLICIT_DO_FILLED_NEW_ARRAY_ALL_TEMPLATE_DECL |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 1895 | #undef EXPLICIT_DO_FILLED_NEW_ARRAY_TEMPLATE_DECL |
| 1896 | |
| 1897 | } // namespace interpreter |
| 1898 | } // namespace art |