Mercurial > hg > graal-compiler
annotate src/share/vm/memory/cardTableRS.hpp @ 1751:2528b5bd749c
6980262: Memory leak when exception is thrown in static initializer
Summary: Use resource memory instead of c-heap for the exception message
Reviewed-by: phh, jmasa
author | kamg |
---|---|
date | Fri, 27 Aug 2010 15:05:28 -0400 |
parents | c18cbe5936b8 |
children | f95d63e2154a |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
diff
changeset
|
2 * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
356
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:
356
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 class Space; | |
26 class OopsInGenClosure; | |
27 class DirtyCardToOopClosure; | |
28 | |
29 // This kind of "GenRemSet" uses a card table both as shared data structure | |
30 // for a mod ref barrier set and for the rem set information. | |
31 | |
32 class CardTableRS: public GenRemSet { | |
33 friend class VMStructs; | |
34 // Below are private classes used in impl. | |
35 friend class VerifyCTSpaceClosure; | |
36 friend class ClearNoncleanCardWrapper; | |
37 | |
38 static jbyte clean_card_val() { | |
39 return CardTableModRefBS::clean_card; | |
40 } | |
41 | |
42 static bool | |
43 card_is_dirty_wrt_gen_iter(jbyte cv) { | |
44 return CardTableModRefBS::card_is_dirty_wrt_gen_iter(cv); | |
45 } | |
46 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
47 CardTableModRefBSForCTRS* _ct_bs; |
0 | 48 |
49 virtual void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl); | |
50 | |
51 void verify_space(Space* s, HeapWord* gen_start); | |
52 | |
53 enum ExtendedCardValue { | |
54 youngergen_card = CardTableModRefBS::CT_MR_BS_last_reserved + 1, | |
55 // These are for parallel collection. | |
56 // There are three P (parallel) youngergen card values. In general, this | |
57 // needs to be more than the number of generations (including the perm | |
58 // gen) that might have younger_refs_do invoked on them separately. So | |
59 // if we add more gens, we have to add more values. | |
60 youngergenP1_card = CardTableModRefBS::CT_MR_BS_last_reserved + 2, | |
61 youngergenP2_card = CardTableModRefBS::CT_MR_BS_last_reserved + 3, | |
62 youngergenP3_card = CardTableModRefBS::CT_MR_BS_last_reserved + 4, | |
63 cur_youngergen_and_prev_nonclean_card = | |
64 CardTableModRefBS::CT_MR_BS_last_reserved + 5 | |
65 }; | |
66 | |
67 // An array that contains, for each generation, the card table value last | |
68 // used as the current value for a younger_refs_do iteration of that | |
69 // portion of the table. (The perm gen is index 0; other gens are at | |
70 // their level plus 1. They youngest gen is in the table, but will | |
71 // always have the value "clean_card".) | |
72 jbyte* _last_cur_val_in_gen; | |
73 | |
74 jbyte _cur_youngergen_card_val; | |
75 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
76 int _regions_to_iterate; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
77 |
0 | 78 jbyte cur_youngergen_card_val() { |
79 return _cur_youngergen_card_val; | |
80 } | |
81 void set_cur_youngergen_card_val(jbyte v) { | |
82 _cur_youngergen_card_val = v; | |
83 } | |
84 bool is_prev_youngergen_card_val(jbyte v) { | |
85 return | |
86 youngergen_card <= v && | |
87 v < cur_youngergen_and_prev_nonclean_card && | |
88 v != _cur_youngergen_card_val; | |
89 } | |
90 // Return a youngergen_card_value that is not currently in use. | |
91 jbyte find_unused_youngergenP_card_value(); | |
92 | |
93 public: | |
94 CardTableRS(MemRegion whole_heap, int max_covered_regions); | |
95 | |
96 // *** GenRemSet functions. | |
97 GenRemSet::Name rs_kind() { return GenRemSet::CardTable; } | |
98 | |
99 CardTableRS* as_CardTableRS() { return this; } | |
100 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
101 CardTableModRefBS* ct_bs() { return _ct_bs; } |
0 | 102 |
103 // Override. | |
104 void prepare_for_younger_refs_iterate(bool parallel); | |
105 | |
106 // Card table entries are cleared before application; "blk" is | |
107 // responsible for dirtying if the oop is still older-to-younger after | |
108 // closure application. | |
109 void younger_refs_iterate(Generation* g, OopsInGenClosure* blk); | |
110 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
6
diff
changeset
|
111 void inline_write_ref_field_gc(void* field, oop new_val) { |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
112 jbyte* byte = _ct_bs->byte_for(field); |
0 | 113 *byte = youngergen_card; |
114 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
6
diff
changeset
|
115 void write_ref_field_gc_work(void* field, oop new_val) { |
0 | 116 inline_write_ref_field_gc(field, new_val); |
117 } | |
118 | |
119 // Override. Might want to devirtualize this in the same fashion as | |
120 // above. Ensures that the value of the card for field says that it's | |
121 // a younger card in the current collection. | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
6
diff
changeset
|
122 virtual void write_ref_field_gc_par(void* field, oop new_val); |
0 | 123 |
124 void resize_covered_region(MemRegion new_region); | |
125 | |
126 bool is_aligned(HeapWord* addr) { | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
127 return _ct_bs->is_card_aligned(addr); |
0 | 128 } |
129 | |
130 void verify(); | |
6
73e96e5c30df
6624765: Guarantee failure "Unexpected dirty card found"
jmasa
parents:
0
diff
changeset
|
131 void verify_aligned_region_empty(MemRegion mr); |
0 | 132 |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
133 void clear(MemRegion mr) { _ct_bs->clear(mr); } |
0 | 134 void clear_into_younger(Generation* gen, bool clear_perm); |
135 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
136 void invalidate(MemRegion mr, bool whole_heap = false) { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
137 _ct_bs->invalidate(mr, whole_heap); |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
138 } |
0 | 139 void invalidate_or_clear(Generation* gen, bool younger, bool perm); |
140 | |
141 static uintx ct_max_alignment_constraint() { | |
142 return CardTableModRefBS::ct_max_alignment_constraint(); | |
143 } | |
144 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
145 jbyte* byte_for(void* p) { return _ct_bs->byte_for(p); } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
146 jbyte* byte_after(void* p) { return _ct_bs->byte_after(p); } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
147 HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); } |
0 | 148 |
149 bool is_prev_nonclean_card_val(jbyte v) { | |
150 return | |
151 youngergen_card <= v && | |
152 v <= cur_youngergen_and_prev_nonclean_card && | |
153 v != _cur_youngergen_card_val; | |
154 } | |
155 | |
156 static bool youngergen_may_have_been_dirty(jbyte cv) { | |
157 return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card; | |
158 } | |
159 | |
160 }; |