37 38 ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL; 39 ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL; 40 jlong ReferenceProcessor::_soft_ref_timestamp_clock = 0; 41 42 void referenceProcessor_init() { 43 ReferenceProcessor::init_statics(); 44 } 45 46 void ReferenceProcessor::init_statics() { 47 // We need a monotonically non-decreasing time in ms but 48 // os::javaTimeMillis() does not guarantee monotonicity. 49 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; 50 51 // Initialize the soft ref timestamp clock. 52 _soft_ref_timestamp_clock = now; 53 // Also update the soft ref clock in j.l.r.SoftReference 54 java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock); 55 56 _always_clear_soft_ref_policy = new AlwaysClearPolicy(); 57 _default_soft_ref_policy = new COMPILER2_PRESENT(LRUMaxHeapPolicy()) 58 NOT_COMPILER2(LRUCurrentHeapPolicy()); 59 if (_always_clear_soft_ref_policy == NULL || _default_soft_ref_policy == NULL) { 60 vm_exit_during_initialization("Could not allocate reference policy object"); 61 } 62 guarantee(RefDiscoveryPolicy == ReferenceBasedDiscovery || 63 RefDiscoveryPolicy == ReferentBasedDiscovery, 64 "Unrecognized RefDiscoveryPolicy"); 65 } 66 67 void ReferenceProcessor::enable_discovery(bool check_no_refs) { 68 #ifdef ASSERT 69 // Verify that we're not currently discovering refs 70 assert(!_discovering_refs, "nested call?"); 71 72 if (check_no_refs) { 73 // Verify that the discovered lists are empty 74 verify_no_references_recorded(); 75 } 76 #endif // ASSERT 77 78 // Someone could have modified the value of the static | 37 38 ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL; 39 ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL; 40 jlong ReferenceProcessor::_soft_ref_timestamp_clock = 0; 41 42 void referenceProcessor_init() { 43 ReferenceProcessor::init_statics(); 44 } 45 46 void ReferenceProcessor::init_statics() { 47 // We need a monotonically non-decreasing time in ms but 48 // os::javaTimeMillis() does not guarantee monotonicity. 49 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; 50 51 // Initialize the soft ref timestamp clock. 52 _soft_ref_timestamp_clock = now; 53 // Also update the soft ref clock in j.l.r.SoftReference 54 java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock); 55 56 _always_clear_soft_ref_policy = new AlwaysClearPolicy(); 57 #if defined(COMPILER2) || INCLUDE_JVMCI 58 _default_soft_ref_policy = new LRUMaxHeapPolicy(); 59 #else 60 _default_soft_ref_policy = new LRUCurrentHeapPolicy(); 61 #endif 62 if (_always_clear_soft_ref_policy == NULL || _default_soft_ref_policy == NULL) { 63 vm_exit_during_initialization("Could not allocate reference policy object"); 64 } 65 guarantee(RefDiscoveryPolicy == ReferenceBasedDiscovery || 66 RefDiscoveryPolicy == ReferentBasedDiscovery, 67 "Unrecognized RefDiscoveryPolicy"); 68 } 69 70 void ReferenceProcessor::enable_discovery(bool check_no_refs) { 71 #ifdef ASSERT 72 // Verify that we're not currently discovering refs 73 assert(!_discovering_refs, "nested call?"); 74 75 if (check_no_refs) { 76 // Verify that the discovered lists are empty 77 verify_no_references_recorded(); 78 } 79 #endif // ASSERT 80 81 // Someone could have modified the value of the static |