47 void referenceProcessor_init() {
48 ReferenceProcessor::init_statics();
49 }
50
51 void ReferenceProcessor::init_statics() {
52 // We need a monotonically non-decreasing time in ms but
53 // os::javaTimeMillis() does not guarantee monotonicity.
54 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
55
56 // Initialize the soft ref timestamp clock.
57 _soft_ref_timestamp_clock = now;
58 // Also update the soft ref clock in j.l.r.SoftReference
59 java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock);
60
61 _always_clear_soft_ref_policy = new AlwaysClearPolicy();
62 if (is_server_compilation_mode_vm()) {
63 _default_soft_ref_policy = new LRUMaxHeapPolicy();
64 } else {
65 _default_soft_ref_policy = new LRUCurrentHeapPolicy();
66 }
67 if (_always_clear_soft_ref_policy == NULL || _default_soft_ref_policy == NULL) {
68 vm_exit_during_initialization("Could not allocate reference policy object");
69 }
70 guarantee(RefDiscoveryPolicy == ReferenceBasedDiscovery ||
71 RefDiscoveryPolicy == ReferentBasedDiscovery,
72 "Unrecognized RefDiscoveryPolicy");
73 }
74
75 void ReferenceProcessor::enable_discovery(bool check_no_refs) {
76 #ifdef ASSERT
77 // Verify that we're not currently discovering refs
78 assert(!_discovering_refs, "nested call?");
79
80 if (check_no_refs) {
81 // Verify that the discovered lists are empty
82 verify_no_references_recorded();
83 }
84 #endif // ASSERT
85
86 // Someone could have modified the value of the static
87 // field in the j.l.r.SoftReference class that holds the
88 // soft reference timestamp clock using reflection or
89 // Unsafe between GCs. Unconditionally update the static
|
47 void referenceProcessor_init() {
48 ReferenceProcessor::init_statics();
49 }
50
51 void ReferenceProcessor::init_statics() {
52 // We need a monotonically non-decreasing time in ms but
53 // os::javaTimeMillis() does not guarantee monotonicity.
54 jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
55
56 // Initialize the soft ref timestamp clock.
57 _soft_ref_timestamp_clock = now;
58 // Also update the soft ref clock in j.l.r.SoftReference
59 java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock);
60
61 _always_clear_soft_ref_policy = new AlwaysClearPolicy();
62 if (is_server_compilation_mode_vm()) {
63 _default_soft_ref_policy = new LRUMaxHeapPolicy();
64 } else {
65 _default_soft_ref_policy = new LRUCurrentHeapPolicy();
66 }
67 guarantee(RefDiscoveryPolicy == ReferenceBasedDiscovery ||
68 RefDiscoveryPolicy == ReferentBasedDiscovery,
69 "Unrecognized RefDiscoveryPolicy");
70 }
71
72 void ReferenceProcessor::enable_discovery(bool check_no_refs) {
73 #ifdef ASSERT
74 // Verify that we're not currently discovering refs
75 assert(!_discovering_refs, "nested call?");
76
77 if (check_no_refs) {
78 // Verify that the discovered lists are empty
79 verify_no_references_recorded();
80 }
81 #endif // ASSERT
82
83 // Someone could have modified the value of the static
84 // field in the j.l.r.SoftReference class that holds the
85 // soft reference timestamp clock using reflection or
86 // Unsafe between GCs. Unconditionally update the static
|