< prev index next >

src/hotspot/share/gc/g1/g1VMOperations.cpp

Print this page

113 
114 void VM_G1CollectForAllocation::doit() {
115   G1CollectedHeap* g1h = G1CollectedHeap::heap();
116   GCCauseSetter x(g1h, _gc_cause);
117   // Try a partial collection of some kind.
118   g1h->do_collection_pause_at_safepoint(_word_size);
119 
120   if (_word_size > 0) {
121     // An allocation had been requested. Do it, eventually trying a stronger
122     // kind of GC.
123     _result = g1h->satisfy_failed_allocation(_word_size);
124   } else if (g1h->should_upgrade_to_full_gc()) {
125     // There has been a request to perform a GC to free some space. We have no
126     // information on how much memory has been asked for. In case there are
127     // absolutely no regions left to allocate into, do a full compaction.
128     g1h->upgrade_to_full_collection();
129   }
130 }
131 
132 void VM_G1PauseConcurrent::doit() {
133   GCIdMark gc_id_mark(_gc_id);
134   G1CollectedHeap* g1h = G1CollectedHeap::heap();






135   GCTraceCPUTime tcpu(g1h->concurrent_mark()->gc_tracer_cm());
136 
137   // GCTraceTime(...) only supports sub-phases, so a more verbose version
138   // is needed when we report the top-level pause phase.
139   GCTraceTimeLogger(Info, gc) logger(_message, GCCause::_no_gc, true);
140   GCTraceTimePauseTimer       timer(_message, g1h->concurrent_mark()->gc_timer_cm());
141   GCTraceTimeDriver           t(&logger, &timer);
142 
143   G1ConcGCMonitoringScope monitoring_scope(g1h->monitoring_support(), affects_memory_pools());
144   SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
145   IsSTWGCActiveMark x;
146 
147   work();
148 }
149 
150 bool VM_G1PauseConcurrent::doit_prologue() {
151   Heap_lock->lock();
152   G1CollectedHeap* g1h = G1CollectedHeap::heap();
153   if (g1h->is_shutting_down()) {

154     Heap_lock->unlock();
155     // JVM shutdown has started. Abort concurrent marking to ensure that any further
156     // concurrent VM operations will not try to start and interfere with the shutdown
157     // process.
158     g1h->concurrent_mark()->abort_marking_threads();
159     return false;
160   }
161   return true;
162 }
163 
164 void VM_G1PauseConcurrent::doit_epilogue() {
165   if (Universe::has_reference_pending_list()) {
166     Heap_lock->notify_all();
167   }
168   Heap_lock->unlock();
169 }
170 
171 void VM_G1PauseRemark::work() {
172   G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark();
173   cm->remark();
174 }
175 
176 void VM_G1PauseCleanup::work() {
177   G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark();
178   cm->cleanup();
179 }

















113 
114 void VM_G1CollectForAllocation::doit() {
115   G1CollectedHeap* g1h = G1CollectedHeap::heap();
116   GCCauseSetter x(g1h, _gc_cause);
117   // Try a partial collection of some kind.
118   g1h->do_collection_pause_at_safepoint(_word_size);
119 
120   if (_word_size > 0) {
121     // An allocation had been requested. Do it, eventually trying a stronger
122     // kind of GC.
123     _result = g1h->satisfy_failed_allocation(_word_size);
124   } else if (g1h->should_upgrade_to_full_gc()) {
125     // There has been a request to perform a GC to free some space. We have no
126     // information on how much memory has been asked for. In case there are
127     // absolutely no regions left to allocate into, do a full compaction.
128     g1h->upgrade_to_full_collection();
129   }
130 }
131 
132 void VM_G1PauseConcurrent::doit() {

133   G1CollectedHeap* g1h = G1CollectedHeap::heap();
134   if (_is_shutting_down) {
135     g1h->concurrent_mark()->shutdown_concurrent_cycle();
136     return;
137   }
138 
139   GCIdMark gc_id_mark(_gc_id);
140   GCTraceCPUTime tcpu(g1h->concurrent_mark()->gc_tracer_cm());
141 
142   // GCTraceTime(...) only supports sub-phases, so a more verbose version
143   // is needed when we report the top-level pause phase.
144   GCTraceTimeLogger(Info, gc) logger(_message, GCCause::_no_gc, true);
145   GCTraceTimePauseTimer       timer(_message, g1h->concurrent_mark()->gc_timer_cm());
146   GCTraceTimeDriver           t(&logger, &timer);
147 
148   G1ConcGCMonitoringScope monitoring_scope(g1h->monitoring_support(), affects_memory_pools());
149   SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
150   IsSTWGCActiveMark x;
151 
152   work();
153 }
154 
155 bool VM_G1PauseConcurrent::doit_prologue() {
156   Heap_lock->lock();
157   G1CollectedHeap* g1h = G1CollectedHeap::heap();
158   _is_shutting_down = g1h->is_shutting_down();
159   if (_is_shutting_down && !g1h->concurrent_mark()->shutdown_cleanup_needed()) {
160     Heap_lock->unlock();




161     return false;
162   }
163   return true;
164 }
165 
166 void VM_G1PauseConcurrent::doit_epilogue() {
167   if (Universe::has_reference_pending_list()) {
168     Heap_lock->notify_all();
169   }
170   Heap_lock->unlock();
171 }
172 
173 void VM_G1PauseRemark::work() {
174   G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark();
175   cm->remark();
176 }
177 
178 void VM_G1PauseCleanup::work() {
179   G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark();
180   cm->cleanup();
181 }
182 
183 bool VM_G1StopMarking::doit_prologue() {
184   G1CollectedHeap* g1h = G1CollectedHeap::heap();
185 #ifdef ASSERT
186   {
187     MutexLocker ml(Heap_lock);
188     assert(g1h->is_shutting_down(), "must be");
189   }
190 #endif
191   return g1h->concurrent_mark()->shutdown_cleanup_needed();
192 }
193 
194 void VM_G1StopMarking::doit() {
195   G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark();
196   cm->shutdown_concurrent_cycle();
197 }
< prev index next >