Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "interpreter.h" |
| 18 | |
| 19 | #include <math.h> |
| 20 | |
Elliott Hughes | 07ed66b | 2012-12-12 18:34:25 -0800 | [diff] [blame] | 21 | #include "base/logging.h" |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 22 | #include "common_throws.h" |
jeffhao | 373c52f | 2012-11-20 16:11:52 -0800 | [diff] [blame] | 23 | #include "debugger.h" |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 24 | #include "dex_instruction.h" |
| 25 | #include "invoke_arg_array_builder.h" |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 26 | #include "nth_caller_visitor.h" |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 27 | #include "object.h" |
| 28 | #include "object_utils.h" |
| 29 | #include "runtime_support.h" |
| 30 | #include "ScopedLocalRef.h" |
| 31 | #include "scoped_thread_state_change.h" |
| 32 | #include "thread.h" |
| 33 | |
| 34 | namespace art { |
| 35 | namespace interpreter { |
| 36 | |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 37 | static const int32_t kMaxInt = std::numeric_limits<int32_t>::max(); |
| 38 | static const int32_t kMinInt = std::numeric_limits<int32_t>::min(); |
| 39 | static const int64_t kMaxLong = std::numeric_limits<int64_t>::max(); |
| 40 | static const int64_t kMinLong = std::numeric_limits<int64_t>::min(); |
| 41 | |
jeffhao | 9b5aa6f | 2012-12-18 11:47:11 -0800 | [diff] [blame] | 42 | static JDWP::FrameId throw_frame_id_ = 0; |
| 43 | static AbstractMethod* throw_method_ = NULL; |
| 44 | static uint32_t throw_dex_pc_ = 0; |
| 45 | |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 46 | static void UnstartedRuntimeInvoke(Thread* self, AbstractMethod* target_method, |
| 47 | Object* receiver, JValue* args, JValue* result) |
| 48 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 49 | // In a runtime that's not started we intercept certain methods to avoid complicated dependency |
| 50 | // problems in core libraries. |
| 51 | std::string name(PrettyMethod(target_method)); |
| 52 | if (name == "java.lang.Class java.lang.Class.forName(java.lang.String)") { |
| 53 | std::string descriptor(DotToDescriptor(args[0].GetL()->AsString()->ToModifiedUtf8().c_str())); |
| 54 | ClassLoader* class_loader = NULL; // shadow_frame.GetMethod()->GetDeclaringClass()->GetClassLoader(); |
| 55 | Class* found = Runtime::Current()->GetClassLinker()->FindClass(descriptor.c_str(), |
| 56 | class_loader); |
| 57 | CHECK(found != NULL) << "Class.forName failed in un-started runtime for class: " |
| 58 | << PrettyDescriptor(descriptor); |
| 59 | result->SetL(found); |
| 60 | } else if (name == "java.lang.Object java.lang.Class.newInstance()") { |
| 61 | Class* klass = receiver->AsClass(); |
| 62 | AbstractMethod* c = klass->FindDeclaredDirectMethod("<init>", "()V"); |
| 63 | CHECK(c != NULL); |
| 64 | Object* obj = klass->AllocObject(self); |
| 65 | CHECK(obj != NULL); |
| 66 | EnterInterpreterFromInvoke(self, c, obj, NULL, NULL); |
| 67 | result->SetL(obj); |
| 68 | } else if (name == "java.lang.reflect.Field java.lang.Class.getDeclaredField(java.lang.String)") { |
| 69 | // Special managed code cut-out to allow field lookup in a un-started runtime that'd fail |
| 70 | // going the reflective Dex way. |
| 71 | Class* klass = receiver->AsClass(); |
| 72 | String* name = args[0].GetL()->AsString(); |
| 73 | Field* found = NULL; |
| 74 | FieldHelper fh; |
| 75 | ObjectArray<Field>* fields = klass->GetIFields(); |
| 76 | for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { |
| 77 | Field* f = fields->Get(i); |
| 78 | fh.ChangeField(f); |
| 79 | if (name->Equals(fh.GetName())) { |
| 80 | found = f; |
| 81 | } |
| 82 | } |
| 83 | if (found == NULL) { |
| 84 | fields = klass->GetSFields(); |
| 85 | for (int32_t i = 0; i < fields->GetLength() && found == NULL; ++i) { |
| 86 | Field* f = fields->Get(i); |
| 87 | fh.ChangeField(f); |
| 88 | if (name->Equals(fh.GetName())) { |
| 89 | found = f; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | CHECK(found != NULL) |
| 94 | << "Failed to find field in Class.getDeclaredField in un-started runtime. name=" |
| 95 | << name->ToModifiedUtf8() << " class=" << PrettyDescriptor(klass); |
| 96 | // TODO: getDeclaredField calls GetType once the field is found to ensure a |
| 97 | // NoClassDefFoundError is thrown if the field's type cannot be resolved. |
| 98 | result->SetL(found); |
| 99 | } else if (name == "void java.lang.System.arraycopy(java.lang.Object, int, java.lang.Object, int, int)") { |
| 100 | // Special case array copying without initializing System. |
| 101 | Class* ctype = args[0].GetL()->GetClass()->GetComponentType(); |
| 102 | jint srcPos = args[1].GetI(); |
| 103 | jint dstPos = args[3].GetI(); |
| 104 | jint length = args[4].GetI(); |
| 105 | if (!ctype->IsPrimitive()) { |
| 106 | ObjectArray<Object>* src = args[0].GetL()->AsObjectArray<Object>(); |
| 107 | ObjectArray<Object>* dst = args[2].GetL()->AsObjectArray<Object>(); |
| 108 | for (jint i = 0; i < length; ++i) { |
| 109 | dst->Set(dstPos + i, src->Get(srcPos + i)); |
| 110 | } |
| 111 | } else if (ctype->IsPrimitiveChar()) { |
| 112 | CharArray* src = args[0].GetL()->AsCharArray(); |
| 113 | CharArray* dst = args[2].GetL()->AsCharArray(); |
| 114 | for (jint i = 0; i < length; ++i) { |
| 115 | dst->Set(dstPos + i, src->Get(srcPos + i)); |
| 116 | } |
| 117 | } else if (ctype->IsPrimitiveInt()) { |
| 118 | IntArray* src = args[0].GetL()->AsIntArray(); |
| 119 | IntArray* dst = args[2].GetL()->AsIntArray(); |
| 120 | for (jint i = 0; i < length; ++i) { |
| 121 | dst->Set(dstPos + i, src->Get(srcPos + i)); |
| 122 | } |
| 123 | } else { |
| 124 | UNIMPLEMENTED(FATAL) << "System.arraycopy of unexpected type: " << PrettyDescriptor(ctype); |
| 125 | } |
| 126 | } else { |
| 127 | // Not special, continue with regular interpreter execution. |
| 128 | EnterInterpreterFromInvoke(self, target_method, receiver, args, result); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | // Hand select a number of methods to be run in a not yet started runtime without using JNI. |
| 133 | static void UnstartedRuntimeJni(Thread* self, AbstractMethod* method, |
| 134 | Object* receiver, JValue* args, JValue* result) |
| 135 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 136 | std::string name(PrettyMethod(method)); |
| 137 | if (name == "java.lang.ClassLoader dalvik.system.VMStack.getCallingClassLoader()") { |
| 138 | result->SetL(NULL); |
| 139 | } else if (name == "java.lang.Class dalvik.system.VMStack.getStackClass2()") { |
| 140 | NthCallerVisitor visitor(self->GetManagedStack(), NULL, 3); |
| 141 | visitor.WalkStack(); |
| 142 | result->SetL(visitor.caller->GetDeclaringClass()); |
| 143 | } else if (name == "double java.lang.Math.log(double)") { |
| 144 | result->SetD(log(args[0].GetD())); |
| 145 | } else if (name == "java.lang.String java.lang.Class.getNameNative()") { |
| 146 | result->SetL(receiver->AsClass()->ComputeName()); |
| 147 | } else if (name == "int java.lang.Float.floatToRawIntBits(float)") { |
| 148 | result->SetI(args[0].GetI()); |
| 149 | } else if (name == "float java.lang.Float.intBitsToFloat(int)") { |
| 150 | result->SetF(args[0].GetF()); |
| 151 | } else if (name == "double java.lang.Math.exp(double)") { |
| 152 | result->SetD(exp(args[0].GetD())); |
| 153 | } else if (name == "java.lang.Object java.lang.Object.internalClone()") { |
| 154 | result->SetL(receiver->Clone(self)); |
| 155 | } else if (name == "void java.lang.Object.notifyAll()") { |
| 156 | receiver->NotifyAll(); |
| 157 | } else if (name == "int java.lang.String.compareTo(java.lang.String)") { |
| 158 | String* rhs = args[0].GetL()->AsString(); |
| 159 | CHECK(rhs != NULL); |
| 160 | result->SetI(receiver->AsString()->CompareTo(rhs)); |
| 161 | } else if (name == "java.lang.String java.lang.String.intern()") { |
| 162 | result->SetL(receiver->AsString()->Intern()); |
| 163 | } else if (name == "int java.lang.String.fastIndexOf(int, int)") { |
| 164 | result->SetI(receiver->AsString()->FastIndexOf(args[0].GetI(), args[1].GetI())); |
| 165 | } else if (name == "java.lang.Object java.lang.reflect.Array.createMultiArray(java.lang.Class, int[])") { |
| 166 | result->SetL(Array::CreateMultiArray(self, args[0].GetL()->AsClass(), args[1].GetL()->AsIntArray())); |
| 167 | } else if (name == "java.lang.Object java.lang.Throwable.nativeFillInStackTrace()") { |
| 168 | ScopedObjectAccessUnchecked soa(self); |
| 169 | result->SetL(soa.Decode<Object*>(self->CreateInternalStackTrace(soa))); |
| 170 | } else if (name == "boolean java.nio.ByteOrder.isLittleEndian()") { |
| 171 | result->SetJ(JNI_TRUE); |
| 172 | } else if (name == "boolean sun.misc.Unsafe.compareAndSwapInt(java.lang.Object, long, int, int)") { |
| 173 | Object* obj = args[0].GetL(); |
| 174 | jlong offset = args[1].GetJ(); |
| 175 | jint expectedValue = args[2].GetI(); |
| 176 | jint newValue = args[3].GetI(); |
| 177 | byte* raw_addr = reinterpret_cast<byte*>(obj) + offset; |
| 178 | volatile int32_t* address = reinterpret_cast<volatile int32_t*>(raw_addr); |
| 179 | // Note: android_atomic_release_cas() returns 0 on success, not failure. |
| 180 | int r = android_atomic_release_cas(expectedValue, newValue, address); |
| 181 | result->SetZ(r == 0); |
| 182 | } else if (name == "void sun.misc.Unsafe.putObject(java.lang.Object, long, java.lang.Object)") { |
| 183 | Object* obj = args[0].GetL(); |
| 184 | Object* newValue = args[2].GetL(); |
| 185 | obj->SetFieldObject(MemberOffset(args[1].GetJ()), newValue, false); |
| 186 | } else { |
| 187 | LOG(FATAL) << "Attempt to invoke native method in non-started runtime: " << name; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | static void InterpreterJni(Thread* self, AbstractMethod* method, StringPiece shorty, |
| 192 | Object* receiver, JValue* args, JValue* result) |
| 193 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 194 | // TODO: The following enters JNI code using a typedef-ed function rather than the JNI compiler, |
| 195 | // it should be removed and JNI compiled stubs used instead. |
| 196 | ScopedObjectAccessUnchecked soa(self); |
| 197 | if (method->IsStatic()) { |
| 198 | if (shorty == "L") { |
| 199 | typedef jobject (fnptr)(JNIEnv*, jclass); |
| 200 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 201 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 202 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 203 | jobject jresult; |
| 204 | { |
| 205 | ScopedThreadStateChange tsc(self, kNative); |
| 206 | jresult = fn(soa.Env(), klass.get()); |
| 207 | } |
| 208 | result->SetL(soa.Decode<Object*>(jresult)); |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 209 | } else if (shorty == "V") { |
| 210 | typedef void (fnptr)(JNIEnv*, jclass); |
| 211 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 212 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 213 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 214 | ScopedThreadStateChange tsc(self, kNative); |
| 215 | fn(soa.Env(), klass.get()); |
| 216 | } else if (shorty == "Z") { |
| 217 | typedef jboolean (fnptr)(JNIEnv*, jclass); |
| 218 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 219 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 220 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 221 | ScopedThreadStateChange tsc(self, kNative); |
| 222 | result->SetZ(fn(soa.Env(), klass.get())); |
| 223 | } else if (shorty == "BI") { |
| 224 | typedef jbyte (fnptr)(JNIEnv*, jclass, jint); |
| 225 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 226 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 227 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 228 | ScopedThreadStateChange tsc(self, kNative); |
| 229 | result->SetB(fn(soa.Env(), klass.get(), args[0].GetI())); |
| 230 | } else if (shorty == "II") { |
| 231 | typedef jint (fnptr)(JNIEnv*, jclass, jint); |
| 232 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 233 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 234 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 235 | ScopedThreadStateChange tsc(self, kNative); |
| 236 | result->SetI(fn(soa.Env(), klass.get(), args[0].GetI())); |
| 237 | } else if (shorty == "LL") { |
| 238 | typedef jobject (fnptr)(JNIEnv*, jclass, jobject); |
| 239 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 240 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 241 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 242 | ScopedLocalRef<jobject> arg0(soa.Env(), |
| 243 | soa.AddLocalReference<jobject>(args[0].GetL())); |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 244 | jobject jresult; |
| 245 | { |
| 246 | ScopedThreadStateChange tsc(self, kNative); |
| 247 | jresult = fn(soa.Env(), klass.get(), arg0.get()); |
| 248 | } |
| 249 | result->SetL(soa.Decode<Object*>(jresult)); |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 250 | } else if (shorty == "IIZ") { |
| 251 | typedef jint (fnptr)(JNIEnv*, jclass, jint, jboolean); |
| 252 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 253 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 254 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 255 | ScopedThreadStateChange tsc(self, kNative); |
| 256 | result->SetI(fn(soa.Env(), klass.get(), args[0].GetI(), args[1].GetZ())); |
| 257 | } else if (shorty == "ILI") { |
| 258 | typedef jint (fnptr)(JNIEnv*, jclass, jobject, jint); |
| 259 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 260 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 261 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 262 | ScopedLocalRef<jobject> arg0(soa.Env(), |
| 263 | soa.AddLocalReference<jobject>(args[0].GetL())); |
| 264 | ScopedThreadStateChange tsc(self, kNative); |
| 265 | result->SetI(fn(soa.Env(), klass.get(), arg0.get(), args[1].GetI())); |
| 266 | } else if (shorty == "SIZ") { |
| 267 | typedef jshort (fnptr)(JNIEnv*, jclass, jint, jboolean); |
| 268 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 269 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 270 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 271 | ScopedThreadStateChange tsc(self, kNative); |
| 272 | result->SetS(fn(soa.Env(), klass.get(), args[0].GetI(), args[1].GetZ())); |
| 273 | } else if (shorty == "VIZ") { |
| 274 | typedef void (fnptr)(JNIEnv*, jclass, jint, jboolean); |
| 275 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 276 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 277 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 278 | ScopedThreadStateChange tsc(self, kNative); |
| 279 | fn(soa.Env(), klass.get(), args[0].GetI(), args[1].GetZ()); |
| 280 | } else if (shorty == "ZLL") { |
| 281 | typedef jboolean (fnptr)(JNIEnv*, jclass, jobject, jobject); |
| 282 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 283 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 284 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 285 | ScopedLocalRef<jobject> arg0(soa.Env(), |
| 286 | soa.AddLocalReference<jobject>(args[0].GetL())); |
| 287 | ScopedLocalRef<jobject> arg1(soa.Env(), |
| 288 | soa.AddLocalReference<jobject>(args[1].GetL())); |
| 289 | ScopedThreadStateChange tsc(self, kNative); |
| 290 | result->SetZ(fn(soa.Env(), klass.get(), arg0.get(), arg1.get())); |
| 291 | } else if (shorty == "ZILL") { |
| 292 | typedef jboolean (fnptr)(JNIEnv*, jclass, jint, jobject, jobject); |
| 293 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 294 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 295 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 296 | ScopedLocalRef<jobject> arg1(soa.Env(), |
| 297 | soa.AddLocalReference<jobject>(args[1].GetL())); |
| 298 | ScopedLocalRef<jobject> arg2(soa.Env(), |
| 299 | soa.AddLocalReference<jobject>(args[2].GetL())); |
| 300 | ScopedThreadStateChange tsc(self, kNative); |
| 301 | result->SetZ(fn(soa.Env(), klass.get(), args[0].GetI(), arg1.get(), arg2.get())); |
| 302 | } else if (shorty == "VILII") { |
| 303 | typedef void (fnptr)(JNIEnv*, jclass, jint, jobject, jint, jint); |
| 304 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 305 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 306 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 307 | ScopedLocalRef<jobject> arg1(soa.Env(), |
| 308 | soa.AddLocalReference<jobject>(args[1].GetL())); |
| 309 | ScopedThreadStateChange tsc(self, kNative); |
| 310 | fn(soa.Env(), klass.get(), args[0].GetI(), arg1.get(), args[2].GetI(), args[3].GetI()); |
| 311 | } else if (shorty == "VLILII") { |
| 312 | typedef void (fnptr)(JNIEnv*, jclass, jobject, jint, jobject, jint, jint); |
| 313 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 314 | ScopedLocalRef<jclass> klass(soa.Env(), |
| 315 | soa.AddLocalReference<jclass>(method->GetDeclaringClass())); |
| 316 | ScopedLocalRef<jobject> arg0(soa.Env(), |
| 317 | soa.AddLocalReference<jobject>(args[0].GetL())); |
| 318 | ScopedLocalRef<jobject> arg2(soa.Env(), |
| 319 | soa.AddLocalReference<jobject>(args[2].GetL())); |
| 320 | ScopedThreadStateChange tsc(self, kNative); |
| 321 | fn(soa.Env(), klass.get(), arg0.get(), args[1].GetI(), arg2.get(), args[3].GetI(), |
| 322 | args[4].GetI()); |
| 323 | } else { |
| 324 | LOG(FATAL) << "Do something with static native method: " << PrettyMethod(method) |
| 325 | << " shorty: " << shorty; |
| 326 | } |
| 327 | } else { |
| 328 | if (shorty == "L") { |
| 329 | typedef jobject (fnptr)(JNIEnv*, jobject); |
| 330 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 331 | ScopedLocalRef<jobject> rcvr(soa.Env(), |
| 332 | soa.AddLocalReference<jobject>(receiver)); |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 333 | jobject jresult; |
| 334 | { |
| 335 | ScopedThreadStateChange tsc(self, kNative); |
| 336 | jresult = fn(soa.Env(), rcvr.get()); |
| 337 | } |
| 338 | result->SetL(soa.Decode<Object*>(jresult)); |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 339 | } else if (shorty == "LL") { |
| 340 | typedef jobject (fnptr)(JNIEnv*, jobject, jobject); |
| 341 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 342 | ScopedLocalRef<jobject> rcvr(soa.Env(), |
| 343 | soa.AddLocalReference<jobject>(receiver)); |
| 344 | ScopedLocalRef<jobject> arg0(soa.Env(), |
| 345 | soa.AddLocalReference<jobject>(args[0].GetL())); |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 346 | jobject jresult; |
| 347 | { |
| 348 | ScopedThreadStateChange tsc(self, kNative); |
| 349 | jresult = fn(soa.Env(), rcvr.get(), arg0.get()); |
| 350 | |
| 351 | } |
| 352 | result->SetL(soa.Decode<Object*>(jresult)); |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 353 | ScopedThreadStateChange tsc(self, kNative); |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 354 | } else if (shorty == "III") { |
| 355 | typedef jint (fnptr)(JNIEnv*, jobject, jint, jint); |
| 356 | fnptr* fn = reinterpret_cast<fnptr*>(method->GetNativeMethod()); |
| 357 | ScopedLocalRef<jobject> rcvr(soa.Env(), |
| 358 | soa.AddLocalReference<jobject>(receiver)); |
| 359 | ScopedThreadStateChange tsc(self, kNative); |
| 360 | result->SetI(fn(soa.Env(), rcvr.get(), args[0].GetI(), args[1].GetI())); |
| 361 | } else { |
| 362 | LOG(FATAL) << "Do something with native method: " << PrettyMethod(method) |
| 363 | << " shorty: " << shorty; |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 368 | static void DoMonitorEnter(Thread* self, Object* ref) NO_THREAD_SAFETY_ANALYSIS { |
| 369 | ref->MonitorEnter(self); |
| 370 | } |
| 371 | |
| 372 | static void DoMonitorExit(Thread* self, Object* ref) NO_THREAD_SAFETY_ANALYSIS { |
| 373 | ref->MonitorExit(self); |
| 374 | } |
| 375 | |
| 376 | static void DoInvoke(Thread* self, MethodHelper& mh, ShadowFrame& shadow_frame, |
| 377 | const DecodedInstruction& dec_insn, InvokeType type, bool is_range, |
| 378 | JValue* result) |
| 379 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 380 | Object* receiver; |
| 381 | if (type == kStatic) { |
| 382 | receiver = NULL; |
| 383 | } else { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 384 | receiver = shadow_frame.GetVRegReference(dec_insn.vC); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 385 | } |
| 386 | uint32_t method_idx = dec_insn.vB; |
| 387 | AbstractMethod* target_method = FindMethodFromCode(method_idx, receiver, |
| 388 | shadow_frame.GetMethod(), self, true, |
| 389 | type); |
| 390 | if (UNLIKELY(target_method == NULL)) { |
| 391 | CHECK(self->IsExceptionPending()); |
| 392 | result->SetJ(0); |
| 393 | return; |
| 394 | } |
| 395 | mh.ChangeMethod(target_method); |
| 396 | ArgArray arg_array(mh.GetShorty(), mh.GetShortyLength()); |
| 397 | if (is_range) { |
| 398 | arg_array.BuildArgArray(shadow_frame, dec_insn.vC + (type != kStatic ? 1 : 0)); |
| 399 | } else { |
| 400 | arg_array.BuildArgArray(shadow_frame, dec_insn.arg + (type != kStatic ? 1 : 0)); |
| 401 | } |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 402 | if (LIKELY(Runtime::Current()->IsStarted())) { |
| 403 | target_method->Invoke(self, receiver, arg_array.get(), result); |
| 404 | } else { |
| 405 | UnstartedRuntimeInvoke(self, target_method, receiver, arg_array.get(), result); |
| 406 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 407 | mh.ChangeMethod(shadow_frame.GetMethod()); |
| 408 | } |
| 409 | |
| 410 | static void DoFieldGet(Thread* self, ShadowFrame& shadow_frame, |
| 411 | const DecodedInstruction& dec_insn, FindFieldType find_type, |
| 412 | Primitive::Type field_type) |
| 413 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 414 | bool is_static = (find_type == StaticObjectRead) || (find_type == StaticPrimitiveRead); |
| 415 | uint32_t field_idx = is_static ? dec_insn.vB : dec_insn.vC; |
| 416 | Field* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, |
| 417 | find_type, Primitive::FieldSize(field_type)); |
| 418 | if (LIKELY(f != NULL)) { |
| 419 | Object* obj; |
| 420 | if (is_static) { |
| 421 | obj = f->GetDeclaringClass(); |
| 422 | } else { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 423 | obj = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 424 | if (UNLIKELY(obj == NULL)) { |
| 425 | ThrowNullPointerExceptionForFieldAccess(f, true); |
Ian Rogers | 689d9f0 | 2012-11-20 16:30:29 -0800 | [diff] [blame] | 426 | return; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 427 | } |
| 428 | } |
| 429 | switch (field_type) { |
| 430 | case Primitive::kPrimBoolean: |
| 431 | shadow_frame.SetVReg(dec_insn.vA, f->GetBoolean(obj)); |
| 432 | break; |
| 433 | case Primitive::kPrimByte: |
| 434 | shadow_frame.SetVReg(dec_insn.vA, f->GetByte(obj)); |
| 435 | break; |
| 436 | case Primitive::kPrimChar: |
| 437 | shadow_frame.SetVReg(dec_insn.vA, f->GetChar(obj)); |
| 438 | break; |
| 439 | case Primitive::kPrimShort: |
| 440 | shadow_frame.SetVReg(dec_insn.vA, f->GetShort(obj)); |
| 441 | break; |
| 442 | case Primitive::kPrimInt: |
| 443 | shadow_frame.SetVReg(dec_insn.vA, f->GetInt(obj)); |
| 444 | break; |
| 445 | case Primitive::kPrimLong: |
| 446 | shadow_frame.SetVRegLong(dec_insn.vA, f->GetLong(obj)); |
| 447 | break; |
| 448 | case Primitive::kPrimNot: |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 449 | shadow_frame.SetVRegReference(dec_insn.vA, f->GetObject(obj)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 450 | break; |
| 451 | default: |
| 452 | LOG(FATAL) << "Unreachable: " << field_type; |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | static void DoFieldPut(Thread* self, ShadowFrame& shadow_frame, |
| 458 | const DecodedInstruction& dec_insn, FindFieldType find_type, |
| 459 | Primitive::Type field_type) |
| 460 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 461 | bool is_static = (find_type == StaticObjectWrite) || (find_type == StaticPrimitiveWrite); |
| 462 | uint32_t field_idx = is_static ? dec_insn.vB : dec_insn.vC; |
| 463 | Field* f = FindFieldFromCode(field_idx, shadow_frame.GetMethod(), self, |
| 464 | find_type, Primitive::FieldSize(field_type)); |
| 465 | if (LIKELY(f != NULL)) { |
| 466 | Object* obj; |
| 467 | if (is_static) { |
| 468 | obj = f->GetDeclaringClass(); |
| 469 | } else { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 470 | obj = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 471 | if (UNLIKELY(obj == NULL)) { |
| 472 | ThrowNullPointerExceptionForFieldAccess(f, false); |
Ian Rogers | 689d9f0 | 2012-11-20 16:30:29 -0800 | [diff] [blame] | 473 | return; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 474 | } |
| 475 | } |
| 476 | switch (field_type) { |
| 477 | case Primitive::kPrimBoolean: |
| 478 | f->SetBoolean(obj, shadow_frame.GetVReg(dec_insn.vA)); |
| 479 | break; |
| 480 | case Primitive::kPrimByte: |
| 481 | f->SetByte(obj, shadow_frame.GetVReg(dec_insn.vA)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 482 | break; |
| 483 | case Primitive::kPrimChar: |
| 484 | f->SetChar(obj, shadow_frame.GetVReg(dec_insn.vA)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 485 | break; |
| 486 | case Primitive::kPrimShort: |
| 487 | f->SetShort(obj, shadow_frame.GetVReg(dec_insn.vA)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 488 | break; |
| 489 | case Primitive::kPrimInt: |
| 490 | f->SetInt(obj, shadow_frame.GetVReg(dec_insn.vA)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 491 | break; |
| 492 | case Primitive::kPrimLong: |
| 493 | f->SetLong(obj, shadow_frame.GetVRegLong(dec_insn.vA)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 494 | break; |
| 495 | case Primitive::kPrimNot: |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 496 | f->SetObj(obj, shadow_frame.GetVRegReference(dec_insn.vA)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 497 | break; |
| 498 | default: |
| 499 | LOG(FATAL) << "Unreachable: " << field_type; |
| 500 | } |
| 501 | } |
| 502 | } |
| 503 | |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 504 | static void DoIntDivide(Thread* self, ShadowFrame& shadow_frame, size_t result_reg, |
| 505 | int32_t dividend, int32_t divisor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 506 | if (UNLIKELY(divisor == 0)) { |
| 507 | self->ThrowNewException("Ljava/lang/ArithmeticException;", "divide by zero"); |
| 508 | } else if (UNLIKELY(dividend == kMinInt && divisor == -1)) { |
| 509 | shadow_frame.SetVReg(result_reg, kMinInt); |
| 510 | } else { |
| 511 | shadow_frame.SetVReg(result_reg, dividend / divisor); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | static void DoIntRemainder(Thread* self, ShadowFrame& shadow_frame, size_t result_reg, |
| 516 | int32_t dividend, int32_t divisor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 517 | if (UNLIKELY(divisor == 0)) { |
| 518 | self->ThrowNewException("Ljava/lang/ArithmeticException;", "divide by zero"); |
| 519 | } else if (UNLIKELY(dividend == kMinInt && divisor == -1)) { |
| 520 | shadow_frame.SetVReg(result_reg, 0); |
| 521 | } else { |
| 522 | shadow_frame.SetVReg(result_reg, dividend % divisor); |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | static void DoLongDivide(Thread* self, ShadowFrame& shadow_frame, size_t result_reg, |
| 527 | int64_t dividend, int64_t divisor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 528 | if (UNLIKELY(divisor == 0)) { |
| 529 | self->ThrowNewException("Ljava/lang/ArithmeticException;", "divide by zero"); |
| 530 | } else if (UNLIKELY(dividend == kMinLong && divisor == -1)) { |
| 531 | shadow_frame.SetVRegLong(result_reg, kMinLong); |
| 532 | } else { |
| 533 | shadow_frame.SetVRegLong(result_reg, dividend / divisor); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | static void DoLongRemainder(Thread* self, ShadowFrame& shadow_frame, size_t result_reg, |
| 538 | int64_t dividend, int64_t divisor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 539 | if (UNLIKELY(divisor == 0)) { |
| 540 | self->ThrowNewException("Ljava/lang/ArithmeticException;", "divide by zero"); |
| 541 | } else if (UNLIKELY(dividend == kMinLong && divisor == -1)) { |
| 542 | shadow_frame.SetVRegLong(result_reg, 0); |
| 543 | } else { |
| 544 | shadow_frame.SetVRegLong(result_reg, dividend % divisor); |
| 545 | } |
| 546 | } |
| 547 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 548 | static JValue Execute(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item, |
Ian Rogers | 306057f | 2012-11-26 12:45:53 -0800 | [diff] [blame] | 549 | ShadowFrame& shadow_frame, JValue result_register) |
| 550 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 551 | const uint16_t* insns = code_item->insns_; |
| 552 | const Instruction* inst = Instruction::At(insns + shadow_frame.GetDexPC()); |
jeffhao | 14f0db9 | 2012-12-14 17:50:42 -0800 | [diff] [blame] | 553 | bool entry = (inst->GetDexPc(insns) == 0); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 554 | while (true) { |
jeffhao | 373c52f | 2012-11-20 16:11:52 -0800 | [diff] [blame] | 555 | CheckSuspend(self); |
| 556 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 557 | shadow_frame.SetDexPC(dex_pc); |
jeffhao | 14f0db9 | 2012-12-14 17:50:42 -0800 | [diff] [blame] | 558 | if (entry) { |
| 559 | Dbg::UpdateDebugger(-1, self); |
| 560 | } |
| 561 | entry = false; |
jeffhao | 373c52f | 2012-11-20 16:11:52 -0800 | [diff] [blame] | 562 | Dbg::UpdateDebugger(dex_pc, self); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 563 | DecodedInstruction dec_insn(inst); |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 564 | const bool kTracing = false; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 565 | if (kTracing) { |
| 566 | LOG(INFO) << PrettyMethod(shadow_frame.GetMethod()) |
| 567 | << StringPrintf("\n0x%x: %s\nReferences:", |
| 568 | inst->GetDexPc(insns), inst->DumpString(&mh.GetDexFile()).c_str()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 569 | for (size_t i = 0; i < shadow_frame.NumberOfVRegs(); ++i) { |
| 570 | Object* o = shadow_frame.GetVRegReference(i); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 571 | if (o != NULL) { |
| 572 | if (o->GetClass()->IsStringClass() && o->AsString()->GetCharArray() != NULL) { |
| 573 | LOG(INFO) << i << ": java.lang.String " << static_cast<void*>(o) |
| 574 | << " \"" << o->AsString()->ToModifiedUtf8() << "\""; |
| 575 | } else { |
| 576 | LOG(INFO) << i << ": " << PrettyTypeOf(o) << " " << static_cast<void*>(o); |
| 577 | } |
| 578 | } else { |
| 579 | LOG(INFO) << i << ": null"; |
| 580 | } |
| 581 | } |
| 582 | LOG(INFO) << "vregs:"; |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 583 | for (size_t i = 0; i < shadow_frame.NumberOfVRegs(); ++i) { |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 584 | LOG(INFO) << StringPrintf("%d: %08x", i, shadow_frame.GetVReg(i)); |
| 585 | } |
| 586 | } |
| 587 | const Instruction* next_inst = inst->Next(); |
| 588 | switch (dec_insn.opcode) { |
| 589 | case Instruction::NOP: |
| 590 | break; |
| 591 | case Instruction::MOVE: |
| 592 | case Instruction::MOVE_FROM16: |
| 593 | case Instruction::MOVE_16: |
| 594 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB)); |
| 595 | break; |
| 596 | case Instruction::MOVE_WIDE: |
| 597 | case Instruction::MOVE_WIDE_FROM16: |
| 598 | case Instruction::MOVE_WIDE_16: |
| 599 | shadow_frame.SetVRegLong(dec_insn.vA, shadow_frame.GetVRegLong(dec_insn.vB)); |
| 600 | break; |
| 601 | case Instruction::MOVE_OBJECT: |
| 602 | case Instruction::MOVE_OBJECT_FROM16: |
| 603 | case Instruction::MOVE_OBJECT_16: |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 604 | shadow_frame.SetVRegReference(dec_insn.vA, shadow_frame.GetVRegReference(dec_insn.vB)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 605 | break; |
| 606 | case Instruction::MOVE_RESULT: |
| 607 | shadow_frame.SetVReg(dec_insn.vA, result_register.GetI()); |
| 608 | break; |
| 609 | case Instruction::MOVE_RESULT_WIDE: |
| 610 | shadow_frame.SetVRegLong(dec_insn.vA, result_register.GetJ()); |
| 611 | break; |
| 612 | case Instruction::MOVE_RESULT_OBJECT: |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 613 | shadow_frame.SetVRegReference(dec_insn.vA, result_register.GetL()); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 614 | break; |
| 615 | case Instruction::MOVE_EXCEPTION: { |
| 616 | Throwable* exception = self->GetException(); |
| 617 | self->ClearException(); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 618 | shadow_frame.SetVRegReference(dec_insn.vA, exception); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 619 | break; |
| 620 | } |
| 621 | case Instruction::RETURN_VOID: { |
| 622 | JValue result; |
| 623 | result.SetJ(0); |
| 624 | return result; |
| 625 | } |
| 626 | case Instruction::RETURN: { |
| 627 | JValue result; |
| 628 | result.SetJ(0); |
| 629 | result.SetI(shadow_frame.GetVReg(dec_insn.vA)); |
| 630 | return result; |
| 631 | } |
| 632 | case Instruction::RETURN_WIDE: { |
| 633 | JValue result; |
| 634 | result.SetJ(shadow_frame.GetVRegLong(dec_insn.vA)); |
| 635 | return result; |
| 636 | } |
| 637 | case Instruction::RETURN_OBJECT: { |
| 638 | JValue result; |
| 639 | result.SetJ(0); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 640 | result.SetL(shadow_frame.GetVRegReference(dec_insn.vA)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 641 | return result; |
| 642 | } |
| 643 | case Instruction::CONST_4: { |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 644 | int32_t val = static_cast<int32_t>(dec_insn.vB << 28) >> 28; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 645 | shadow_frame.SetVReg(dec_insn.vA, val); |
| 646 | if (val == 0) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 647 | shadow_frame.SetVRegReference(dec_insn.vA, NULL); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 648 | } |
| 649 | break; |
| 650 | } |
| 651 | case Instruction::CONST_16: { |
| 652 | int32_t val = static_cast<int16_t>(dec_insn.vB); |
| 653 | shadow_frame.SetVReg(dec_insn.vA, val); |
| 654 | if (val == 0) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 655 | shadow_frame.SetVRegReference(dec_insn.vA, NULL); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 656 | } |
| 657 | break; |
| 658 | } |
| 659 | case Instruction::CONST: { |
| 660 | int32_t val = dec_insn.vB; |
| 661 | shadow_frame.SetVReg(dec_insn.vA, val); |
| 662 | if (val == 0) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 663 | shadow_frame.SetVRegReference(dec_insn.vA, NULL); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 664 | } |
| 665 | break; |
| 666 | } |
| 667 | case Instruction::CONST_HIGH16: { |
| 668 | int32_t val = dec_insn.vB << 16; |
| 669 | shadow_frame.SetVReg(dec_insn.vA, val); |
| 670 | if (val == 0) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 671 | shadow_frame.SetVRegReference(dec_insn.vA, NULL); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 672 | } |
| 673 | break; |
| 674 | } |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 675 | case Instruction::CONST_WIDE_16: |
| 676 | shadow_frame.SetVRegLong(dec_insn.vA, static_cast<int16_t>(dec_insn.vB)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 677 | break; |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 678 | case Instruction::CONST_WIDE_32: |
| 679 | shadow_frame.SetVRegLong(dec_insn.vA, static_cast<int32_t>(dec_insn.vB)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 680 | break; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 681 | case Instruction::CONST_WIDE: |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 682 | shadow_frame.SetVRegLong(dec_insn.vA, dec_insn.vB_wide); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 683 | break; |
| 684 | case Instruction::CONST_WIDE_HIGH16: |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 685 | shadow_frame.SetVRegLong(dec_insn.vA, static_cast<uint64_t>(dec_insn.vB) << 48); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 686 | break; |
| 687 | case Instruction::CONST_STRING: |
| 688 | case Instruction::CONST_STRING_JUMBO: { |
| 689 | if (UNLIKELY(!String::GetJavaLangString()->IsInitialized())) { |
| 690 | Runtime::Current()->GetClassLinker()->EnsureInitialized(String::GetJavaLangString(), |
| 691 | true, true); |
| 692 | } |
| 693 | String* s = mh.ResolveString(dec_insn.vB); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 694 | shadow_frame.SetVRegReference(dec_insn.vA, s); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 695 | break; |
| 696 | } |
jeffhao | 0a9bb73 | 2012-11-26 12:28:49 -0800 | [diff] [blame] | 697 | case Instruction::CONST_CLASS: { |
| 698 | Class* c = ResolveVerifyAndClinit(dec_insn.vB, shadow_frame.GetMethod(), self, false, true); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 699 | shadow_frame.SetVRegReference(dec_insn.vA, c); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 700 | break; |
jeffhao | 0a9bb73 | 2012-11-26 12:28:49 -0800 | [diff] [blame] | 701 | } |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 702 | case Instruction::MONITOR_ENTER: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 703 | Object* obj = shadow_frame.GetVRegReference(dec_insn.vA); |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 704 | if (UNLIKELY(obj == NULL)) { |
| 705 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 706 | } else { |
| 707 | DoMonitorEnter(self, obj); |
| 708 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 709 | break; |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 710 | } |
| 711 | case Instruction::MONITOR_EXIT: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 712 | Object* obj = shadow_frame.GetVRegReference(dec_insn.vA); |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 713 | if (UNLIKELY(obj == NULL)) { |
| 714 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 715 | } else { |
| 716 | DoMonitorExit(self, obj); |
| 717 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 718 | break; |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 719 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 720 | case Instruction::CHECK_CAST: { |
jeffhao | 0a9bb73 | 2012-11-26 12:28:49 -0800 | [diff] [blame] | 721 | Class* c = ResolveVerifyAndClinit(dec_insn.vB, shadow_frame.GetMethod(), self, false, true); |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 722 | if (UNLIKELY(c == NULL)) { |
| 723 | CHECK(self->IsExceptionPending()); |
| 724 | } else { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 725 | Object* obj = shadow_frame.GetVRegReference(dec_insn.vA); |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 726 | if (UNLIKELY(obj != NULL && !obj->InstanceOf(c))) { |
| 727 | self->ThrowNewExceptionF("Ljava/lang/ClassCastException;", |
| 728 | "%s cannot be cast to %s", |
| 729 | PrettyDescriptor(obj->GetClass()).c_str(), |
| 730 | PrettyDescriptor(c).c_str()); |
| 731 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 732 | } |
| 733 | break; |
| 734 | } |
| 735 | case Instruction::INSTANCE_OF: { |
jeffhao | 0a9bb73 | 2012-11-26 12:28:49 -0800 | [diff] [blame] | 736 | Class* c = ResolveVerifyAndClinit(dec_insn.vC, shadow_frame.GetMethod(), self, false, true); |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 737 | if (UNLIKELY(c == NULL)) { |
| 738 | CHECK(self->IsExceptionPending()); |
| 739 | } else { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 740 | Object* obj = shadow_frame.GetVRegReference(dec_insn.vB); |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 741 | shadow_frame.SetVReg(dec_insn.vA, (obj != NULL && obj->InstanceOf(c)) ? 1 : 0); |
| 742 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 743 | break; |
| 744 | } |
| 745 | case Instruction::ARRAY_LENGTH: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 746 | Object* array = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 747 | if (UNLIKELY(array == NULL)) { |
| 748 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 749 | break; |
| 750 | } |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 751 | shadow_frame.SetVReg(dec_insn.vA, array->AsArray()->GetLength()); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 752 | break; |
| 753 | } |
| 754 | case Instruction::NEW_INSTANCE: { |
| 755 | Object* obj = AllocObjectFromCode(dec_insn.vB, shadow_frame.GetMethod(), self, true); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 756 | shadow_frame.SetVRegReference(dec_insn.vA, obj); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 757 | break; |
| 758 | } |
| 759 | case Instruction::NEW_ARRAY: { |
| 760 | int32_t length = shadow_frame.GetVReg(dec_insn.vB); |
| 761 | Object* obj = AllocArrayFromCode(dec_insn.vC, shadow_frame.GetMethod(), length, self, true); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 762 | shadow_frame.SetVRegReference(dec_insn.vA, obj); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 763 | break; |
| 764 | } |
| 765 | case Instruction::FILLED_NEW_ARRAY: |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 766 | case Instruction::FILLED_NEW_ARRAY_RANGE: { |
| 767 | bool is_range = (dec_insn.opcode == Instruction::FILLED_NEW_ARRAY_RANGE); |
| 768 | int32_t length = dec_insn.vA; |
| 769 | CHECK(is_range || length <= 5); |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 770 | if (UNLIKELY(length < 0)) { |
| 771 | self->ThrowNewExceptionF("Ljava/lang/NegativeArraySizeException;", "%d", length); |
| 772 | break; |
| 773 | } |
jeffhao | 0a9bb73 | 2012-11-26 12:28:49 -0800 | [diff] [blame] | 774 | Class* arrayClass = ResolveVerifyAndClinit(dec_insn.vB, shadow_frame.GetMethod(), self, false, true); |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 775 | if (UNLIKELY(arrayClass == NULL)) { |
| 776 | CHECK(self->IsExceptionPending()); |
| 777 | break; |
| 778 | } |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 779 | CHECK(arrayClass->IsArrayClass()); |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 780 | Class* componentClass = arrayClass->GetComponentType(); |
| 781 | if (UNLIKELY(componentClass->IsPrimitive() && !componentClass->IsPrimitiveInt())) { |
| 782 | if (componentClass->IsPrimitiveLong() || componentClass->IsPrimitiveDouble()) { |
| 783 | self->ThrowNewExceptionF("Ljava/lang/RuntimeException;", |
| 784 | "Bad filled array request for type %s", |
| 785 | PrettyDescriptor(componentClass).c_str()); |
| 786 | } else { |
| 787 | self->ThrowNewExceptionF("Ljava/lang/InternalError;", |
| 788 | "Found type %s; filled-new-array not implemented for anything but \'int\'", |
| 789 | PrettyDescriptor(componentClass).c_str()); |
| 790 | } |
| 791 | break; |
| 792 | } |
| 793 | Object* newArray = Array::Alloc(self, arrayClass, length); |
| 794 | if (newArray != NULL) { |
| 795 | for (int32_t i = 0; i < length; ++i) { |
| 796 | if (is_range) { |
| 797 | if (componentClass->IsPrimitiveInt()) { |
| 798 | newArray->AsIntArray()->Set(i, shadow_frame.GetVReg(dec_insn.vC + i)); |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 799 | } else { |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 800 | newArray->AsObjectArray<Object>()->Set(i, shadow_frame.GetVRegReference(dec_insn.vC + i)); |
| 801 | } |
| 802 | } else { |
| 803 | if (componentClass->IsPrimitiveInt()) { |
| 804 | newArray->AsIntArray()->Set(i, shadow_frame.GetVReg(dec_insn.arg[i])); |
| 805 | } else { |
| 806 | newArray->AsObjectArray<Object>()->Set(i, shadow_frame.GetVRegReference(dec_insn.arg[i])); |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 807 | } |
| 808 | } |
| 809 | } |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 810 | } |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 811 | result_register.SetL(newArray); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 812 | break; |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 813 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 814 | case Instruction::CMPL_FLOAT: { |
| 815 | float val1 = shadow_frame.GetVRegFloat(dec_insn.vB); |
| 816 | float val2 = shadow_frame.GetVRegFloat(dec_insn.vC); |
| 817 | int32_t result; |
| 818 | if (val1 == val2) { |
| 819 | result = 0; |
| 820 | } else if (val1 > val2) { |
| 821 | result = 1; |
| 822 | } else { |
| 823 | result = -1; |
| 824 | } |
| 825 | shadow_frame.SetVReg(dec_insn.vA, result); |
| 826 | break; |
| 827 | } |
| 828 | case Instruction::CMPG_FLOAT: { |
| 829 | float val1 = shadow_frame.GetVRegFloat(dec_insn.vB); |
| 830 | float val2 = shadow_frame.GetVRegFloat(dec_insn.vC); |
| 831 | int32_t result; |
| 832 | if (val1 == val2) { |
| 833 | result = 0; |
| 834 | } else if (val1 < val2) { |
| 835 | result = -1; |
| 836 | } else { |
| 837 | result = 1; |
| 838 | } |
| 839 | shadow_frame.SetVReg(dec_insn.vA, result); |
| 840 | break; |
| 841 | } |
| 842 | case Instruction::CMPL_DOUBLE: { |
| 843 | double val1 = shadow_frame.GetVRegDouble(dec_insn.vB); |
| 844 | double val2 = shadow_frame.GetVRegDouble(dec_insn.vC); |
| 845 | int32_t result; |
| 846 | if (val1 == val2) { |
| 847 | result = 0; |
Ian Rogers | 58bf0c6 | 2012-11-20 16:24:12 -0800 | [diff] [blame] | 848 | } else if (val1 > val2) { |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 849 | result = 1; |
| 850 | } else { |
| 851 | result = -1; |
| 852 | } |
| 853 | shadow_frame.SetVReg(dec_insn.vA, result); |
| 854 | break; |
| 855 | } |
| 856 | |
| 857 | case Instruction::CMPG_DOUBLE: { |
| 858 | double val1 = shadow_frame.GetVRegDouble(dec_insn.vB); |
| 859 | double val2 = shadow_frame.GetVRegDouble(dec_insn.vC); |
| 860 | int32_t result; |
| 861 | if (val1 == val2) { |
| 862 | result = 0; |
Ian Rogers | 58bf0c6 | 2012-11-20 16:24:12 -0800 | [diff] [blame] | 863 | } else if (val1 < val2) { |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 864 | result = -1; |
| 865 | } else { |
| 866 | result = 1; |
| 867 | } |
| 868 | shadow_frame.SetVReg(dec_insn.vA, result); |
| 869 | break; |
| 870 | } |
| 871 | case Instruction::CMP_LONG: { |
| 872 | int64_t val1 = shadow_frame.GetVRegLong(dec_insn.vB); |
| 873 | int64_t val2 = shadow_frame.GetVRegLong(dec_insn.vC); |
| 874 | int32_t result; |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 875 | if (val1 > val2) { |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 876 | result = 1; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 877 | } else if (val1 == val2) { |
| 878 | result = 0; |
| 879 | } else { |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 880 | result = -1; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 881 | } |
| 882 | shadow_frame.SetVReg(dec_insn.vA, result); |
| 883 | break; |
| 884 | } |
| 885 | case Instruction::THROW: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 886 | Throwable* t = shadow_frame.GetVRegReference(dec_insn.vA)->AsThrowable(); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 887 | self->DeliverException(t); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 888 | break; |
| 889 | } |
| 890 | case Instruction::GOTO: |
| 891 | case Instruction::GOTO_16: |
| 892 | case Instruction::GOTO_32: { |
| 893 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 894 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vA); |
| 895 | break; |
| 896 | } |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 897 | case Instruction::PACKED_SWITCH: { |
| 898 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 899 | const uint16_t* switch_data = insns + dex_pc + dec_insn.vB; |
| 900 | int32_t test_val = shadow_frame.GetVReg(dec_insn.vA); |
| 901 | CHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kPackedSwitchSignature)); |
| 902 | uint16_t size = switch_data[1]; |
| 903 | CHECK_GT(size, 0); |
| 904 | const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]); |
| 905 | CHECK(IsAligned<4>(keys)); |
| 906 | int32_t first_key = keys[0]; |
| 907 | const int32_t* targets = reinterpret_cast<const int32_t*>(&switch_data[4]); |
| 908 | CHECK(IsAligned<4>(targets)); |
| 909 | int32_t index = test_val - first_key; |
| 910 | if (index >= 0 && index < size) { |
| 911 | next_inst = Instruction::At(insns + dex_pc + targets[index]); |
| 912 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 913 | break; |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 914 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 915 | case Instruction::SPARSE_SWITCH: { |
| 916 | uint32_t dex_pc = inst->GetDexPc(insns); |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 917 | const uint16_t* switch_data = insns + dex_pc + dec_insn.vB; |
| 918 | int32_t test_val = shadow_frame.GetVReg(dec_insn.vA); |
| 919 | CHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kSparseSwitchSignature)); |
| 920 | uint16_t size = switch_data[1]; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 921 | CHECK_GT(size, 0); |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 922 | const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 923 | CHECK(IsAligned<4>(keys)); |
| 924 | const int32_t* entries = keys + size; |
| 925 | CHECK(IsAligned<4>(entries)); |
| 926 | int lo = 0; |
| 927 | int hi = size - 1; |
| 928 | while (lo <= hi) { |
| 929 | int mid = (lo + hi) / 2; |
| 930 | int32_t foundVal = keys[mid]; |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 931 | if (test_val < foundVal) { |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 932 | hi = mid - 1; |
Ian Rogers | 556d637 | 2012-11-20 12:19:36 -0800 | [diff] [blame] | 933 | } else if (test_val > foundVal) { |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 934 | lo = mid + 1; |
| 935 | } else { |
| 936 | next_inst = Instruction::At(insns + dex_pc + entries[mid]); |
| 937 | break; |
| 938 | } |
| 939 | } |
| 940 | break; |
| 941 | } |
| 942 | case Instruction::FILL_ARRAY_DATA: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 943 | Object* obj = shadow_frame.GetVRegReference(dec_insn.vA); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 944 | if (UNLIKELY(obj == NULL)) { |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 945 | Thread::Current()->ThrowNewExceptionF("Ljava/lang/NullPointerException;", |
| 946 | "null array in FILL_ARRAY_DATA"); |
| 947 | break; |
| 948 | } |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 949 | Array* array = obj->AsArray(); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 950 | DCHECK(array->IsArrayInstance() && !array->IsObjectArray()); |
| 951 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 952 | const Instruction::ArrayDataPayload* payload = |
| 953 | reinterpret_cast<const Instruction::ArrayDataPayload*>(insns + dex_pc + dec_insn.vB); |
| 954 | if (UNLIKELY(static_cast<int32_t>(payload->element_count) > array->GetLength())) { |
| 955 | Thread::Current()->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;", |
| 956 | "failed FILL_ARRAY_DATA; length=%d, index=%d", |
| 957 | array->GetLength(), payload->element_count); |
| 958 | break; |
| 959 | } |
| 960 | uint32_t size_in_bytes = payload->element_count * payload->element_width; |
| 961 | memcpy(array->GetRawData(payload->element_width), payload->data, size_in_bytes); |
| 962 | break; |
| 963 | } |
| 964 | case Instruction::IF_EQ: { |
| 965 | if (shadow_frame.GetVReg(dec_insn.vA) == shadow_frame.GetVReg(dec_insn.vB)) { |
| 966 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 967 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vC); |
| 968 | } |
| 969 | break; |
| 970 | } |
| 971 | case Instruction::IF_NE: { |
| 972 | if (shadow_frame.GetVReg(dec_insn.vA) != shadow_frame.GetVReg(dec_insn.vB)) { |
| 973 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 974 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vC); |
| 975 | } |
| 976 | break; |
| 977 | } |
| 978 | case Instruction::IF_LT: { |
| 979 | if (shadow_frame.GetVReg(dec_insn.vA) < shadow_frame.GetVReg(dec_insn.vB)) { |
| 980 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 981 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vC); |
| 982 | } |
| 983 | break; |
| 984 | } |
| 985 | case Instruction::IF_GE: { |
| 986 | if (shadow_frame.GetVReg(dec_insn.vA) >= shadow_frame.GetVReg(dec_insn.vB)) { |
| 987 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 988 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vC); |
| 989 | } |
| 990 | break; |
| 991 | } |
| 992 | case Instruction::IF_GT: { |
| 993 | if (shadow_frame.GetVReg(dec_insn.vA) > shadow_frame.GetVReg(dec_insn.vB)) { |
| 994 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 995 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vC); |
| 996 | } |
| 997 | break; |
| 998 | } |
| 999 | case Instruction::IF_LE: { |
| 1000 | if (shadow_frame.GetVReg(dec_insn.vA) <= shadow_frame.GetVReg(dec_insn.vB)) { |
| 1001 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 1002 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vC); |
| 1003 | } |
| 1004 | break; |
| 1005 | } |
| 1006 | case Instruction::IF_EQZ: { |
| 1007 | if (shadow_frame.GetVReg(dec_insn.vA) == 0) { |
| 1008 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 1009 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vB); |
| 1010 | } |
| 1011 | break; |
| 1012 | } |
| 1013 | case Instruction::IF_NEZ: { |
| 1014 | if (shadow_frame.GetVReg(dec_insn.vA) != 0) { |
| 1015 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 1016 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vB); |
| 1017 | } |
| 1018 | break; |
| 1019 | } |
| 1020 | case Instruction::IF_LTZ: { |
| 1021 | if (shadow_frame.GetVReg(dec_insn.vA) < 0) { |
| 1022 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 1023 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vB); |
| 1024 | } |
| 1025 | break; |
| 1026 | } |
| 1027 | case Instruction::IF_GEZ: { |
| 1028 | if (shadow_frame.GetVReg(dec_insn.vA) >= 0) { |
| 1029 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 1030 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vB); |
| 1031 | } |
| 1032 | break; |
| 1033 | } |
| 1034 | case Instruction::IF_GTZ: { |
| 1035 | if (shadow_frame.GetVReg(dec_insn.vA) > 0) { |
| 1036 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 1037 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vB); |
| 1038 | } |
| 1039 | break; |
| 1040 | } |
| 1041 | case Instruction::IF_LEZ: { |
| 1042 | if (shadow_frame.GetVReg(dec_insn.vA) <= 0) { |
| 1043 | uint32_t dex_pc = inst->GetDexPc(insns); |
| 1044 | next_inst = Instruction::At(insns + dex_pc + dec_insn.vB); |
| 1045 | } |
| 1046 | break; |
| 1047 | } |
| 1048 | case Instruction::AGET_BOOLEAN: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1049 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1050 | if (UNLIKELY(a == NULL)) { |
| 1051 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1052 | break; |
| 1053 | } |
| 1054 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1055 | shadow_frame.SetVReg(dec_insn.vA, a->AsBooleanArray()->Get(index)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1056 | break; |
| 1057 | } |
| 1058 | case Instruction::AGET_BYTE: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1059 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1060 | if (UNLIKELY(a == NULL)) { |
| 1061 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1062 | break; |
| 1063 | } |
| 1064 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1065 | shadow_frame.SetVReg(dec_insn.vA, a->AsByteArray()->Get(index)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1066 | break; |
| 1067 | } |
| 1068 | case Instruction::AGET_CHAR: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1069 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1070 | if (UNLIKELY(a == NULL)) { |
| 1071 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1072 | break; |
| 1073 | } |
| 1074 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1075 | shadow_frame.SetVReg(dec_insn.vA, a->AsCharArray()->Get(index)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1076 | break; |
| 1077 | } |
| 1078 | case Instruction::AGET_SHORT: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1079 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1080 | if (UNLIKELY(a == NULL)) { |
| 1081 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1082 | break; |
| 1083 | } |
| 1084 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1085 | shadow_frame.SetVReg(dec_insn.vA, a->AsShortArray()->Get(index)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1086 | break; |
| 1087 | } |
| 1088 | case Instruction::AGET: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1089 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1090 | if (UNLIKELY(a == NULL)) { |
| 1091 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1092 | break; |
| 1093 | } |
| 1094 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1095 | shadow_frame.SetVReg(dec_insn.vA, a->AsIntArray()->Get(index)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1096 | break; |
| 1097 | } |
| 1098 | case Instruction::AGET_WIDE: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1099 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1100 | if (UNLIKELY(a == NULL)) { |
| 1101 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1102 | break; |
| 1103 | } |
| 1104 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1105 | shadow_frame.SetVRegLong(dec_insn.vA, a->AsLongArray()->Get(index)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1106 | break; |
| 1107 | } |
| 1108 | case Instruction::AGET_OBJECT: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1109 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1110 | if (UNLIKELY(a == NULL)) { |
| 1111 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1112 | break; |
| 1113 | } |
| 1114 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1115 | shadow_frame.SetVRegReference(dec_insn.vA, a->AsObjectArray<Object>()->Get(index)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1116 | break; |
| 1117 | } |
| 1118 | case Instruction::APUT_BOOLEAN: { |
| 1119 | uint8_t val = shadow_frame.GetVReg(dec_insn.vA); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1120 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1121 | if (UNLIKELY(a == NULL)) { |
| 1122 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1123 | break; |
| 1124 | } |
| 1125 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1126 | a->AsBooleanArray()->Set(index, val); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1127 | break; |
| 1128 | } |
| 1129 | case Instruction::APUT_BYTE: { |
| 1130 | int8_t val = shadow_frame.GetVReg(dec_insn.vA); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1131 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1132 | if (UNLIKELY(a == NULL)) { |
| 1133 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1134 | break; |
| 1135 | } |
| 1136 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1137 | a->AsByteArray()->Set(index, val); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1138 | break; |
| 1139 | } |
| 1140 | case Instruction::APUT_CHAR: { |
| 1141 | uint16_t val = shadow_frame.GetVReg(dec_insn.vA); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1142 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1143 | if (UNLIKELY(a == NULL)) { |
| 1144 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1145 | break; |
| 1146 | } |
| 1147 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1148 | a->AsCharArray()->Set(index, val); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1149 | break; |
| 1150 | } |
| 1151 | case Instruction::APUT_SHORT: { |
| 1152 | int16_t val = shadow_frame.GetVReg(dec_insn.vA); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1153 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1154 | if (UNLIKELY(a == NULL)) { |
| 1155 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1156 | break; |
| 1157 | } |
| 1158 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1159 | a->AsShortArray()->Set(index, val); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1160 | break; |
| 1161 | } |
| 1162 | case Instruction::APUT: { |
| 1163 | int32_t val = shadow_frame.GetVReg(dec_insn.vA); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1164 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1165 | if (UNLIKELY(a == NULL)) { |
| 1166 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1167 | break; |
| 1168 | } |
| 1169 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1170 | a->AsIntArray()->Set(index, val); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1171 | break; |
| 1172 | } |
| 1173 | case Instruction::APUT_WIDE: { |
| 1174 | int64_t val = shadow_frame.GetVRegLong(dec_insn.vA); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1175 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1176 | if (UNLIKELY(a == NULL)) { |
| 1177 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1178 | break; |
| 1179 | } |
| 1180 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1181 | a->AsLongArray()->Set(index, val); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1182 | break; |
| 1183 | } |
| 1184 | case Instruction::APUT_OBJECT: { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1185 | Object* val = shadow_frame.GetVRegReference(dec_insn.vA); |
| 1186 | Object* a = shadow_frame.GetVRegReference(dec_insn.vB); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1187 | if (UNLIKELY(a == NULL)) { |
| 1188 | ThrowNullPointerExceptionFromDexPC(shadow_frame.GetMethod(), inst->GetDexPc(insns)); |
| 1189 | break; |
| 1190 | } |
| 1191 | int32_t index = shadow_frame.GetVReg(dec_insn.vC); |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1192 | a->AsObjectArray<Object>()->Set(index, val); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1193 | break; |
| 1194 | } |
| 1195 | case Instruction::IGET_BOOLEAN: |
| 1196 | DoFieldGet(self, shadow_frame, dec_insn, InstancePrimitiveRead, Primitive::kPrimBoolean); |
| 1197 | break; |
| 1198 | case Instruction::IGET_BYTE: |
| 1199 | DoFieldGet(self, shadow_frame, dec_insn, InstancePrimitiveRead, Primitive::kPrimByte); |
| 1200 | break; |
| 1201 | case Instruction::IGET_CHAR: |
| 1202 | DoFieldGet(self, shadow_frame, dec_insn, InstancePrimitiveRead, Primitive::kPrimChar); |
| 1203 | break; |
| 1204 | case Instruction::IGET_SHORT: |
| 1205 | DoFieldGet(self, shadow_frame, dec_insn, InstancePrimitiveRead, Primitive::kPrimShort); |
| 1206 | break; |
| 1207 | case Instruction::IGET: |
| 1208 | DoFieldGet(self, shadow_frame, dec_insn, InstancePrimitiveRead, Primitive::kPrimInt); |
| 1209 | break; |
| 1210 | case Instruction::IGET_WIDE: |
| 1211 | DoFieldGet(self, shadow_frame, dec_insn, InstancePrimitiveRead, Primitive::kPrimLong); |
| 1212 | break; |
| 1213 | case Instruction::IGET_OBJECT: |
| 1214 | DoFieldGet(self, shadow_frame, dec_insn, InstanceObjectRead, Primitive::kPrimNot); |
| 1215 | break; |
| 1216 | case Instruction::SGET_BOOLEAN: |
| 1217 | DoFieldGet(self, shadow_frame, dec_insn, StaticPrimitiveRead, Primitive::kPrimBoolean); |
| 1218 | break; |
| 1219 | case Instruction::SGET_BYTE: |
| 1220 | DoFieldGet(self, shadow_frame, dec_insn, StaticPrimitiveRead, Primitive::kPrimByte); |
| 1221 | break; |
| 1222 | case Instruction::SGET_CHAR: |
| 1223 | DoFieldGet(self, shadow_frame, dec_insn, StaticPrimitiveRead, Primitive::kPrimChar); |
| 1224 | break; |
| 1225 | case Instruction::SGET_SHORT: |
| 1226 | DoFieldGet(self, shadow_frame, dec_insn, StaticPrimitiveRead, Primitive::kPrimShort); |
| 1227 | break; |
| 1228 | case Instruction::SGET: |
| 1229 | DoFieldGet(self, shadow_frame, dec_insn, StaticPrimitiveRead, Primitive::kPrimInt); |
| 1230 | break; |
| 1231 | case Instruction::SGET_WIDE: |
| 1232 | DoFieldGet(self, shadow_frame, dec_insn, StaticPrimitiveRead, Primitive::kPrimLong); |
| 1233 | break; |
| 1234 | case Instruction::SGET_OBJECT: |
| 1235 | DoFieldGet(self, shadow_frame, dec_insn, StaticObjectRead, Primitive::kPrimNot); |
| 1236 | break; |
| 1237 | case Instruction::IPUT_BOOLEAN: |
| 1238 | DoFieldPut(self, shadow_frame, dec_insn, InstancePrimitiveWrite, Primitive::kPrimBoolean); |
| 1239 | break; |
| 1240 | case Instruction::IPUT_BYTE: |
| 1241 | DoFieldPut(self, shadow_frame, dec_insn, InstancePrimitiveWrite, Primitive::kPrimByte); |
| 1242 | break; |
| 1243 | case Instruction::IPUT_CHAR: |
| 1244 | DoFieldPut(self, shadow_frame, dec_insn, InstancePrimitiveWrite, Primitive::kPrimChar); |
| 1245 | break; |
| 1246 | case Instruction::IPUT_SHORT: |
| 1247 | DoFieldPut(self, shadow_frame, dec_insn, InstancePrimitiveWrite, Primitive::kPrimShort); |
| 1248 | break; |
| 1249 | case Instruction::IPUT: |
| 1250 | DoFieldPut(self, shadow_frame, dec_insn, InstancePrimitiveWrite, Primitive::kPrimInt); |
| 1251 | break; |
| 1252 | case Instruction::IPUT_WIDE: |
| 1253 | DoFieldPut(self, shadow_frame, dec_insn, InstancePrimitiveWrite, Primitive::kPrimLong); |
| 1254 | break; |
| 1255 | case Instruction::IPUT_OBJECT: |
| 1256 | DoFieldPut(self, shadow_frame, dec_insn, InstanceObjectWrite, Primitive::kPrimNot); |
| 1257 | break; |
| 1258 | case Instruction::SPUT_BOOLEAN: |
| 1259 | DoFieldPut(self, shadow_frame, dec_insn, StaticPrimitiveWrite, Primitive::kPrimBoolean); |
| 1260 | break; |
| 1261 | case Instruction::SPUT_BYTE: |
| 1262 | DoFieldPut(self, shadow_frame, dec_insn, StaticPrimitiveWrite, Primitive::kPrimByte); |
| 1263 | break; |
| 1264 | case Instruction::SPUT_CHAR: |
| 1265 | DoFieldPut(self, shadow_frame, dec_insn, StaticPrimitiveWrite, Primitive::kPrimChar); |
| 1266 | break; |
| 1267 | case Instruction::SPUT_SHORT: |
| 1268 | DoFieldPut(self, shadow_frame, dec_insn, StaticPrimitiveWrite, Primitive::kPrimShort); |
| 1269 | break; |
| 1270 | case Instruction::SPUT: |
| 1271 | DoFieldPut(self, shadow_frame, dec_insn, StaticPrimitiveWrite, Primitive::kPrimInt); |
| 1272 | break; |
| 1273 | case Instruction::SPUT_WIDE: |
| 1274 | DoFieldPut(self, shadow_frame, dec_insn, StaticPrimitiveWrite, Primitive::kPrimLong); |
| 1275 | break; |
| 1276 | case Instruction::SPUT_OBJECT: |
| 1277 | DoFieldPut(self, shadow_frame, dec_insn, StaticObjectWrite, Primitive::kPrimNot); |
| 1278 | break; |
| 1279 | case Instruction::INVOKE_VIRTUAL: |
| 1280 | DoInvoke(self, mh, shadow_frame, dec_insn, kVirtual, false, &result_register); |
| 1281 | break; |
| 1282 | case Instruction::INVOKE_VIRTUAL_RANGE: |
| 1283 | DoInvoke(self, mh, shadow_frame, dec_insn, kVirtual, true, &result_register); |
| 1284 | break; |
| 1285 | case Instruction::INVOKE_SUPER: |
| 1286 | DoInvoke(self, mh, shadow_frame, dec_insn, kSuper, false, &result_register); |
| 1287 | break; |
| 1288 | case Instruction::INVOKE_SUPER_RANGE: |
| 1289 | DoInvoke(self, mh, shadow_frame, dec_insn, kSuper, true, &result_register); |
| 1290 | break; |
| 1291 | case Instruction::INVOKE_DIRECT: |
| 1292 | DoInvoke(self, mh, shadow_frame, dec_insn, kDirect, false, &result_register); |
| 1293 | break; |
| 1294 | case Instruction::INVOKE_DIRECT_RANGE: |
| 1295 | DoInvoke(self, mh, shadow_frame, dec_insn, kDirect, true, &result_register); |
| 1296 | break; |
| 1297 | case Instruction::INVOKE_INTERFACE: |
| 1298 | DoInvoke(self, mh, shadow_frame, dec_insn, kInterface, false, &result_register); |
| 1299 | break; |
| 1300 | case Instruction::INVOKE_INTERFACE_RANGE: |
| 1301 | DoInvoke(self, mh, shadow_frame, dec_insn, kInterface, true, &result_register); |
| 1302 | break; |
| 1303 | case Instruction::INVOKE_STATIC: |
| 1304 | DoInvoke(self, mh, shadow_frame, dec_insn, kStatic, false, &result_register); |
| 1305 | break; |
| 1306 | case Instruction::INVOKE_STATIC_RANGE: |
| 1307 | DoInvoke(self, mh, shadow_frame, dec_insn, kStatic, true, &result_register); |
| 1308 | break; |
| 1309 | case Instruction::NEG_INT: |
| 1310 | shadow_frame.SetVReg(dec_insn.vA, -shadow_frame.GetVReg(dec_insn.vB)); |
| 1311 | break; |
| 1312 | case Instruction::NOT_INT: |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1313 | shadow_frame.SetVReg(dec_insn.vA, ~shadow_frame.GetVReg(dec_insn.vB)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1314 | break; |
| 1315 | case Instruction::NEG_LONG: |
| 1316 | shadow_frame.SetVRegLong(dec_insn.vA, -shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1317 | break; |
| 1318 | case Instruction::NOT_LONG: |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1319 | shadow_frame.SetVRegLong(dec_insn.vA, ~shadow_frame.GetVRegLong(dec_insn.vB)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1320 | break; |
| 1321 | case Instruction::NEG_FLOAT: |
| 1322 | shadow_frame.SetVRegFloat(dec_insn.vA, -shadow_frame.GetVRegFloat(dec_insn.vB)); |
| 1323 | break; |
| 1324 | case Instruction::NEG_DOUBLE: |
| 1325 | shadow_frame.SetVRegDouble(dec_insn.vA, -shadow_frame.GetVRegDouble(dec_insn.vB)); |
| 1326 | break; |
| 1327 | case Instruction::INT_TO_LONG: |
| 1328 | shadow_frame.SetVRegLong(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB)); |
| 1329 | break; |
| 1330 | case Instruction::INT_TO_FLOAT: |
| 1331 | shadow_frame.SetVRegFloat(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB)); |
| 1332 | break; |
| 1333 | case Instruction::INT_TO_DOUBLE: |
| 1334 | shadow_frame.SetVRegDouble(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB)); |
| 1335 | break; |
| 1336 | case Instruction::LONG_TO_INT: |
| 1337 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1338 | break; |
| 1339 | case Instruction::LONG_TO_FLOAT: |
| 1340 | shadow_frame.SetVRegFloat(dec_insn.vA, shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1341 | break; |
| 1342 | case Instruction::LONG_TO_DOUBLE: |
| 1343 | shadow_frame.SetVRegDouble(dec_insn.vA, shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1344 | break; |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 1345 | case Instruction::FLOAT_TO_INT: { |
| 1346 | float val = shadow_frame.GetVRegFloat(dec_insn.vB); |
| 1347 | if (val != val) { |
| 1348 | shadow_frame.SetVReg(dec_insn.vA, 0); |
| 1349 | } else if (val > static_cast<float>(kMaxInt)) { |
| 1350 | shadow_frame.SetVReg(dec_insn.vA, kMaxInt); |
| 1351 | } else if (val < static_cast<float>(kMinInt)) { |
| 1352 | shadow_frame.SetVReg(dec_insn.vA, kMinInt); |
| 1353 | } else { |
| 1354 | shadow_frame.SetVReg(dec_insn.vA, val); |
| 1355 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1356 | break; |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 1357 | } |
| 1358 | case Instruction::FLOAT_TO_LONG: { |
| 1359 | float val = shadow_frame.GetVRegFloat(dec_insn.vB); |
| 1360 | if (val != val) { |
| 1361 | shadow_frame.SetVRegLong(dec_insn.vA, 0); |
| 1362 | } else if (val > static_cast<float>(kMaxLong)) { |
| 1363 | shadow_frame.SetVRegLong(dec_insn.vA, kMaxLong); |
| 1364 | } else if (val < static_cast<float>(kMinLong)) { |
| 1365 | shadow_frame.SetVRegLong(dec_insn.vA, kMinLong); |
| 1366 | } else { |
| 1367 | shadow_frame.SetVRegLong(dec_insn.vA, val); |
| 1368 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1369 | break; |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 1370 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1371 | case Instruction::FLOAT_TO_DOUBLE: |
| 1372 | shadow_frame.SetVRegDouble(dec_insn.vA, shadow_frame.GetVRegFloat(dec_insn.vB)); |
| 1373 | break; |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 1374 | case Instruction::DOUBLE_TO_INT: { |
| 1375 | double val = shadow_frame.GetVRegDouble(dec_insn.vB); |
| 1376 | if (val != val) { |
| 1377 | shadow_frame.SetVReg(dec_insn.vA, 0); |
| 1378 | } else if (val > static_cast<double>(kMaxInt)) { |
| 1379 | shadow_frame.SetVReg(dec_insn.vA, kMaxInt); |
| 1380 | } else if (val < static_cast<double>(kMinInt)) { |
| 1381 | shadow_frame.SetVReg(dec_insn.vA, kMinInt); |
| 1382 | } else { |
| 1383 | shadow_frame.SetVReg(dec_insn.vA, val); |
| 1384 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1385 | break; |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 1386 | } |
| 1387 | case Instruction::DOUBLE_TO_LONG: { |
| 1388 | double val = shadow_frame.GetVRegDouble(dec_insn.vB); |
| 1389 | if (val != val) { |
| 1390 | shadow_frame.SetVRegLong(dec_insn.vA, 0); |
| 1391 | } else if (val > static_cast<double>(kMaxLong)) { |
| 1392 | shadow_frame.SetVRegLong(dec_insn.vA, kMaxLong); |
| 1393 | } else if (val < static_cast<double>(kMinLong)) { |
| 1394 | shadow_frame.SetVRegLong(dec_insn.vA, kMinLong); |
| 1395 | } else { |
| 1396 | shadow_frame.SetVRegLong(dec_insn.vA, val); |
| 1397 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1398 | break; |
jeffhao | 87a6edd | 2012-11-20 18:05:18 -0800 | [diff] [blame] | 1399 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1400 | case Instruction::DOUBLE_TO_FLOAT: |
| 1401 | shadow_frame.SetVRegFloat(dec_insn.vA, shadow_frame.GetVRegDouble(dec_insn.vB)); |
| 1402 | break; |
| 1403 | case Instruction::INT_TO_BYTE: |
| 1404 | shadow_frame.SetVReg(dec_insn.vA, static_cast<int8_t>(shadow_frame.GetVReg(dec_insn.vB))); |
| 1405 | break; |
| 1406 | case Instruction::INT_TO_CHAR: |
| 1407 | shadow_frame.SetVReg(dec_insn.vA, static_cast<uint16_t>(shadow_frame.GetVReg(dec_insn.vB))); |
| 1408 | break; |
| 1409 | case Instruction::INT_TO_SHORT: |
| 1410 | shadow_frame.SetVReg(dec_insn.vA, static_cast<int16_t>(shadow_frame.GetVReg(dec_insn.vB))); |
| 1411 | break; |
| 1412 | case Instruction::ADD_INT: |
| 1413 | shadow_frame.SetVReg(dec_insn.vA, |
| 1414 | shadow_frame.GetVReg(dec_insn.vB) + shadow_frame.GetVReg(dec_insn.vC)); |
| 1415 | break; |
| 1416 | case Instruction::SUB_INT: |
| 1417 | shadow_frame.SetVReg(dec_insn.vA, |
| 1418 | shadow_frame.GetVReg(dec_insn.vB) - shadow_frame.GetVReg(dec_insn.vC)); |
| 1419 | break; |
| 1420 | case Instruction::MUL_INT: |
| 1421 | shadow_frame.SetVReg(dec_insn.vA, |
| 1422 | shadow_frame.GetVReg(dec_insn.vB) * shadow_frame.GetVReg(dec_insn.vC)); |
| 1423 | break; |
| 1424 | case Instruction::REM_INT: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1425 | DoIntRemainder(self, shadow_frame, dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB), |
| 1426 | shadow_frame.GetVReg(dec_insn.vC)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1427 | break; |
| 1428 | case Instruction::DIV_INT: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1429 | DoIntDivide(self, shadow_frame, dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB), |
| 1430 | shadow_frame.GetVReg(dec_insn.vC)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1431 | break; |
| 1432 | case Instruction::SHL_INT: |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1433 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB) << |
| 1434 | (shadow_frame.GetVReg(dec_insn.vC) & 0x1f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1435 | break; |
| 1436 | case Instruction::SHR_INT: |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1437 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB) >> |
| 1438 | (shadow_frame.GetVReg(dec_insn.vC) & 0x1f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1439 | break; |
| 1440 | case Instruction::USHR_INT: |
| 1441 | shadow_frame.SetVReg(dec_insn.vA, |
| 1442 | static_cast<uint32_t>(shadow_frame.GetVReg(dec_insn.vB)) >> |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1443 | (shadow_frame.GetVReg(dec_insn.vC) & 0x1f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1444 | break; |
| 1445 | case Instruction::AND_INT: |
| 1446 | shadow_frame.SetVReg(dec_insn.vA, |
| 1447 | shadow_frame.GetVReg(dec_insn.vB) & shadow_frame.GetVReg(dec_insn.vC)); |
| 1448 | break; |
| 1449 | case Instruction::OR_INT: |
| 1450 | shadow_frame.SetVReg(dec_insn.vA, |
| 1451 | shadow_frame.GetVReg(dec_insn.vB) | shadow_frame.GetVReg(dec_insn.vC)); |
| 1452 | break; |
| 1453 | case Instruction::XOR_INT: |
| 1454 | shadow_frame.SetVReg(dec_insn.vA, |
| 1455 | shadow_frame.GetVReg(dec_insn.vB) ^ shadow_frame.GetVReg(dec_insn.vC)); |
| 1456 | break; |
| 1457 | case Instruction::ADD_LONG: |
| 1458 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1459 | shadow_frame.GetVRegLong(dec_insn.vB) + |
| 1460 | shadow_frame.GetVRegLong(dec_insn.vC)); |
| 1461 | break; |
| 1462 | case Instruction::SUB_LONG: |
| 1463 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1464 | shadow_frame.GetVRegLong(dec_insn.vB) - |
| 1465 | shadow_frame.GetVRegLong(dec_insn.vC)); |
| 1466 | break; |
| 1467 | case Instruction::MUL_LONG: |
| 1468 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1469 | shadow_frame.GetVRegLong(dec_insn.vB) * |
| 1470 | shadow_frame.GetVRegLong(dec_insn.vC)); |
| 1471 | break; |
| 1472 | case Instruction::DIV_LONG: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1473 | DoLongDivide(self, shadow_frame, dec_insn.vA, shadow_frame.GetVRegLong(dec_insn.vB), |
| 1474 | shadow_frame.GetVRegLong(dec_insn.vC)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1475 | break; |
| 1476 | case Instruction::REM_LONG: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1477 | DoLongRemainder(self, shadow_frame, dec_insn.vA, shadow_frame.GetVRegLong(dec_insn.vB), |
| 1478 | shadow_frame.GetVRegLong(dec_insn.vC)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1479 | break; |
| 1480 | case Instruction::AND_LONG: |
| 1481 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1482 | shadow_frame.GetVRegLong(dec_insn.vB) & |
| 1483 | shadow_frame.GetVRegLong(dec_insn.vC)); |
| 1484 | break; |
| 1485 | case Instruction::OR_LONG: |
| 1486 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1487 | shadow_frame.GetVRegLong(dec_insn.vB) | |
| 1488 | shadow_frame.GetVRegLong(dec_insn.vC)); |
| 1489 | break; |
| 1490 | case Instruction::XOR_LONG: |
| 1491 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1492 | shadow_frame.GetVRegLong(dec_insn.vB) ^ |
| 1493 | shadow_frame.GetVRegLong(dec_insn.vC)); |
| 1494 | break; |
| 1495 | case Instruction::SHL_LONG: |
| 1496 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1497 | shadow_frame.GetVRegLong(dec_insn.vB) << |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1498 | (shadow_frame.GetVReg(dec_insn.vC) & 0x3f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1499 | break; |
| 1500 | case Instruction::SHR_LONG: |
| 1501 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1502 | shadow_frame.GetVRegLong(dec_insn.vB) >> |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1503 | (shadow_frame.GetVReg(dec_insn.vC) & 0x3f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1504 | break; |
| 1505 | case Instruction::USHR_LONG: |
| 1506 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1507 | static_cast<uint64_t>(shadow_frame.GetVRegLong(dec_insn.vB)) >> |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1508 | (shadow_frame.GetVReg(dec_insn.vC) & 0x3f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1509 | break; |
| 1510 | case Instruction::ADD_FLOAT: |
| 1511 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1512 | shadow_frame.GetVRegFloat(dec_insn.vB) + |
| 1513 | shadow_frame.GetVRegFloat(dec_insn.vC)); |
| 1514 | break; |
| 1515 | case Instruction::SUB_FLOAT: |
| 1516 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1517 | shadow_frame.GetVRegFloat(dec_insn.vB) - |
| 1518 | shadow_frame.GetVRegFloat(dec_insn.vC)); |
| 1519 | break; |
| 1520 | case Instruction::MUL_FLOAT: |
| 1521 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1522 | shadow_frame.GetVRegFloat(dec_insn.vB) * |
| 1523 | shadow_frame.GetVRegFloat(dec_insn.vC)); |
| 1524 | break; |
| 1525 | case Instruction::DIV_FLOAT: |
| 1526 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1527 | shadow_frame.GetVRegFloat(dec_insn.vB) / |
| 1528 | shadow_frame.GetVRegFloat(dec_insn.vC)); |
| 1529 | break; |
| 1530 | case Instruction::REM_FLOAT: |
| 1531 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1532 | fmodf(shadow_frame.GetVRegFloat(dec_insn.vB), |
| 1533 | shadow_frame.GetVRegFloat(dec_insn.vC))); |
| 1534 | break; |
| 1535 | case Instruction::ADD_DOUBLE: |
| 1536 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1537 | shadow_frame.GetVRegDouble(dec_insn.vB) + |
| 1538 | shadow_frame.GetVRegDouble(dec_insn.vC)); |
| 1539 | break; |
| 1540 | case Instruction::SUB_DOUBLE: |
| 1541 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1542 | shadow_frame.GetVRegDouble(dec_insn.vB) - |
| 1543 | shadow_frame.GetVRegDouble(dec_insn.vC)); |
| 1544 | break; |
| 1545 | case Instruction::MUL_DOUBLE: |
| 1546 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1547 | shadow_frame.GetVRegDouble(dec_insn.vB) * |
| 1548 | shadow_frame.GetVRegDouble(dec_insn.vC)); |
| 1549 | break; |
| 1550 | case Instruction::DIV_DOUBLE: |
| 1551 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1552 | shadow_frame.GetVRegDouble(dec_insn.vB) / |
| 1553 | shadow_frame.GetVRegDouble(dec_insn.vC)); |
| 1554 | break; |
| 1555 | case Instruction::REM_DOUBLE: |
| 1556 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1557 | fmod(shadow_frame.GetVRegDouble(dec_insn.vB), |
| 1558 | shadow_frame.GetVRegDouble(dec_insn.vC))); |
| 1559 | break; |
| 1560 | case Instruction::ADD_INT_2ADDR: |
| 1561 | shadow_frame.SetVReg(dec_insn.vA, |
| 1562 | shadow_frame.GetVReg(dec_insn.vA) + shadow_frame.GetVReg(dec_insn.vB)); |
| 1563 | break; |
| 1564 | case Instruction::SUB_INT_2ADDR: |
| 1565 | shadow_frame.SetVReg(dec_insn.vA, |
| 1566 | shadow_frame.GetVReg(dec_insn.vA) - shadow_frame.GetVReg(dec_insn.vB)); |
| 1567 | break; |
| 1568 | case Instruction::MUL_INT_2ADDR: |
| 1569 | shadow_frame.SetVReg(dec_insn.vA, |
| 1570 | shadow_frame.GetVReg(dec_insn.vA) * shadow_frame.GetVReg(dec_insn.vB)); |
| 1571 | break; |
| 1572 | case Instruction::REM_INT_2ADDR: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1573 | DoIntRemainder(self, shadow_frame, dec_insn.vA, shadow_frame.GetVReg(dec_insn.vA), |
| 1574 | shadow_frame.GetVReg(dec_insn.vB)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1575 | break; |
| 1576 | case Instruction::SHL_INT_2ADDR: |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1577 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vA) << |
| 1578 | (shadow_frame.GetVReg(dec_insn.vB) & 0x1f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1579 | break; |
| 1580 | case Instruction::SHR_INT_2ADDR: |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1581 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vA) >> |
| 1582 | (shadow_frame.GetVReg(dec_insn.vB) & 0x1f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1583 | break; |
| 1584 | case Instruction::USHR_INT_2ADDR: |
| 1585 | shadow_frame.SetVReg(dec_insn.vA, |
| 1586 | static_cast<uint32_t>(shadow_frame.GetVReg(dec_insn.vA)) >> |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1587 | (shadow_frame.GetVReg(dec_insn.vB) & 0x1f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1588 | break; |
| 1589 | case Instruction::AND_INT_2ADDR: |
| 1590 | shadow_frame.SetVReg(dec_insn.vA, |
| 1591 | shadow_frame.GetVReg(dec_insn.vA) & shadow_frame.GetVReg(dec_insn.vB)); |
| 1592 | break; |
| 1593 | case Instruction::OR_INT_2ADDR: |
| 1594 | shadow_frame.SetVReg(dec_insn.vA, |
| 1595 | shadow_frame.GetVReg(dec_insn.vA) | shadow_frame.GetVReg(dec_insn.vB)); |
| 1596 | break; |
| 1597 | case Instruction::XOR_INT_2ADDR: |
| 1598 | shadow_frame.SetVReg(dec_insn.vA, |
| 1599 | shadow_frame.GetVReg(dec_insn.vA) ^ shadow_frame.GetVReg(dec_insn.vB)); |
| 1600 | break; |
| 1601 | case Instruction::DIV_INT_2ADDR: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1602 | DoIntDivide(self, shadow_frame, dec_insn.vA, shadow_frame.GetVReg(dec_insn.vA), |
| 1603 | shadow_frame.GetVReg(dec_insn.vB)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1604 | break; |
| 1605 | case Instruction::ADD_LONG_2ADDR: |
| 1606 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1607 | shadow_frame.GetVRegLong(dec_insn.vA) + |
| 1608 | shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1609 | break; |
| 1610 | case Instruction::SUB_LONG_2ADDR: |
| 1611 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1612 | shadow_frame.GetVRegLong(dec_insn.vA) - |
| 1613 | shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1614 | break; |
| 1615 | case Instruction::MUL_LONG_2ADDR: |
| 1616 | shadow_frame.SetVRegLong(dec_insn.vA, |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 1617 | shadow_frame.GetVRegLong(dec_insn.vA) * |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1618 | shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1619 | break; |
| 1620 | case Instruction::DIV_LONG_2ADDR: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1621 | DoLongDivide(self, shadow_frame, dec_insn.vA, shadow_frame.GetVRegLong(dec_insn.vA), |
| 1622 | shadow_frame.GetVRegLong(dec_insn.vB)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1623 | break; |
| 1624 | case Instruction::REM_LONG_2ADDR: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1625 | DoLongRemainder(self, shadow_frame, dec_insn.vA, shadow_frame.GetVRegLong(dec_insn.vA), |
| 1626 | shadow_frame.GetVRegLong(dec_insn.vB)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1627 | break; |
| 1628 | case Instruction::AND_LONG_2ADDR: |
| 1629 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1630 | shadow_frame.GetVRegLong(dec_insn.vA) & |
| 1631 | shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1632 | break; |
| 1633 | case Instruction::OR_LONG_2ADDR: |
| 1634 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1635 | shadow_frame.GetVRegLong(dec_insn.vA) | |
| 1636 | shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1637 | break; |
| 1638 | case Instruction::XOR_LONG_2ADDR: |
| 1639 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1640 | shadow_frame.GetVRegLong(dec_insn.vA) ^ |
| 1641 | shadow_frame.GetVRegLong(dec_insn.vB)); |
| 1642 | break; |
| 1643 | case Instruction::SHL_LONG_2ADDR: |
| 1644 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1645 | shadow_frame.GetVRegLong(dec_insn.vA) << |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1646 | (shadow_frame.GetVReg(dec_insn.vB) & 0x3f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1647 | break; |
| 1648 | case Instruction::SHR_LONG_2ADDR: |
| 1649 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1650 | shadow_frame.GetVRegLong(dec_insn.vA) >> |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1651 | (shadow_frame.GetVReg(dec_insn.vB) & 0x3f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1652 | break; |
| 1653 | case Instruction::USHR_LONG_2ADDR: |
| 1654 | shadow_frame.SetVRegLong(dec_insn.vA, |
| 1655 | static_cast<uint64_t>(shadow_frame.GetVRegLong(dec_insn.vA)) >> |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1656 | (shadow_frame.GetVReg(dec_insn.vB) & 0x3f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1657 | break; |
| 1658 | case Instruction::ADD_FLOAT_2ADDR: |
| 1659 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1660 | shadow_frame.GetVRegFloat(dec_insn.vA) + |
| 1661 | shadow_frame.GetVRegFloat(dec_insn.vB)); |
| 1662 | break; |
| 1663 | case Instruction::SUB_FLOAT_2ADDR: |
| 1664 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1665 | shadow_frame.GetVRegFloat(dec_insn.vA) - |
| 1666 | shadow_frame.GetVRegFloat(dec_insn.vB)); |
| 1667 | break; |
| 1668 | case Instruction::MUL_FLOAT_2ADDR: |
| 1669 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1670 | shadow_frame.GetVRegFloat(dec_insn.vA) * |
| 1671 | shadow_frame.GetVRegFloat(dec_insn.vB)); |
| 1672 | break; |
| 1673 | case Instruction::DIV_FLOAT_2ADDR: |
| 1674 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1675 | shadow_frame.GetVRegFloat(dec_insn.vA) / |
| 1676 | shadow_frame.GetVRegFloat(dec_insn.vB)); |
| 1677 | break; |
| 1678 | case Instruction::REM_FLOAT_2ADDR: |
| 1679 | shadow_frame.SetVRegFloat(dec_insn.vA, |
| 1680 | fmodf(shadow_frame.GetVRegFloat(dec_insn.vA), |
| 1681 | shadow_frame.GetVRegFloat(dec_insn.vB))); |
| 1682 | break; |
| 1683 | case Instruction::ADD_DOUBLE_2ADDR: |
| 1684 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1685 | shadow_frame.GetVRegDouble(dec_insn.vA) + |
| 1686 | shadow_frame.GetVRegDouble(dec_insn.vB)); |
| 1687 | break; |
| 1688 | case Instruction::SUB_DOUBLE_2ADDR: |
| 1689 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1690 | shadow_frame.GetVRegDouble(dec_insn.vA) - |
| 1691 | shadow_frame.GetVRegDouble(dec_insn.vB)); |
| 1692 | break; |
| 1693 | case Instruction::MUL_DOUBLE_2ADDR: |
| 1694 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1695 | shadow_frame.GetVRegDouble(dec_insn.vA) * |
| 1696 | shadow_frame.GetVRegDouble(dec_insn.vB)); |
| 1697 | break; |
| 1698 | case Instruction::DIV_DOUBLE_2ADDR: |
| 1699 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1700 | shadow_frame.GetVRegDouble(dec_insn.vA) / |
| 1701 | shadow_frame.GetVRegDouble(dec_insn.vB)); |
| 1702 | break; |
| 1703 | case Instruction::REM_DOUBLE_2ADDR: |
| 1704 | shadow_frame.SetVRegDouble(dec_insn.vA, |
| 1705 | fmod(shadow_frame.GetVRegDouble(dec_insn.vA), |
| 1706 | shadow_frame.GetVRegDouble(dec_insn.vB))); |
| 1707 | break; |
| 1708 | case Instruction::ADD_INT_LIT16: |
| 1709 | case Instruction::ADD_INT_LIT8: |
| 1710 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB) + dec_insn.vC); |
| 1711 | break; |
| 1712 | case Instruction::RSUB_INT: |
| 1713 | case Instruction::RSUB_INT_LIT8: |
| 1714 | shadow_frame.SetVReg(dec_insn.vA, dec_insn.vC - shadow_frame.GetVReg(dec_insn.vB)); |
| 1715 | break; |
| 1716 | case Instruction::MUL_INT_LIT16: |
| 1717 | case Instruction::MUL_INT_LIT8: |
| 1718 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB) * dec_insn.vC); |
| 1719 | break; |
| 1720 | case Instruction::DIV_INT_LIT16: |
| 1721 | case Instruction::DIV_INT_LIT8: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1722 | DoIntDivide(self, shadow_frame, dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB), |
| 1723 | dec_insn.vC); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1724 | break; |
| 1725 | case Instruction::REM_INT_LIT16: |
| 1726 | case Instruction::REM_INT_LIT8: |
jeffhao | d91398c | 2012-11-20 17:17:33 -0800 | [diff] [blame] | 1727 | DoIntRemainder(self, shadow_frame, dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB), |
| 1728 | dec_insn.vC); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1729 | break; |
| 1730 | case Instruction::AND_INT_LIT16: |
| 1731 | case Instruction::AND_INT_LIT8: |
| 1732 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB) & dec_insn.vC); |
| 1733 | break; |
| 1734 | case Instruction::OR_INT_LIT16: |
| 1735 | case Instruction::OR_INT_LIT8: |
| 1736 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB) | dec_insn.vC); |
| 1737 | break; |
| 1738 | case Instruction::XOR_INT_LIT16: |
| 1739 | case Instruction::XOR_INT_LIT8: |
| 1740 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB) ^ dec_insn.vC); |
| 1741 | break; |
| 1742 | case Instruction::SHL_INT_LIT8: |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1743 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB) << |
| 1744 | (dec_insn.vC & 0x1f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1745 | break; |
| 1746 | case Instruction::SHR_INT_LIT8: |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1747 | shadow_frame.SetVReg(dec_insn.vA, shadow_frame.GetVReg(dec_insn.vB) >> |
| 1748 | (dec_insn.vC & 0x1f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1749 | break; |
| 1750 | case Instruction::USHR_INT_LIT8: |
| 1751 | shadow_frame.SetVReg(dec_insn.vA, |
| 1752 | static_cast<uint32_t>(shadow_frame.GetVReg(dec_insn.vB)) >> |
jeffhao | 42b4dc4 | 2012-12-10 10:25:43 -0800 | [diff] [blame] | 1753 | (dec_insn.vC & 0x1f)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1754 | break; |
| 1755 | default: |
| 1756 | LOG(FATAL) << "Unexpected instruction: " << inst->DumpString(&mh.GetDexFile()); |
| 1757 | break; |
| 1758 | } |
| 1759 | if (UNLIKELY(self->IsExceptionPending())) { |
jeffhao | 9b5aa6f | 2012-12-18 11:47:11 -0800 | [diff] [blame] | 1760 | if (throw_frame_id_ == 0) { |
| 1761 | throw_method_ = shadow_frame.GetMethod(); |
| 1762 | throw_dex_pc_ = dex_pc; |
| 1763 | } |
| 1764 | throw_frame_id_++; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1765 | uint32_t found_dex_pc = |
| 1766 | shadow_frame.GetMethod()->FindCatchBlock(self->GetException()->GetClass(), |
| 1767 | inst->GetDexPc(insns)); |
| 1768 | if (found_dex_pc == DexFile::kDexNoIndex) { |
| 1769 | JValue result; |
| 1770 | result.SetJ(0); |
| 1771 | return result; // Handler in caller. |
| 1772 | } else { |
jeffhao | 9b5aa6f | 2012-12-18 11:47:11 -0800 | [diff] [blame] | 1773 | Dbg::PostException(self, throw_frame_id_, throw_method_, throw_dex_pc_, |
| 1774 | shadow_frame.GetMethod(), found_dex_pc, self->GetException()); |
| 1775 | throw_frame_id_ = 0; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1776 | next_inst = Instruction::At(insns + found_dex_pc); |
| 1777 | } |
| 1778 | } |
| 1779 | inst = next_inst; |
| 1780 | } |
| 1781 | } |
| 1782 | |
| 1783 | void EnterInterpreterFromInvoke(Thread* self, AbstractMethod* method, Object* receiver, |
| 1784 | JValue* args, JValue* result) { |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 1785 | DCHECK_EQ(self, Thread::Current()); |
jeffhao | d752132 | 2012-11-21 15:38:24 -0800 | [diff] [blame] | 1786 | if (__builtin_frame_address(0) < self->GetStackEnd()) { |
| 1787 | ThrowStackOverflowError(self); |
| 1788 | return; |
| 1789 | } |
| 1790 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1791 | MethodHelper mh(method); |
| 1792 | const DexFile::CodeItem* code_item = mh.GetCodeItem(); |
| 1793 | uint16_t num_regs; |
| 1794 | uint16_t num_ins; |
| 1795 | if (code_item != NULL) { |
| 1796 | num_regs = code_item->registers_size_; |
| 1797 | num_ins = code_item->ins_size_; |
jeffhao | 0a9bb73 | 2012-11-26 12:28:49 -0800 | [diff] [blame] | 1798 | } else if (method->IsAbstract()) { |
| 1799 | self->ThrowNewExceptionF("Ljava/lang/AbstractMethodError;", "abstract method \"%s\"", |
| 1800 | PrettyMethod(method).c_str()); |
| 1801 | return; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1802 | } else { |
| 1803 | DCHECK(method->IsNative()); |
| 1804 | num_regs = num_ins = AbstractMethod::NumArgRegisters(mh.GetShorty()); |
| 1805 | if (!method->IsStatic()) { |
| 1806 | num_regs++; |
| 1807 | num_ins++; |
| 1808 | } |
| 1809 | } |
| 1810 | // Set up shadow frame with matching number of reference slots to vregs. |
| 1811 | ShadowFrame* last_shadow_frame = self->GetManagedStack()->GetTopShadowFrame(); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1812 | UniquePtr<ShadowFrame> shadow_frame(ShadowFrame::Create(num_regs, |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1813 | (last_shadow_frame == NULL) ? NULL : last_shadow_frame->GetLink(), |
| 1814 | method, 0)); |
| 1815 | self->PushShadowFrame(shadow_frame.get()); |
| 1816 | size_t cur_reg = num_regs - num_ins; |
| 1817 | if (!method->IsStatic()) { |
| 1818 | CHECK(receiver != NULL); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1819 | shadow_frame->SetVRegReference(cur_reg, receiver); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1820 | ++cur_reg; |
| 1821 | } else if (!method->GetDeclaringClass()->IsInitializing()) { |
jeffhao | 94d6df4 | 2012-11-26 16:02:12 -0800 | [diff] [blame] | 1822 | if (!Runtime::Current()->GetClassLinker()->EnsureInitialized(method->GetDeclaringClass(), |
| 1823 | true, true)) { |
| 1824 | DCHECK(Thread::Current()->IsExceptionPending()); |
| 1825 | return; |
| 1826 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1827 | CHECK(method->GetDeclaringClass()->IsInitializing()); |
| 1828 | } |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 1829 | const char* shorty = mh.GetShorty(); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1830 | size_t arg_pos = 0; |
| 1831 | for (; cur_reg < num_regs; ++cur_reg, ++arg_pos) { |
| 1832 | DCHECK_LT(arg_pos + 1, mh.GetShortyLength()); |
| 1833 | switch (shorty[arg_pos + 1]) { |
| 1834 | case 'L': { |
| 1835 | Object* o = args[arg_pos].GetL(); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 1836 | shadow_frame->SetVRegReference(cur_reg, o); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1837 | break; |
| 1838 | } |
| 1839 | case 'J': case 'D': |
| 1840 | shadow_frame->SetVRegLong(cur_reg, args[arg_pos].GetJ()); |
| 1841 | cur_reg++; |
| 1842 | break; |
| 1843 | default: |
| 1844 | shadow_frame->SetVReg(cur_reg, args[arg_pos].GetI()); |
| 1845 | break; |
| 1846 | } |
| 1847 | } |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 1848 | if (LIKELY(!method->IsNative())) { |
Ian Rogers | 306057f | 2012-11-26 12:45:53 -0800 | [diff] [blame] | 1849 | JValue r = Execute(self, mh, code_item, *shadow_frame.get(), JValue()); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1850 | if (result != NULL) { |
| 1851 | *result = r; |
| 1852 | } |
| 1853 | } else { |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 1854 | // We don't expect to be asked to interpret native code (which is entered via a JNI compiler |
| 1855 | // generated stub) except during testing and image writing. |
| 1856 | if (!Runtime::Current()->IsStarted()) { |
| 1857 | UnstartedRuntimeJni(self, method, receiver, args, result); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1858 | } else { |
Ian Rogers | 64b6d14 | 2012-10-29 16:34:15 -0700 | [diff] [blame] | 1859 | InterpreterJni(self, method, shorty, receiver, args, result); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1860 | } |
| 1861 | } |
| 1862 | self->PopShadowFrame(); |
| 1863 | } |
| 1864 | |
Ian Rogers | 306057f | 2012-11-26 12:45:53 -0800 | [diff] [blame] | 1865 | JValue EnterInterpreterFromDeoptimize(Thread* self, ShadowFrame& shadow_frame, JValue ret_val) |
| 1866 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
| 1867 | MethodHelper mh(shadow_frame.GetMethod()); |
| 1868 | const DexFile::CodeItem* code_item = mh.GetCodeItem(); |
| 1869 | return Execute(self, mh, code_item, shadow_frame, ret_val); |
| 1870 | } |
| 1871 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 1872 | } // namespace interpreter |
| 1873 | } // namespace art |