blob: 7e685e87e0ece334cdbd2929e37b294f67002f64 [file] [log] [blame]
Ian Rogers2fa6b2e2012-10-17 00:10:17 -07001/*
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
Sebastien Hertz8ece0502013-08-07 11:26:41 +020017#include "interpreter_common.h"
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070018
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +010019#include <limits>
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080020
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070021#include "mirror/string-inl.h"
22
Ian Rogers2fa6b2e2012-10-17 00:10:17 -070023namespace art {
24namespace interpreter {
25
Ian Rogers64b6d142012-10-29 16:34:15 -070026// Hand select a number of methods to be run in a not yet started runtime without using JNI.
Brian Carlstromea46f952013-07-30 01:26:50 -070027static void UnstartedRuntimeJni(Thread* self, ArtMethod* method,
Jeff Hao5d917302013-02-27 17:57:33 -080028 Object* receiver, uint32_t* args, JValue* result)
Ian Rogers64b6d142012-10-29 16:34:15 -070029 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
30 std::string name(PrettyMethod(method));
Ian Rogersa4e74132014-05-06 01:14:54 -070031 if (name == "java.lang.Object dalvik.system.VMRuntime.newUnpaddedArray(java.lang.Class, int)") {
32 int32_t length = args[1];
33 DCHECK_GE(length, 0);
34 mirror::Class* element_class = reinterpret_cast<Object*>(args[0])->AsClass();
35 Runtime* runtime = Runtime::Current();
Mathieu Chartierb74cd292014-05-29 14:31:33 -070036 mirror::Class* array_class = runtime->GetClassLinker()->FindArrayClass(self, &element_class);
Ian Rogersa4e74132014-05-06 01:14:54 -070037 DCHECK(array_class != nullptr);
38 gc::AllocatorType allocator = runtime->GetHeap()->GetCurrentAllocator();
39 result->SetL(mirror::Array::Alloc<true>(self, array_class, length,
40 array_class->GetComponentSize(), allocator, true));
41 } else if (name == "java.lang.ClassLoader dalvik.system.VMStack.getCallingClassLoader()") {
Ian Rogers64b6d142012-10-29 16:34:15 -070042 result->SetL(NULL);
43 } else if (name == "java.lang.Class dalvik.system.VMStack.getStackClass2()") {
Ian Rogers7a22fa62013-01-23 12:16:16 -080044 NthCallerVisitor visitor(self, 3);
Ian Rogers64b6d142012-10-29 16:34:15 -070045 visitor.WalkStack();
46 result->SetL(visitor.caller->GetDeclaringClass());
47 } else if (name == "double java.lang.Math.log(double)") {
Jeff Hao5d917302013-02-27 17:57:33 -080048 JValue value;
49 value.SetJ((static_cast<uint64_t>(args[1]) << 32) | args[0]);
50 result->SetD(log(value.GetD()));
Ian Rogers64b6d142012-10-29 16:34:15 -070051 } else if (name == "java.lang.String java.lang.Class.getNameNative()") {
Mathieu Chartierf8322842014-05-16 10:59:25 -070052 StackHandleScope<1> hs(self);
53 result->SetL(mirror::Class::ComputeName(hs.NewHandle(receiver->AsClass())));
Ian Rogers64b6d142012-10-29 16:34:15 -070054 } else if (name == "int java.lang.Float.floatToRawIntBits(float)") {
Jeff Hao5d917302013-02-27 17:57:33 -080055 result->SetI(args[0]);
Ian Rogers64b6d142012-10-29 16:34:15 -070056 } else if (name == "float java.lang.Float.intBitsToFloat(int)") {
Jeff Hao5d917302013-02-27 17:57:33 -080057 result->SetI(args[0]);
Ian Rogers64b6d142012-10-29 16:34:15 -070058 } else if (name == "double java.lang.Math.exp(double)") {
Jeff Hao5d917302013-02-27 17:57:33 -080059 JValue value;
60 value.SetJ((static_cast<uint64_t>(args[1]) << 32) | args[0]);
61 result->SetD(exp(value.GetD()));
Ian Rogers64b6d142012-10-29 16:34:15 -070062 } else if (name == "java.lang.Object java.lang.Object.internalClone()") {
63 result->SetL(receiver->Clone(self));
64 } else if (name == "void java.lang.Object.notifyAll()") {
Ian Rogers05f30572013-02-20 12:13:11 -080065 receiver->NotifyAll(self);
Ian Rogers64b6d142012-10-29 16:34:15 -070066 } else if (name == "int java.lang.String.compareTo(java.lang.String)") {
Jeff Hao5d917302013-02-27 17:57:33 -080067 String* rhs = reinterpret_cast<Object*>(args[0])->AsString();
Ian Rogers64b6d142012-10-29 16:34:15 -070068 CHECK(rhs != NULL);
69 result->SetI(receiver->AsString()->CompareTo(rhs));
70 } else if (name == "java.lang.String java.lang.String.intern()") {
71 result->SetL(receiver->AsString()->Intern());
72 } else if (name == "int java.lang.String.fastIndexOf(int, int)") {
Jeff Hao5d917302013-02-27 17:57:33 -080073 result->SetI(receiver->AsString()->FastIndexOf(args[0], args[1]));
Ian Rogers64b6d142012-10-29 16:34:15 -070074 } else if (name == "java.lang.Object java.lang.reflect.Array.createMultiArray(java.lang.Class, int[])") {
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070075 StackHandleScope<2> hs(self);
76 auto h_class(hs.NewHandle(reinterpret_cast<mirror::Class*>(args[0])->AsClass()));
77 auto h_dimensions(hs.NewHandle(reinterpret_cast<mirror::IntArray*>(args[1])->AsIntArray()));
78 result->SetL(Array::CreateMultiArray(self, h_class, h_dimensions));
Ian Rogers64b6d142012-10-29 16:34:15 -070079 } else if (name == "java.lang.Object java.lang.Throwable.nativeFillInStackTrace()") {
80 ScopedObjectAccessUnchecked soa(self);
Ian Rogers5d27faf2014-05-02 17:17:18 -070081 if (Runtime::Current()->IsActiveTransaction()) {
82 result->SetL(soa.Decode<Object*>(self->CreateInternalStackTrace<true>(soa)));
83 } else {
84 result->SetL(soa.Decode<Object*>(self->CreateInternalStackTrace<false>(soa)));
85 }
Sebastien Hertzf48644b2014-02-17 15:16:03 +010086 } else if (name == "int java.lang.System.identityHashCode(java.lang.Object)") {
87 mirror::Object* obj = reinterpret_cast<Object*>(args[0]);
88 result->SetI((obj != nullptr) ? obj->IdentityHashCode() : 0);
Ian Rogers64b6d142012-10-29 16:34:15 -070089 } else if (name == "boolean java.nio.ByteOrder.isLittleEndian()") {
Sebastien Hertzf48644b2014-02-17 15:16:03 +010090 result->SetZ(JNI_TRUE);
Ian Rogers64b6d142012-10-29 16:34:15 -070091 } else if (name == "boolean sun.misc.Unsafe.compareAndSwapInt(java.lang.Object, long, int, int)") {
Jeff Hao5d917302013-02-27 17:57:33 -080092 Object* obj = reinterpret_cast<Object*>(args[0]);
93 jlong offset = (static_cast<uint64_t>(args[2]) << 32) | args[1];
94 jint expectedValue = args[3];
95 jint newValue = args[4];
Ian Rogers5d27faf2014-05-02 17:17:18 -070096 bool success;
97 if (Runtime::Current()->IsActiveTransaction()) {
Hans Boehmd8434432014-07-11 09:56:07 -070098 success = obj->CasFieldStrongSequentiallyConsistent32<true>(MemberOffset(offset),
99 expectedValue, newValue);
Ian Rogers5d27faf2014-05-02 17:17:18 -0700100 } else {
Hans Boehmd8434432014-07-11 09:56:07 -0700101 success = obj->CasFieldStrongSequentiallyConsistent32<false>(MemberOffset(offset),
102 expectedValue, newValue);
Ian Rogers5d27faf2014-05-02 17:17:18 -0700103 }
Sebastien Hertzf48644b2014-02-17 15:16:03 +0100104 result->SetZ(success ? JNI_TRUE : JNI_FALSE);
Ian Rogers64b6d142012-10-29 16:34:15 -0700105 } else if (name == "void sun.misc.Unsafe.putObject(java.lang.Object, long, java.lang.Object)") {
Jeff Hao5d917302013-02-27 17:57:33 -0800106 Object* obj = reinterpret_cast<Object*>(args[0]);
Sebastien Hertzf48644b2014-02-17 15:16:03 +0100107 jlong offset = (static_cast<uint64_t>(args[2]) << 32) | args[1];
Jeff Hao5d917302013-02-27 17:57:33 -0800108 Object* newValue = reinterpret_cast<Object*>(args[3]);
Ian Rogers5d27faf2014-05-02 17:17:18 -0700109 if (Runtime::Current()->IsActiveTransaction()) {
110 obj->SetFieldObject<true>(MemberOffset(offset), newValue);
111 } else {
112 obj->SetFieldObject<false>(MemberOffset(offset), newValue);
113 }
Hiroshi Yamauchi4d2efce2014-02-10 16:19:09 -0800114 } else if (name == "int sun.misc.Unsafe.getArrayBaseOffsetForComponentType(java.lang.Class)") {
115 mirror::Class* component = reinterpret_cast<Object*>(args[0])->AsClass();
116 Primitive::Type primitive_type = component->GetPrimitiveType();
117 result->SetI(mirror::Array::DataOffset(Primitive::ComponentSize(primitive_type)).Int32Value());
118 } else if (name == "int sun.misc.Unsafe.getArrayIndexScaleForComponentType(java.lang.Class)") {
119 mirror::Class* component = reinterpret_cast<Object*>(args[0])->AsClass();
120 Primitive::Type primitive_type = component->GetPrimitiveType();
121 result->SetI(Primitive::ComponentSize(primitive_type));
Ian Rogers5d27faf2014-05-02 17:17:18 -0700122 } else if (Runtime::Current()->IsActiveTransaction()) {
Mathieu Chartierb2c7ead2014-04-29 11:13:16 -0700123 AbortTransaction(self, "Attempt to invoke native method in non-started runtime: %s",
124 name.c_str());
Ian Rogers5d27faf2014-05-02 17:17:18 -0700125
126 } else {
127 LOG(FATAL) << "Calling native method " << PrettyMethod(method) << " in an unstarted "
128 "non-transactional runtime";
Ian Rogers64b6d142012-10-29 16:34:15 -0700129 }
130}
131
Ian Rogersfc0e94b2013-09-23 23:51:32 -0700132static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& shorty,
Jeff Hao5d917302013-02-27 17:57:33 -0800133 Object* receiver, uint32_t* args, JValue* result)
Ian Rogers64b6d142012-10-29 16:34:15 -0700134 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
135 // TODO: The following enters JNI code using a typedef-ed function rather than the JNI compiler,
136 // it should be removed and JNI compiled stubs used instead.
137 ScopedObjectAccessUnchecked soa(self);
138 if (method->IsStatic()) {
139 if (shorty == "L") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100140 typedef jobject (fntype)(JNIEnv*, jclass);
141 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700142 ScopedLocalRef<jclass> klass(soa.Env(),
143 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
Ian Rogers556d6372012-11-20 12:19:36 -0800144 jobject jresult;
145 {
146 ScopedThreadStateChange tsc(self, kNative);
147 jresult = fn(soa.Env(), klass.get());
148 }
149 result->SetL(soa.Decode<Object*>(jresult));
Ian Rogers64b6d142012-10-29 16:34:15 -0700150 } else if (shorty == "V") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100151 typedef void (fntype)(JNIEnv*, jclass);
152 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700153 ScopedLocalRef<jclass> klass(soa.Env(),
154 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
155 ScopedThreadStateChange tsc(self, kNative);
156 fn(soa.Env(), klass.get());
157 } else if (shorty == "Z") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100158 typedef jboolean (fntype)(JNIEnv*, jclass);
159 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700160 ScopedLocalRef<jclass> klass(soa.Env(),
161 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
162 ScopedThreadStateChange tsc(self, kNative);
163 result->SetZ(fn(soa.Env(), klass.get()));
164 } else if (shorty == "BI") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100165 typedef jbyte (fntype)(JNIEnv*, jclass, jint);
166 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700167 ScopedLocalRef<jclass> klass(soa.Env(),
168 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
169 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800170 result->SetB(fn(soa.Env(), klass.get(), args[0]));
Ian Rogers64b6d142012-10-29 16:34:15 -0700171 } else if (shorty == "II") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100172 typedef jint (fntype)(JNIEnv*, jclass, jint);
173 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700174 ScopedLocalRef<jclass> klass(soa.Env(),
175 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
176 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800177 result->SetI(fn(soa.Env(), klass.get(), args[0]));
Ian Rogers64b6d142012-10-29 16:34:15 -0700178 } else if (shorty == "LL") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100179 typedef jobject (fntype)(JNIEnv*, jclass, jobject);
180 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700181 ScopedLocalRef<jclass> klass(soa.Env(),
182 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
183 ScopedLocalRef<jobject> arg0(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800184 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[0])));
Ian Rogers556d6372012-11-20 12:19:36 -0800185 jobject jresult;
186 {
187 ScopedThreadStateChange tsc(self, kNative);
188 jresult = fn(soa.Env(), klass.get(), arg0.get());
189 }
190 result->SetL(soa.Decode<Object*>(jresult));
Ian Rogers64b6d142012-10-29 16:34:15 -0700191 } else if (shorty == "IIZ") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100192 typedef jint (fntype)(JNIEnv*, jclass, jint, jboolean);
193 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700194 ScopedLocalRef<jclass> klass(soa.Env(),
195 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
196 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800197 result->SetI(fn(soa.Env(), klass.get(), args[0], args[1]));
Ian Rogers64b6d142012-10-29 16:34:15 -0700198 } else if (shorty == "ILI") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100199 typedef jint (fntype)(JNIEnv*, jclass, jobject, jint);
200 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700201 ScopedLocalRef<jclass> klass(soa.Env(),
202 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
203 ScopedLocalRef<jobject> arg0(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800204 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[0])));
Ian Rogers64b6d142012-10-29 16:34:15 -0700205 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800206 result->SetI(fn(soa.Env(), klass.get(), arg0.get(), args[1]));
Ian Rogers64b6d142012-10-29 16:34:15 -0700207 } else if (shorty == "SIZ") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100208 typedef jshort (fntype)(JNIEnv*, jclass, jint, jboolean);
209 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700210 ScopedLocalRef<jclass> klass(soa.Env(),
211 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
212 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800213 result->SetS(fn(soa.Env(), klass.get(), args[0], args[1]));
Ian Rogers64b6d142012-10-29 16:34:15 -0700214 } else if (shorty == "VIZ") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100215 typedef void (fntype)(JNIEnv*, jclass, jint, jboolean);
216 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700217 ScopedLocalRef<jclass> klass(soa.Env(),
218 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
219 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800220 fn(soa.Env(), klass.get(), args[0], args[1]);
Ian Rogers64b6d142012-10-29 16:34:15 -0700221 } else if (shorty == "ZLL") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100222 typedef jboolean (fntype)(JNIEnv*, jclass, jobject, jobject);
223 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700224 ScopedLocalRef<jclass> klass(soa.Env(),
225 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
226 ScopedLocalRef<jobject> arg0(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800227 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[0])));
Ian Rogers64b6d142012-10-29 16:34:15 -0700228 ScopedLocalRef<jobject> arg1(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800229 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[1])));
Ian Rogers64b6d142012-10-29 16:34:15 -0700230 ScopedThreadStateChange tsc(self, kNative);
231 result->SetZ(fn(soa.Env(), klass.get(), arg0.get(), arg1.get()));
232 } else if (shorty == "ZILL") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100233 typedef jboolean (fntype)(JNIEnv*, jclass, jint, jobject, jobject);
234 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700235 ScopedLocalRef<jclass> klass(soa.Env(),
236 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
237 ScopedLocalRef<jobject> arg1(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800238 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[1])));
Ian Rogers64b6d142012-10-29 16:34:15 -0700239 ScopedLocalRef<jobject> arg2(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800240 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[2])));
Ian Rogers64b6d142012-10-29 16:34:15 -0700241 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800242 result->SetZ(fn(soa.Env(), klass.get(), args[0], arg1.get(), arg2.get()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700243 } else if (shorty == "VILII") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100244 typedef void (fntype)(JNIEnv*, jclass, jint, jobject, jint, jint);
245 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700246 ScopedLocalRef<jclass> klass(soa.Env(),
247 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
248 ScopedLocalRef<jobject> arg1(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800249 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[1])));
Ian Rogers64b6d142012-10-29 16:34:15 -0700250 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800251 fn(soa.Env(), klass.get(), args[0], arg1.get(), args[2], args[3]);
Ian Rogers64b6d142012-10-29 16:34:15 -0700252 } else if (shorty == "VLILII") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100253 typedef void (fntype)(JNIEnv*, jclass, jobject, jint, jobject, jint, jint);
254 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700255 ScopedLocalRef<jclass> klass(soa.Env(),
256 soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
257 ScopedLocalRef<jobject> arg0(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800258 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[0])));
Ian Rogers64b6d142012-10-29 16:34:15 -0700259 ScopedLocalRef<jobject> arg2(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800260 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[2])));
Ian Rogers64b6d142012-10-29 16:34:15 -0700261 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800262 fn(soa.Env(), klass.get(), arg0.get(), args[1], arg2.get(), args[3], args[4]);
Ian Rogers64b6d142012-10-29 16:34:15 -0700263 } else {
264 LOG(FATAL) << "Do something with static native method: " << PrettyMethod(method)
265 << " shorty: " << shorty;
266 }
267 } else {
268 if (shorty == "L") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100269 typedef jobject (fntype)(JNIEnv*, jobject);
270 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700271 ScopedLocalRef<jobject> rcvr(soa.Env(),
272 soa.AddLocalReference<jobject>(receiver));
Ian Rogers556d6372012-11-20 12:19:36 -0800273 jobject jresult;
274 {
275 ScopedThreadStateChange tsc(self, kNative);
276 jresult = fn(soa.Env(), rcvr.get());
277 }
278 result->SetL(soa.Decode<Object*>(jresult));
Jeff Hao3dd9f762013-07-08 13:09:25 -0700279 } else if (shorty == "V") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100280 typedef void (fntype)(JNIEnv*, jobject);
281 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Jeff Hao3dd9f762013-07-08 13:09:25 -0700282 ScopedLocalRef<jobject> rcvr(soa.Env(),
283 soa.AddLocalReference<jobject>(receiver));
284 ScopedThreadStateChange tsc(self, kNative);
285 fn(soa.Env(), rcvr.get());
Ian Rogers64b6d142012-10-29 16:34:15 -0700286 } else if (shorty == "LL") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100287 typedef jobject (fntype)(JNIEnv*, jobject, jobject);
288 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700289 ScopedLocalRef<jobject> rcvr(soa.Env(),
290 soa.AddLocalReference<jobject>(receiver));
291 ScopedLocalRef<jobject> arg0(soa.Env(),
Jeff Hao5d917302013-02-27 17:57:33 -0800292 soa.AddLocalReference<jobject>(reinterpret_cast<Object*>(args[0])));
Ian Rogers556d6372012-11-20 12:19:36 -0800293 jobject jresult;
294 {
295 ScopedThreadStateChange tsc(self, kNative);
296 jresult = fn(soa.Env(), rcvr.get(), arg0.get());
Ian Rogers556d6372012-11-20 12:19:36 -0800297 }
298 result->SetL(soa.Decode<Object*>(jresult));
Ian Rogers64b6d142012-10-29 16:34:15 -0700299 ScopedThreadStateChange tsc(self, kNative);
Ian Rogers64b6d142012-10-29 16:34:15 -0700300 } else if (shorty == "III") {
Bernhard Rosenkränzer46053622013-12-12 02:15:52 +0100301 typedef jint (fntype)(JNIEnv*, jobject, jint, jint);
302 fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
Ian Rogers64b6d142012-10-29 16:34:15 -0700303 ScopedLocalRef<jobject> rcvr(soa.Env(),
304 soa.AddLocalReference<jobject>(receiver));
305 ScopedThreadStateChange tsc(self, kNative);
Jeff Hao5d917302013-02-27 17:57:33 -0800306 result->SetI(fn(soa.Env(), rcvr.get(), args[0], args[1]));
Ian Rogers64b6d142012-10-29 16:34:15 -0700307 } else {
308 LOG(FATAL) << "Do something with native method: " << PrettyMethod(method)
309 << " shorty: " << shorty;
310 }
311 }
312}
313
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200314enum InterpreterImplKind {
Ian Rogersb48b9eb2014-02-28 16:20:21 -0800315 kSwitchImpl, // Switch-based interpreter implementation.
316 kComputedGotoImplKind // Computed-goto-based interpreter implementation.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200317};
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700318
Ian Rogersb48b9eb2014-02-28 16:20:21 -0800319#if !defined(__clang__)
320static constexpr InterpreterImplKind kInterpreterImplKind = kComputedGotoImplKind;
321#else
322// Clang 3.4 fails to build the goto interpreter implementation.
323static constexpr InterpreterImplKind kInterpreterImplKind = kSwitchImpl;
324template<bool do_access_check, bool transaction_active>
325JValue ExecuteGotoImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item,
326 ShadowFrame& shadow_frame, JValue result_register) {
327 LOG(FATAL) << "UNREACHABLE";
328 exit(0);
329}
330// Explicit definitions of ExecuteGotoImpl.
Stephen Hines861ea562014-04-23 16:03:57 -0700331template<> SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
Ian Rogersb48b9eb2014-02-28 16:20:21 -0800332JValue ExecuteGotoImpl<true, false>(Thread* self, MethodHelper& mh,
333 const DexFile::CodeItem* code_item,
334 ShadowFrame& shadow_frame, JValue result_register);
Stephen Hines861ea562014-04-23 16:03:57 -0700335template<> SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
Ian Rogersb48b9eb2014-02-28 16:20:21 -0800336JValue ExecuteGotoImpl<false, false>(Thread* self, MethodHelper& mh,
337 const DexFile::CodeItem* code_item,
338 ShadowFrame& shadow_frame, JValue result_register);
Stephen Hines861ea562014-04-23 16:03:57 -0700339template<> SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
Ian Rogersb48b9eb2014-02-28 16:20:21 -0800340JValue ExecuteGotoImpl<true, true>(Thread* self, MethodHelper& mh,
341 const DexFile::CodeItem* code_item,
342 ShadowFrame& shadow_frame, JValue result_register);
Stephen Hines861ea562014-04-23 16:03:57 -0700343template<> SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
Ian Rogersb48b9eb2014-02-28 16:20:21 -0800344JValue ExecuteGotoImpl<false, true>(Thread* self, MethodHelper& mh,
345 const DexFile::CodeItem* code_item,
346 ShadowFrame& shadow_frame, JValue result_register);
347#endif
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700348
Sebastien Hertz233ea8e2013-06-06 11:57:09 +0200349static JValue Execute(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item,
350 ShadowFrame& shadow_frame, JValue result_register)
351 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
352
353static inline JValue Execute(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item,
354 ShadowFrame& shadow_frame, JValue result_register) {
Ian Rogers848871b2013-08-05 10:56:33 -0700355 DCHECK(shadow_frame.GetMethod() == mh.GetMethod() ||
356 shadow_frame.GetMethod()->GetDeclaringClass()->IsProxyClass());
357 DCHECK(!shadow_frame.GetMethod()->IsAbstract());
358 DCHECK(!shadow_frame.GetMethod()->IsNative());
Sebastien Hertz4e99b3d2014-06-24 14:35:40 +0200359 shadow_frame.GetMethod()->GetDeclaringClass()->AssertInitializedOrInitializingInThread(self);
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200360
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100361 bool transaction_active = Runtime::Current()->IsActiveTransaction();
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200362 if (LIKELY(shadow_frame.GetMethod()->IsPreverified())) {
Sebastien Hertz233ea8e2013-06-06 11:57:09 +0200363 // Enter the "without access check" interpreter.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200364 if (kInterpreterImplKind == kSwitchImpl) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100365 if (transaction_active) {
366 return ExecuteSwitchImpl<false, true>(self, mh, code_item, shadow_frame, result_register);
367 } else {
368 return ExecuteSwitchImpl<false, false>(self, mh, code_item, shadow_frame, result_register);
369 }
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200370 } else {
371 DCHECK_EQ(kInterpreterImplKind, kComputedGotoImplKind);
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100372 if (transaction_active) {
373 return ExecuteGotoImpl<false, true>(self, mh, code_item, shadow_frame, result_register);
374 } else {
375 return ExecuteGotoImpl<false, false>(self, mh, code_item, shadow_frame, result_register);
376 }
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200377 }
Sebastien Hertz233ea8e2013-06-06 11:57:09 +0200378 } else {
379 // Enter the "with access check" interpreter.
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200380 if (kInterpreterImplKind == kSwitchImpl) {
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100381 if (transaction_active) {
382 return ExecuteSwitchImpl<true, true>(self, mh, code_item, shadow_frame, result_register);
383 } else {
384 return ExecuteSwitchImpl<true, false>(self, mh, code_item, shadow_frame, result_register);
385 }
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200386 } else {
387 DCHECK_EQ(kInterpreterImplKind, kComputedGotoImplKind);
Sebastien Hertzd2fe10a2014-01-15 10:20:56 +0100388 if (transaction_active) {
389 return ExecuteGotoImpl<true, true>(self, mh, code_item, shadow_frame, result_register);
390 } else {
391 return ExecuteGotoImpl<true, false>(self, mh, code_item, shadow_frame, result_register);
392 }
Sebastien Hertz8ece0502013-08-07 11:26:41 +0200393 }
Sebastien Hertz233ea8e2013-06-06 11:57:09 +0200394 }
395}
396
Brian Carlstromea46f952013-07-30 01:26:50 -0700397void EnterInterpreterFromInvoke(Thread* self, ArtMethod* method, Object* receiver,
Jeff Hao6474d192013-03-26 14:08:09 -0700398 uint32_t* args, JValue* result) {
Ian Rogers64b6d142012-10-29 16:34:15 -0700399 DCHECK_EQ(self, Thread::Current());
Nicolas Geoffray535a3fb2014-07-22 15:17:38 +0100400 bool implicit_check = !Runtime::Current()->ExplicitStackOverflowChecks();
401 if (UNLIKELY(__builtin_frame_address(0) < self->GetStackEndForInterpreter(implicit_check))) {
jeffhaod7521322012-11-21 15:38:24 -0800402 ThrowStackOverflowError(self);
403 return;
404 }
405
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700406 const char* old_cause = self->StartAssertNoThreadSuspension("EnterInterpreterFromInvoke");
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700407 const DexFile::CodeItem* code_item = method->GetCodeItem();
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700408 uint16_t num_regs;
409 uint16_t num_ins;
410 if (code_item != NULL) {
411 num_regs = code_item->registers_size_;
412 num_ins = code_item->ins_size_;
jeffhao0a9bb732012-11-26 12:28:49 -0800413 } else if (method->IsAbstract()) {
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700414 self->EndAssertNoThreadSuspension(old_cause);
Sebastien Hertz56adf602013-07-09 17:27:07 +0200415 ThrowAbstractMethodError(method);
jeffhao0a9bb732012-11-26 12:28:49 -0800416 return;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700417 } else {
418 DCHECK(method->IsNative());
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700419 num_regs = num_ins = ArtMethod::NumArgRegisters(method->GetShorty());
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700420 if (!method->IsStatic()) {
421 num_regs++;
422 num_ins++;
423 }
424 }
425 // Set up shadow frame with matching number of reference slots to vregs.
426 ShadowFrame* last_shadow_frame = self->GetManagedStack()->GetTopShadowFrame();
Jeff Hao66135192013-05-14 11:02:41 -0700427 void* memory = alloca(ShadowFrame::ComputeSize(num_regs));
428 ShadowFrame* shadow_frame(ShadowFrame::Create(num_regs, last_shadow_frame, method, 0, memory));
429 self->PushShadowFrame(shadow_frame);
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700430
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700431 size_t cur_reg = num_regs - num_ins;
432 if (!method->IsStatic()) {
433 CHECK(receiver != NULL);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800434 shadow_frame->SetVRegReference(cur_reg, receiver);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700435 ++cur_reg;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700436 }
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700437 uint32_t shorty_len = 0;
438 const char* shorty = method->GetShorty(&shorty_len);
Jeff Hao5d917302013-02-27 17:57:33 -0800439 for (size_t shorty_pos = 0, arg_pos = 0; cur_reg < num_regs; ++shorty_pos, ++arg_pos, cur_reg++) {
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700440 DCHECK_LT(shorty_pos + 1, shorty_len);
Jeff Hao5d917302013-02-27 17:57:33 -0800441 switch (shorty[shorty_pos + 1]) {
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700442 case 'L': {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800443 Object* o = reinterpret_cast<StackReference<Object>*>(&args[arg_pos])->AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800444 shadow_frame->SetVRegReference(cur_reg, o);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700445 break;
446 }
Jeff Hao5d917302013-02-27 17:57:33 -0800447 case 'J': case 'D': {
448 uint64_t wide_value = (static_cast<uint64_t>(args[arg_pos + 1]) << 32) | args[arg_pos];
449 shadow_frame->SetVRegLong(cur_reg, wide_value);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700450 cur_reg++;
Jeff Hao5d917302013-02-27 17:57:33 -0800451 arg_pos++;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700452 break;
Jeff Hao5d917302013-02-27 17:57:33 -0800453 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700454 default:
Jeff Hao5d917302013-02-27 17:57:33 -0800455 shadow_frame->SetVReg(cur_reg, args[arg_pos]);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700456 break;
457 }
458 }
Mathieu Chartier92246bb2014-02-25 18:22:39 -0800459 self->EndAssertNoThreadSuspension(old_cause);
460 // Do this after populating the shadow frame in case EnsureInitialized causes a GC.
Ian Rogers6c5cb212014-06-18 16:07:20 -0700461 if (method->IsStatic() && UNLIKELY(!method->GetDeclaringClass()->IsInitialized())) {
Mathieu Chartier92246bb2014-02-25 18:22:39 -0800462 ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700463 StackHandleScope<1> hs(self);
464 Handle<mirror::Class> h_class(hs.NewHandle(method->GetDeclaringClass()));
Ian Rogers7b078e82014-09-10 14:44:24 -0700465 if (UNLIKELY(!class_linker->EnsureInitialized(self, h_class, true, true))) {
Mathieu Chartier92246bb2014-02-25 18:22:39 -0800466 CHECK(self->IsExceptionPending());
467 self->PopShadowFrame();
468 return;
469 }
470 }
Ian Rogers64b6d142012-10-29 16:34:15 -0700471 if (LIKELY(!method->IsNative())) {
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700472 StackHandleScope<1> hs(self);
473 MethodHelper mh(hs.NewHandle(method));
Jeff Hao66135192013-05-14 11:02:41 -0700474 JValue r = Execute(self, mh, code_item, *shadow_frame, JValue());
Jeff Hao6474d192013-03-26 14:08:09 -0700475 if (result != NULL) {
476 *result = r;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700477 }
478 } else {
Ian Rogers64b6d142012-10-29 16:34:15 -0700479 // We don't expect to be asked to interpret native code (which is entered via a JNI compiler
480 // generated stub) except during testing and image writing.
Mathieu Chartier92246bb2014-02-25 18:22:39 -0800481 // Update args to be the args in the shadow frame since the input ones could hold stale
482 // references pointers due to moving GC.
483 args = shadow_frame->GetVRegArgs(method->IsStatic() ? 0 : 1);
Ian Rogers64b6d142012-10-29 16:34:15 -0700484 if (!Runtime::Current()->IsStarted()) {
Jeff Hao6474d192013-03-26 14:08:09 -0700485 UnstartedRuntimeJni(self, method, receiver, args, result);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700486 } else {
Jeff Hao6474d192013-03-26 14:08:09 -0700487 InterpreterJni(self, method, shorty, receiver, args, result);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700488 }
489 }
490 self->PopShadowFrame();
491}
492
Ian Rogers62d6c772013-02-27 08:32:07 -0800493void EnterInterpreterFromDeoptimize(Thread* self, ShadowFrame* shadow_frame, JValue* ret_val)
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800494 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
495 JValue value;
Ian Rogers62d6c772013-02-27 08:32:07 -0800496 value.SetJ(ret_val->GetJ()); // Set value to last known result in case the shadow frame chain is empty.
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800497 while (shadow_frame != NULL) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800498 self->SetTopOfShadowStack(shadow_frame);
Mathieu Chartierbfd9a432014-05-21 17:43:44 -0700499 StackHandleScope<1> hs(self);
500 MethodHelper mh(hs.NewHandle(shadow_frame->GetMethod()));
501 const DexFile::CodeItem* code_item = mh.GetMethod()->GetCodeItem();
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800502 value = Execute(self, mh, code_item, *shadow_frame, value);
503 ShadowFrame* old_frame = shadow_frame;
504 shadow_frame = shadow_frame->GetLink();
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800505 delete old_frame;
506 }
507 ret_val->SetJ(value.GetJ());
508}
509
Ian Rogers7db619b2013-01-16 18:35:48 -0800510JValue EnterInterpreterFromStub(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item,
Ian Rogers848871b2013-08-05 10:56:33 -0700511 ShadowFrame& shadow_frame) {
Ian Rogersf3e98552013-03-20 15:49:49 -0700512 DCHECK_EQ(self, Thread::Current());
Nicolas Geoffray535a3fb2014-07-22 15:17:38 +0100513 bool implicit_check = !Runtime::Current()->ExplicitStackOverflowChecks();
514 if (UNLIKELY(__builtin_frame_address(0) < self->GetStackEndForInterpreter(implicit_check))) {
Ian Rogersf3e98552013-03-20 15:49:49 -0700515 ThrowStackOverflowError(self);
516 return JValue();
517 }
518
Ian Rogers7db619b2013-01-16 18:35:48 -0800519 return Execute(self, mh, code_item, shadow_frame, JValue());
520}
521
Ian Rogers848871b2013-08-05 10:56:33 -0700522extern "C" void artInterpreterToInterpreterBridge(Thread* self, MethodHelper& mh,
523 const DexFile::CodeItem* code_item,
524 ShadowFrame* shadow_frame, JValue* result) {
Nicolas Geoffray535a3fb2014-07-22 15:17:38 +0100525 bool implicit_check = !Runtime::Current()->ExplicitStackOverflowChecks();
526 if (UNLIKELY(__builtin_frame_address(0) < self->GetStackEndForInterpreter(implicit_check))) {
Jeff Hao16743632013-05-08 10:59:04 -0700527 ThrowStackOverflowError(self);
Jeff Hao69510672013-05-21 17:34:55 -0700528 return;
Jeff Hao16743632013-05-08 10:59:04 -0700529 }
530
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700531 self->PushShadowFrame(shadow_frame);
Brian Carlstromea46f952013-07-30 01:26:50 -0700532 ArtMethod* method = shadow_frame->GetMethod();
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200533 // Ensure static methods are initialized.
534 if (method->IsStatic()) {
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700535 mirror::Class* declaring_class = method->GetDeclaringClass();
Ian Rogers6c5cb212014-06-18 16:07:20 -0700536 if (UNLIKELY(!declaring_class->IsInitialized())) {
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700537 StackHandleScope<1> hs(self);
538 HandleWrapper<Class> h_declaring_class(hs.NewHandleWrapper(&declaring_class));
539 if (UNLIKELY(!Runtime::Current()->GetClassLinker()->EnsureInitialized(
Ian Rogers7b078e82014-09-10 14:44:24 -0700540 self, h_declaring_class, true, true))) {
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700541 DCHECK(self->IsExceptionPending());
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700542 self->PopShadowFrame();
Sebastien Hertzc61124b2013-09-10 11:44:19 +0200543 return;
544 }
Mathieu Chartier0cd81352014-05-22 16:48:55 -0700545 CHECK(h_declaring_class->IsInitializing());
Jeff Hao16743632013-05-08 10:59:04 -0700546 }
Jeff Hao16743632013-05-08 10:59:04 -0700547 }
Jeff Hao16743632013-05-08 10:59:04 -0700548
Jeff Hao16743632013-05-08 10:59:04 -0700549 if (LIKELY(!method->IsNative())) {
Jeff Hao69510672013-05-21 17:34:55 -0700550 result->SetJ(Execute(self, mh, code_item, *shadow_frame, JValue()).GetJ());
Jeff Hao16743632013-05-08 10:59:04 -0700551 } else {
552 // We don't expect to be asked to interpret native code (which is entered via a JNI compiler
553 // generated stub) except during testing and image writing.
554 CHECK(!Runtime::Current()->IsStarted());
Mathieu Chartiere861ebd2013-10-09 15:01:21 -0700555 Object* receiver = method->IsStatic() ? nullptr : shadow_frame->GetVRegReference(0);
Jeff Hao16743632013-05-08 10:59:04 -0700556 uint32_t* args = shadow_frame->GetVRegArgs(method->IsStatic() ? 0 : 1);
Jeff Hao69510672013-05-21 17:34:55 -0700557 UnstartedRuntimeJni(self, method, receiver, args, result);
Jeff Hao16743632013-05-08 10:59:04 -0700558 }
559
560 self->PopShadowFrame();
Jeff Hao16743632013-05-08 10:59:04 -0700561}
562
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700563} // namespace interpreter
564} // namespace art