Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.hpp @ 1286:ab75c83d7c37
Merge
author | johnc |
---|---|
date | Tue, 02 Mar 2010 13:57:46 -0800 |
parents | 89e0543e1737 |
children | 2a1472c30599 |
rev | line source |
---|---|
0 | 1 /* |
948 | 2 * Copyright 2005-2009 Sun Microsystems, Inc. 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 * | |
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; |
941 | 96 GrowableArray<DataLayout*>* _revisit_mdo_stack; |
0 | 97 #endif |
98 static ParMarkBitMap* _mark_bitmap; | |
99 | |
100 Action _action; | |
101 | |
102 static PSOldGen* old_gen() { return _old_gen; } | |
103 static ObjectStartArray* start_array() { return _start_array; } | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
104 static OopTaskQueueSet* stack_array() { return _stack_array; } |
0 | 105 |
106 static void initialize(ParMarkBitMap* mbm); | |
107 | |
108 protected: | |
109 // Array of tasks. Needed by the ParallelTaskTerminator. | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
110 static RegionTaskQueueSet* region_array() { return _region_array; } |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
111 OopTaskQueue* marking_stack() { return &_marking_stack; } |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
112 GrowableArray<oop>* overflow_stack() { return _overflow_stack; } |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
113 #ifdef USE_RegionTaskQueueWithOverflow |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
114 RegionTaskQueueWithOverflow* region_stack() { return &_region_stack; } |
0 | 115 #else |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
116 RegionTaskQueue* region_stack() { return &_region_stack; } |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
117 GrowableArray<size_t>* region_overflow_stack() { |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
118 return _region_overflow_stack; |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
119 } |
0 | 120 #endif |
121 | |
122 // Pushes onto the marking stack. If the marking stack is full, | |
123 // pushes onto the overflow stack. | |
124 void stack_push(oop obj); | |
125 // Do not implement an equivalent stack_pop. Deal with the | |
126 // marking stack and overflow stack directly. | |
127 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
128 // 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
|
129 // pushes onto the region overflow stack. |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
130 void region_stack_push(size_t region_index); |
0 | 131 public: |
132 | |
133 Action action() { return _action; } | |
134 void set_action(Action v) { _action = v; } | |
135 | |
136 inline static ParCompactionManager* manager_array(int index); | |
137 | |
138 ParCompactionManager(); | |
139 ~ParCompactionManager(); | |
140 | |
141 void allocate_stacks(); | |
142 void deallocate_stacks(); | |
143 ParMarkBitMap* mark_bitmap() { return _mark_bitmap; } | |
144 | |
145 // Take actions in preparation for a compaction. | |
146 static void reset(); | |
147 | |
148 // void drain_stacks(); | |
149 | |
150 bool should_update(); | |
151 bool should_copy(); | |
152 bool should_verify_only(); | |
153 bool should_reset_only(); | |
154 | |
155 #if 1 | |
156 // Probably stays as a growable array | |
157 GrowableArray<Klass*>* revisit_klass_stack() { return _revisit_klass_stack; } | |
941 | 158 GrowableArray<DataLayout*>* revisit_mdo_stack() { return _revisit_mdo_stack; } |
0 | 159 #endif |
160 | |
161 // Save oop for later processing. Must not fail. | |
162 void save_for_scanning(oop m); | |
163 // Get a oop for scanning. If returns null, no oop were found. | |
164 oop retrieve_for_scanning(); | |
165 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
166 // Save region for later processing. Must not fail. |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
167 void save_for_processing(size_t region_index); |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
168 // 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
|
169 bool retrieve_for_processing(size_t& region_index); |
0 | 170 |
171 // Access function for compaction managers | |
172 static ParCompactionManager* gc_thread_compaction_manager(int index); | |
173 | |
174 static bool steal(int queue_num, int* seed, Task& t) { | |
175 return stack_array()->steal(queue_num, seed, t); | |
176 } | |
177 | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
178 static bool steal(int queue_num, int* seed, RegionTask& t) { |
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
179 return region_array()->steal(queue_num, seed, t); |
0 | 180 } |
181 | |
182 // Process tasks remaining on any stack | |
183 void drain_marking_stacks(OopClosure *blk); | |
184 | |
185 // Process tasks remaining on any stack | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
186 void drain_region_stacks(); |
0 | 187 |
188 // Process tasks remaining on any stack | |
375
81cd571500b0
6725697: par compact - rename class ChunkData to RegionData
jcoomes
parents:
0
diff
changeset
|
189 void drain_region_overflow_stack(); |
0 | 190 |
191 // Debugging support | |
192 #ifdef ASSERT | |
193 bool stacks_have_been_allocated(); | |
194 #endif | |
195 }; | |
196 | |
197 inline ParCompactionManager* ParCompactionManager::manager_array(int index) { | |
198 assert(_manager_array != NULL, "access of NULL manager_array"); | |
199 assert(index >= 0 && index <= (int)ParallelGCThreads, | |
200 "out of range manager_array access"); | |
201 return _manager_array[index]; | |
202 } |