Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.hpp @ 453:c96030fff130
6684579: SoftReference processing can be made more efficient
Summary: For current soft-ref clearing policies, we can decide at marking time if a soft-reference will definitely not be cleared, postponing the decision of whether it will definitely be cleared to the final reference processing phase. This can be especially beneficial in the case of concurrent collectors where the marking is usually concurrent but reference processing is usually not.
Reviewed-by: jmasa
author | ysr |
---|---|
date | Thu, 20 Nov 2008 16:56:09 -0800 |
parents | 81cd571500b0 |
children | ad8c8ca4ab0f |
rev | line source |
---|---|
0 | 1 /* |
2 * Copyright 2005-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 // | |
26 // psPromotionManager is used by a single thread to manage object survival | |
27 // during a scavenge. The promotion manager contains thread local data only. | |
28 // | |
29 // NOTE! Be carefull when allocating the stacks on cheap. If you are going | |
30 // to use a promotion manager in more than one thread, the stacks MUST be | |
31 // on cheap. This can lead to memory leaks, though, as they are not auto | |
32 // deallocated. | |
33 // | |
34 // FIX ME FIX ME Add a destructor, and don't rely on the user to drain/flush/deallocate! | |
35 // | |
36 | |
37 // Move to some global location | |
38 #define HAS_BEEN_MOVED 0x1501d01d | |
39 // End move to some global location | |
40 | |
41 | |
42 class MutableSpace; | |
43 class PSOldGen; | |
44 class ParCompactionManager; | |
45 class ObjectStartArray; | |
46 class ParallelCompactData; | |
47 class ParMarkBitMap; | |
48 | |
49 // Move to it's own file if this works out. | |
50 | |
51 class ParCompactionManager : public CHeapObj { | |
52 friend class ParallelTaskTerminator; | |
53 friend class ParMarkBitMap; | |
54 friend class PSParallelCompact; | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
55 friend class StealRegionCompactionTask; |
0 | 56 friend class UpdateAndFillClosure; |
57 friend class RefProcTaskExecutor; | |
58 | |
59 public: | |
60 | |
61 // ------------------------ Don't putback if not needed | |
62 // Actions that the compaction manager should take. | |
63 enum Action { | |
64 Update, | |
65 Copy, | |
66 UpdateAndCopy, | |
67 CopyAndUpdate, | |
68 VerifyUpdate, | |
69 ResetObjects, | |
70 NotValid | |
71 }; | |
72 // ------------------------ End don't putback if not needed | |
73 | |
74 private: | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
75 static ParCompactionManager** _manager_array; |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
76 static OopTaskQueueSet* _stack_array; |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
77 static ObjectStartArray* _start_array; |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
78 static RegionTaskQueueSet* _region_array; |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
79 static PSOldGen* _old_gen; |
0 | 80 |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
81 OopTaskQueue _marking_stack; |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
82 GrowableArray<oop>* _overflow_stack; |
0 | 83 // Is there a way to reuse the _marking_stack for the |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
84 // saving empty regions? For now just create a different |
0 | 85 // type of TaskQueue. |
86 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
87 #ifdef USE_RegionTaskQueueWithOverflow |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
88 RegionTaskQueueWithOverflow _region_stack; |
0 | 89 #else |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
90 RegionTaskQueue _region_stack; |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
91 GrowableArray<size_t>* _region_overflow_stack; |
0 | 92 #endif |
93 | |
94 #if 1 // does this happen enough to need a per thread stack? | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
95 GrowableArray<Klass*>* _revisit_klass_stack; |
0 | 96 #endif |
97 static ParMarkBitMap* _mark_bitmap; | |
98 | |
99 Action _action; | |
100 | |
101 static PSOldGen* old_gen() { return _old_gen; } | |
102 static ObjectStartArray* start_array() { return _start_array; } | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
103 static OopTaskQueueSet* stack_array() { return _stack_array; } |
0 | 104 |
105 static void initialize(ParMarkBitMap* mbm); | |
106 | |
107 protected: | |
108 // Array of tasks. Needed by the ParallelTaskTerminator. | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
109 static RegionTaskQueueSet* region_array() { return _region_array; } |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
110 OopTaskQueue* marking_stack() { return &_marking_stack; } |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
111 GrowableArray<oop>* overflow_stack() { return _overflow_stack; } |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
112 #ifdef USE_RegionTaskQueueWithOverflow |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
113 RegionTaskQueueWithOverflow* region_stack() { return &_region_stack; } |
0 | 114 #else |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
115 RegionTaskQueue* region_stack() { return &_region_stack; } |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
116 GrowableArray<size_t>* region_overflow_stack() { |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
117 return _region_overflow_stack; |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
118 } |
0 | 119 #endif |
120 | |
121 // Pushes onto the marking stack. If the marking stack is full, | |
122 // pushes onto the overflow stack. | |
123 void stack_push(oop obj); | |
124 // Do not implement an equivalent stack_pop. Deal with the | |
125 // marking stack and overflow stack directly. | |
126 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
127 // Pushes onto the region stack. If the region stack is full, |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
128 // pushes onto the region overflow stack. |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
129 void region_stack_push(size_t region_index); |
0 | 130 public: |
131 | |
132 Action action() { return _action; } | |
133 void set_action(Action v) { _action = v; } | |
134 | |
135 inline static ParCompactionManager* manager_array(int index); | |
136 | |
137 ParCompactionManager(); | |
138 ~ParCompactionManager(); | |
139 | |
140 void allocate_stacks(); | |
141 void deallocate_stacks(); | |
142 ParMarkBitMap* mark_bitmap() { return _mark_bitmap; } | |
143 | |
144 // Take actions in preparation for a compaction. | |
145 static void reset(); | |
146 | |
147 // void drain_stacks(); | |
148 | |
149 bool should_update(); | |
150 bool should_copy(); | |
151 bool should_verify_only(); | |
152 bool should_reset_only(); | |
153 | |
154 #if 1 | |
155 // Probably stays as a growable array | |
156 GrowableArray<Klass*>* revisit_klass_stack() { return _revisit_klass_stack; } | |
157 #endif | |
158 | |
159 // Save oop for later processing. Must not fail. | |
160 void save_for_scanning(oop m); | |
161 // Get a oop for scanning. If returns null, no oop were found. | |
162 oop retrieve_for_scanning(); | |
163 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
164 // Save region for later processing. Must not fail. |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
165 void save_for_processing(size_t region_index); |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
166 // Get a region for processing. If returns null, no region were found. |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
167 bool retrieve_for_processing(size_t& region_index); |
0 | 168 |
169 // Access function for compaction managers | |
170 static ParCompactionManager* gc_thread_compaction_manager(int index); | |
171 | |
172 static bool steal(int queue_num, int* seed, Task& t) { | |
173 return stack_array()->steal(queue_num, seed, t); | |
174 } | |
175 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
176 static bool steal(int queue_num, int* seed, RegionTask& t) { |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
177 return region_array()->steal(queue_num, seed, t); |
0 | 178 } |
179 | |
180 // Process tasks remaining on any stack | |
181 void drain_marking_stacks(OopClosure *blk); | |
182 | |
183 // Process tasks remaining on any stack | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
184 void drain_region_stacks(); |
0 | 185 |
186 // Process tasks remaining on any stack | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
187 void drain_region_overflow_stack(); |
0 | 188 |
189 // Debugging support | |
190 #ifdef ASSERT | |
191 bool stacks_have_been_allocated(); | |
192 #endif | |
193 }; | |
194 | |
195 inline ParCompactionManager* ParCompactionManager::manager_array(int index) { | |
196 assert(_manager_array != NULL, "access of NULL manager_array"); | |
197 assert(index >= 0 && index <= (int)ParallelGCThreads, | |
198 "out of range manager_array access"); | |
199 return _manager_array[index]; | |
200 } |