174 _weak_global_handles->release(&jweak_ref(handle)); 175 } 176 } 177 178 179 void JNIHandles::oops_do(OopClosure* f) { 180 _global_handles->oops_do(f); 181 } 182 183 184 void JNIHandles::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) { 185 _weak_global_handles->weak_oops_do(is_alive, f); 186 } 187 188 189 void JNIHandles::weak_oops_do(OopClosure* f) { 190 _weak_global_handles->weak_oops_do(f); 191 } 192 193 194 void JNIHandles::initialize() { 195 _global_handles = new OopStorage("JNI Global", 196 JNIGlobalAlloc_lock, 197 JNIGlobalActive_lock); 198 _weak_global_handles = new OopStorage("JNI Weak", 199 JNIWeakAlloc_lock, 200 JNIWeakActive_lock); 201 } 202 203 204 inline bool is_storage_handle(const OopStorage* storage, const oop* ptr) { 205 return storage->allocation_status(ptr) == OopStorage::ALLOCATED_ENTRY; 206 } 207 208 209 jobjectRefType JNIHandles::handle_type(Thread* thread, jobject handle) { 210 jobjectRefType result = JNIInvalidRefType; 211 if (is_jweak(handle)) { 212 if (is_storage_handle(_weak_global_handles, &jweak_ref(handle))) { 213 result = JNIWeakGlobalRefType; | 174 _weak_global_handles->release(&jweak_ref(handle)); 175 } 176 } 177 178 179 void JNIHandles::oops_do(OopClosure* f) { 180 _global_handles->oops_do(f); 181 } 182 183 184 void JNIHandles::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) { 185 _weak_global_handles->weak_oops_do(is_alive, f); 186 } 187 188 189 void JNIHandles::weak_oops_do(OopClosure* f) { 190 _weak_global_handles->weak_oops_do(f); 191 } 192 193 194 OopStorage* JNIHandles::weak_global_handles() { 195 return _weak_global_handles; 196 } 197 198 199 void JNIHandles::initialize() { 200 _global_handles = new OopStorage("JNI Global", 201 JNIGlobalAlloc_lock, 202 JNIGlobalActive_lock); 203 _weak_global_handles = new OopStorage("JNI Weak", 204 JNIWeakAlloc_lock, 205 JNIWeakActive_lock); 206 } 207 208 209 inline bool is_storage_handle(const OopStorage* storage, const oop* ptr) { 210 return storage->allocation_status(ptr) == OopStorage::ALLOCATED_ENTRY; 211 } 212 213 214 jobjectRefType JNIHandles::handle_type(Thread* thread, jobject handle) { 215 jobjectRefType result = JNIInvalidRefType; 216 if (is_jweak(handle)) { 217 if (is_storage_handle(_weak_global_handles, &jweak_ref(handle))) { 218 result = JNIWeakGlobalRefType; |