309 // Update statistics
310 ZStatSample(ZSamplerHeapUsedAfterMark, used());
311 ZStatHeap::set_at_mark_end(capacity(), allocated(), used());
312
313 // Block resurrection of weak/phantom references
314 ZResurrection::block();
315
316 // Process weak roots
317 _weak_roots_processor.process_weak_roots();
318
319 // Prepare to unload stale metadata and nmethods
320 _unload.prepare();
321
322 return true;
323 }
324
325 void ZHeap::set_soft_reference_policy(bool clear) {
326 _reference_processor.set_soft_reference_policy(clear);
327 }
328
329 class ZRendezvousClosure : public ThreadClosure {
330 public:
331 virtual void do_thread(Thread* thread) {}
332 };
333
334 void ZHeap::process_non_strong_references() {
335 // Process Soft/Weak/Final/PhantomReferences
336 _reference_processor.process_references();
337
338 // Process concurrent weak roots
339 _weak_roots_processor.process_concurrent_weak_roots();
340
341 // Unlink stale metadata and nmethods
342 _unload.unlink();
343
344 // Perform a handshake. This is needed 1) to make sure that stale
345 // metadata and nmethods are no longer observable. And 2), to
346 // prevent the race where a mutator first loads an oop, which is
347 // logically null but not yet cleared. Then this oop gets cleared
348 // by the reference processor and resurrection is unblocked. At
349 // this point the mutator could see the unblocked state and pass
350 // this invalid oop through the normal barrier path, which would
351 // incorrectly try to mark the oop.
352 ZRendezvousClosure cl;
353 Handshake::execute(&cl);
354
355 // Purge stale metadata and nmethods that were unlinked
356 _unload.purge();
357
358 // Unblock resurrection of weak/phantom references
359 ZResurrection::unblock();
360
361 // Enqueue Soft/Weak/Final/PhantomReferences. Note that this
362 // must be done after unblocking resurrection. Otherwise the
363 // Finalizer thread could call Reference.get() on the Finalizers
364 // that were just enqueued, which would incorrectly return null
365 // during the resurrection block window, since such referents
366 // are only Finalizable marked.
367 _reference_processor.enqueue_references();
368 }
369
370 void ZHeap::select_relocation_set() {
371 // Do not allow pages to be deleted
372 _page_allocator.enable_deferred_delete();
373
|
309 // Update statistics
310 ZStatSample(ZSamplerHeapUsedAfterMark, used());
311 ZStatHeap::set_at_mark_end(capacity(), allocated(), used());
312
313 // Block resurrection of weak/phantom references
314 ZResurrection::block();
315
316 // Process weak roots
317 _weak_roots_processor.process_weak_roots();
318
319 // Prepare to unload stale metadata and nmethods
320 _unload.prepare();
321
322 return true;
323 }
324
325 void ZHeap::set_soft_reference_policy(bool clear) {
326 _reference_processor.set_soft_reference_policy(clear);
327 }
328
329 class ZRendezvousClosure : public HandshakeOperation {
330 public:
331 ZRendezvousClosure() : HandshakeOperation("ZRendezvous") {}
332 void do_thread(JavaThread* thread) {}
333 };
334
335 void ZHeap::process_non_strong_references() {
336 // Process Soft/Weak/Final/PhantomReferences
337 _reference_processor.process_references();
338
339 // Process concurrent weak roots
340 _weak_roots_processor.process_concurrent_weak_roots();
341
342 // Unlink stale metadata and nmethods
343 _unload.unlink();
344
345 // Perform a handshake. This is needed 1) to make sure that stale
346 // metadata and nmethods are no longer observable. And 2), to
347 // prevent the race where a mutator first loads an oop, which is
348 // logically null but not yet cleared. Then this oop gets cleared
349 // by the reference processor and resurrection is unblocked. At
350 // this point the mutator could see the unblocked state and pass
351 // this invalid oop through the normal barrier path, which would
352 // incorrectly try to mark the oop.
353 ZRendezvousClosure zr_hs;
354 Handshake::execute(&zr_hs);
355
356 // Purge stale metadata and nmethods that were unlinked
357 _unload.purge();
358
359 // Unblock resurrection of weak/phantom references
360 ZResurrection::unblock();
361
362 // Enqueue Soft/Weak/Final/PhantomReferences. Note that this
363 // must be done after unblocking resurrection. Otherwise the
364 // Finalizer thread could call Reference.get() on the Finalizers
365 // that were just enqueued, which would incorrectly return null
366 // during the resurrection block window, since such referents
367 // are only Finalizable marked.
368 _reference_processor.enqueue_references();
369 }
370
371 void ZHeap::select_relocation_set() {
372 // Do not allow pages to be deleted
373 _page_allocator.enable_deferred_delete();
374
|