134 }
135 return res;
136 }
137
138 // Resolve some erroneous cases to NULL, rather than treating them as
139 // possibly unchecked errors. In particular, deleted handles are
140 // treated as NULL (though a deleted and later reallocated handle
141 // isn't detected).
142 oop JNIHandles::resolve_external_guard(jobject handle) {
143 oop result = NULL;
144 if (handle != NULL) {
145 result = resolve_impl<true /* external_guard */ >(handle);
146 }
147 return result;
148 }
149
150 oop JNIHandles::resolve_jweak(jweak handle) {
151 assert(handle != NULL, "precondition");
152 assert(is_jweak(handle), "precondition");
153 #if INCLUDE_ALL_GCS
154 if (UseLoadBarrier) {
155 oop* ref_addr = jweak_ref_addr(handle);
156 return RootAccess<ON_PHANTOM_OOP_REF>::oop_load(ref_addr);
157 }
158 #endif
159
160 oop result = jweak_ref(handle);
161 #if INCLUDE_ALL_GCS
162 if (result != NULL && UseG1GC) {
163 G1BarrierSet::enqueue(result);
164 }
165 #endif // INCLUDE_ALL_GCS
166 return result;
167 }
168
169 bool JNIHandles::is_global_weak_cleared(jweak handle) {
170 assert(handle != NULL, "precondition");
171 assert(is_jweak(handle), "not a weak handle");
172 return jweak_ref(handle) == NULL;
173 }
174
|
134 }
135 return res;
136 }
137
138 // Resolve some erroneous cases to NULL, rather than treating them as
139 // possibly unchecked errors. In particular, deleted handles are
140 // treated as NULL (though a deleted and later reallocated handle
141 // isn't detected).
142 oop JNIHandles::resolve_external_guard(jobject handle) {
143 oop result = NULL;
144 if (handle != NULL) {
145 result = resolve_impl<true /* external_guard */ >(handle);
146 }
147 return result;
148 }
149
150 oop JNIHandles::resolve_jweak(jweak handle) {
151 assert(handle != NULL, "precondition");
152 assert(is_jweak(handle), "precondition");
153 #if INCLUDE_ALL_GCS
154 if (UseZGC) {
155 oop* ref_addr = jweak_ref_addr(handle);
156 return RootAccess<ON_PHANTOM_OOP_REF>::oop_load(ref_addr);
157 }
158 #endif
159
160 oop result = jweak_ref(handle);
161 #if INCLUDE_ALL_GCS
162 if (result != NULL && UseG1GC) {
163 G1BarrierSet::enqueue(result);
164 }
165 #endif // INCLUDE_ALL_GCS
166 return result;
167 }
168
169 bool JNIHandles::is_global_weak_cleared(jweak handle) {
170 assert(handle != NULL, "precondition");
171 assert(is_jweak(handle), "not a weak handle");
172 return jweak_ref(handle) == NULL;
173 }
174
|