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 | |
Ian Rogers | cf7f191 | 2014-10-22 22:06:39 -0700 | [diff] [blame] | 24 | #include <iostream> |
Ian Rogers | c7dd295 | 2014-10-21 23:31:19 -0700 | [diff] [blame] | 25 | #include <sstream> |
Christina Wadsworth | bf44e0e | 2016-08-18 10:37:42 -0700 | [diff] [blame^] | 26 | #include <atomic> |
Ian Rogers | c7dd295 | 2014-10-21 23:31:19 -0700 | [diff] [blame] | 27 | |
Mathieu Chartier | c785344 | 2015-03-27 14:35:38 -0700 | [diff] [blame] | 28 | #include "art_field-inl.h" |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 29 | #include "art_method-inl.h" |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 30 | #include "base/enums.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 31 | #include "base/logging.h" |
Andreas Gampe | 794ad76 | 2015-02-23 08:12:24 -0800 | [diff] [blame] | 32 | #include "base/macros.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 33 | #include "class_linker-inl.h" |
| 34 | #include "common_throws.h" |
| 35 | #include "dex_file-inl.h" |
| 36 | #include "dex_instruction-inl.h" |
Mingyao Yang | 98d1cc8 | 2014-05-15 17:02:16 -0700 | [diff] [blame] | 37 | #include "entrypoints/entrypoint_utils-inl.h" |
Mathieu Chartier | 0cd8135 | 2014-05-22 16:48:55 -0700 | [diff] [blame] | 38 | #include "handle_scope-inl.h" |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 39 | #include "jit/jit.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 40 | #include "mirror/class-inl.h" |
Christina Wadsworth | bf44e0e | 2016-08-18 10:37:42 -0700 | [diff] [blame^] | 41 | #include "mirror/dex_cache.h" |
| 42 | #include "mirror/method.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 43 | #include "mirror/object-inl.h" |
| 44 | #include "mirror/object_array-inl.h" |
Douglas Leung | 4965c02 | 2014-06-11 11:41:11 -0700 | [diff] [blame] | 45 | #include "mirror/string-inl.h" |
Andreas Gampe | 03ec930 | 2015-08-27 17:41:47 -0700 | [diff] [blame] | 46 | #include "stack.h" |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 47 | #include "thread.h" |
| 48 | #include "well_known_classes.h" |
| 49 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 50 | using ::art::ArtMethod; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 51 | using ::art::mirror::Array; |
| 52 | using ::art::mirror::BooleanArray; |
| 53 | using ::art::mirror::ByteArray; |
| 54 | using ::art::mirror::CharArray; |
| 55 | using ::art::mirror::Class; |
| 56 | using ::art::mirror::ClassLoader; |
| 57 | using ::art::mirror::IntArray; |
| 58 | using ::art::mirror::LongArray; |
| 59 | using ::art::mirror::Object; |
| 60 | using ::art::mirror::ObjectArray; |
| 61 | using ::art::mirror::ShortArray; |
| 62 | using ::art::mirror::String; |
| 63 | using ::art::mirror::Throwable; |
| 64 | |
| 65 | namespace art { |
| 66 | namespace interpreter { |
| 67 | |
buzbee | 1452bee | 2015-03-06 14:43:04 -0800 | [diff] [blame] | 68 | // External references to all interpreter implementations. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 69 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 70 | template<bool do_access_check, bool transaction_active> |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 71 | extern JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, |
buzbee | 1452bee | 2015-03-06 14:43:04 -0800 | [diff] [blame] | 72 | ShadowFrame& shadow_frame, JValue result_register, |
| 73 | bool interpret_one_instruction); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 74 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 75 | template<bool do_access_check, bool transaction_active> |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 76 | extern JValue ExecuteGotoImpl(Thread* self, const DexFile::CodeItem* code_item, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 77 | ShadowFrame& shadow_frame, JValue result_register); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 78 | |
buzbee | 1452bee | 2015-03-06 14:43:04 -0800 | [diff] [blame] | 79 | // Mterp does not support transactions or access check, thus no templated versions. |
| 80 | extern "C" bool ExecuteMterpImpl(Thread* self, const DexFile::CodeItem* code_item, |
| 81 | ShadowFrame* shadow_frame, JValue* result_register); |
| 82 | |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 83 | void ThrowNullPointerExceptionFromInterpreter() |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 84 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | da843e1 | 2014-05-28 19:28:31 +0200 | [diff] [blame] | 85 | |
Andreas Gampe | 03ec930 | 2015-08-27 17:41:47 -0700 | [diff] [blame] | 86 | template <bool kMonitorCounting> |
| 87 | static inline void DoMonitorEnter(Thread* self, |
| 88 | ShadowFrame* frame, |
Mathieu Chartier | 2d096c9 | 2015-10-12 16:18:20 -0700 | [diff] [blame] | 89 | Object* ref) |
| 90 | NO_THREAD_SAFETY_ANALYSIS |
| 91 | REQUIRES(!Roles::uninterruptible_) { |
| 92 | StackHandleScope<1> hs(self); |
| 93 | Handle<Object> h_ref(hs.NewHandle(ref)); |
| 94 | h_ref->MonitorEnter(self); |
Andreas Gampe | 56fdd0e | 2016-04-28 14:56:54 -0700 | [diff] [blame] | 95 | if (kMonitorCounting && frame->GetMethod()->MustCountLocks()) { |
| 96 | frame->GetLockCountData().AddMonitor(self, h_ref.Get()); |
| 97 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 98 | } |
| 99 | |
Andreas Gampe | 03ec930 | 2015-08-27 17:41:47 -0700 | [diff] [blame] | 100 | template <bool kMonitorCounting> |
| 101 | static inline void DoMonitorExit(Thread* self, |
| 102 | ShadowFrame* frame, |
Mathieu Chartier | 2d096c9 | 2015-10-12 16:18:20 -0700 | [diff] [blame] | 103 | Object* ref) |
| 104 | NO_THREAD_SAFETY_ANALYSIS |
| 105 | REQUIRES(!Roles::uninterruptible_) { |
| 106 | StackHandleScope<1> hs(self); |
| 107 | Handle<Object> h_ref(hs.NewHandle(ref)); |
| 108 | h_ref->MonitorExit(self); |
Andreas Gampe | 56fdd0e | 2016-04-28 14:56:54 -0700 | [diff] [blame] | 109 | if (kMonitorCounting && frame->GetMethod()->MustCountLocks()) { |
| 110 | frame->GetLockCountData().RemoveMonitorOrThrow(self, h_ref.Get()); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | template <bool kMonitorCounting> |
| 115 | static inline bool DoMonitorCheckOnExit(Thread* self, ShadowFrame* frame) |
| 116 | NO_THREAD_SAFETY_ANALYSIS |
| 117 | REQUIRES(!Roles::uninterruptible_) { |
| 118 | if (kMonitorCounting && frame->GetMethod()->MustCountLocks()) { |
| 119 | return frame->GetLockCountData().CheckAllMonitorsReleasedOrThrow(self); |
| 120 | } |
| 121 | return true; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 122 | } |
| 123 | |
Sebastien Hertz | 45b1597 | 2015-04-03 16:07:05 +0200 | [diff] [blame] | 124 | void AbortTransactionF(Thread* self, const char* fmt, ...) |
| 125 | __attribute__((__format__(__printf__, 2, 3))) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 126 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 45b1597 | 2015-04-03 16:07:05 +0200 | [diff] [blame] | 127 | |
| 128 | void AbortTransactionV(Thread* self, const char* fmt, va_list args) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 129 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | b2c7ead | 2014-04-29 11:13:16 -0700 | [diff] [blame] | 130 | |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 131 | void RecordArrayElementsInTransaction(mirror::Array* array, int32_t count) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 132 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 133 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 134 | // Invokes the given method. This is part of the invocation support and is used by DoInvoke and |
| 135 | // DoInvokeVirtualQuick functions. |
| 136 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 137 | template<bool is_range, bool do_assignability_check> |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 138 | bool DoCall(ArtMethod* called_method, Thread* self, ShadowFrame& shadow_frame, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 139 | const Instruction* inst, uint16_t inst_data, JValue* result); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 140 | |
Narayan Kamath | 14832ef | 2016-08-05 11:44:32 +0100 | [diff] [blame] | 141 | // Handles invoke-XXX/range instructions. |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 142 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 143 | template<InvokeType type, bool is_range, bool do_access_check> |
| 144 | static inline bool DoInvoke(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, |
| 145 | uint16_t inst_data, JValue* result) { |
| 146 | const uint32_t method_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); |
| 147 | const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 148 | Object* receiver = (type == kStatic) ? nullptr : shadow_frame.GetVRegReference(vregC); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 149 | ArtMethod* sf_method = shadow_frame.GetMethod(); |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 150 | ArtMethod* const called_method = FindMethodFromCode<type, do_access_check>( |
Andreas Gampe | 3a35714 | 2015-08-07 17:20:11 -0700 | [diff] [blame] | 151 | method_idx, &receiver, sf_method, self); |
Mathieu Chartier | 0cd8135 | 2014-05-22 16:48:55 -0700 | [diff] [blame] | 152 | // The shadow frame should already be pushed, so we don't need to update it. |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 153 | if (UNLIKELY(called_method == nullptr)) { |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 154 | CHECK(self->IsExceptionPending()); |
| 155 | result->SetJ(0); |
| 156 | return false; |
Alex Light | 9139e00 | 2015-10-09 15:59:48 -0700 | [diff] [blame] | 157 | } else if (UNLIKELY(!called_method->IsInvokable())) { |
| 158 | called_method->ThrowInvocationTimeError(); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 159 | result->SetJ(0); |
| 160 | return false; |
| 161 | } else { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 162 | jit::Jit* jit = Runtime::Current()->GetJit(); |
| 163 | if (jit != nullptr) { |
| 164 | if (type == kVirtual || type == kInterface) { |
| 165 | jit->InvokeVirtualOrInterface( |
| 166 | self, receiver, sf_method, shadow_frame.GetDexPC(), called_method); |
| 167 | } |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 168 | jit->AddSamples(self, sf_method, 1, /*with_backedges*/false); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 169 | } |
| 170 | // TODO: Remove the InvokeVirtualOrInterface instrumentation, as it was only used by the JIT. |
Nicolas Geoffray | 5550ca8 | 2015-08-21 18:38:30 +0100 | [diff] [blame] | 171 | if (type == kVirtual || type == kInterface) { |
| 172 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
| 173 | if (UNLIKELY(instrumentation->HasInvokeVirtualOrInterfaceListeners())) { |
| 174 | instrumentation->InvokeVirtualOrInterface( |
| 175 | self, receiver, sf_method, shadow_frame.GetDexPC(), called_method); |
| 176 | } |
| 177 | } |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 178 | return DoCall<is_range, do_access_check>(called_method, self, shadow_frame, inst, inst_data, |
| 179 | result); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 180 | } |
| 181 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 182 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 183 | // Handles invoke-virtual-quick and invoke-virtual-quick-range instructions. |
| 184 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 185 | template<bool is_range> |
| 186 | static inline bool DoInvokeVirtualQuick(Thread* self, ShadowFrame& shadow_frame, |
| 187 | const Instruction* inst, uint16_t inst_data, |
| 188 | JValue* result) { |
| 189 | const uint32_t vregC = (is_range) ? inst->VRegC_3rc() : inst->VRegC_35c(); |
| 190 | Object* const receiver = shadow_frame.GetVRegReference(vregC); |
Sebastien Hertz | d4beb6b | 2013-10-02 17:07:20 +0200 | [diff] [blame] | 191 | if (UNLIKELY(receiver == nullptr)) { |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 192 | // We lost the reference to the method index so we cannot get a more |
| 193 | // precised exception message. |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 194 | ThrowNullPointerExceptionFromDexPC(); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 195 | return false; |
| 196 | } |
| 197 | const uint32_t vtable_idx = (is_range) ? inst->VRegB_3rc() : inst->VRegB_35c(); |
Artem Udovichenko | a62cb9b | 2016-06-30 09:18:25 +0000 | [diff] [blame] | 198 | CHECK(receiver->GetClass()->ShouldHaveEmbeddedVTable()); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 199 | ArtMethod* const called_method = receiver->GetClass()->GetEmbeddedVTableEntry( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 200 | vtable_idx, kRuntimePointerSize); |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 201 | if (UNLIKELY(called_method == nullptr)) { |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 202 | CHECK(self->IsExceptionPending()); |
| 203 | result->SetJ(0); |
| 204 | return false; |
Alex Light | 9139e00 | 2015-10-09 15:59:48 -0700 | [diff] [blame] | 205 | } else if (UNLIKELY(!called_method->IsInvokable())) { |
| 206 | called_method->ThrowInvocationTimeError(); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 207 | result->SetJ(0); |
| 208 | return false; |
| 209 | } else { |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 210 | jit::Jit* jit = Runtime::Current()->GetJit(); |
| 211 | if (jit != nullptr) { |
| 212 | jit->InvokeVirtualOrInterface( |
| 213 | self, receiver, shadow_frame.GetMethod(), shadow_frame.GetDexPC(), called_method); |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 214 | jit->AddSamples(self, shadow_frame.GetMethod(), 1, /*with_backedges*/false); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 215 | } |
Nicolas Geoffray | 5550ca8 | 2015-08-21 18:38:30 +0100 | [diff] [blame] | 216 | instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); |
Nicolas Geoffray | 274fe4a | 2016-04-12 16:33:24 +0100 | [diff] [blame] | 217 | // TODO: Remove the InvokeVirtualOrInterface instrumentation, as it was only used by the JIT. |
Nicolas Geoffray | 5550ca8 | 2015-08-21 18:38:30 +0100 | [diff] [blame] | 218 | if (UNLIKELY(instrumentation->HasInvokeVirtualOrInterfaceListeners())) { |
| 219 | instrumentation->InvokeVirtualOrInterface( |
| 220 | self, receiver, shadow_frame.GetMethod(), shadow_frame.GetDexPC(), called_method); |
| 221 | } |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 222 | // No need to check since we've been quickened. |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 223 | return DoCall<is_range, false>(called_method, self, shadow_frame, inst, inst_data, result); |
Sebastien Hertz | c61124b | 2013-09-10 11:44:19 +0200 | [diff] [blame] | 224 | } |
| 225 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 226 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 227 | // Handles iget-XXX and sget-XXX instructions. |
| 228 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 229 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check> |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 230 | bool DoFieldGet(Thread* self, ShadowFrame& shadow_frame, const Instruction* inst, |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 231 | uint16_t inst_data) SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 232 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 233 | // Handles iget-quick, iget-wide-quick and iget-object-quick instructions. |
| 234 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 235 | template<Primitive::Type field_type> |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 236 | bool DoIGetQuick(ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 237 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 479fc1e | 2014-04-04 17:51:34 +0200 | [diff] [blame] | 238 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 239 | // Handles iput-XXX and sput-XXX instructions. |
| 240 | // Returns true on success, otherwise throws an exception and returns false. |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 241 | template<FindFieldType find_type, Primitive::Type field_type, bool do_access_check, |
| 242 | bool transaction_active> |
| 243 | bool DoFieldPut(Thread* self, const ShadowFrame& shadow_frame, const Instruction* inst, |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 244 | uint16_t inst_data) SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 245 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 246 | // Handles iput-quick, iput-wide-quick and iput-object-quick instructions. |
| 247 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 248 | template<Primitive::Type field_type, bool transaction_active> |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 249 | bool DoIPutQuick(const ShadowFrame& shadow_frame, const Instruction* inst, uint16_t inst_data) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 250 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 251 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 252 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 253 | // Handles string resolution for const-string and const-string-jumbo instructions. Also ensures the |
| 254 | // java.lang.String class is initialized. |
Ian Rogers | 6786a58 | 2014-10-28 12:49:06 -0700 | [diff] [blame] | 255 | static inline String* ResolveString(Thread* self, ShadowFrame& shadow_frame, uint32_t string_idx) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 256 | SHARED_REQUIRES(Locks::mutator_lock_) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 257 | Class* java_lang_string_class = String::GetJavaLangString(); |
| 258 | if (UNLIKELY(!java_lang_string_class->IsInitialized())) { |
| 259 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 260 | StackHandleScope<1> hs(self); |
| 261 | Handle<mirror::Class> h_class(hs.NewHandle(java_lang_string_class)); |
Ian Rogers | 7b078e8 | 2014-09-10 14:44:24 -0700 | [diff] [blame] | 262 | if (UNLIKELY(!class_linker->EnsureInitialized(self, h_class, true, true))) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 263 | DCHECK(self->IsExceptionPending()); |
Mathieu Chartier | c528dba | 2013-11-26 12:00:11 -0800 | [diff] [blame] | 264 | return nullptr; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 265 | } |
| 266 | } |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 267 | ArtMethod* method = shadow_frame.GetMethod(); |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 268 | mirror::Class* declaring_class = method->GetDeclaringClass(); |
Vladimir Marko | 05792b9 | 2015-08-03 11:56:49 +0100 | [diff] [blame] | 269 | // MethodVerifier refuses methods with string_idx out of bounds. |
Christina Wadsworth | bf44e0e | 2016-08-18 10:37:42 -0700 | [diff] [blame^] | 270 | DCHECK_LT(string_idx % mirror::DexCache::kDexCacheStringCacheSize, |
| 271 | declaring_class->GetDexFile().NumStringIds()); |
| 272 | mirror::String* string_ptr = |
| 273 | mirror::StringDexCachePair::LookupString(declaring_class->GetDexCacheStrings(), |
| 274 | string_idx, |
| 275 | mirror::DexCache::kDexCacheStringCacheSize).Read(); |
| 276 | if (UNLIKELY(string_ptr == nullptr)) { |
Ian Rogers | 6786a58 | 2014-10-28 12:49:06 -0700 | [diff] [blame] | 277 | StackHandleScope<1> hs(self); |
Mathieu Chartier | eace458 | 2014-11-24 18:29:54 -0800 | [diff] [blame] | 278 | Handle<mirror::DexCache> dex_cache(hs.NewHandle(declaring_class->GetDexCache())); |
Christina Wadsworth | bf44e0e | 2016-08-18 10:37:42 -0700 | [diff] [blame^] | 279 | string_ptr = Runtime::Current()->GetClassLinker()->ResolveString(*method->GetDexFile(), |
| 280 | string_idx, |
| 281 | dex_cache); |
Ian Rogers | 6786a58 | 2014-10-28 12:49:06 -0700 | [diff] [blame] | 282 | } |
Christina Wadsworth | bf44e0e | 2016-08-18 10:37:42 -0700 | [diff] [blame^] | 283 | return string_ptr; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 284 | } |
| 285 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 286 | // Handles div-int, div-int/2addr, div-int/li16 and div-int/lit8 instructions. |
| 287 | // 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] | 288 | static inline bool DoIntDivide(ShadowFrame& shadow_frame, size_t result_reg, |
| 289 | int32_t dividend, int32_t divisor) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 290 | SHARED_REQUIRES(Locks::mutator_lock_) { |
Ian Rogers | f72a11d | 2014-10-30 15:41:08 -0700 | [diff] [blame] | 291 | constexpr int32_t kMinInt = std::numeric_limits<int32_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 292 | if (UNLIKELY(divisor == 0)) { |
| 293 | ThrowArithmeticExceptionDivideByZero(); |
| 294 | return false; |
| 295 | } |
| 296 | if (UNLIKELY(dividend == kMinInt && divisor == -1)) { |
| 297 | shadow_frame.SetVReg(result_reg, kMinInt); |
| 298 | } else { |
| 299 | shadow_frame.SetVReg(result_reg, dividend / divisor); |
| 300 | } |
| 301 | return true; |
| 302 | } |
| 303 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 304 | // Handles rem-int, rem-int/2addr, rem-int/li16 and rem-int/lit8 instructions. |
| 305 | // 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] | 306 | static inline bool DoIntRemainder(ShadowFrame& shadow_frame, size_t result_reg, |
| 307 | int32_t dividend, int32_t divisor) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 308 | SHARED_REQUIRES(Locks::mutator_lock_) { |
Ian Rogers | f72a11d | 2014-10-30 15:41:08 -0700 | [diff] [blame] | 309 | constexpr int32_t kMinInt = std::numeric_limits<int32_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 310 | if (UNLIKELY(divisor == 0)) { |
| 311 | ThrowArithmeticExceptionDivideByZero(); |
| 312 | return false; |
| 313 | } |
| 314 | if (UNLIKELY(dividend == kMinInt && divisor == -1)) { |
| 315 | shadow_frame.SetVReg(result_reg, 0); |
| 316 | } else { |
| 317 | shadow_frame.SetVReg(result_reg, dividend % divisor); |
| 318 | } |
| 319 | return true; |
| 320 | } |
| 321 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 322 | // Handles div-long and div-long-2addr instructions. |
| 323 | // 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] | 324 | static inline bool DoLongDivide(ShadowFrame& shadow_frame, size_t result_reg, |
| 325 | int64_t dividend, int64_t divisor) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 326 | SHARED_REQUIRES(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 327 | const int64_t kMinLong = std::numeric_limits<int64_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 328 | if (UNLIKELY(divisor == 0)) { |
| 329 | ThrowArithmeticExceptionDivideByZero(); |
| 330 | return false; |
| 331 | } |
| 332 | if (UNLIKELY(dividend == kMinLong && divisor == -1)) { |
| 333 | shadow_frame.SetVRegLong(result_reg, kMinLong); |
| 334 | } else { |
| 335 | shadow_frame.SetVRegLong(result_reg, dividend / divisor); |
| 336 | } |
| 337 | return true; |
| 338 | } |
| 339 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 340 | // Handles rem-long and rem-long-2addr instructions. |
| 341 | // 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] | 342 | static inline bool DoLongRemainder(ShadowFrame& shadow_frame, size_t result_reg, |
| 343 | int64_t dividend, int64_t divisor) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 344 | SHARED_REQUIRES(Locks::mutator_lock_) { |
Ian Rogers | 2e2deeb | 2013-09-23 11:58:57 -0700 | [diff] [blame] | 345 | const int64_t kMinLong = std::numeric_limits<int64_t>::min(); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 346 | if (UNLIKELY(divisor == 0)) { |
| 347 | ThrowArithmeticExceptionDivideByZero(); |
| 348 | return false; |
| 349 | } |
| 350 | if (UNLIKELY(dividend == kMinLong && divisor == -1)) { |
| 351 | shadow_frame.SetVRegLong(result_reg, 0); |
| 352 | } else { |
| 353 | shadow_frame.SetVRegLong(result_reg, dividend % divisor); |
| 354 | } |
| 355 | return true; |
| 356 | } |
| 357 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 358 | // Handles filled-new-array and filled-new-array-range instructions. |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 359 | // Returns true on success, otherwise throws an exception and returns false. |
Sebastien Hertz | d2fe10a | 2014-01-15 10:20:56 +0100 | [diff] [blame] | 360 | template <bool is_range, bool do_access_check, bool transaction_active> |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 361 | bool DoFilledNewArray(const Instruction* inst, const ShadowFrame& shadow_frame, |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 362 | Thread* self, JValue* result); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 363 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 364 | // Handles packed-switch instruction. |
| 365 | // Returns the branch offset to the next instruction to execute. |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 366 | static inline int32_t DoPackedSwitch(const Instruction* inst, const ShadowFrame& shadow_frame, |
| 367 | uint16_t inst_data) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 368 | SHARED_REQUIRES(Locks::mutator_lock_) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 369 | DCHECK(inst->Opcode() == Instruction::PACKED_SWITCH); |
| 370 | 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] | 371 | int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 372 | DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kPackedSwitchSignature)); |
| 373 | uint16_t size = switch_data[1]; |
David Brazdil | 2ef645b | 2015-06-17 18:20:52 +0100 | [diff] [blame] | 374 | if (size == 0) { |
| 375 | // Empty packed switch, move forward by 3 (size of PACKED_SWITCH). |
| 376 | return 3; |
| 377 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 378 | const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]); |
Roland Levillain | 14d9057 | 2015-07-16 10:52:26 +0100 | [diff] [blame] | 379 | DCHECK_ALIGNED(keys, 4); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 380 | int32_t first_key = keys[0]; |
| 381 | const int32_t* targets = reinterpret_cast<const int32_t*>(&switch_data[4]); |
Roland Levillain | 14d9057 | 2015-07-16 10:52:26 +0100 | [diff] [blame] | 382 | DCHECK_ALIGNED(targets, 4); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 383 | int32_t index = test_val - first_key; |
| 384 | if (index >= 0 && index < size) { |
| 385 | return targets[index]; |
| 386 | } else { |
| 387 | // No corresponding value: move forward by 3 (size of PACKED_SWITCH). |
| 388 | return 3; |
| 389 | } |
| 390 | } |
| 391 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 392 | // Handles sparse-switch instruction. |
| 393 | // Returns the branch offset to the next instruction to execute. |
Sebastien Hertz | 3b588e0 | 2013-09-11 14:33:18 +0200 | [diff] [blame] | 394 | static inline int32_t DoSparseSwitch(const Instruction* inst, const ShadowFrame& shadow_frame, |
| 395 | uint16_t inst_data) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 396 | SHARED_REQUIRES(Locks::mutator_lock_) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 397 | DCHECK(inst->Opcode() == Instruction::SPARSE_SWITCH); |
| 398 | 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] | 399 | int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data)); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 400 | DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kSparseSwitchSignature)); |
| 401 | uint16_t size = switch_data[1]; |
Jeff Hao | 935e01a | 2015-03-20 19:44:35 -0700 | [diff] [blame] | 402 | // Return length of SPARSE_SWITCH if size is 0. |
| 403 | if (size == 0) { |
| 404 | return 3; |
| 405 | } |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 406 | const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]); |
Roland Levillain | 14d9057 | 2015-07-16 10:52:26 +0100 | [diff] [blame] | 407 | DCHECK_ALIGNED(keys, 4); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 408 | const int32_t* entries = keys + size; |
Roland Levillain | 14d9057 | 2015-07-16 10:52:26 +0100 | [diff] [blame] | 409 | DCHECK_ALIGNED(entries, 4); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 410 | int lo = 0; |
| 411 | int hi = size - 1; |
| 412 | while (lo <= hi) { |
| 413 | int mid = (lo + hi) / 2; |
| 414 | int32_t foundVal = keys[mid]; |
| 415 | if (test_val < foundVal) { |
| 416 | hi = mid - 1; |
| 417 | } else if (test_val > foundVal) { |
| 418 | lo = mid + 1; |
| 419 | } else { |
| 420 | return entries[mid]; |
| 421 | } |
| 422 | } |
| 423 | // No corresponding value: move forward by 3 (size of SPARSE_SWITCH). |
| 424 | return 3; |
| 425 | } |
| 426 | |
Ian Rogers | 5487494 | 2014-06-10 16:31:03 -0700 | [diff] [blame] | 427 | uint32_t FindNextInstructionFollowingException(Thread* self, ShadowFrame& shadow_frame, |
Sebastien Hertz | 9f10203 | 2014-05-23 08:59:42 +0200 | [diff] [blame] | 428 | uint32_t dex_pc, const instrumentation::Instrumentation* instrumentation) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 429 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 430 | |
Andreas Gampe | 794ad76 | 2015-02-23 08:12:24 -0800 | [diff] [blame] | 431 | NO_RETURN void UnexpectedOpcode(const Instruction* inst, const ShadowFrame& shadow_frame) |
| 432 | __attribute__((cold)) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 433 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 434 | |
Bill Buzbee | d47fd90 | 2016-07-07 14:42:43 +0000 | [diff] [blame] | 435 | // Set true if you want TraceExecution invocation before each bytecode execution. |
| 436 | constexpr bool kTraceExecutionEnabled = false; |
Serguei Katkov | 9fb0ac7 | 2016-02-20 12:55:24 +0600 | [diff] [blame] | 437 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 438 | static inline void TraceExecution(const ShadowFrame& shadow_frame, const Instruction* inst, |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 439 | const uint32_t dex_pc) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 440 | SHARED_REQUIRES(Locks::mutator_lock_) { |
Bill Buzbee | d47fd90 | 2016-07-07 14:42:43 +0000 | [diff] [blame] | 441 | if (kTraceExecutionEnabled) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 442 | #define TRACE_LOG std::cerr |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 443 | std::ostringstream oss; |
| 444 | oss << PrettyMethod(shadow_frame.GetMethod()) |
| 445 | << StringPrintf("\n0x%x: ", dex_pc) |
Ian Rogers | e94652f | 2014-12-02 11:13:19 -0800 | [diff] [blame] | 446 | << inst->DumpString(shadow_frame.GetMethod()->GetDexFile()) << "\n"; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 447 | for (uint32_t i = 0; i < shadow_frame.NumberOfVRegs(); ++i) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 448 | uint32_t raw_value = shadow_frame.GetVReg(i); |
| 449 | Object* ref_value = shadow_frame.GetVRegReference(i); |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 450 | oss << StringPrintf(" vreg%u=0x%08X", i, raw_value); |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 451 | if (ref_value != nullptr) { |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 452 | if (ref_value->GetClass()->IsStringClass() && |
Jeff Hao | 848f70a | 2014-01-15 13:49:50 -0800 | [diff] [blame] | 453 | ref_value->AsString()->GetValue() != nullptr) { |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 454 | oss << "/java.lang.String \"" << ref_value->AsString()->ToModifiedUtf8() << "\""; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 455 | } else { |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 456 | oss << "/" << PrettyTypeOf(ref_value); |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 457 | } |
| 458 | } |
| 459 | } |
Mathieu Chartier | e861ebd | 2013-10-09 15:01:21 -0700 | [diff] [blame] | 460 | TRACE_LOG << oss.str() << "\n"; |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 461 | #undef TRACE_LOG |
| 462 | } |
| 463 | } |
| 464 | |
Sebastien Hertz | 1eda226 | 2013-09-09 16:53:14 +0200 | [diff] [blame] | 465 | static inline bool IsBackwardBranch(int32_t branch_offset) { |
| 466 | return branch_offset <= 0; |
| 467 | } |
| 468 | |
Nicolas Geoffray | 71cd50f | 2016-04-14 15:00:33 +0100 | [diff] [blame] | 469 | void ArtInterpreterToCompiledCodeBridge(Thread* self, |
| 470 | ArtMethod* caller, |
| 471 | const DexFile::CodeItem* code_item, |
| 472 | ShadowFrame* shadow_frame, |
| 473 | JValue* result); |
Siva Chandra | 05d2415 | 2016-01-05 17:43:17 -0800 | [diff] [blame] | 474 | |
Mingyao Yang | ffedec5 | 2016-05-19 10:48:40 -0700 | [diff] [blame] | 475 | // Set string value created from StringFactory.newStringFromXXX() into all aliases of |
| 476 | // StringFactory.newEmptyString(). |
| 477 | void SetStringInitValueToAllAliases(ShadowFrame* shadow_frame, |
| 478 | uint16_t this_obj_vreg, |
| 479 | JValue result); |
| 480 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 481 | // Explicitly instantiate all DoInvoke functions. |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 482 | #define EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, _is_range, _do_check) \ |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 483 | template SHARED_REQUIRES(Locks::mutator_lock_) \ |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 484 | bool DoInvoke<_type, _is_range, _do_check>(Thread* self, ShadowFrame& shadow_frame, \ |
| 485 | const Instruction* inst, uint16_t inst_data, \ |
| 486 | JValue* result) |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 487 | |
| 488 | #define EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(_type) \ |
| 489 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, false, false); \ |
| 490 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, false, true); \ |
| 491 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, true, false); \ |
| 492 | EXPLICIT_DO_INVOKE_TEMPLATE_DECL(_type, true, true); |
| 493 | |
Andreas Gampe | c8ccf68 | 2014-09-29 20:07:43 -0700 | [diff] [blame] | 494 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kStatic) // invoke-static/range. |
| 495 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kDirect) // invoke-direct/range. |
| 496 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kVirtual) // invoke-virtual/range. |
| 497 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kSuper) // invoke-super/range. |
| 498 | EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL(kInterface) // invoke-interface/range. |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 499 | #undef EXPLICIT_DO_INVOKE_ALL_TEMPLATE_DECL |
| 500 | #undef EXPLICIT_DO_INVOKE_TEMPLATE_DECL |
| 501 | |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 502 | // Explicitly instantiate all DoInvokeVirtualQuick functions. |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 503 | #define EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(_is_range) \ |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 504 | template SHARED_REQUIRES(Locks::mutator_lock_) \ |
Bernhard Rosenkränzer | 4605362 | 2013-12-12 02:15:52 +0100 | [diff] [blame] | 505 | bool DoInvokeVirtualQuick<_is_range>(Thread* self, ShadowFrame& shadow_frame, \ |
| 506 | const Instruction* inst, uint16_t inst_data, \ |
| 507 | JValue* result) |
Sebastien Hertz | c671485 | 2013-09-30 16:42:32 +0200 | [diff] [blame] | 508 | |
| 509 | EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(false); // invoke-virtual-quick. |
| 510 | EXPLICIT_DO_INVOKE_VIRTUAL_QUICK_TEMPLATE_DECL(true); // invoke-virtual-quick-range. |
| 511 | #undef EXPLICIT_INSTANTIATION_DO_INVOKE_VIRTUAL_QUICK |
| 512 | |
Sebastien Hertz | 8ece050 | 2013-08-07 11:26:41 +0200 | [diff] [blame] | 513 | } // namespace interpreter |
| 514 | } // namespace art |
| 515 | |
| 516 | #endif // ART_RUNTIME_INTERPRETER_INTERPRETER_COMMON_H_ |