9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
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 "gc/g1/concurrentMarkThread.inline.hpp"
27 #include "gc/g1/g1CollectedHeap.inline.hpp"
28 #include "gc/g1/g1CollectorPolicy.hpp"
29 #include "gc/shared/gcId.hpp"
30 #include "gc/g1/g1Log.hpp"
31 #include "gc/g1/vm_operations_g1.hpp"
32 #include "gc/shared/gcTimer.hpp"
33 #include "gc/shared/gcTraceTime.hpp"
34 #include "gc/shared/isGCActiveMark.hpp"
35 #include "runtime/interfaceSupport.hpp"
36
37 VM_G1CollectForAllocation::VM_G1CollectForAllocation(uint gc_count_before,
38 size_t word_size)
39 : VM_G1OperationWithAllocRequest(gc_count_before, word_size,
40 GCCause::_allocation_failure) {
41 guarantee(word_size != 0, "An allocation should always be requested with this operation.");
42 }
43
44 void VM_G1CollectForAllocation::doit() {
45 G1CollectedHeap* g1h = G1CollectedHeap::heap();
46 GCCauseSetter x(g1h, _gc_cause);
47
48 _result = g1h->satisfy_failed_allocation(_word_size, allocation_context(), &_pause_succeeded);
49 assert(_result == NULL || _pause_succeeded,
211 // with the SLT thread in order to acquire/release the PLL.
212 SurrogateLockerThread* slt = ConcurrentMarkThread::slt();
213 if (slt != NULL) {
214 slt->manipulatePLL(SurrogateLockerThread::acquirePLL);
215 } else {
216 SurrogateLockerThread::report_missing_slt();
217 }
218 }
219
220 void VM_CGC_Operation::release_and_notify_pending_list_lock() {
221 assert(_needs_pll, "don't call this otherwise");
222 // The caller may block while communicating
223 // with the SLT thread in order to acquire/release the PLL.
224 ConcurrentMarkThread::slt()->
225 manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL);
226 }
227
228 void VM_CGC_Operation::doit() {
229 TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
230 G1CollectedHeap* g1h = G1CollectedHeap::heap();
231 GCIdMark gc_id_mark(_gc_id);
232 GCTraceTime t(_printGCMessage, G1Log::fine(), true, g1h->gc_timer_cm());
233 IsGCActiveMark x;
234 _cl->do_void();
235 }
236
237 bool VM_CGC_Operation::doit_prologue() {
238 // Note the relative order of the locks must match that in
239 // VM_GC_Operation::doit_prologue() or deadlocks can occur
240 if (_needs_pll) {
241 acquire_pending_list_lock();
242 }
243
244 Heap_lock->lock();
245 return true;
246 }
247
248 void VM_CGC_Operation::doit_epilogue() {
249 // Note the relative order of the unlocks must match that in
250 // VM_GC_Operation::doit_epilogue()
251 Heap_lock->unlock();
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
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 "gc/g1/concurrentMarkThread.inline.hpp"
27 #include "gc/g1/g1CollectedHeap.inline.hpp"
28 #include "gc/g1/g1CollectorPolicy.hpp"
29 #include "gc/g1/g1Log.hpp"
30 #include "gc/g1/vm_operations_g1.hpp"
31 #include "gc/shared/gcTimer.hpp"
32 #include "gc/shared/gcTraceTime.hpp"
33 #include "gc/shared/isGCActiveMark.hpp"
34 #include "runtime/interfaceSupport.hpp"
35
36 VM_G1CollectForAllocation::VM_G1CollectForAllocation(uint gc_count_before,
37 size_t word_size)
38 : VM_G1OperationWithAllocRequest(gc_count_before, word_size,
39 GCCause::_allocation_failure) {
40 guarantee(word_size != 0, "An allocation should always be requested with this operation.");
41 }
42
43 void VM_G1CollectForAllocation::doit() {
44 G1CollectedHeap* g1h = G1CollectedHeap::heap();
45 GCCauseSetter x(g1h, _gc_cause);
46
47 _result = g1h->satisfy_failed_allocation(_word_size, allocation_context(), &_pause_succeeded);
48 assert(_result == NULL || _pause_succeeded,
210 // with the SLT thread in order to acquire/release the PLL.
211 SurrogateLockerThread* slt = ConcurrentMarkThread::slt();
212 if (slt != NULL) {
213 slt->manipulatePLL(SurrogateLockerThread::acquirePLL);
214 } else {
215 SurrogateLockerThread::report_missing_slt();
216 }
217 }
218
219 void VM_CGC_Operation::release_and_notify_pending_list_lock() {
220 assert(_needs_pll, "don't call this otherwise");
221 // The caller may block while communicating
222 // with the SLT thread in order to acquire/release the PLL.
223 ConcurrentMarkThread::slt()->
224 manipulatePLL(SurrogateLockerThread::releaseAndNotifyPLL);
225 }
226
227 void VM_CGC_Operation::doit() {
228 TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
229 G1CollectedHeap* g1h = G1CollectedHeap::heap();
230 GCTraceTime t(_printGCMessage, G1Log::fine(), true, g1h->gc_timer_cm());
231 IsGCActiveMark x;
232 _cl->do_void();
233 }
234
235 bool VM_CGC_Operation::doit_prologue() {
236 // Note the relative order of the locks must match that in
237 // VM_GC_Operation::doit_prologue() or deadlocks can occur
238 if (_needs_pll) {
239 acquire_pending_list_lock();
240 }
241
242 Heap_lock->lock();
243 return true;
244 }
245
246 void VM_CGC_Operation::doit_epilogue() {
247 // Note the relative order of the unlocks must match that in
248 // VM_GC_Operation::doit_epilogue()
249 Heap_lock->unlock();
|