135 assert(*ptr == NULL, "invariant");
136 NativeAccess<ON_PHANTOM_OOP_REF>::oop_store(ptr, obj());
137 char* tptr = reinterpret_cast<char*>(ptr) + weak_tag_value;
138 res = reinterpret_cast<jobject>(tptr);
139 } else {
140 report_handle_allocation_failure(alloc_failmode, "weak global");
141 }
142 } else {
143 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
144 }
145 return res;
146 }
147
148 // Resolve some erroneous cases to NULL, rather than treating them as
149 // possibly unchecked errors. In particular, deleted handles are
150 // treated as NULL (though a deleted and later reallocated handle
151 // isn't detected).
152 oop JNIHandles::resolve_external_guard(jobject handle) {
153 oop result = NULL;
154 if (handle != NULL) {
155 result = resolve_impl<0 /* decorators */, true /* external_guard */>(handle);
156 }
157 return result;
158 }
159
160 bool JNIHandles::is_global_weak_cleared(jweak handle) {
161 assert(handle != NULL, "precondition");
162 assert(is_jweak(handle), "not a weak handle");
163 oop* oop_ptr = jweak_ptr(handle);
164 oop value = NativeAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(oop_ptr);
165 return value == NULL;
166 }
167
168 void JNIHandles::destroy_global(jobject handle) {
169 if (handle != NULL) {
170 assert(!is_jweak(handle), "wrong method for detroying jweak");
171 oop* oop_ptr = jobject_ptr(handle);
172 NativeAccess<>::oop_store(oop_ptr, (oop)NULL);
173 global_handles()->release(oop_ptr);
174 }
175 }
|
135 assert(*ptr == NULL, "invariant");
136 NativeAccess<ON_PHANTOM_OOP_REF>::oop_store(ptr, obj());
137 char* tptr = reinterpret_cast<char*>(ptr) + weak_tag_value;
138 res = reinterpret_cast<jobject>(tptr);
139 } else {
140 report_handle_allocation_failure(alloc_failmode, "weak global");
141 }
142 } else {
143 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
144 }
145 return res;
146 }
147
148 // Resolve some erroneous cases to NULL, rather than treating them as
149 // possibly unchecked errors. In particular, deleted handles are
150 // treated as NULL (though a deleted and later reallocated handle
151 // isn't detected).
152 oop JNIHandles::resolve_external_guard(jobject handle) {
153 oop result = NULL;
154 if (handle != NULL) {
155 result = resolve_impl<DECORATORS_NONE, true /* external_guard */>(handle);
156 }
157 return result;
158 }
159
160 bool JNIHandles::is_global_weak_cleared(jweak handle) {
161 assert(handle != NULL, "precondition");
162 assert(is_jweak(handle), "not a weak handle");
163 oop* oop_ptr = jweak_ptr(handle);
164 oop value = NativeAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(oop_ptr);
165 return value == NULL;
166 }
167
168 void JNIHandles::destroy_global(jobject handle) {
169 if (handle != NULL) {
170 assert(!is_jweak(handle), "wrong method for detroying jweak");
171 oop* oop_ptr = jobject_ptr(handle);
172 NativeAccess<>::oop_store(oop_ptr, (oop)NULL);
173 global_handles()->release(oop_ptr);
174 }
175 }
|