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 | #ifndef ART_RUNTIME_INTERPRETER_INTERPRETER_COMMON_H_ |
| 18 | #define ART_RUNTIME_INTERPRETER_INTERPRETER_COMMON_H_ |
| 19 | |
| 20 | #include "interpreter.h" |
| 21 | |
| 22 | #include <math.h> |
| 23 | |
| 24 | #include "base/logging.h" |
| 25 | #include "class_linker-inl.h" |
| 26 | #include "common_throws.h" |
| 27 | #include "dex_file-inl.h" |
| 28 | #include "dex_instruction-inl.h" |
| 29 | #include "dex_instruction.h" |
| 30 | #include "entrypoints/entrypoint_utils.h" |
| 31 | #include "gc/accounting/card_table-inl.h" |
Mathieu Chartier | 0cd8135 | 2014-05-22 16:48:55 -0700 | [diff] [blame] | 32 | #include "handle_scope-inl.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 33 | #include "nth_caller_visitor.h" |
| 34 | #include "mirror/art_field-inl.h" |
| 35 | #include "mirror/art_method.h" |
| 36 | #include "mirror/art_method-inl.h" |
| 37 | #include "mirror/class.h" |
| 38 | #include "mirror/class-inl.h" |
| 39 | #include "mirror/object-inl.h" |
| 40 | #include "mirror/object_array-inl.h" |
Douglas Leung | 4965c02 | 2014-06-11 11:41:11 -0700 | [diff] [blame^] | 41 | #include "mirror/string-inl.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 42 | #include "object_utils.h" |
| 43 | #include "ScopedLocalRef.h" |
| 44 | #include "scoped_thread_state_change.h" |
| 45 | #include "thread.h" |
| 46 | #include "well_known_classes.h" |
| 47 | |
| 48 | using ::art::mirror::ArtField; |
| 49 | using ::art::mirror::ArtMethod; |
| 50 | using ::art::mirror::Array; |
| 51 | using ::art::mirror::BooleanArray; |
| 52 | using ::art::mirror::ByteArray; |
| 53 | using ::art::mirror::CharArray; |
| 54 | using ::art::mirror::Class; |
| 55 | using ::art::mirror::ClassLoader; |
| 56 | using ::art::mirror::IntArray; |
| 57 | using ::art::mirror::LongArray; |
| 58 | using ::art::mirror::Object; |
| 59 | using ::art::mirror::ObjectArray; |
| 60 | using ::art::mirror::ShortArray; |
| 61 | using ::art::mirror::String; |
| 62 | using ::art::mirror::Throwable; |
| 63 | |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 64 | // b/14882674 Workaround stack overflow issue with clang |
| 65 | #if defined(__clang__) && defined(__aarch64__) |
| 66 | #define SOMETIMES_INLINE __attribute__((noinline)) |
| 67 | #define SOMETIMES_INLINE_KEYWORD |
| 68 | #else |
| 69 | #define SOMETIMES_INLINE ALWAYS_INLINE |
| 70 | #define SOMETIMES_INLINE_KEYWORD inline |
| 71 | #endif |
| 72 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 73 | namespace art { |
| 74 | namespace interpreter { |
| 75 | |
| 76 | // External references to both interpreter implementations. |
| 77 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 78 | template<bool do_access_check, bool transaction_active> |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 79 | extern JValue ExecuteSwitchImpl(Thread* self, MethodHelper& mh, |
| 80 | const DexFile::CodeItem* code_item, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 81 | ShadowFrame& shadow_frame, JValue result_register); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 82 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 83 | template<bool do_access_check, bool transaction_active> |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 84 | extern JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, |
| 85 | const DexFile::CodeItem* code_item, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 86 | ShadowFrame& shadow_frame, JValue result_register); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 87 | |
Sebastien Hertz | da843e1 | 2014-05-28 19:28:31 +0200 | [diff] [blame] | 88 | // Workaround for b/14882674 where clang allocates stack for each ThrowLocation created by calls to |
| 89 | // ShadowFrame::GetCurrentLocationForThrow(). Moving the call here prevents from doing such |
| 90 | // allocation in the interpreter itself. |
| 91 | static inline void ThrowNullPointerExceptionFromInterpreter(const ShadowFrame& shadow_frame) |
| 92 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) SOMETIMES_INLINE; |
| 93 | |
| 94 | static inline void ThrowNullPointerExceptionFromInterpreter( |
| 95 | const ShadowFrame& shadow_frame) { |
| 96 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 97 | } |
| 98 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 99 | static inline void DoMonitorEnter(Thread* self, Object* ref) NO_THREAD_SAFETY_ANALYSIS { |
| 100 | ref->MonitorEnter(self); |
| 101 | } |
| 102 | |
| 103 | static inline void DoMonitorExit(Thread* self, Object* ref) NO_THREAD_SAFETY_ANALYSIS { |
| 104 | ref->MonitorExit(self); |
| 105 | } |
| 106 | |
Mathieu Chartier | b2c7ead | 2014-04-29 11:13:16 -0700 | [diff] [blame] | 107 | void AbortTransaction(Thread* self, const char* fmt, ...) |
| 108 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 109 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 110 | void RecordArrayElementsInTransaction(mirror::Array* array, int32_t count) |
| 111 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 112 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 113 | // Invokes the given method. This is part of the invocation support and is used by DoInvoke and |
| 114 | // DoInvokeVirtualQuick functions. |
| 115 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 116 | template<bool is_range, bool do_assignability_check> |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 117 | bool DoCall(ArtMethod* method, Thread* self, ShadowFrame& shadow_frame, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 118 | const Instruction* inst, uint16_t inst_data, JValue* result); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 119 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 120 | // Handles invoke-XXX/range instructions. |
| 121 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 122 | template<InvokeType type, bool is_range, bool do_access_check> |
| 123 | static inline bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, |
| 124 | uint16_t inst_data, JValue* result) { |
| 125 | const uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); |
| 126 | const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 127 | Object* receiver = (type == kStatic) ? nullptr : shadow_frame.GetVRegReference(vregC); |
Mathieu Chartier | 0cd8135 | 2014-05-22 16:48:55 -0700 | [diff] [blame] | 128 | mirror::ArtMethod* sf_method = shadow_frame.GetMethod(); |
| 129 | ArtMethod* const method = FindMethodFromCode<type, do_access_check>( |
| 130 | method_idx, &receiver, &sf_method, self); |
| 131 | // The shadow frame should already be pushed, so we don't need to update it. |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 132 | if (UNLIKELY(method == nullptr)) { |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 133 | CHECK(self->IsExceptionPending()); |
| 134 | result->SetJ(0); |
| 135 | return false; |
| 136 | } else if (UNLIKELY(method->IsAbstract())) { |
| 137 | ThrowAbstractMethodError(method); |
| 138 | result->SetJ(0); |
| 139 | return false; |
| 140 | } else { |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 141 | return DoCall<is_range, do_access_check>(method, self, shadow_frame, inst, inst_data, result); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 142 | } |
| 143 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 144 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 145 | // Handles invoke-virtual-quick and invoke-virtual-quick-range instructions. |
| 146 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 147 | template<bool is_range> |
| 148 | static inline bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame, |
| 149 | const Instruction* inst, uint16_t inst_data, |
| 150 | JValue* result) { |
| 151 | const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); |
| 152 | Object* const receiver = shadow_frame.GetVRegReference(vregC); |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 153 | if (UNLIKELY(receiver == nullptr)) { |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 154 | // We lost the reference to the method index so we cannot get a more |
| 155 | // precised exception message. |
| 156 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 157 | return false; |
| 158 | } |
| 159 | const uint32_t vtable_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); |
| 160 | ArtMethod* const method = receiver->GetClass()->GetVTable()->GetWithoutChecks(vtable_idx); |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 161 | if (UNLIKELY(method == nullptr)) { |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 162 | CHECK(self->IsExceptionPending()); |
| 163 | result->SetJ(0); |
| 164 | return false; |
| 165 | } else if (UNLIKELY(method->IsAbstract())) { |
| 166 | ThrowAbstractMethodError(method); |
| 167 | result->SetJ(0); |
| 168 | return false; |
| 169 | } else { |
| 170 | // No need to check since we've been quickened. |
Sebastien Hertz | 9119c5f | 2013-12-16 11:31:45 +0100 | [diff] [blame] | 171 | return DoCall<is_range, false>(method, self, shadow_frame, inst, inst_data, result); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 172 | } |
| 173 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 174 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 175 | // Handles iget-XXX and sget-XXX instructions. |
| 176 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 177 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check> |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 178 | static SOMETIMES_INLINE_KEYWORD bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, |
| 179 | const Instruction* inst, uint16_t inst_data) { |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 180 | const bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead); |
| 181 | const uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
| 182 | ArtField* f = FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self, |
| 183 | Primitive::FieldSize(field_type)); |
| 184 | if (UNLIKELY(f == nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 185 | CHECK(self->IsExceptionPending()); |
| 186 | return false; |
| 187 | } |
| 188 | Object* obj; |
| 189 | if (is_static) { |
| 190 | obj = f->GetDeclaringClass(); |
| 191 | } else { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 192 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 193 | if (UNLIKELY(obj == nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 194 | ThrowNullPointerExceptionForFieldAccess(shadow_frame.GetCurrentLocationForThrow(), f, true); |
| 195 | return false; |
| 196 | } |
| 197 | } |
Sebastien Hertz | 479fc1e | 2014-04-04 17:51:34 +0200 | [diff] [blame] | 198 | // Report this field access to instrumentation if needed. |
| 199 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 200 | if (UNLIKELY(instrumentation->HasFieldReadListeners())) { |
| 201 | Object* this_object = f->IsStatic() ? nullptr : obj; |
| 202 | instrumentation->FieldReadEvent(self, this_object, shadow_frame.GetMethod(), |
| 203 | shadow_frame.GetDexPC(), f); |
| 204 | } |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 205 | uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 206 | switch (field_type) { |
| 207 | case Primitive::kPrimBoolean: |
| 208 | shadow_frame.SetVReg(vregA, f->GetBoolean(obj)); |
| 209 | break; |
| 210 | case Primitive::kPrimByte: |
| 211 | shadow_frame.SetVReg(vregA, f->GetByte(obj)); |
| 212 | break; |
| 213 | case Primitive::kPrimChar: |
| 214 | shadow_frame.SetVReg(vregA, f->GetChar(obj)); |
| 215 | break; |
| 216 | case Primitive::kPrimShort: |
| 217 | shadow_frame.SetVReg(vregA, f->GetShort(obj)); |
| 218 | break; |
| 219 | case Primitive::kPrimInt: |
| 220 | shadow_frame.SetVReg(vregA, f->GetInt(obj)); |
| 221 | break; |
| 222 | case Primitive::kPrimLong: |
| 223 | shadow_frame.SetVRegLong(vregA, f->GetLong(obj)); |
| 224 | break; |
| 225 | case Primitive::kPrimNot: |
| 226 | shadow_frame.SetVRegReference(vregA, f->GetObject(obj)); |
| 227 | break; |
| 228 | default: |
| 229 | LOG(FATAL) << "Unreachable: " << field_type; |
| 230 | } |
| 231 | return true; |
| 232 | } |
| 233 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 234 | // Handles iget-quick, iget-wide-quick and iget-object-quick instructions. |
| 235 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 236 | template<Primitive::Type field_type> |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 237 | static SOMETIMES_INLINE_KEYWORD bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 238 | Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 239 | if (UNLIKELY(obj == nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 240 | // We lost the reference to the field index so we cannot get a more |
| 241 | // precised exception message. |
| 242 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 243 | return false; |
| 244 | } |
| 245 | MemberOffset field_offset(inst->VRegC_22c()); |
Sebastien Hertz | 479fc1e | 2014-04-04 17:51:34 +0200 | [diff] [blame] | 246 | // Report this field access to instrumentation if needed. Since we only have the offset of |
| 247 | // the field from the base of the object, we need to look for it first. |
| 248 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 249 | if (UNLIKELY(instrumentation->HasFieldReadListeners())) { |
| 250 | ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(), |
| 251 | field_offset.Uint32Value()); |
| 252 | DCHECK(f != nullptr); |
| 253 | DCHECK(!f->IsStatic()); |
| 254 | instrumentation->FieldReadEvent(Thread::Current(), obj, shadow_frame.GetMethod(), |
| 255 | shadow_frame.GetDexPC(), f); |
| 256 | } |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 257 | // Note: iget-x-quick instructions are only for non-volatile fields. |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 258 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 259 | switch (field_type) { |
| 260 | case Primitive::kPrimInt: |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 261 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetField32(field_offset))); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 262 | break; |
| 263 | case Primitive::kPrimLong: |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 264 | shadow_frame.SetVRegLong(vregA, static_cast<int64_t>(obj->GetField64(field_offset))); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 265 | break; |
| 266 | case Primitive::kPrimNot: |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 267 | shadow_frame.SetVRegReference(vregA, obj->GetFieldObject<mirror::Object>(field_offset)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 268 | break; |
| 269 | default: |
| 270 | LOG(FATAL) << "Unreachable: " << field_type; |
| 271 | } |
| 272 | return true; |
| 273 | } |
| 274 | |
Sebastien Hertz | 479fc1e | 2014-04-04 17:51:34 +0200 | [diff] [blame] | 275 | template<Primitive::Type field_type> |
| 276 | static inline JValue GetFieldValue(const ShadowFrame& shadow_frame, uint32_t vreg) |
| 277 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 278 | JValue field_value; |
| 279 | switch (field_type) { |
| 280 | case Primitive::kPrimBoolean: |
| 281 | field_value.SetZ(static_cast<uint8_t>(shadow_frame.GetVReg(vreg))); |
| 282 | break; |
| 283 | case Primitive::kPrimByte: |
| 284 | field_value.SetB(static_cast<int8_t>(shadow_frame.GetVReg(vreg))); |
| 285 | break; |
| 286 | case Primitive::kPrimChar: |
| 287 | field_value.SetC(static_cast<uint16_t>(shadow_frame.GetVReg(vreg))); |
| 288 | break; |
| 289 | case Primitive::kPrimShort: |
| 290 | field_value.SetS(static_cast<int16_t>(shadow_frame.GetVReg(vreg))); |
| 291 | break; |
| 292 | case Primitive::kPrimInt: |
| 293 | field_value.SetI(shadow_frame.GetVReg(vreg)); |
| 294 | break; |
| 295 | case Primitive::kPrimLong: |
| 296 | field_value.SetJ(shadow_frame.GetVRegLong(vreg)); |
| 297 | break; |
| 298 | case Primitive::kPrimNot: |
| 299 | field_value.SetL(shadow_frame.GetVRegReference(vreg)); |
| 300 | break; |
| 301 | default: |
| 302 | LOG(FATAL) << "Unreachable: " << field_type; |
| 303 | break; |
| 304 | } |
| 305 | return field_value; |
| 306 | } |
| 307 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 308 | // Handles iput-XXX and sput-XXX instructions. |
| 309 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 310 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check, bool transaction_active> |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 311 | static SOMETIMES_INLINE_KEYWORD bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, |
| 312 | const Instruction* inst, uint16_t inst_data) { |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 313 | bool do_assignability_check = do_access_check; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 314 | bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite); |
| 315 | uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 316 | ArtField* f = FindFieldFromCode<find_type, do_access_check>(field_idx, shadow_frame.GetMethod(), self, |
| 317 | Primitive::FieldSize(field_type)); |
| 318 | if (UNLIKELY(f == nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 319 | CHECK(self->IsExceptionPending()); |
| 320 | return false; |
| 321 | } |
| 322 | Object* obj; |
| 323 | if (is_static) { |
| 324 | obj = f->GetDeclaringClass(); |
| 325 | } else { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 326 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 327 | if (UNLIKELY(obj == nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 328 | ThrowNullPointerExceptionForFieldAccess(shadow_frame.GetCurrentLocationForThrow(), |
| 329 | f, false); |
| 330 | return false; |
| 331 | } |
| 332 | } |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 333 | uint32_t vregA = is_static ? inst->VRegA_21c(inst_data) : inst->VRegA_22c(inst_data); |
Sebastien Hertz | 479fc1e | 2014-04-04 17:51:34 +0200 | [diff] [blame] | 334 | // Report this field access to instrumentation if needed. Since we only have the offset of |
| 335 | // the field from the base of the object, we need to look for it first. |
| 336 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 337 | if (UNLIKELY(instrumentation->HasFieldWriteListeners())) { |
| 338 | JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA); |
| 339 | Object* this_object = f->IsStatic() ? nullptr : obj; |
| 340 | instrumentation->FieldWriteEvent(self, this_object, shadow_frame.GetMethod(), |
| 341 | shadow_frame.GetDexPC(), f, field_value); |
| 342 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 343 | switch (field_type) { |
| 344 | case Primitive::kPrimBoolean: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 345 | f->SetBoolean<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 346 | break; |
| 347 | case Primitive::kPrimByte: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 348 | f->SetByte<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 349 | break; |
| 350 | case Primitive::kPrimChar: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 351 | f->SetChar<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 352 | break; |
| 353 | case Primitive::kPrimShort: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 354 | f->SetShort<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 355 | break; |
| 356 | case Primitive::kPrimInt: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 357 | f->SetInt<transaction_active>(obj, shadow_frame.GetVReg(vregA)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 358 | break; |
| 359 | case Primitive::kPrimLong: |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 360 | f->SetLong<transaction_active>(obj, shadow_frame.GetVRegLong(vregA)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 361 | break; |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 362 | case Primitive::kPrimNot: { |
| 363 | Object* reg = shadow_frame.GetVRegReference(vregA); |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 364 | if (do_assignability_check && reg != nullptr) { |
Mathieu Chartier | 0cd8135 | 2014-05-22 16:48:55 -0700 | [diff] [blame] | 365 | // FieldHelper::GetType can resolve classes, use a handle wrapper which will restore the |
| 366 | // object in the destructor. |
Mathieu Chartier | 61c5ebc | 2014-06-05 17:42:53 -0700 | [diff] [blame] | 367 | Class* field_class; |
| 368 | { |
| 369 | StackHandleScope<3> hs(self); |
| 370 | HandleWrapper<mirror::ArtField> h_f(hs.NewHandleWrapper(&f)); |
| 371 | HandleWrapper<mirror::Object> h_reg(hs.NewHandleWrapper(®)); |
| 372 | HandleWrapper<mirror::Object> h_obj(hs.NewHandleWrapper(&obj)); |
| 373 | FieldHelper fh(h_f); |
| 374 | field_class = fh.GetType(); |
| 375 | } |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 376 | if (!reg->VerifierInstanceOf(field_class)) { |
| 377 | // This should never happen. |
| 378 | self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(), |
| 379 | "Ljava/lang/VirtualMachineError;", |
| 380 | "Put '%s' that is not instance of field '%s' in '%s'", |
Mathieu Chartier | f832284 | 2014-05-16 10:59:25 -0700 | [diff] [blame] | 381 | reg->GetClass()->GetDescriptor().c_str(), |
| 382 | field_class->GetDescriptor().c_str(), |
| 383 | f->GetDeclaringClass()->GetDescriptor().c_str()); |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 384 | return false; |
| 385 | } |
| 386 | } |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 387 | f->SetObj<transaction_active>(obj, reg); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 388 | break; |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 389 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 390 | default: |
| 391 | LOG(FATAL) << "Unreachable: " << field_type; |
| 392 | } |
| 393 | return true; |
| 394 | } |
| 395 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 396 | // Handles iput-quick, iput-wide-quick and iput-object-quick instructions. |
| 397 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 398 | template<Primitive::Type field_type, bool transaction_active> |
Mathieu Chartier | 0cd8135 | 2014-05-22 16:48:55 -0700 | [diff] [blame] | 399 | static SOMETIMES_INLINE_KEYWORD bool DoIPutQuick(const ShadowFrame& shadow_frame, |
| 400 | const Instruction* inst, uint16_t inst_data) { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 401 | Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 402 | if (UNLIKELY(obj == nullptr)) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 403 | // We lost the reference to the field index so we cannot get a more |
| 404 | // precised exception message. |
| 405 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 406 | return false; |
| 407 | } |
| 408 | MemberOffset field_offset(inst->VRegC_22c()); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 409 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
Sebastien Hertz | 479fc1e | 2014-04-04 17:51:34 +0200 | [diff] [blame] | 410 | // Report this field modification to instrumentation if needed. Since we only have the offset of |
| 411 | // the field from the base of the object, we need to look for it first. |
| 412 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 413 | if (UNLIKELY(instrumentation->HasFieldWriteListeners())) { |
| 414 | ArtField* f = ArtField::FindInstanceFieldWithOffset(obj->GetClass(), |
| 415 | field_offset.Uint32Value()); |
| 416 | DCHECK(f != nullptr); |
| 417 | DCHECK(!f->IsStatic()); |
| 418 | JValue field_value = GetFieldValue<field_type>(shadow_frame, vregA); |
| 419 | instrumentation->FieldWriteEvent(Thread::Current(), obj, shadow_frame.GetMethod(), |
| 420 | shadow_frame.GetDexPC(), f, field_value); |
| 421 | } |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 422 | // Note: iput-x-quick instructions are only for non-volatile fields. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 423 | switch (field_type) { |
| 424 | case Primitive::kPrimInt: |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 425 | obj->SetField32<transaction_active>(field_offset, shadow_frame.GetVReg(vregA)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 426 | break; |
| 427 | case Primitive::kPrimLong: |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 428 | obj->SetField64<transaction_active>(field_offset, shadow_frame.GetVRegLong(vregA)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 429 | break; |
| 430 | case Primitive::kPrimNot: |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 431 | obj->SetFieldObject<transaction_active>(field_offset, shadow_frame.GetVRegReference(vregA)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 432 | break; |
| 433 | default: |
| 434 | LOG(FATAL) << "Unreachable: " << field_type; |
| 435 | } |
| 436 | return true; |
| 437 | } |
| 438 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 439 | // Handles string resolution for const-string and const-string-jumbo instructions. Also ensures the |
| 440 | // java.lang.String class is initialized. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 441 | static inline String* ResolveString(Thread* self, MethodHelper& mh, uint32_t string_idx) |
| 442 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 443 | CHECK(!kMovingMethods); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 444 | Class* java_lang_string_class = String::GetJavaLangString(); |
| 445 | if (UNLIKELY(!java_lang_string_class->IsInitialized())) { |
| 446 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 447 | StackHandleScope<1> hs(self); |
| 448 | Handle<mirror::Class> h_class(hs.NewHandle(java_lang_string_class)); |
| 449 | if (UNLIKELY(!class_linker->EnsureInitialized(h_class, true, true))) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 450 | DCHECK(self->IsExceptionPending()); |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 451 | return nullptr; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 452 | } |
| 453 | } |
| 454 | return mh.ResolveString(string_idx); |
| 455 | } |
| 456 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 457 | // Handles div-int, div-int/2addr, div-int/li16 and div-int/lit8 instructions. |
| 458 | // Returns true on success, otherwise throws a java.lang.ArithmeticException and return false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 459 | static inline bool DoIntDivide(ShadowFrame& shadow_frame, size_t result_reg, |
| 460 | int32_t dividend, int32_t divisor) |
| 461 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 462 | const int32_t kMinInt = std::numeric_limits<int32_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 463 | if (UNLIKELY(divisor == 0)) { |
| 464 | ThrowArithmeticExceptionDivideByZero(); |
| 465 | return false; |
| 466 | } |
| 467 | if (UNLIKELY(dividend == kMinInt && divisor == -1)) { |
| 468 | shadow_frame.SetVReg(result_reg, kMinInt); |
| 469 | } else { |
| 470 | shadow_frame.SetVReg(result_reg, dividend / divisor); |
| 471 | } |
| 472 | return true; |
| 473 | } |
| 474 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 475 | // Handles rem-int, rem-int/2addr, rem-int/li16 and rem-int/lit8 instructions. |
| 476 | // Returns true on success, otherwise throws a java.lang.ArithmeticException and return false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 477 | static inline bool DoIntRemainder(ShadowFrame& shadow_frame, size_t result_reg, |
| 478 | int32_t dividend, int32_t divisor) |
| 479 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 480 | const int32_t kMinInt = std::numeric_limits<int32_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 481 | if (UNLIKELY(divisor == 0)) { |
| 482 | ThrowArithmeticExceptionDivideByZero(); |
| 483 | return false; |
| 484 | } |
| 485 | if (UNLIKELY(dividend == kMinInt && divisor == -1)) { |
| 486 | shadow_frame.SetVReg(result_reg, 0); |
| 487 | } else { |
| 488 | shadow_frame.SetVReg(result_reg, dividend % divisor); |
| 489 | } |
| 490 | return true; |
| 491 | } |
| 492 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 493 | // Handles div-long and div-long-2addr instructions. |
| 494 | // Returns true on success, otherwise throws a java.lang.ArithmeticException and return false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 495 | static inline bool DoLongDivide(ShadowFrame& shadow_frame, size_t result_reg, |
| 496 | int64_t dividend, int64_t divisor) |
| 497 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 498 | const int64_t kMinLong = std::numeric_limits<int64_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 499 | if (UNLIKELY(divisor == 0)) { |
| 500 | ThrowArithmeticExceptionDivideByZero(); |
| 501 | return false; |
| 502 | } |
| 503 | if (UNLIKELY(dividend == kMinLong && divisor == -1)) { |
| 504 | shadow_frame.SetVRegLong(result_reg, kMinLong); |
| 505 | } else { |
| 506 | shadow_frame.SetVRegLong(result_reg, dividend / divisor); |
| 507 | } |
| 508 | return true; |
| 509 | } |
| 510 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 511 | // Handles rem-long and rem-long-2addr instructions. |
| 512 | // Returns true on success, otherwise throws a java.lang.ArithmeticException and return false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 513 | static inline bool DoLongRemainder(ShadowFrame& shadow_frame, size_t result_reg, |
| 514 | int64_t dividend, int64_t divisor) |
| 515 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 516 | const int64_t kMinLong = std::numeric_limits<int64_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 517 | if (UNLIKELY(divisor == 0)) { |
| 518 | ThrowArithmeticExceptionDivideByZero(); |
| 519 | return false; |
| 520 | } |
| 521 | if (UNLIKELY(dividend == kMinLong && divisor == -1)) { |
| 522 | shadow_frame.SetVRegLong(result_reg, 0); |
| 523 | } else { |
| 524 | shadow_frame.SetVRegLong(result_reg, dividend % divisor); |
| 525 | } |
| 526 | return true; |
| 527 | } |
| 528 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 529 | // Handles filled-new-array and filled-new-array-range instructions. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 530 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 531 | template <bool is_range, bool do_access_check, bool transaction_active> |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 532 | bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 533 | Thread* self, JValue* result); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 534 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 535 | // Handles packed-switch instruction. |
| 536 | // Returns the branch offset to the next instruction to execute. |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 537 | static inline int32_t DoPackedSwitch(const Instruction* inst, const ShadowFrame& shadow_frame, |
| 538 | uint16_t inst_data) |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 539 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 540 | DCHECK(inst->Opcode() == Instruction::PACKED_SWITCH); |
| 541 | const uint16_t* switch_data = reinterpret_cast<const uint16_t*>(inst) + inst->VRegB_31t(); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 542 | int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 543 | DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kPackedSwitchSignature)); |
| 544 | uint16_t size = switch_data[1]; |
| 545 | DCHECK_GT(size, 0); |
| 546 | const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]); |
| 547 | DCHECK(IsAligned<4>(keys)); |
| 548 | int32_t first_key = keys[0]; |
| 549 | const int32_t* targets = reinterpret_cast<const int32_t*>(&switch_data[4]); |
| 550 | DCHECK(IsAligned<4>(targets)); |
| 551 | int32_t index = test_val - first_key; |
| 552 | if (index >= 0 && index < size) { |
| 553 | return targets[index]; |
| 554 | } else { |
| 555 | // No corresponding value: move forward by 3 (size of PACKED_SWITCH). |
| 556 | return 3; |
| 557 | } |
| 558 | } |
| 559 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 560 | // Handles sparse-switch instruction. |
| 561 | // Returns the branch offset to the next instruction to execute. |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 562 | static inline int32_t DoSparseSwitch(const Instruction* inst, const ShadowFrame& shadow_frame, |
| 563 | uint16_t inst_data) |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 564 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 565 | DCHECK(inst->Opcode() == Instruction::SPARSE_SWITCH); |
| 566 | const uint16_t* switch_data = reinterpret_cast<const uint16_t*>(inst) + inst->VRegB_31t(); |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 567 | int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 568 | DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kSparseSwitchSignature)); |
| 569 | uint16_t size = switch_data[1]; |
| 570 | DCHECK_GT(size, 0); |
| 571 | const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]); |
| 572 | DCHECK(IsAligned<4>(keys)); |
| 573 | const int32_t* entries = keys + size; |
| 574 | DCHECK(IsAligned<4>(entries)); |
| 575 | int lo = 0; |
| 576 | int hi = size - 1; |
| 577 | while (lo <= hi) { |
| 578 | int mid = (lo + hi) / 2; |
| 579 | int32_t foundVal = keys[mid]; |
| 580 | if (test_val < foundVal) { |
| 581 | hi = mid - 1; |
| 582 | } else if (test_val > foundVal) { |
| 583 | lo = mid + 1; |
| 584 | } else { |
| 585 | return entries[mid]; |
| 586 | } |
| 587 | } |
| 588 | // No corresponding value: move forward by 3 (size of SPARSE_SWITCH). |
| 589 | return 3; |
| 590 | } |
| 591 | |
| 592 | static inline uint32_t FindNextInstructionFollowingException(Thread* self, |
| 593 | ShadowFrame& shadow_frame, |
| 594 | uint32_t dex_pc, |
Sebastien Hertz | 947ff08 | 2013-09-17 14:10:13 +0200 | [diff] [blame] | 595 | mirror::Object* this_object, |
| 596 | const instrumentation::Instrumentation* instrumentation) |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 597 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) SOMETIMES_INLINE; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 598 | |
| 599 | static inline uint32_t FindNextInstructionFollowingException(Thread* self, |
| 600 | ShadowFrame& shadow_frame, |
| 601 | uint32_t dex_pc, |
Sebastien Hertz | 947ff08 | 2013-09-17 14:10:13 +0200 | [diff] [blame] | 602 | mirror::Object* this_object, |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 603 | const instrumentation::Instrumentation* instrumentation) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 604 | self->VerifyStack(); |
| 605 | ThrowLocation throw_location; |
| 606 | mirror::Throwable* exception = self->GetException(&throw_location); |
Sebastien Hertz | 947ff08 | 2013-09-17 14:10:13 +0200 | [diff] [blame] | 607 | bool clear_exception = false; |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 608 | uint32_t found_dex_pc; |
| 609 | { |
| 610 | StackHandleScope<3> hs(self); |
| 611 | Handle<mirror::Class> exception_class(hs.NewHandle(exception->GetClass())); |
| 612 | Handle<mirror::ArtMethod> h_method(hs.NewHandle(shadow_frame.GetMethod())); |
| 613 | HandleWrapper<mirror::Object> h(hs.NewHandleWrapper(&this_object)); |
| 614 | found_dex_pc = mirror::ArtMethod::FindCatchBlock(h_method, exception_class, dex_pc, |
| 615 | &clear_exception); |
| 616 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 617 | if (found_dex_pc == DexFile::kDexNoIndex) { |
Sebastien Hertz | 947ff08 | 2013-09-17 14:10:13 +0200 | [diff] [blame] | 618 | instrumentation->MethodUnwindEvent(self, this_object, |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 619 | shadow_frame.GetMethod(), dex_pc); |
| 620 | } else { |
| 621 | instrumentation->ExceptionCaughtEvent(self, throw_location, |
| 622 | shadow_frame.GetMethod(), |
| 623 | found_dex_pc, exception); |
| 624 | if (clear_exception) { |
| 625 | self->ClearException(); |
| 626 | } |
| 627 | } |
| 628 | return found_dex_pc; |
| 629 | } |
| 630 | |
Ian Rogers | b48b9eb | 2014-02-28 16:20:21 -0800 | [diff] [blame] | 631 | static inline void UnexpectedOpcode(const Instruction* inst, MethodHelper& mh) |
| 632 | __attribute__((cold, noreturn)) |
| 633 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 634 | |
Ian Rogers | b48b9eb | 2014-02-28 16:20:21 -0800 | [diff] [blame] | 635 | static inline void UnexpectedOpcode(const Instruction* inst, MethodHelper& mh) { |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 636 | LOG(FATAL) << "Unexpected instruction: " << inst->DumpString(mh.GetMethod()->GetDexFile()); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 637 | exit(0); // Unreachable, keep GCC happy. |
| 638 | } |
| 639 | |
| 640 | static inline void TraceExecution(const ShadowFrame& shadow_frame, const Instruction* inst, |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 641 | const uint32_t dex_pc, MethodHelper& mh) |
| 642 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 643 | constexpr bool kTracing = false; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 644 | if (kTracing) { |
| 645 | #define TRACE_LOG std::cerr |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 646 | std::ostringstream oss; |
| 647 | oss << PrettyMethod(shadow_frame.GetMethod()) |
| 648 | << StringPrintf("\n0x%x: ", dex_pc) |
Mathieu Chartier | bfd9a43 | 2014-05-21 17:43:44 -0700 | [diff] [blame] | 649 | << inst->DumpString(mh.GetMethod()->GetDexFile()) << "\n"; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 650 | for (uint32_t i = 0; i < shadow_frame.NumberOfVRegs(); ++i) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 651 | uint32_t raw_value = shadow_frame.GetVReg(i); |
| 652 | Object* ref_value = shadow_frame.GetVRegReference(i); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 653 | oss << StringPrintf(" vreg%u=0x%08X", i, raw_value); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 654 | if (ref_value != NULL) { |
| 655 | if (ref_value->GetClass()->IsStringClass() && |
| 656 | ref_value->AsString()->GetCharArray() != NULL) { |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 657 | oss << "/java.lang.String \"" << ref_value->AsString()->ToModifiedUtf8() << "\""; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 658 | } else { |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 659 | oss << "/" << PrettyTypeOf(ref_value); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 660 | } |
| 661 | } |
| 662 | } |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 663 | TRACE_LOG << oss.str() << "\n"; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 664 | #undef TRACE_LOG |
| 665 | } |
| 666 | } |
| 667 | |
Sebastien Hertz | 1eda226 | 2013-09-09 16:53:14 +0200 | [diff] [blame] | 668 | static inline bool IsBackwardBranch(int32_t branch_offset) { |
| 669 | return branch_offset <= 0; |
| 670 | } |
| 671 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 672 | // Explicitly instantiate all DoInvoke functions. |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 673 | #define EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, _is_range, _do_check) \ |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 674 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) SOMETIMES_INLINE \ |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 675 | bool DoInvoke<_type, _is_range, _do_check>(Thread* self, ShadowFrame& shadow_frame, \ |
| 676 | const Instruction* inst, uint16_t inst_data, \ |
| 677 | JValue* result) |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 678 | |
| 679 | #define EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(_type) \ |
| 680 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, false, false); \ |
| 681 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, false, true); \ |
| 682 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, true, false); \ |
| 683 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, true, true); |
| 684 | |
| 685 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kStatic); // invoke-static/range. |
| 686 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kDirect); // invoke-direct/range. |
| 687 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kVirtual); // invoke-virtual/range. |
| 688 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kSuper); // invoke-super/range. |
| 689 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kInterface); // invoke-interface/range. |
| 690 | #undef EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL |
| 691 | #undef EXPLICIT_DO_INVOKE_TEMPLATE_DECL |
| 692 | |
| 693 | // Explicitly instantiate all DoFieldGet functions. |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 694 | #define EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, _do_check) \ |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 695 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) SOMETIMES_INLINE \ |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 696 | bool DoFieldGet<_find_type, _field_type, _do_check>(Thread* self, ShadowFrame& shadow_frame, \ |
| 697 | const Instruction* inst, uint16_t inst_data) |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 698 | |
| 699 | #define EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
| 700 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, false); \ |
| 701 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, true); |
| 702 | |
| 703 | // iget-XXX |
| 704 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimBoolean); |
| 705 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimByte); |
| 706 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimChar); |
| 707 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimShort); |
| 708 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimInt); |
| 709 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimLong); |
| 710 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstanceObjectRead, Primitive::kPrimNot); |
| 711 | |
| 712 | // sget-XXX |
| 713 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimBoolean); |
| 714 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimByte); |
| 715 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimChar); |
| 716 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimShort); |
| 717 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimInt); |
| 718 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimLong); |
| 719 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticObjectRead, Primitive::kPrimNot); |
| 720 | |
| 721 | #undef EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL |
| 722 | #undef EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL |
| 723 | |
| 724 | // Explicitly instantiate all DoFieldPut functions. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 725 | #define EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, _do_check, _transaction_active) \ |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 726 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) SOMETIMES_INLINE \ |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 727 | bool DoFieldPut<_find_type, _field_type, _do_check, _transaction_active>(Thread* self, const ShadowFrame& shadow_frame, \ |
| 728 | const Instruction* inst, uint16_t inst_data) |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 729 | |
| 730 | #define EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 731 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, false); \ |
| 732 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, false); \ |
| 733 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false, true); \ |
| 734 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true, true); |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 735 | |
| 736 | // iput-XXX |
| 737 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimBoolean); |
| 738 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimByte); |
| 739 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimChar); |
| 740 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimShort); |
| 741 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimInt); |
| 742 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimLong); |
| 743 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstanceObjectWrite, Primitive::kPrimNot); |
| 744 | |
| 745 | // sput-XXX |
| 746 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimBoolean); |
| 747 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimByte); |
| 748 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimChar); |
| 749 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimShort); |
| 750 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimInt); |
| 751 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimLong); |
| 752 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticObjectWrite, Primitive::kPrimNot); |
| 753 | |
| 754 | #undef EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL |
| 755 | #undef EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL |
| 756 | |
| 757 | // Explicitly instantiate all DoInvokeVirtualQuick functions. |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 758 | #define EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(_is_range) \ |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 759 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) SOMETIMES_INLINE \ |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 760 | bool DoInvokeVirtualQuick<_is_range>(Thread* self, ShadowFrame& shadow_frame, \ |
| 761 | const Instruction* inst, uint16_t inst_data, \ |
| 762 | JValue* result) |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 763 | |
| 764 | EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(false); // invoke-virtual-quick. |
| 765 | EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(true); // invoke-virtual-quick-range. |
| 766 | #undef EXPLICIT_INSTANTIATION_DO_INVOKE_VIRTUAL_QUICK |
| 767 | |
| 768 | // Explicitly instantiate all DoIGetQuick functions. |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 769 | #define EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(_field_type) \ |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 770 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) SOMETIMES_INLINE \ |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 771 | bool DoIGetQuick<_field_type>(ShadowFrame& shadow_frame, const Instruction* inst, \ |
| 772 | uint16_t inst_data) |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 773 | |
| 774 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimInt); // iget-quick. |
| 775 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimLong); // iget-wide-quick. |
| 776 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimNot); // iget-object-quick. |
| 777 | #undef EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL |
| 778 | |
| 779 | // Explicitly instantiate all DoIPutQuick functions. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 780 | #define EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, _transaction_active) \ |
Sebastien Hertz | 82aeddb | 2014-05-20 20:09:45 +0200 | [diff] [blame] | 781 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) SOMETIMES_INLINE \ |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 782 | bool DoIPutQuick<_field_type, _transaction_active>(const ShadowFrame& shadow_frame, \ |
| 783 | const Instruction* inst, \ |
| 784 | uint16_t inst_data) |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 785 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 786 | #define EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(_field_type) \ |
| 787 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, false); \ |
| 788 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type, true); |
| 789 | |
| 790 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimInt); // iget-quick. |
| 791 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimLong); // iget-wide-quick. |
| 792 | EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimNot); // iget-object-quick. |
| 793 | #undef EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 794 | #undef EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL |
| 795 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 796 | } // namespace interpreter |
| 797 | } // namespace art |
| 798 | |
| 799 | #endif // ART_RUNTIME_INTERPRETER_INTERPRETER_COMMON_H_ |