diff options
| author | 2012-01-08 12:46:11 -0800 | |
|---|---|---|
| committer | 2012-01-13 10:08:08 -0800 | |
| commit | 24782c6aa7abf396de057d7eb15035b4c594a3b4 (patch) | |
| tree | 2cf92cf18e0b6610a4eb4a355b32b84b6c77de52 | |
| parent | 9f23e24937efe175d24bb712010690a2358e61ca (diff) | |
Add a macro GCC_VERSION and use it to control code paths.
Code paths that work on lower version of GCC are required because
Mac OS will never move beyond GCC 4.2. I added the code paths so
that Mac builds can pass.
Change-Id: I4a3340355133dff4a5107b94970bc809d9de264e
| -rw-r--r-- | build/Android.common.mk | 2 | ||||
| -rw-r--r-- | src/assembler_x86.h | 9 | ||||
| -rw-r--r-- | src/common_test.h | 8 | ||||
| -rw-r--r-- | src/jni_internal.cc | 17 | ||||
| -rw-r--r-- | src/logging.h | 4 | ||||
| -rw-r--r-- | src/macros.h | 4 |
6 files changed, 37 insertions, 7 deletions
diff --git a/build/Android.common.mk b/build/Android.common.mk index c6e7366dc3..9e05a1c0ad 100644 --- a/build/Android.common.mk +++ b/build/Android.common.mk @@ -45,7 +45,7 @@ art_cflags := \ -fstrict-aliasing ifeq ($(HOST_OS),linux) -art_non_debug_cflags := \ + art_non_debug_cflags := \ -Wframe-larger-than=1728 endif diff --git a/src/assembler_x86.h b/src/assembler_x86.h index b1d34d3acc..2f293e4a39 100644 --- a/src/assembler_x86.h +++ b/src/assembler_x86.h @@ -28,7 +28,10 @@ class Immediate { private: const int32_t value_; + // TODO: Remove the #if when Mac OS build server no longer uses GCC 4.2.*. +#if GCC_VERSION >= 40300 DISALLOW_COPY_AND_ASSIGN(Immediate); +#endif }; @@ -116,7 +119,10 @@ class Operand { friend class X86Assembler; + // TODO: Remove the #if when Mac OS build server no longer uses GCC 4.2.*. +#if GCC_VERSION >= 40300 DISALLOW_COPY_AND_ASSIGN(Operand); +#endif }; @@ -192,7 +198,10 @@ class Address : public Operand { private: Address() {} + // TODO: Remove the #if when Mac OS build server no longer uses GCC 4.2.*. +#if GCC_VERSION >= 40300 DISALLOW_COPY_AND_ASSIGN(Address); +#endif }; diff --git a/src/common_test.h b/src/common_test.h index 396cda5ee8..c89527cbdb 100644 --- a/src/common_test.h +++ b/src/common_test.h @@ -173,8 +173,16 @@ class CommonTest : public testing::Test { uintptr_t limit = RoundUp(data + code_length, kPageSize); uintptr_t len = limit - base; int result = mprotect(reinterpret_cast<void*>(base), len, PROT_READ | PROT_WRITE | PROT_EXEC); + // Flush instruction cache + // Only uses __builtin___clear_cache if GCC >= 4.3.3 +#if GCC_VERSION >= 40303 __builtin___clear_cache(reinterpret_cast<void*>(base), reinterpret_cast<void*>(base + len)); +#else + // Currently, only Mac OS builds use GCC 4.2.*. Those host builds do not + // need to generate clear_cache on x86. +#endif + CHECK_EQ(result, 0); } diff --git a/src/jni_internal.cc b/src/jni_internal.cc index 597c58bd7a..95acf99eef 100644 --- a/src/jni_internal.cc +++ b/src/jni_internal.cc @@ -126,6 +126,11 @@ T Decode(JNIEnv* public_env, jobject obj) { JNIEnvExt* env = reinterpret_cast<JNIEnvExt*>(public_env); return reinterpret_cast<T>(env->self->DecodeJObject(obj)); } +// TODO: Change to use template when Mac OS build server no longer uses GCC 4.2.*. +Object* DecodeObj(JNIEnv* public_env, jobject obj) { + JNIEnvExt* env = reinterpret_cast<JNIEnvExt*>(public_env); + return reinterpret_cast<Object*>(env->self->DecodeJObject(obj)); +} // Explicit instantiations. template Array* Decode<Array*>(JNIEnv*, jobject); template Class* Decode<Class*>(JNIEnv*, jobject); @@ -179,7 +184,7 @@ static byte* CreateArgArray(JNIEnv* public_env, Method* method, va_list ap) { offset += 4; break; case 'L': { - Object* obj = Decode<Object*>(env, va_arg(ap, jobject)); + Object* obj = DecodeObj(env, va_arg(ap, jobject)); *reinterpret_cast<Object**>(&arg_array[offset]) = obj; offset += sizeof(Object*); break; @@ -218,7 +223,7 @@ static byte* CreateArgArray(JNIEnv* public_env, Method* method, jvalue* args) { offset += 4; break; case 'L': { - Object* obj = Decode<Object*>(env, args[i - 1].l); + Object* obj = DecodeObj(env, args[i - 1].l); *reinterpret_cast<Object**>(&arg_array[offset]) = obj; offset += sizeof(Object*); break; @@ -281,7 +286,7 @@ static JValue InvokeWithArgArray(JNIEnv* public_env, Object* receiver, Method* m static JValue InvokeWithVarArgs(JNIEnv* public_env, jobject obj, jmethodID mid, va_list args) { JNIEnvExt* env = reinterpret_cast<JNIEnvExt*>(public_env); - Object* receiver = Decode<Object*>(env, obj); + Object* receiver = DecodeObj(env, obj); Method* method = DecodeMethod(mid); UniquePtr<byte[]> arg_array(CreateArgArray(env, method, args)); return InvokeWithArgArray(env, receiver, method, arg_array.get()); @@ -294,7 +299,7 @@ static Method* FindVirtualMethod(Object* receiver, Method* method) { static JValue InvokeVirtualOrInterfaceWithJValues(JNIEnv* public_env, jobject obj, jmethodID mid, jvalue* args) { JNIEnvExt* env = reinterpret_cast<JNIEnvExt*>(public_env); - Object* receiver = Decode<Object*>(env, obj); + Object* receiver = DecodeObj(env, obj); Method* method = FindVirtualMethod(receiver, DecodeMethod(mid)); UniquePtr<byte[]> arg_array(CreateArgArray(env, method, args)); return InvokeWithArgArray(env, receiver, method, arg_array.get()); @@ -303,7 +308,7 @@ static JValue InvokeVirtualOrInterfaceWithJValues(JNIEnv* public_env, jobject ob static JValue InvokeVirtualOrInterfaceWithVarArgs(JNIEnv* public_env, jobject obj, jmethodID mid, va_list args) { JNIEnvExt* env = reinterpret_cast<JNIEnvExt*>(public_env); - Object* receiver = Decode<Object*>(env, obj); + Object* receiver = DecodeObj(env, obj); Method* method = FindVirtualMethod(receiver, DecodeMethod(mid)); UniquePtr<byte[]> arg_array(CreateArgArray(env, method, args)); return InvokeWithArgArray(env, receiver, method, arg_array.get()); @@ -2977,7 +2982,7 @@ std::ostream& operator<<(std::ostream& os, const jobjectRefType& rhs) { os << "JNIWeakGlobalRefType"; return os; default: - os << "jobjectRefType[" << static_cast<int>(rhs) << "]"; + LOG(FATAL) << "jobjectRefType[" << static_cast<int>(rhs) << "]"; return os; } } diff --git a/src/logging.h b/src/logging.h index 51d4496770..9e10bd9a51 100644 --- a/src/logging.h +++ b/src/logging.h @@ -191,7 +191,11 @@ class Dumpable { private: T& value_; + +// TODO: Remove the #if when Mac OS build server no longer uses GCC 4.2.*. +#if GCC_VERSION >= 40300 DISALLOW_COPY_AND_ASSIGN(Dumpable); +#endif }; template<typename T> diff --git a/src/macros.h b/src/macros.h index 7652f717ee..5b9bdb6463 100644 --- a/src/macros.h +++ b/src/macros.h @@ -16,6 +16,10 @@ #include <stddef.h> // for size_t +#define GCC_VERSION ( _GNUC_ * 10000 \ + + _GNUC_MINOR_ * 100 \ + + __GNUC_PATCHLEVEL__) + // The COMPILE_ASSERT macro can be used to verify that a compile time // expression is true. For example, you could use it to verify the // size of a static array: |