99 MutexLocker ml(JNIGlobalHandle_lock);
100 assert(Universe::heap()->is_in_reserved(obj()), "sanity check");
101 res = _weak_global_handles->allocate_handle(obj());
102 }
103 // Add weak tag.
104 assert(is_ptr_aligned(res, weak_tag_alignment), "invariant");
105 char* tptr = reinterpret_cast<char*>(res) + weak_tag_value;
106 res = reinterpret_cast<jobject>(tptr);
107 } else {
108 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
109 }
110 return res;
111 }
112
113 template<bool external_guard>
114 oop JNIHandles::resolve_jweak(jweak handle) {
115 assert(is_jweak(handle), "precondition");
116 oop result = jweak_ref(handle);
117 result = guard_value<external_guard>(result);
118 #if INCLUDE_ALL_GCS
119 if (result != NULL && UseG1GC) {
120 G1SATBCardTableModRefBS::enqueue(result);
121 }
122 #endif // INCLUDE_ALL_GCS
123 return result;
124 }
125
126 template oop JNIHandles::resolve_jweak<true>(jweak);
127 template oop JNIHandles::resolve_jweak<false>(jweak);
128
129 void JNIHandles::destroy_global(jobject handle) {
130 if (handle != NULL) {
131 assert(is_global_handle(handle), "Invalid delete of global JNI handle");
132 jobject_ref(handle) = deleted_handle();
133 }
134 }
135
136 void JNIHandles::destroy_weak_global(jobject handle) {
137 if (handle != NULL) {
138 jweak_ref(handle) = deleted_handle();
139 }
|
99 MutexLocker ml(JNIGlobalHandle_lock);
100 assert(Universe::heap()->is_in_reserved(obj()), "sanity check");
101 res = _weak_global_handles->allocate_handle(obj());
102 }
103 // Add weak tag.
104 assert(is_ptr_aligned(res, weak_tag_alignment), "invariant");
105 char* tptr = reinterpret_cast<char*>(res) + weak_tag_value;
106 res = reinterpret_cast<jobject>(tptr);
107 } else {
108 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
109 }
110 return res;
111 }
112
113 template<bool external_guard>
114 oop JNIHandles::resolve_jweak(jweak handle) {
115 assert(is_jweak(handle), "precondition");
116 oop result = jweak_ref(handle);
117 result = guard_value<external_guard>(result);
118 #if INCLUDE_ALL_GCS
119 if (result != NULL && (UseG1GC || (UseShenandoahGC && ShenandoahSATBBarrier))) {
120 G1SATBCardTableModRefBS::enqueue(result);
121 }
122 #endif // INCLUDE_ALL_GCS
123 return result;
124 }
125
126 template oop JNIHandles::resolve_jweak<true>(jweak);
127 template oop JNIHandles::resolve_jweak<false>(jweak);
128
129 void JNIHandles::destroy_global(jobject handle) {
130 if (handle != NULL) {
131 assert(is_global_handle(handle), "Invalid delete of global JNI handle");
132 jobject_ref(handle) = deleted_handle();
133 }
134 }
135
136 void JNIHandles::destroy_weak_global(jobject handle) {
137 if (handle != NULL) {
138 jweak_ref(handle) = deleted_handle();
139 }
|