annotate src/share/vm/memory/tenuredGeneration.hpp @ 452:00b023ae2d78

6722113: CMS: Incorrect overflow handling during precleaning of Reference lists Summary: When we encounter marking stack overflow during precleaning of Reference lists, we were using the overflow list mechanism, which can cause problems on account of mutating the mark word of the header because of conflicts with mutator accesses and updates of that field. Instead we should use the usual mechanism for overflow handling in concurrent phases, namely dirtying of the card on which the overflowed object lies. Since precleaning effectively does a form of discovered list processing, albeit with discovery enabled, we needed to adjust some code to be correct in the face of interleaved processing and discovery. Reviewed-by: apetrusenko, jcoomes
author ysr
date Thu, 20 Nov 2008 12:27:41 -0800
parents 122d10c82f3f
children ad8c8ca4ab0f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // TenuredGeneration models the heap containing old (promoted/tenured) objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 class ParGCAllocBufferWithBOT;
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 class TenuredGeneration: public OneContigSpaceCardGeneration {
a61af66fc99e Initial load
duke
parents:
diff changeset
30 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // current shrinking effect: this damps shrinking when the heap gets empty.
a61af66fc99e Initial load
duke
parents:
diff changeset
33 size_t _shrink_factor;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // Some statistics from before gc started.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // These are gathered in the gc_prologue (and should_collect)
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // to control growing/shrinking policy in spite of promotions.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 size_t _capacity_at_prologue;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 size_t _used_at_prologue;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // To support parallel promotion: an array of parallel allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // buffers, one per thread, initially NULL.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 ParGCAllocBufferWithBOT** _alloc_buffers;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // Retire all alloc buffers before a full GC, so that they will be
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // re-allocated at the start of the next young GC.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 void retire_alloc_buffers_before_full_gc();
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 GenerationCounters* _gen_counters;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 CSpaceCounters* _space_counters;
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
54 TenuredGeneration(ReservedSpace rs, size_t initial_byte_size, int level,
a61af66fc99e Initial load
duke
parents:
diff changeset
55 GenRemSet* remset);
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 Generation::Name kind() { return Generation::MarkSweepCompact; }
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
60 const char* name() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 const char* short_name() const { return "Tenured"; }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 bool must_be_youngest() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 bool must_be_oldest() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Does a "full" (forced) collection invoked on this generation collect
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // all younger generations as well? Note that this is a
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // hack to allow the collection of the younger gen first if the flag is
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // set. This is better than using th policy's should_collect_gen0_first()
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // since that causes us to do an extra unnecessary pair of restart-&-stop-world.
a61af66fc99e Initial load
duke
parents:
diff changeset
70 virtual bool full_collects_younger_generations() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return !CollectGen0First;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // Mark sweep support
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void compute_new_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 virtual void gc_prologue(bool full);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 virtual void gc_epilogue(bool full);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 bool should_collect(bool full,
a61af66fc99e Initial load
duke
parents:
diff changeset
80 size_t word_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
81 bool is_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 virtual void collect(bool full,
a61af66fc99e Initial load
duke
parents:
diff changeset
84 bool clear_all_soft_refs,
a61af66fc99e Initial load
duke
parents:
diff changeset
85 size_t size,
a61af66fc99e Initial load
duke
parents:
diff changeset
86 bool is_tlab);
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Overrides.
a61af66fc99e Initial load
duke
parents:
diff changeset
90 virtual oop par_promote(int thread_num,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 oop obj, markOop m, size_t word_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 virtual void par_promote_alloc_undo(int thread_num,
a61af66fc99e Initial load
duke
parents:
diff changeset
93 HeapWord* obj, size_t word_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 virtual void par_promote_alloc_done(int thread_num);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // Performance Counter support
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void update_counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Statistics
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 virtual void update_gc_stats(int level, bool full);
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 virtual bool promotion_attempt_is_safe(size_t max_promoted_in_bytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
105 bool younger_handles_promotion_failure) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 void verify_alloc_buffers_clean();
a61af66fc99e Initial load
duke
parents:
diff changeset
108 };