comparison src/share/vm/prims/unsafe.cpp @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents d8041d695d19
children 52b4284cb496
comparison
equal deleted inserted replaced
14908:8db6e76cb658 14909:4ca6dc0799b6
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 */
47 52
48 #define MAX_OBJECT_SIZE \ 53 #define MAX_OBJECT_SIZE \
49 ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \ 54 ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \
50 + ((julong)max_jint * sizeof(double)) ) 55 + ((julong)max_jint * sizeof(double)) )
51 56
155 oop p = JNIHandles::resolve(obj); \ 160 oop p = JNIHandles::resolve(obj); \
156 *(type_name*)index_oop_from_field_offset_long(p, offset) = x 161 *(type_name*)index_oop_from_field_offset_long(p, offset) = x
157 162
158 #define GET_FIELD_VOLATILE(obj, offset, type_name, v) \ 163 #define GET_FIELD_VOLATILE(obj, offset, type_name, v) \
159 oop p = JNIHandles::resolve(obj); \ 164 oop p = JNIHandles::resolve(obj); \
160 if (support_IRIW_for_not_multiple_copy_atomic_cpu) { \
161 OrderAccess::fence(); \
162 } \
163 volatile type_name v = OrderAccess::load_acquire((volatile type_name*)index_oop_from_field_offset_long(p, offset)); 165 volatile type_name v = OrderAccess::load_acquire((volatile type_name*)index_oop_from_field_offset_long(p, offset));
164 166
165 #define SET_FIELD_VOLATILE(obj, offset, type_name, x) \ 167 #define SET_FIELD_VOLATILE(obj, offset, type_name, x) \
166 oop p = JNIHandles::resolve(obj); \ 168 oop p = JNIHandles::resolve(obj); \
167 OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), x); 169 OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), x);
854 static inline void throw_new(JNIEnv *env, const char *ename) { 856 static inline void throw_new(JNIEnv *env, const char *ename) {
855 char buf[100]; 857 char buf[100];
856 strcpy(buf, "java/lang/"); 858 strcpy(buf, "java/lang/");
857 strcat(buf, ename); 859 strcat(buf, ename);
858 jclass cls = env->FindClass(buf); 860 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 }
864 char* msg = NULL; 861 char* msg = NULL;
865 env->ThrowNew(cls, msg); 862 env->ThrowNew(cls, msg);
866 } 863 }
867 864
868 static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) { 865 static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data, int offset, int length, jobject loader, jobject pd) {
1207 UNSAFE_END 1204 UNSAFE_END
1208 1205
1209 UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time)) 1206 UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time))
1210 UnsafeWrapper("Unsafe_Park"); 1207 UnsafeWrapper("Unsafe_Park");
1211 EventThreadPark event; 1208 EventThreadPark event;
1212 HOTSPOT_THREAD_PARK_BEGIN((uintptr_t) thread->parker(), (int) isAbsolute, time); 1209 #ifndef USDT2
1213 1210 HS_DTRACE_PROBE3(hotspot, thread__park__begin, thread->parker(), (int) isAbsolute, time);
1211 #else /* USDT2 */
1212 HOTSPOT_THREAD_PARK_BEGIN(
1213 (uintptr_t) thread->parker(), (int) isAbsolute, time);
1214 #endif /* USDT2 */
1214 JavaThreadParkedState jtps(thread, time != 0); 1215 JavaThreadParkedState jtps(thread, time != 0);
1215 thread->parker()->park(isAbsolute != 0, time); 1216 thread->parker()->park(isAbsolute != 0, time);
1216 1217 #ifndef USDT2
1217 HOTSPOT_THREAD_PARK_END((uintptr_t) thread->parker()); 1218 HS_DTRACE_PROBE1(hotspot, thread__park__end, thread->parker());
1219 #else /* USDT2 */
1220 HOTSPOT_THREAD_PARK_END(
1221 (uintptr_t) thread->parker());
1222 #endif /* USDT2 */
1218 if (event.should_commit()) { 1223 if (event.should_commit()) {
1219 oop obj = thread->current_park_blocker(); 1224 oop obj = thread->current_park_blocker();
1220 event.set_klass((obj != NULL) ? obj->klass() : NULL); 1225 event.set_klass((obj != NULL) ? obj->klass() : NULL);
1221 event.set_timeout(time); 1226 event.set_timeout(time);
1222 event.set_address((obj != NULL) ? (TYPE_ADDRESS) cast_from_oop<uintptr_t>(obj) : 0); 1227 event.set_address((obj != NULL) ? (TYPE_ADDRESS) cast_from_oop<uintptr_t>(obj) : 0);
1251 } 1256 }
1252 } 1257 }
1253 } 1258 }
1254 } 1259 }
1255 if (p != NULL) { 1260 if (p != NULL) {
1256 HOTSPOT_THREAD_UNPARK((uintptr_t) p); 1261 #ifndef USDT2
1262 HS_DTRACE_PROBE1(hotspot, thread__unpark, p);
1263 #else /* USDT2 */
1264 HOTSPOT_THREAD_UNPARK(
1265 (uintptr_t) p);
1266 #endif /* USDT2 */
1257 p->unpark(); 1267 p->unpark();
1258 } 1268 }
1259 UNSAFE_END 1269 UNSAFE_END
1260 1270
1261 UNSAFE_ENTRY(jint, Unsafe_Loadavg(JNIEnv *env, jobject unsafe, jdoubleArray loadavg, jint nelem)) 1271 UNSAFE_ENTRY(jint, Unsafe_Loadavg(JNIEnv *env, jobject unsafe, jdoubleArray loadavg, jint nelem))