235 // Weak global JNI references. It would make more sense (semantically) to
236 // traverse these simultaneously with the regular weak references above, but
237 // that is not how the JDK1.2 specification is. See #4126360. Native code can
238 // thus use JNI weak references to circumvent the phantom references and
239 // resurrect a "post-mortem" object.
240 {
241 TraceTime tt("JNI Weak Reference", trace_time, false, gclog_or_tty);
242 if (task_executor != NULL) {
243 task_executor->set_single_threaded_mode();
244 }
245 process_phaseJNI(is_alive, keep_alive, complete_gc);
246 }
247 }
248
249 #ifndef PRODUCT
250 // Calculate the number of jni handles.
251 uint ReferenceProcessor::count_jni_refs() {
252 class AlwaysAliveClosure: public BoolObjectClosure {
253 public:
254 virtual bool do_object_b(oop obj) { return true; }
255 virtual void do_object(oop obj) { assert(false, "Don't call"); }
256 };
257
258 class CountHandleClosure: public OopClosure {
259 private:
260 int _count;
261 public:
262 CountHandleClosure(): _count(0) {}
263 void do_oop(oop* unused) { _count++; }
264 void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
265 int count() { return _count; }
266 };
267 CountHandleClosure global_handle_count;
268 AlwaysAliveClosure always_alive;
269 JNIHandles::weak_oops_do(&always_alive, &global_handle_count);
270 return global_handle_count.count();
271 }
272 #endif
273
274 void ReferenceProcessor::process_phaseJNI(BoolObjectClosure* is_alive,
275 OopClosure* keep_alive,
|
235 // Weak global JNI references. It would make more sense (semantically) to
236 // traverse these simultaneously with the regular weak references above, but
237 // that is not how the JDK1.2 specification is. See #4126360. Native code can
238 // thus use JNI weak references to circumvent the phantom references and
239 // resurrect a "post-mortem" object.
240 {
241 TraceTime tt("JNI Weak Reference", trace_time, false, gclog_or_tty);
242 if (task_executor != NULL) {
243 task_executor->set_single_threaded_mode();
244 }
245 process_phaseJNI(is_alive, keep_alive, complete_gc);
246 }
247 }
248
249 #ifndef PRODUCT
250 // Calculate the number of jni handles.
251 uint ReferenceProcessor::count_jni_refs() {
252 class AlwaysAliveClosure: public BoolObjectClosure {
253 public:
254 virtual bool do_object_b(oop obj) { return true; }
255 };
256
257 class CountHandleClosure: public OopClosure {
258 private:
259 int _count;
260 public:
261 CountHandleClosure(): _count(0) {}
262 void do_oop(oop* unused) { _count++; }
263 void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
264 int count() { return _count; }
265 };
266 CountHandleClosure global_handle_count;
267 AlwaysAliveClosure always_alive;
268 JNIHandles::weak_oops_do(&always_alive, &global_handle_count);
269 return global_handle_count.count();
270 }
271 #endif
272
273 void ReferenceProcessor::process_phaseJNI(BoolObjectClosure* is_alive,
274 OopClosure* keep_alive,
|