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" |
| 32 | #include "invoke_arg_array_builder.h" |
| 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" |
| 41 | #include "object_utils.h" |
| 42 | #include "ScopedLocalRef.h" |
| 43 | #include "scoped_thread_state_change.h" |
| 44 | #include "thread.h" |
| 45 | #include "well_known_classes.h" |
| 46 | |
| 47 | using ::art::mirror::ArtField; |
| 48 | using ::art::mirror::ArtMethod; |
| 49 | using ::art::mirror::Array; |
| 50 | using ::art::mirror::BooleanArray; |
| 51 | using ::art::mirror::ByteArray; |
| 52 | using ::art::mirror::CharArray; |
| 53 | using ::art::mirror::Class; |
| 54 | using ::art::mirror::ClassLoader; |
| 55 | using ::art::mirror::IntArray; |
| 56 | using ::art::mirror::LongArray; |
| 57 | using ::art::mirror::Object; |
| 58 | using ::art::mirror::ObjectArray; |
| 59 | using ::art::mirror::ShortArray; |
| 60 | using ::art::mirror::String; |
| 61 | using ::art::mirror::Throwable; |
| 62 | |
| 63 | namespace art { |
| 64 | namespace interpreter { |
| 65 | |
| 66 | // External references to both interpreter implementations. |
| 67 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 68 | template<bool do_access_check> |
| 69 | extern JValue ExecuteSwitchImpl(Thread* self, MethodHelper& mh, |
| 70 | const DexFile::CodeItem* code_item, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 71 | ShadowFrame& shadow_frame, JValue result_register); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 72 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 73 | template<bool do_access_check> |
| 74 | extern JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, |
| 75 | const DexFile::CodeItem* code_item, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 76 | ShadowFrame& shadow_frame, JValue result_register); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 77 | |
| 78 | static inline void DoMonitorEnter(Thread* self, Object* ref) NO_THREAD_SAFETY_ANALYSIS { |
| 79 | ref->MonitorEnter(self); |
| 80 | } |
| 81 | |
| 82 | static inline void DoMonitorExit(Thread* self, Object* ref) NO_THREAD_SAFETY_ANALYSIS { |
| 83 | ref->MonitorExit(self); |
| 84 | } |
| 85 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 86 | // Invokes the given method. This is part of the invocation support and is used by DoInvoke and |
| 87 | // DoInvokeVirtualQuick functions. |
| 88 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 89 | template<bool is_range, bool do_assignability_check> |
| 90 | bool DoCall(ArtMethod* method, Object* receiver, Thread* self, ShadowFrame& shadow_frame, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 91 | const Instruction* inst, uint16_t inst_data, JValue* result); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 92 | |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 93 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 94 | // Handles invoke-XXX/range instructions. |
| 95 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 96 | template<InvokeType type, bool is_range, bool do_access_check> |
| 97 | static inline bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, |
| 98 | uint16_t inst_data, JValue* result) { |
| 99 | const uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); |
| 100 | const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); |
| 101 | Object* const receiver = (type == kStatic) ? NULL : shadow_frame.GetVRegReference(vregC); |
| 102 | ArtMethod* const method = FindMethodFromCode(method_idx, receiver, shadow_frame.GetMethod(), self, |
| 103 | do_access_check, type); |
| 104 | if (UNLIKELY(method == NULL)) { |
| 105 | CHECK(self->IsExceptionPending()); |
| 106 | result->SetJ(0); |
| 107 | return false; |
| 108 | } else if (UNLIKELY(method->IsAbstract())) { |
| 109 | ThrowAbstractMethodError(method); |
| 110 | result->SetJ(0); |
| 111 | return false; |
| 112 | } else { |
| 113 | return DoCall<is_range, do_access_check>(method, receiver, self, shadow_frame, inst, |
| 114 | inst_data, result); |
| 115 | } |
| 116 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 117 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 118 | // Handles invoke-virtual-quick and invoke-virtual-quick-range instructions. |
| 119 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 120 | template<bool is_range> |
| 121 | static inline bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame, |
| 122 | const Instruction* inst, uint16_t inst_data, |
| 123 | JValue* result) { |
| 124 | const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); |
| 125 | Object* const receiver = shadow_frame.GetVRegReference(vregC); |
| 126 | if (UNLIKELY(receiver == NULL)) { |
| 127 | // We lost the reference to the method index so we cannot get a more |
| 128 | // precised exception message. |
| 129 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 130 | return false; |
| 131 | } |
| 132 | const uint32_t vtable_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); |
| 133 | ArtMethod* const method = receiver->GetClass()->GetVTable()->GetWithoutChecks(vtable_idx); |
| 134 | if (UNLIKELY(method == NULL)) { |
| 135 | CHECK(self->IsExceptionPending()); |
| 136 | result->SetJ(0); |
| 137 | return false; |
| 138 | } else if (UNLIKELY(method->IsAbstract())) { |
| 139 | ThrowAbstractMethodError(method); |
| 140 | result->SetJ(0); |
| 141 | return false; |
| 142 | } else { |
| 143 | // No need to check since we've been quickened. |
| 144 | return DoCall<is_range, false>(method, receiver, self, shadow_frame, inst, inst_data, result); |
| 145 | } |
| 146 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 147 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 148 | // Handles iget-XXX and sget-XXX instructions. |
| 149 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 150 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check> |
| 151 | static inline bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 152 | const Instruction* inst, uint16_t inst_data) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 153 | bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead); |
| 154 | uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
| 155 | ArtField* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, |
| 156 | find_type, Primitive::FieldSize(field_type), |
| 157 | do_access_check); |
| 158 | if (UNLIKELY(f == NULL)) { |
| 159 | CHECK(self->IsExceptionPending()); |
| 160 | return false; |
| 161 | } |
| 162 | Object* obj; |
| 163 | if (is_static) { |
| 164 | obj = f->GetDeclaringClass(); |
| 165 | } else { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 166 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 167 | if (UNLIKELY(obj == NULL)) { |
| 168 | ThrowNullPointerExceptionForFieldAccess(shadow_frame.GetCurrentLocationForThrow(), f, true); |
| 169 | return false; |
| 170 | } |
| 171 | } |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 172 | 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] | 173 | switch (field_type) { |
| 174 | case Primitive::kPrimBoolean: |
| 175 | shadow_frame.SetVReg(vregA, f->GetBoolean(obj)); |
| 176 | break; |
| 177 | case Primitive::kPrimByte: |
| 178 | shadow_frame.SetVReg(vregA, f->GetByte(obj)); |
| 179 | break; |
| 180 | case Primitive::kPrimChar: |
| 181 | shadow_frame.SetVReg(vregA, f->GetChar(obj)); |
| 182 | break; |
| 183 | case Primitive::kPrimShort: |
| 184 | shadow_frame.SetVReg(vregA, f->GetShort(obj)); |
| 185 | break; |
| 186 | case Primitive::kPrimInt: |
| 187 | shadow_frame.SetVReg(vregA, f->GetInt(obj)); |
| 188 | break; |
| 189 | case Primitive::kPrimLong: |
| 190 | shadow_frame.SetVRegLong(vregA, f->GetLong(obj)); |
| 191 | break; |
| 192 | case Primitive::kPrimNot: |
| 193 | shadow_frame.SetVRegReference(vregA, f->GetObject(obj)); |
| 194 | break; |
| 195 | default: |
| 196 | LOG(FATAL) << "Unreachable: " << field_type; |
| 197 | } |
| 198 | return true; |
| 199 | } |
| 200 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 201 | // Handles iget-quick, iget-wide-quick and iget-object-quick instructions. |
| 202 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 203 | template<Primitive::Type field_type> |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 204 | static inline bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) { |
| 205 | Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 206 | if (UNLIKELY(obj == NULL)) { |
| 207 | // We lost the reference to the field index so we cannot get a more |
| 208 | // precised exception message. |
| 209 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 210 | return false; |
| 211 | } |
| 212 | MemberOffset field_offset(inst->VRegC_22c()); |
| 213 | const bool is_volatile = false; // iget-x-quick only on non volatile fields. |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 214 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 215 | switch (field_type) { |
| 216 | case Primitive::kPrimInt: |
| 217 | shadow_frame.SetVReg(vregA, static_cast<int32_t>(obj->GetField32(field_offset, is_volatile))); |
| 218 | break; |
| 219 | case Primitive::kPrimLong: |
| 220 | shadow_frame.SetVRegLong(vregA, static_cast<int64_t>(obj->GetField64(field_offset, is_volatile))); |
| 221 | break; |
| 222 | case Primitive::kPrimNot: |
| 223 | shadow_frame.SetVRegReference(vregA, obj->GetFieldObject<mirror::Object*>(field_offset, is_volatile)); |
| 224 | break; |
| 225 | default: |
| 226 | LOG(FATAL) << "Unreachable: " << field_type; |
| 227 | } |
| 228 | return true; |
| 229 | } |
| 230 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 231 | // Handles iput-XXX and sput-XXX instructions. |
| 232 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 233 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check> |
| 234 | static inline bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 235 | const Instruction* inst, uint16_t inst_data) { |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 236 | bool do_assignability_check = do_access_check; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 237 | bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite); |
| 238 | uint32_t field_idx = is_static ? inst->VRegB_21c() : inst->VRegC_22c(); |
| 239 | ArtField* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, |
| 240 | find_type, Primitive::FieldSize(field_type), |
| 241 | do_access_check); |
| 242 | if (UNLIKELY(f == NULL)) { |
| 243 | CHECK(self->IsExceptionPending()); |
| 244 | return false; |
| 245 | } |
| 246 | Object* obj; |
| 247 | if (is_static) { |
| 248 | obj = f->GetDeclaringClass(); |
| 249 | } else { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 250 | obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 251 | if (UNLIKELY(obj == NULL)) { |
| 252 | ThrowNullPointerExceptionForFieldAccess(shadow_frame.GetCurrentLocationForThrow(), |
| 253 | f, false); |
| 254 | return false; |
| 255 | } |
| 256 | } |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 257 | 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] | 258 | switch (field_type) { |
| 259 | case Primitive::kPrimBoolean: |
| 260 | f->SetBoolean(obj, shadow_frame.GetVReg(vregA)); |
| 261 | break; |
| 262 | case Primitive::kPrimByte: |
| 263 | f->SetByte(obj, shadow_frame.GetVReg(vregA)); |
| 264 | break; |
| 265 | case Primitive::kPrimChar: |
| 266 | f->SetChar(obj, shadow_frame.GetVReg(vregA)); |
| 267 | break; |
| 268 | case Primitive::kPrimShort: |
| 269 | f->SetShort(obj, shadow_frame.GetVReg(vregA)); |
| 270 | break; |
| 271 | case Primitive::kPrimInt: |
| 272 | f->SetInt(obj, shadow_frame.GetVReg(vregA)); |
| 273 | break; |
| 274 | case Primitive::kPrimLong: |
| 275 | f->SetLong(obj, shadow_frame.GetVRegLong(vregA)); |
| 276 | break; |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 277 | case Primitive::kPrimNot: { |
| 278 | Object* reg = shadow_frame.GetVRegReference(vregA); |
| 279 | if (do_assignability_check && reg != NULL) { |
| 280 | Class* field_class = FieldHelper(f).GetType(); |
| 281 | if (!reg->VerifierInstanceOf(field_class)) { |
| 282 | // This should never happen. |
| 283 | self->ThrowNewExceptionF(self->GetCurrentLocationForThrow(), |
| 284 | "Ljava/lang/VirtualMachineError;", |
| 285 | "Put '%s' that is not instance of field '%s' in '%s'", |
| 286 | ClassHelper(reg->GetClass()).GetDescriptor(), |
| 287 | ClassHelper(field_class).GetDescriptor(), |
| 288 | ClassHelper(f->GetDeclaringClass()).GetDescriptor()); |
| 289 | return false; |
| 290 | } |
| 291 | } |
| 292 | f->SetObj(obj, reg); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 293 | break; |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 294 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 295 | default: |
| 296 | LOG(FATAL) << "Unreachable: " << field_type; |
| 297 | } |
| 298 | return true; |
| 299 | } |
| 300 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 301 | // Handles iput-quick, iput-wide-quick and iput-object-quick instructions. |
| 302 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 303 | template<Primitive::Type field_type> |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 304 | static inline bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) { |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 305 | Object* obj = shadow_frame.GetVRegReference(inst->VRegB_22c(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 306 | if (UNLIKELY(obj == NULL)) { |
| 307 | // We lost the reference to the field index so we cannot get a more |
| 308 | // precised exception message. |
| 309 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetCurrentLocationForThrow()); |
| 310 | return false; |
| 311 | } |
| 312 | MemberOffset field_offset(inst->VRegC_22c()); |
| 313 | const bool is_volatile = false; // iput-x-quick only on non volatile fields. |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 314 | const uint32_t vregA = inst->VRegA_22c(inst_data); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 315 | switch (field_type) { |
| 316 | case Primitive::kPrimInt: |
| 317 | obj->SetField32(field_offset, shadow_frame.GetVReg(vregA), is_volatile); |
| 318 | break; |
| 319 | case Primitive::kPrimLong: |
| 320 | obj->SetField64(field_offset, shadow_frame.GetVRegLong(vregA), is_volatile); |
| 321 | break; |
| 322 | case Primitive::kPrimNot: |
| 323 | obj->SetFieldObject(field_offset, shadow_frame.GetVRegReference(vregA), is_volatile); |
| 324 | break; |
| 325 | default: |
| 326 | LOG(FATAL) << "Unreachable: " << field_type; |
| 327 | } |
| 328 | return true; |
| 329 | } |
| 330 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 331 | // Handles string resolution for const-string and const-string-jumbo instructions. Also ensures the |
| 332 | // java.lang.String class is initialized. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 333 | static inline String* ResolveString(Thread* self, MethodHelper& mh, uint32_t string_idx) |
| 334 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 335 | Class* java_lang_string_class = String::GetJavaLangString(); |
| 336 | if (UNLIKELY(!java_lang_string_class->IsInitialized())) { |
| 337 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
| 338 | if (UNLIKELY(!class_linker->EnsureInitialized(java_lang_string_class, |
| 339 | true, true))) { |
| 340 | DCHECK(self->IsExceptionPending()); |
| 341 | return NULL; |
| 342 | } |
| 343 | } |
| 344 | return mh.ResolveString(string_idx); |
| 345 | } |
| 346 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 347 | // Handles div-int, div-int/2addr, div-int/li16 and div-int/lit8 instructions. |
| 348 | // 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] | 349 | static inline bool DoIntDivide(ShadowFrame& shadow_frame, size_t result_reg, |
| 350 | int32_t dividend, int32_t divisor) |
| 351 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 352 | const int32_t kMinInt = std::numeric_limits<int32_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 353 | if (UNLIKELY(divisor == 0)) { |
| 354 | ThrowArithmeticExceptionDivideByZero(); |
| 355 | return false; |
| 356 | } |
| 357 | if (UNLIKELY(dividend == kMinInt && divisor == -1)) { |
| 358 | shadow_frame.SetVReg(result_reg, kMinInt); |
| 359 | } else { |
| 360 | shadow_frame.SetVReg(result_reg, dividend / divisor); |
| 361 | } |
| 362 | return true; |
| 363 | } |
| 364 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 365 | // Handles rem-int, rem-int/2addr, rem-int/li16 and rem-int/lit8 instructions. |
| 366 | // 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] | 367 | static inline bool DoIntRemainder(ShadowFrame& shadow_frame, size_t result_reg, |
| 368 | int32_t dividend, int32_t divisor) |
| 369 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 370 | const int32_t kMinInt = std::numeric_limits<int32_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 371 | if (UNLIKELY(divisor == 0)) { |
| 372 | ThrowArithmeticExceptionDivideByZero(); |
| 373 | return false; |
| 374 | } |
| 375 | if (UNLIKELY(dividend == kMinInt && divisor == -1)) { |
| 376 | shadow_frame.SetVReg(result_reg, 0); |
| 377 | } else { |
| 378 | shadow_frame.SetVReg(result_reg, dividend % divisor); |
| 379 | } |
| 380 | return true; |
| 381 | } |
| 382 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 383 | // Handles div-long and div-long-2addr instructions. |
| 384 | // 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] | 385 | static inline bool DoLongDivide(ShadowFrame& shadow_frame, size_t result_reg, |
| 386 | int64_t dividend, int64_t divisor) |
| 387 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 388 | const int64_t kMinLong = std::numeric_limits<int64_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 389 | if (UNLIKELY(divisor == 0)) { |
| 390 | ThrowArithmeticExceptionDivideByZero(); |
| 391 | return false; |
| 392 | } |
| 393 | if (UNLIKELY(dividend == kMinLong && divisor == -1)) { |
| 394 | shadow_frame.SetVRegLong(result_reg, kMinLong); |
| 395 | } else { |
| 396 | shadow_frame.SetVRegLong(result_reg, dividend / divisor); |
| 397 | } |
| 398 | return true; |
| 399 | } |
| 400 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 401 | // Handles rem-long and rem-long-2addr instructions. |
| 402 | // 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] | 403 | static inline bool DoLongRemainder(ShadowFrame& shadow_frame, size_t result_reg, |
| 404 | int64_t dividend, int64_t divisor) |
| 405 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 406 | const int64_t kMinLong = std::numeric_limits<int64_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 407 | if (UNLIKELY(divisor == 0)) { |
| 408 | ThrowArithmeticExceptionDivideByZero(); |
| 409 | return false; |
| 410 | } |
| 411 | if (UNLIKELY(dividend == kMinLong && divisor == -1)) { |
| 412 | shadow_frame.SetVRegLong(result_reg, 0); |
| 413 | } else { |
| 414 | shadow_frame.SetVRegLong(result_reg, dividend % divisor); |
| 415 | } |
| 416 | return true; |
| 417 | } |
| 418 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 419 | // Handles filled-new-array and filled-new-array-range instructions. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 420 | // Returns true on success, otherwise throws an exception and returns false. |
| 421 | template <bool is_range, bool do_access_check> |
| 422 | bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 423 | Thread* self, JValue* result); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 424 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 425 | // Handles packed-switch instruction. |
| 426 | // Returns the branch offset to the next instruction to execute. |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 427 | static inline int32_t DoPackedSwitch(const Instruction* inst, const ShadowFrame& shadow_frame, |
| 428 | uint16_t inst_data) |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 429 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 430 | DCHECK(inst->Opcode() == Instruction::PACKED_SWITCH); |
| 431 | 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] | 432 | int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 433 | DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kPackedSwitchSignature)); |
| 434 | uint16_t size = switch_data[1]; |
| 435 | DCHECK_GT(size, 0); |
| 436 | const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]); |
| 437 | DCHECK(IsAligned<4>(keys)); |
| 438 | int32_t first_key = keys[0]; |
| 439 | const int32_t* targets = reinterpret_cast<const int32_t*>(&switch_data[4]); |
| 440 | DCHECK(IsAligned<4>(targets)); |
| 441 | int32_t index = test_val - first_key; |
| 442 | if (index >= 0 && index < size) { |
| 443 | return targets[index]; |
| 444 | } else { |
| 445 | // No corresponding value: move forward by 3 (size of PACKED_SWITCH). |
| 446 | return 3; |
| 447 | } |
| 448 | } |
| 449 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 450 | // Handles sparse-switch instruction. |
| 451 | // Returns the branch offset to the next instruction to execute. |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 452 | static inline int32_t DoSparseSwitch(const Instruction* inst, const ShadowFrame& shadow_frame, |
| 453 | uint16_t inst_data) |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 454 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 455 | DCHECK(inst->Opcode() == Instruction::SPARSE_SWITCH); |
| 456 | 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] | 457 | int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 458 | DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kSparseSwitchSignature)); |
| 459 | uint16_t size = switch_data[1]; |
| 460 | DCHECK_GT(size, 0); |
| 461 | const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]); |
| 462 | DCHECK(IsAligned<4>(keys)); |
| 463 | const int32_t* entries = keys + size; |
| 464 | DCHECK(IsAligned<4>(entries)); |
| 465 | int lo = 0; |
| 466 | int hi = size - 1; |
| 467 | while (lo <= hi) { |
| 468 | int mid = (lo + hi) / 2; |
| 469 | int32_t foundVal = keys[mid]; |
| 470 | if (test_val < foundVal) { |
| 471 | hi = mid - 1; |
| 472 | } else if (test_val > foundVal) { |
| 473 | lo = mid + 1; |
| 474 | } else { |
| 475 | return entries[mid]; |
| 476 | } |
| 477 | } |
| 478 | // No corresponding value: move forward by 3 (size of SPARSE_SWITCH). |
| 479 | return 3; |
| 480 | } |
| 481 | |
| 482 | static inline uint32_t FindNextInstructionFollowingException(Thread* self, |
| 483 | ShadowFrame& shadow_frame, |
| 484 | uint32_t dex_pc, |
Sebastien Hertz | 947ff08 | 2013-09-17 14:10:13 +0200 | [diff] [blame] | 485 | mirror::Object* this_object, |
| 486 | const instrumentation::Instrumentation* instrumentation) |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 487 | ALWAYS_INLINE; |
| 488 | |
| 489 | static inline uint32_t FindNextInstructionFollowingException(Thread* self, |
| 490 | ShadowFrame& shadow_frame, |
| 491 | uint32_t dex_pc, |
Sebastien Hertz | 947ff08 | 2013-09-17 14:10:13 +0200 | [diff] [blame] | 492 | mirror::Object* this_object, |
| 493 | const instrumentation::Instrumentation* instrumentation) |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 494 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 495 | self->VerifyStack(); |
| 496 | ThrowLocation throw_location; |
| 497 | mirror::Throwable* exception = self->GetException(&throw_location); |
Sebastien Hertz | 947ff08 | 2013-09-17 14:10:13 +0200 | [diff] [blame] | 498 | bool clear_exception = false; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 499 | uint32_t found_dex_pc = shadow_frame.GetMethod()->FindCatchBlock(exception->GetClass(), dex_pc, |
| 500 | &clear_exception); |
| 501 | if (found_dex_pc == DexFile::kDexNoIndex) { |
Sebastien Hertz | 947ff08 | 2013-09-17 14:10:13 +0200 | [diff] [blame] | 502 | instrumentation->MethodUnwindEvent(self, this_object, |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 503 | shadow_frame.GetMethod(), dex_pc); |
| 504 | } else { |
| 505 | instrumentation->ExceptionCaughtEvent(self, throw_location, |
| 506 | shadow_frame.GetMethod(), |
| 507 | found_dex_pc, exception); |
| 508 | if (clear_exception) { |
| 509 | self->ClearException(); |
| 510 | } |
| 511 | } |
| 512 | return found_dex_pc; |
| 513 | } |
| 514 | |
| 515 | static void UnexpectedOpcode(const Instruction* inst, MethodHelper& mh) |
| 516 | __attribute__((cold, noreturn, noinline)); |
| 517 | |
| 518 | static void UnexpectedOpcode(const Instruction* inst, MethodHelper& mh) |
| 519 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 520 | LOG(FATAL) << "Unexpected instruction: " << inst->DumpString(&mh.GetDexFile()); |
| 521 | exit(0); // Unreachable, keep GCC happy. |
| 522 | } |
| 523 | |
| 524 | static inline void TraceExecution(const ShadowFrame& shadow_frame, const Instruction* inst, |
Jeff Hao | a3faaf4 | 2013-09-03 19:07:00 -0700 | [diff] [blame] | 525 | const uint32_t dex_pc, MethodHelper& mh) |
| 526 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 527 | const bool kTracing = false; |
| 528 | if (kTracing) { |
| 529 | #define TRACE_LOG std::cerr |
| 530 | TRACE_LOG << PrettyMethod(shadow_frame.GetMethod()) |
| 531 | << StringPrintf("\n0x%x: ", dex_pc) |
| 532 | << inst->DumpString(&mh.GetDexFile()) << "\n"; |
| 533 | for (size_t i = 0; i < shadow_frame.NumberOfVRegs(); ++i) { |
| 534 | uint32_t raw_value = shadow_frame.GetVReg(i); |
| 535 | Object* ref_value = shadow_frame.GetVRegReference(i); |
| 536 | TRACE_LOG << StringPrintf(" vreg%d=0x%08X", i, raw_value); |
| 537 | if (ref_value != NULL) { |
| 538 | if (ref_value->GetClass()->IsStringClass() && |
| 539 | ref_value->AsString()->GetCharArray() != NULL) { |
| 540 | TRACE_LOG << "/java.lang.String \"" << ref_value->AsString()->ToModifiedUtf8() << "\""; |
| 541 | } else { |
| 542 | TRACE_LOG << "/" << PrettyTypeOf(ref_value); |
| 543 | } |
| 544 | } |
| 545 | } |
| 546 | TRACE_LOG << "\n"; |
| 547 | #undef TRACE_LOG |
| 548 | } |
| 549 | } |
| 550 | |
Sebastien Hertz | 1eda226 | 2013-09-09 16:53:14 +0200 | [diff] [blame] | 551 | static inline bool IsBackwardBranch(int32_t branch_offset) { |
| 552 | return branch_offset <= 0; |
| 553 | } |
| 554 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame^] | 555 | // Explicitly instantiate all DoInvoke functions. |
| 556 | #define EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, _is_range, _do_check) \ |
| 557 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE \ |
| 558 | static bool DoInvoke<_type, _is_range, _do_check>(Thread* self, ShadowFrame& shadow_frame, \ |
| 559 | const Instruction* inst, uint16_t inst_data, \ |
| 560 | JValue* result) |
| 561 | |
| 562 | #define EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(_type) \ |
| 563 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, false, false); \ |
| 564 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, false, true); \ |
| 565 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, true, false); \ |
| 566 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, true, true); |
| 567 | |
| 568 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kStatic); // invoke-static/range. |
| 569 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kDirect); // invoke-direct/range. |
| 570 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kVirtual); // invoke-virtual/range. |
| 571 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kSuper); // invoke-super/range. |
| 572 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kInterface); // invoke-interface/range. |
| 573 | #undef EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL |
| 574 | #undef EXPLICIT_DO_INVOKE_TEMPLATE_DECL |
| 575 | |
| 576 | // Explicitly instantiate all DoFieldGet functions. |
| 577 | #define EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, _do_check) \ |
| 578 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE \ |
| 579 | static bool DoFieldGet<_find_type, _field_type, _do_check>(Thread* self, ShadowFrame& shadow_frame, \ |
| 580 | const Instruction* inst, uint16_t inst_data) |
| 581 | |
| 582 | #define EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
| 583 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, false); \ |
| 584 | EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL(_find_type, _field_type, true); |
| 585 | |
| 586 | // iget-XXX |
| 587 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimBoolean); |
| 588 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimByte); |
| 589 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimChar); |
| 590 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimShort); |
| 591 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimInt); |
| 592 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstancePrimitiveRead, Primitive::kPrimLong); |
| 593 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(InstanceObjectRead, Primitive::kPrimNot); |
| 594 | |
| 595 | // sget-XXX |
| 596 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimBoolean); |
| 597 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimByte); |
| 598 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimChar); |
| 599 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimShort); |
| 600 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimInt); |
| 601 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticPrimitiveRead, Primitive::kPrimLong); |
| 602 | EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL(StaticObjectRead, Primitive::kPrimNot); |
| 603 | |
| 604 | #undef EXPLICIT_DO_FIELD_GET_ALL_TEMPLATE_DECL |
| 605 | #undef EXPLICIT_DO_FIELD_GET_TEMPLATE_DECL |
| 606 | |
| 607 | // Explicitly instantiate all DoFieldPut functions. |
| 608 | #define EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, _do_check) \ |
| 609 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE \ |
| 610 | static bool DoFieldPut<_find_type, _field_type, _do_check>(Thread* self, const ShadowFrame& shadow_frame, \ |
| 611 | const Instruction* inst, uint16_t inst_data) |
| 612 | |
| 613 | #define EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(_find_type, _field_type) \ |
| 614 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, false); \ |
| 615 | EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL(_find_type, _field_type, true); |
| 616 | |
| 617 | // iput-XXX |
| 618 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimBoolean); |
| 619 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimByte); |
| 620 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimChar); |
| 621 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimShort); |
| 622 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimInt); |
| 623 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstancePrimitiveWrite, Primitive::kPrimLong); |
| 624 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(InstanceObjectWrite, Primitive::kPrimNot); |
| 625 | |
| 626 | // sput-XXX |
| 627 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimBoolean); |
| 628 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimByte); |
| 629 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimChar); |
| 630 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimShort); |
| 631 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimInt); |
| 632 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticPrimitiveWrite, Primitive::kPrimLong); |
| 633 | EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL(StaticObjectWrite, Primitive::kPrimNot); |
| 634 | |
| 635 | #undef EXPLICIT_DO_FIELD_PUT_ALL_TEMPLATE_DECL |
| 636 | #undef EXPLICIT_DO_FIELD_PUT_TEMPLATE_DECL |
| 637 | |
| 638 | // Explicitly instantiate all DoInvokeVirtualQuick functions. |
| 639 | #define EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(_is_range) \ |
| 640 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE \ |
| 641 | static bool DoInvokeVirtualQuick<_is_range>(Thread* self, ShadowFrame& shadow_frame, \ |
| 642 | const Instruction* inst, uint16_t inst_data, \ |
| 643 | JValue* result) |
| 644 | |
| 645 | EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(false); // invoke-virtual-quick. |
| 646 | EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(true); // invoke-virtual-quick-range. |
| 647 | #undef EXPLICIT_INSTANTIATION_DO_INVOKE_VIRTUAL_QUICK |
| 648 | |
| 649 | // Explicitly instantiate all DoIGetQuick functions. |
| 650 | #define EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(_field_type) \ |
| 651 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE \ |
| 652 | static bool DoIGetQuick<_field_type>(ShadowFrame& shadow_frame, const Instruction* inst, \ |
| 653 | uint16_t inst_data) |
| 654 | |
| 655 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimInt); // iget-quick. |
| 656 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimLong); // iget-wide-quick. |
| 657 | EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL(Primitive::kPrimNot); // iget-object-quick. |
| 658 | #undef EXPLICIT_DO_IGET_QUICK_TEMPLATE_DECL |
| 659 | |
| 660 | // Explicitly instantiate all DoIPutQuick functions. |
| 661 | #define EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(_field_type) \ |
| 662 | template SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE \ |
| 663 | static bool DoIPutQuick<_field_type>(const ShadowFrame& shadow_frame, const Instruction* inst, \ |
| 664 | uint16_t inst_data) |
| 665 | |
| 666 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(Primitive::kPrimInt); // iget-quick. |
| 667 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(Primitive::kPrimLong); // iget-wide-quick. |
| 668 | EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL(Primitive::kPrimNot); // iget-object-quick. |
| 669 | #undef EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL |
| 670 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 671 | } // namespace interpreter |
| 672 | } // namespace art |
| 673 | |
| 674 | #endif // ART_RUNTIME_INTERPRETER_INTERPRETER_COMMON_H_ |