summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter/interpreter.cc
diff options
context:
space:
mode:
authorBernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>2013-12-12 02:15:52 +0100
committerBernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>2013-12-12 13:08:03 +0100
commit460536209b741bc469f1b0857775449abb2102fb (patch)
tree4bc7f636b86ab2531811827d0fd0c33011a7280e /runtime/interpreter/interpreter.cc
parent19031d51ab9edfc3b1996891d654a6b86ca937c0 (diff)
downloadart-460536209b741bc469f1b0857775449abb2102fb.zip
art-460536209b741bc469f1b0857775449abb2102fb.tar.gz
art-460536209b741bc469f1b0857775449abb2102fb.tar.bz2
Don't rely on gcc extensions
Make the code more compatible with different compilers. clang doesn't allow extra static qualifiers on template specializations, const qualifiers on function types, or inline attributes on lambda functions, and is more picky about casting away constness with reinterpret_cast. These modifications are compatible with both gcc and clang. Change-Id: I739b10df2780bec537827a13679fd2bcc2cc7188 Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
Diffstat (limited to 'runtime/interpreter/interpreter.cc')
-rw-r--r--runtime/interpreter/interpreter.cc72
1 files changed, 36 insertions, 36 deletions
diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc
index 02c9012..f574a0f 100644
--- a/runtime/interpreter/interpreter.cc
+++ b/runtime/interpreter/interpreter.cc
@@ -90,8 +90,8 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
ScopedObjectAccessUnchecked soa(self);
if (method->IsStatic()) {
if (shorty == "L") {
- typedef jobject (fnptr)(JNIEnv*, jclass);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jobject (fntype)(JNIEnv*, jclass);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
jobject jresult;
@@ -101,36 +101,36 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
}
result->SetL(soa.Decode<Object*>(jresult));
} else if (shorty == "V") {
- typedef void (fnptr)(JNIEnv*, jclass);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef void (fntype)(JNIEnv*, jclass);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedThreadStateChange tsc(self, kNative);
fn(soa.Env(), klass.get());
} else if (shorty == "Z") {
- typedef jboolean (fnptr)(JNIEnv*, jclass);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jboolean (fntype)(JNIEnv*, jclass);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedThreadStateChange tsc(self, kNative);
result->SetZ(fn(soa.Env(), klass.get()));
} else if (shorty == "BI") {
- typedef jbyte (fnptr)(JNIEnv*, jclass, jint);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jbyte (fntype)(JNIEnv*, jclass, jint);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedThreadStateChange tsc(self, kNative);
result->SetB(fn(soa.Env(), klass.get(), args[0]));
} else if (shorty == "II") {
- typedef jint (fnptr)(JNIEnv*, jclass, jint);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jint (fntype)(JNIEnv*, jclass, jint);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedThreadStateChange tsc(self, kNative);
result->SetI(fn(soa.Env(), klass.get(), args[0]));
} else if (shorty == "LL") {
- typedef jobject (fnptr)(JNIEnv*, jclass, jobject);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jobject (fntype)(JNIEnv*, jclass, jobject);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedLocalRef<jobject> arg0(soa.Env(),
@@ -142,15 +142,15 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
}
result->SetL(soa.Decode<Object*>(jresult));
} else if (shorty == "IIZ") {
- typedef jint (fnptr)(JNIEnv*, jclass, jint, jboolean);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jint (fntype)(JNIEnv*, jclass, jint, jboolean);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedThreadStateChange tsc(self, kNative);
result->SetI(fn(soa.Env(), klass.get(), args[0], args[1]));
} else if (shorty == "ILI") {
- typedef jint (fnptr)(JNIEnv*, jclass, jobject, jint);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jint (fntype)(JNIEnv*, jclass, jobject, jint);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedLocalRef<jobject> arg0(soa.Env(),
@@ -158,22 +158,22 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
ScopedThreadStateChange tsc(self, kNative);
result->SetI(fn(soa.Env(), klass.get(), arg0.get(), args[1]));
} else if (shorty == "SIZ") {
- typedef jshort (fnptr)(JNIEnv*, jclass, jint, jboolean);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jshort (fntype)(JNIEnv*, jclass, jint, jboolean);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedThreadStateChange tsc(self, kNative);
result->SetS(fn(soa.Env(), klass.get(), args[0], args[1]));
} else if (shorty == "VIZ") {
- typedef void (fnptr)(JNIEnv*, jclass, jint, jboolean);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef void (fntype)(JNIEnv*, jclass, jint, jboolean);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedThreadStateChange tsc(self, kNative);
fn(soa.Env(), klass.get(), args[0], args[1]);
} else if (shorty == "ZLL") {
- typedef jboolean (fnptr)(JNIEnv*, jclass, jobject, jobject);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jboolean (fntype)(JNIEnv*, jclass, jobject, jobject);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedLocalRef<jobject> arg0(soa.Env(),
@@ -183,8 +183,8 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
ScopedThreadStateChange tsc(self, kNative);
result->SetZ(fn(soa.Env(), klass.get(), arg0.get(), arg1.get()));
} else if (shorty == "ZILL") {
- typedef jboolean (fnptr)(JNIEnv*, jclass, jint, jobject, jobject);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jboolean (fntype)(JNIEnv*, jclass, jint, jobject, jobject);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedLocalRef<jobject> arg1(soa.Env(),
@@ -194,8 +194,8 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
ScopedThreadStateChange tsc(self, kNative);
result->SetZ(fn(soa.Env(), klass.get(), args[0], arg1.get(), arg2.get()));
} else if (shorty == "VILII") {
- typedef void (fnptr)(JNIEnv*, jclass, jint, jobject, jint, jint);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef void (fntype)(JNIEnv*, jclass, jint, jobject, jint, jint);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedLocalRef<jobject> arg1(soa.Env(),
@@ -203,8 +203,8 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
ScopedThreadStateChange tsc(self, kNative);
fn(soa.Env(), klass.get(), args[0], arg1.get(), args[2], args[3]);
} else if (shorty == "VLILII") {
- typedef void (fnptr)(JNIEnv*, jclass, jobject, jint, jobject, jint, jint);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef void (fntype)(JNIEnv*, jclass, jobject, jint, jobject, jint, jint);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jclass> klass(soa.Env(),
soa.AddLocalReference<jclass>(method->GetDeclaringClass()));
ScopedLocalRef<jobject> arg0(soa.Env(),
@@ -219,8 +219,8 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
}
} else {
if (shorty == "L") {
- typedef jobject (fnptr)(JNIEnv*, jobject);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jobject (fntype)(JNIEnv*, jobject);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jobject> rcvr(soa.Env(),
soa.AddLocalReference<jobject>(receiver));
jobject jresult;
@@ -230,15 +230,15 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
}
result->SetL(soa.Decode<Object*>(jresult));
} else if (shorty == "V") {
- typedef void (fnptr)(JNIEnv*, jobject);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef void (fntype)(JNIEnv*, jobject);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jobject> rcvr(soa.Env(),
soa.AddLocalReference<jobject>(receiver));
ScopedThreadStateChange tsc(self, kNative);
fn(soa.Env(), rcvr.get());
} else if (shorty == "LL") {
- typedef jobject (fnptr)(JNIEnv*, jobject, jobject);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jobject (fntype)(JNIEnv*, jobject, jobject);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jobject> rcvr(soa.Env(),
soa.AddLocalReference<jobject>(receiver));
ScopedLocalRef<jobject> arg0(soa.Env(),
@@ -251,8 +251,8 @@ static void InterpreterJni(Thread* self, ArtMethod* method, const StringPiece& s
result->SetL(soa.Decode<Object*>(jresult));
ScopedThreadStateChange tsc(self, kNative);
} else if (shorty == "III") {
- typedef jint (fnptr)(JNIEnv*, jobject, jint, jint);
- const fnptr* fn = reinterpret_cast<const fnptr*>(method->GetNativeMethod());
+ typedef jint (fntype)(JNIEnv*, jobject, jint, jint);
+ fntype* const fn = reinterpret_cast<fntype*>(const_cast<void*>(method->GetNativeMethod()));
ScopedLocalRef<jobject> rcvr(soa.Env(),
soa.AddLocalReference<jobject>(receiver));
ScopedThreadStateChange tsc(self, kNative);