17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/javaClasses.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "gc_implementation/shared/gcTimer.hpp"
29 #include "gc_implementation/shared/gcTraceTime.hpp"
30 #include "gc_interface/collectedHeap.hpp"
31 #include "gc_interface/collectedHeap.inline.hpp"
32 #include "memory/referencePolicy.hpp"
33 #include "memory/referenceProcessor.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "runtime/java.hpp"
36 #include "runtime/jniHandles.hpp"
37
38 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
39
40 ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
41 ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL;
42 bool ReferenceProcessor::_pending_list_uses_discovered_field = false;
43 jlong ReferenceProcessor::_soft_ref_timestamp_clock = 0;
44
45 void referenceProcessor_init() {
46 ReferenceProcessor::init_statics();
47 }
48
49 void ReferenceProcessor::init_statics() {
50 // We need a monotonically non-deccreasing time in ms but
51 // os::javaTimeMillis() does not guarantee monotonicity.
52 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
53
54 // Initialize the soft ref timestamp clock.
55 _soft_ref_timestamp_clock = now;
56 // Also update the soft ref clock in j.l.r.SoftReference
289 void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
290 int count() { return _count; }
291 };
292 CountHandleClosure global_handle_count;
293 AlwaysAliveClosure always_alive;
294 JNIHandles::weak_oops_do(&always_alive, &global_handle_count);
295 return global_handle_count.count();
296 }
297 #endif
298
299 void ReferenceProcessor::process_phaseJNI(BoolObjectClosure* is_alive,
300 OopClosure* keep_alive,
301 VoidClosure* complete_gc) {
302 #ifndef PRODUCT
303 if (PrintGCDetails && PrintReferenceGC) {
304 unsigned int count = count_jni_refs();
305 gclog_or_tty->print(", %u refs", count);
306 }
307 #endif
308 JNIHandles::weak_oops_do(is_alive, keep_alive);
309 complete_gc->do_void();
310 }
311
312
313 template <class T>
314 bool enqueue_discovered_ref_helper(ReferenceProcessor* ref,
315 AbstractRefProcTaskExecutor* task_executor) {
316
317 // Remember old value of pending references list
318 T* pending_list_addr = (T*)java_lang_ref_Reference::pending_list_addr();
319 T old_pending_list_value = *pending_list_addr;
320
321 // Enqueue references that are not made active again, and
322 // clear the decks for the next collection (cycle).
323 ref->enqueue_discovered_reflists((HeapWord*)pending_list_addr, task_executor);
324 // Do the post-barrier on pending_list_addr missed in
325 // enqueue_discovered_reflist.
326 oopDesc::bs()->write_ref_field(pending_list_addr, oopDesc::load_decode_heap_oop(pending_list_addr));
327
328 // Stop treating discovered references specially.
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/javaClasses.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "gc_implementation/shared/gcTimer.hpp"
29 #include "gc_implementation/shared/gcTraceTime.hpp"
30 #include "gc_interface/collectedHeap.hpp"
31 #include "gc_interface/collectedHeap.inline.hpp"
32 #include "memory/referencePolicy.hpp"
33 #include "memory/referenceProcessor.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "runtime/java.hpp"
36 #include "runtime/jniHandles.hpp"
37 #if INCLUDE_JFR
38 #include "jfr/jfr.hpp"
39 #endif // INCLUDE_JFR
40
41 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
42
43 ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
44 ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL;
45 bool ReferenceProcessor::_pending_list_uses_discovered_field = false;
46 jlong ReferenceProcessor::_soft_ref_timestamp_clock = 0;
47
48 void referenceProcessor_init() {
49 ReferenceProcessor::init_statics();
50 }
51
52 void ReferenceProcessor::init_statics() {
53 // We need a monotonically non-deccreasing time in ms but
54 // os::javaTimeMillis() does not guarantee monotonicity.
55 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
56
57 // Initialize the soft ref timestamp clock.
58 _soft_ref_timestamp_clock = now;
59 // Also update the soft ref clock in j.l.r.SoftReference
292 void do_oop(narrowOop* unused) { ShouldNotReachHere(); }
293 int count() { return _count; }
294 };
295 CountHandleClosure global_handle_count;
296 AlwaysAliveClosure always_alive;
297 JNIHandles::weak_oops_do(&always_alive, &global_handle_count);
298 return global_handle_count.count();
299 }
300 #endif
301
302 void ReferenceProcessor::process_phaseJNI(BoolObjectClosure* is_alive,
303 OopClosure* keep_alive,
304 VoidClosure* complete_gc) {
305 #ifndef PRODUCT
306 if (PrintGCDetails && PrintReferenceGC) {
307 unsigned int count = count_jni_refs();
308 gclog_or_tty->print(", %u refs", count);
309 }
310 #endif
311 JNIHandles::weak_oops_do(is_alive, keep_alive);
312 JFR_ONLY(Jfr::weak_oops_do(is_alive, keep_alive));
313 complete_gc->do_void();
314 }
315
316
317 template <class T>
318 bool enqueue_discovered_ref_helper(ReferenceProcessor* ref,
319 AbstractRefProcTaskExecutor* task_executor) {
320
321 // Remember old value of pending references list
322 T* pending_list_addr = (T*)java_lang_ref_Reference::pending_list_addr();
323 T old_pending_list_value = *pending_list_addr;
324
325 // Enqueue references that are not made active again, and
326 // clear the decks for the next collection (cycle).
327 ref->enqueue_discovered_reflists((HeapWord*)pending_list_addr, task_executor);
328 // Do the post-barrier on pending_list_addr missed in
329 // enqueue_discovered_reflist.
330 oopDesc::bs()->write_ref_field(pending_list_addr, oopDesc::load_decode_heap_oop(pending_list_addr));
331
332 // Stop treating discovered references specially.
|