Tue, 07 Oct 2008 11:01:35 -0700
Merge
1 /*
2 * Copyright (c) 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 */
25 # include "incls/_precompiled.incl"
26 # include "incls/_vmPSOperations.cpp.incl"
28 // The following methods are used by the parallel scavenge collector
29 VM_ParallelGCFailedAllocation::VM_ParallelGCFailedAllocation(size_t size,
30 bool is_tlab, unsigned int gc_count) :
31 VM_GC_Operation(gc_count),
32 _size(size),
33 _is_tlab(is_tlab),
34 _result(NULL)
35 {
36 }
38 void VM_ParallelGCFailedAllocation::doit() {
39 JvmtiGCForAllocationMarker jgcm;
40 notify_gc_begin(false);
42 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
43 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "must be a ParallelScavengeHeap");
45 GCCauseSetter gccs(heap, _gc_cause);
46 _result = heap->failed_mem_allocate(_size, _is_tlab);
48 if (_result == NULL && GC_locker::is_active_and_needs_gc()) {
49 set_gc_locked();
50 }
52 notify_gc_end();
53 }
55 VM_ParallelGCFailedPermanentAllocation::VM_ParallelGCFailedPermanentAllocation(size_t size,
56 unsigned int gc_count, unsigned int full_gc_count) :
57 VM_GC_Operation(gc_count, full_gc_count, true /* full */),
58 _size(size),
59 _result(NULL)
60 {
61 }
63 void VM_ParallelGCFailedPermanentAllocation::doit() {
64 JvmtiGCFullMarker jgcm;
65 notify_gc_begin(true);
67 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
68 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "must be a ParallelScavengeHeap");
70 GCCauseSetter gccs(heap, _gc_cause);
71 _result = heap->failed_permanent_mem_allocate(_size);
72 if (_result == NULL && GC_locker::is_active_and_needs_gc()) {
73 set_gc_locked();
74 }
75 notify_gc_end();
76 }
78 // Only used for System.gc() calls
79 VM_ParallelGCSystemGC::VM_ParallelGCSystemGC(unsigned int gc_count,
80 unsigned int full_gc_count,
81 GCCause::Cause gc_cause) :
82 VM_GC_Operation(gc_count, full_gc_count, true /* full */)
83 {
84 _gc_cause = gc_cause;
85 }
87 void VM_ParallelGCSystemGC::doit() {
88 JvmtiGCFullMarker jgcm;
89 notify_gc_begin(true);
91 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
92 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap,
93 "must be a ParallelScavengeHeap");
95 GCCauseSetter gccs(heap, _gc_cause);
96 if (_gc_cause == GCCause::_gc_locker
97 DEBUG_ONLY(|| _gc_cause == GCCause::_scavenge_alot)) {
98 // If (and only if) the scavenge fails, this will invoke a full gc.
99 heap->invoke_scavenge();
100 } else {
101 heap->invoke_full_gc(false);
102 }
103 notify_gc_end();
104 }