comparison src/share/vm/gc_implementation/g1/vm_operations_g1.cpp @ 342:37f87013dfd8

6711316: Open source the Garbage-First garbage collector Summary: First mercurial integration of the code for the Garbage-First garbage collector. Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr
author ysr
date Thu, 05 Jun 2008 15:57:56 -0700
parents
children 96b229c54d1e
comparison
equal deleted inserted replaced
189:0b27f3512f9e 342:37f87013dfd8
1 /*
2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 #include "incls/_precompiled.incl"
26 #include "incls/_vm_operations_g1.cpp.incl"
27
28 void VM_G1CollectForAllocation::doit() {
29 JvmtiGCForAllocationMarker jgcm;
30 G1CollectedHeap* g1h = G1CollectedHeap::heap();
31 _res = g1h->satisfy_failed_allocation(_size);
32 assert(g1h->is_in_or_null(_res), "result not in heap");
33 }
34
35 void VM_G1CollectFull::doit() {
36 JvmtiGCFullMarker jgcm;
37 G1CollectedHeap* g1h = G1CollectedHeap::heap();
38 GCCauseSetter x(g1h, _gc_cause);
39 g1h->do_full_collection(false /* clear_all_soft_refs */);
40 }
41
42 void VM_G1IncCollectionPause::doit() {
43 JvmtiGCForAllocationMarker jgcm;
44 G1CollectedHeap* g1h = G1CollectedHeap::heap();
45 GCCauseSetter x(g1h, GCCause::_g1_inc_collection_pause);
46 g1h->do_collection_pause_at_safepoint(NULL);
47 }
48
49 void VM_G1PopRegionCollectionPause::doit() {
50 JvmtiGCForAllocationMarker jgcm;
51 G1CollectedHeap* g1h = G1CollectedHeap::heap();
52 g1h->do_collection_pause_at_safepoint(_pop_region);
53 }
54
55
56 void VM_CGC_Operation::doit() {
57 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
58 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
59 TraceTime t(_printGCMessage, PrintGC, true, gclog_or_tty);
60 SharedHeap* sh = SharedHeap::heap();
61 // This could go away if CollectedHeap gave access to _gc_is_active...
62 if (sh != NULL) {
63 IsGCActiveMark x;
64 _cl->do_void();
65 } else {
66 _cl->do_void();
67 }
68 }
69
70 bool VM_CGC_Operation::doit_prologue() {
71 Heap_lock->lock();
72 SharedHeap::heap()->_thread_holds_heap_lock_for_gc = true;
73 return true;
74 }
75
76 void VM_CGC_Operation::doit_epilogue() {
77 SharedHeap::heap()->_thread_holds_heap_lock_for_gc = false;
78 Heap_lock->unlock();
79 }