Mercurial > hg > truffle
comparison src/share/vm/prims/unsafe.cpp @ 14521:29ccc4cbabca
Merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 12 Mar 2014 13:30:08 +0100 |
parents | d8041d695d19 |
children | 4ca6dc0799b6 |
comparison
equal
deleted
inserted
replaced
14520:f84115370178 | 14521:29ccc4cbabca |
---|---|
42 | 42 |
43 /* | 43 /* |
44 * Implementation of class sun.misc.Unsafe | 44 * Implementation of class sun.misc.Unsafe |
45 */ | 45 */ |
46 | 46 |
47 #ifndef USDT2 | |
48 HS_DTRACE_PROBE_DECL3(hotspot, thread__park__begin, uintptr_t, int, long long); | |
49 HS_DTRACE_PROBE_DECL1(hotspot, thread__park__end, uintptr_t); | |
50 HS_DTRACE_PROBE_DECL1(hotspot, thread__unpark, uintptr_t); | |
51 #endif /* !USDT2 */ | |
52 | 47 |
53 #define MAX_OBJECT_SIZE \ | 48 #define MAX_OBJECT_SIZE \ |
54 ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \ | 49 ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \ |
55 + ((julong)max_jint * sizeof(double)) ) | 50 + ((julong)max_jint * sizeof(double)) ) |
56 | 51 |
160 oop p = JNIHandles::resolve(obj); \ | 155 oop p = JNIHandles::resolve(obj); \ |
161 *(type_name*)index_oop_from_field_offset_long(p, offset) = x | 156 *(type_name*)index_oop_from_field_offset_long(p, offset) = x |
162 | 157 |
163 #define GET_FIELD_VOLATILE(obj, offset, type_name, v) \ | 158 #define GET_FIELD_VOLATILE(obj, offset, type_name, v) \ |
164 oop p = JNIHandles::resolve(obj); \ | 159 oop p = JNIHandles::resolve(obj); \ |
160 if (support_IRIW_for_not_multiple_copy_atomic_cpu) { \ | |
161 OrderAccess::fence(); \ | |
162 } \ | |
165 volatile type_name v = OrderAccess::load_acquire((volatile type_name*)index_oop_from_field_offset_long(p, offset)); | 163 volatile type_name v = OrderAccess::load_acquire((volatile type_name*)index_oop_from_field_offset_long(p, offset)); |
166 | 164 |
167 #define SET_FIELD_VOLATILE(obj, offset, type_name, x) \ | 165 #define SET_FIELD_VOLATILE(obj, offset, type_name, x) \ |
168 oop p = JNIHandles::resolve(obj); \ | 166 oop p = JNIHandles::resolve(obj); \ |
169 OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), x); | 167 OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), x); |
856 static inline void throw_new(JNIEnv *env, const char *ename) { | 854 static inline void throw_new(JNIEnv *env, const char *ename) { |
857 char buf[100]; | 855 char buf[100]; |
858 strcpy(buf, "java/lang/"); | 856 strcpy(buf, "java/lang/"); |
859 strcat(buf, ename); | 857 strcat(buf, ename); |
860 jclass cls = env->FindClass(buf); | 858 jclass cls = env->FindClass(buf); |
859 if (env->ExceptionCheck()) { | |
860 env->ExceptionClear(); | |
861 tty->print_cr("Unsafe: cannot throw %s because FindClass has failed", buf); | |
862 return; | |
863 } | |
861 char* msg = NULL; | 864 char* msg = NULL; |
862 env->ThrowNew(cls, msg); | 865 env->ThrowNew(cls, msg); |
863 } | 866 } |
864 | 867 |
865 static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) { | 868 static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) { |
1204 UNSAFE_END | 1207 UNSAFE_END |
1205 | 1208 |
1206 UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time)) | 1209 UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time)) |
1207 UnsafeWrapper("Unsafe_Park"); | 1210 UnsafeWrapper("Unsafe_Park"); |
1208 EventThreadPark event; | 1211 EventThreadPark event; |
1209 #ifndef USDT2 | 1212 HOTSPOT_THREAD_PARK_BEGIN((uintptr_t) thread->parker(), (int) isAbsolute, time); |
1210 HS_DTRACE_PROBE3(hotspot, thread__park__begin, thread->parker(), (int) isAbsolute, time); | 1213 |
1211 #else /* USDT2 */ | |
1212 HOTSPOT_THREAD_PARK_BEGIN( | |
1213 (uintptr_t) thread->parker(), (int) isAbsolute, time); | |
1214 #endif /* USDT2 */ | |
1215 JavaThreadParkedState jtps(thread, time != 0); | 1214 JavaThreadParkedState jtps(thread, time != 0); |
1216 thread->parker()->park(isAbsolute != 0, time); | 1215 thread->parker()->park(isAbsolute != 0, time); |
1217 #ifndef USDT2 | 1216 |
1218 HS_DTRACE_PROBE1(hotspot, thread__park__end, thread->parker()); | 1217 HOTSPOT_THREAD_PARK_END((uintptr_t) thread->parker()); |
1219 #else /* USDT2 */ | |
1220 HOTSPOT_THREAD_PARK_END( | |
1221 (uintptr_t) thread->parker()); | |
1222 #endif /* USDT2 */ | |
1223 if (event.should_commit()) { | 1218 if (event.should_commit()) { |
1224 oop obj = thread->current_park_blocker(); | 1219 oop obj = thread->current_park_blocker(); |
1225 event.set_klass((obj != NULL) ? obj->klass() : NULL); | 1220 event.set_klass((obj != NULL) ? obj->klass() : NULL); |
1226 event.set_timeout(time); | 1221 event.set_timeout(time); |
1227 event.set_address((obj != NULL) ? (TYPE_ADDRESS) cast_from_oop<uintptr_t>(obj) : 0); | 1222 event.set_address((obj != NULL) ? (TYPE_ADDRESS) cast_from_oop<uintptr_t>(obj) : 0); |
1256 } | 1251 } |
1257 } | 1252 } |
1258 } | 1253 } |
1259 } | 1254 } |
1260 if (p != NULL) { | 1255 if (p != NULL) { |
1261 #ifndef USDT2 | 1256 HOTSPOT_THREAD_UNPARK((uintptr_t) p); |
1262 HS_DTRACE_PROBE1(hotspot, thread__unpark, p); | |
1263 #else /* USDT2 */ | |
1264 HOTSPOT_THREAD_UNPARK( | |
1265 (uintptr_t) p); | |
1266 #endif /* USDT2 */ | |
1267 p->unpark(); | 1257 p->unpark(); |
1268 } | 1258 } |
1269 UNSAFE_END | 1259 UNSAFE_END |
1270 | 1260 |
1271 UNSAFE_ENTRY(jint, Unsafe_Loadavg(JNIEnv *env, jobject unsafe, jdoubleArray loadavg, jint nelem)) | 1261 UNSAFE_ENTRY(jint, Unsafe_Loadavg(JNIEnv *env, jobject unsafe, jdoubleArray loadavg, jint nelem)) |