annotate src/share/vm/gc_implementation/parallelScavenge/psPermGen.cpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children eda9eb483d29
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 470
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 470
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 470
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "gc_implementation/parallelScavenge/psPermGen.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "gc_implementation/shared/gcUtil.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "gc_implementation/shared/markSweep.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "oops/markOop.inline.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 PSPermGen::PSPermGen(ReservedSpace rs, size_t alignment,
a61af66fc99e Initial load
duke
parents:
diff changeset
35 size_t initial_size, size_t min_size, size_t max_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
36 const char* gen_name, int level) :
a61af66fc99e Initial load
duke
parents:
diff changeset
37 PSOldGen(rs, alignment, initial_size, min_size, max_size, gen_name, level),
a61af66fc99e Initial load
duke
parents:
diff changeset
38 _last_used(0)
a61af66fc99e Initial load
duke
parents:
diff changeset
39 {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 assert(object_mark_sweep() != NULL, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 object_mark_sweep()->set_allowed_dead_ratio(PermMarkSweepDeadRatio);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 _avg_size = new AdaptivePaddedAverage(AdaptivePermSizeWeight,
a61af66fc99e Initial load
duke
parents:
diff changeset
44 PermGenPadding);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 HeapWord* PSPermGen::allocate_permanent(size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 assert_locked_or_safepoint(Heap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 HeapWord* obj = allocate_noexpand(size, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if (obj == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 obj = expand_and_allocate(size, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 return obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void PSPermGen::compute_new_size(size_t used_before_collection) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Update our padded average of objects allocated in perm
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // gen between collections.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 assert(used_before_collection >= _last_used,
a61af66fc99e Initial load
duke
parents:
diff changeset
62 "negative allocation amount since last GC?");
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 const size_t alloc_since_last_gc = used_before_collection - _last_used;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 _avg_size->sample(alloc_since_last_gc);
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 const size_t current_live = used_in_bytes();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Stash away the current amount live for the next call to this method.
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _last_used = current_live;
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // We have different alignment constraints than the rest of the heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 const size_t alignment = MAX2(MinPermHeapExpansion,
a61af66fc99e Initial load
duke
parents:
diff changeset
73 virtual_space()->alignment());
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Compute the desired size:
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // The free space is the newly computed padded average,
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // so the desired size is what's live + the free space.
a61af66fc99e Initial load
duke
parents:
diff changeset
78 size_t desired_size = current_live + (size_t)_avg_size->padded_average();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 desired_size = align_size_up(desired_size, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // ...and no larger or smaller than our max and min allowed.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 desired_size = MAX2(MIN2(desired_size, _max_gen_size), _min_gen_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 assert(desired_size <= _max_gen_size, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 const size_t size_before = _virtual_space->committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 if (desired_size == size_before) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // no change, we're done
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // We'll be growing or shrinking the heap: in either case,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // we need to hold a lock.
a61af66fc99e Initial load
duke
parents:
diff changeset
95 MutexLocker x(ExpandHeap_lock);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 if (desired_size > size_before) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 const size_t change_bytes = desired_size - size_before;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 const size_t aligned_change_bytes =
a61af66fc99e Initial load
duke
parents:
diff changeset
99 align_size_up(change_bytes, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 expand_by(aligned_change_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // Shrinking
a61af66fc99e Initial load
duke
parents:
diff changeset
103 const size_t change_bytes =
a61af66fc99e Initial load
duke
parents:
diff changeset
104 size_before - desired_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 const size_t aligned_change_bytes = align_size_down(change_bytes, alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 shrink(aligned_change_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // While this code isn't controlled by AdaptiveSizePolicy, it's
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // convenient to see all resizing decsions under the same flag.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (PrintAdaptiveSizePolicy) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 gclog_or_tty->print_cr("AdaptiveSizePolicy::perm generation size: "
a61af66fc99e Initial load
duke
parents:
diff changeset
117 "collection: %d "
a61af66fc99e Initial load
duke
parents:
diff changeset
118 "(" SIZE_FORMAT ") -> (" SIZE_FORMAT ") ",
a61af66fc99e Initial load
duke
parents:
diff changeset
119 heap->total_collections(),
a61af66fc99e Initial load
duke
parents:
diff changeset
120 size_before, _virtual_space->committed_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 void PSPermGen::move_and_update(ParCompactionManager* cm) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 PSParallelCompact::move_and_update(cm, PSParallelCompact::perm_space_id);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 void PSPermGen::precompact() {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // Reset start array first.
a61af66fc99e Initial load
duke
parents:
diff changeset
132 _start_array.reset();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 object_mark_sweep()->precompact();
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }