38 #include "runtime/init.hpp"
39 #include "utilities/dtrace.hpp"
40 #include "utilities/macros.hpp"
41 #include "utilities/preserveException.hpp"
42 #if INCLUDE_G1GC
43 #include "gc/g1/g1CollectedHeap.inline.hpp"
44 #include "gc/g1/g1Policy.hpp"
45 #endif // INCLUDE_G1GC
46
47 VM_GC_Operation::~VM_GC_Operation() {
48 CollectedHeap* ch = Universe::heap();
49 ch->soft_ref_policy()->set_all_soft_refs_clear(false);
50 }
51
52 // The same dtrace probe can't be inserted in two different files, so we
53 // have to call it here, so it's only in one file. Can't create new probes
54 // for the other file anymore. The dtrace probes have to remain stable.
55 void VM_GC_Operation::notify_gc_begin(bool full) {
56 HOTSPOT_GC_BEGIN(
57 full);
58 HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
59 }
60
61 void VM_GC_Operation::notify_gc_end() {
62 HOTSPOT_GC_END();
63 HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
64 }
65
66 // Allocations may fail in several threads at about the same time,
67 // resulting in multiple gc requests. We only want to do one of them.
68 // In case a GC locker is active and the need for a GC is already signaled,
69 // we want to skip this GC attempt altogether, without doing a futile
70 // safepoint operation.
71 bool VM_GC_Operation::skip_operation() const {
72 bool skip = (_gc_count_before != Universe::heap()->total_collections());
73 if (_full && skip) {
74 skip = (_full_gc_count_before != Universe::heap()->total_full_collections());
75 }
76 if (!skip && GCLocker::is_active_and_needs_gc()) {
77 skip = Universe::heap()->is_maximal_no_gc();
78 assert(!(skip && (_gc_cause == GCCause::_gc_locker)),
79 "GCLocker cannot be active when initiating GC");
80 }
81 return skip;
82 }
83
|
38 #include "runtime/init.hpp"
39 #include "utilities/dtrace.hpp"
40 #include "utilities/macros.hpp"
41 #include "utilities/preserveException.hpp"
42 #if INCLUDE_G1GC
43 #include "gc/g1/g1CollectedHeap.inline.hpp"
44 #include "gc/g1/g1Policy.hpp"
45 #endif // INCLUDE_G1GC
46
47 VM_GC_Operation::~VM_GC_Operation() {
48 CollectedHeap* ch = Universe::heap();
49 ch->soft_ref_policy()->set_all_soft_refs_clear(false);
50 }
51
52 // The same dtrace probe can't be inserted in two different files, so we
53 // have to call it here, so it's only in one file. Can't create new probes
54 // for the other file anymore. The dtrace probes have to remain stable.
55 void VM_GC_Operation::notify_gc_begin(bool full) {
56 HOTSPOT_GC_BEGIN(
57 full);
58 }
59
60 void VM_GC_Operation::notify_gc_end() {
61 HOTSPOT_GC_END();
62 }
63
64 // Allocations may fail in several threads at about the same time,
65 // resulting in multiple gc requests. We only want to do one of them.
66 // In case a GC locker is active and the need for a GC is already signaled,
67 // we want to skip this GC attempt altogether, without doing a futile
68 // safepoint operation.
69 bool VM_GC_Operation::skip_operation() const {
70 bool skip = (_gc_count_before != Universe::heap()->total_collections());
71 if (_full && skip) {
72 skip = (_full_gc_count_before != Universe::heap()->total_full_collections());
73 }
74 if (!skip && GCLocker::is_active_and_needs_gc()) {
75 skip = Universe::heap()->is_maximal_no_gc();
76 assert(!(skip && (_gc_cause == GCCause::_gc_locker)),
77 "GCLocker cannot be active when initiating GC");
78 }
79 return skip;
80 }
81
|