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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_GENCOLLECTEDHEAP_HPP
26 #define SHARE_VM_GC_SHARED_GENCOLLECTEDHEAP_HPP
27
28 #include "gc/shared/adaptiveSizePolicy.hpp"
29 #include "gc/shared/collectedHeap.hpp"
30 #include "gc/shared/collectorPolicy.hpp"
31 #include "gc/shared/generation.hpp"
32
33 class SubTasksDone;
34 class FlexibleWorkGang;
35
36 // A "GenCollectedHeap" is a CollectedHeap that uses generational
37 // collection. It has two generations, young and old.
38 class GenCollectedHeap : public CollectedHeap {
39 friend class GenCollectorPolicy;
40 friend class Generation;
41 friend class DefNewGeneration;
42 friend class TenuredGeneration;
43 friend class ConcurrentMarkSweepGeneration;
44 friend class CMSCollector;
45 friend class GenMarkSweep;
46 friend class VM_GenCollectForAllocation;
47 friend class VM_GenCollectFull;
48 friend class VM_GenCollectFullConcurrent;
49 friend class VM_GC_HeapInspection;
50 friend class VM_HeapDumper;
51 friend class HeapInspection;
52 friend class GCCauseSetter;
53 friend class VMStructs;
54 public:
346 virtual void do_generation(Generation* gen) = 0;
347 };
348
349 // Apply "cl.do_generation" to all generations in the heap
350 // If "old_to_young" determines the order.
351 void generation_iterate(GenClosure* cl, bool old_to_young);
352
353 // Return "true" if all generations have reached the
354 // maximal committed limit that they can reach, without a garbage
355 // collection.
356 virtual bool is_maximal_no_gc() const;
357
358 // This function returns the "GenRemSet" object that allows us to scan
359 // generations in a fully generational heap.
360 GenRemSet* rem_set() { return _rem_set; }
361
362 // Convenience function to be used in situations where the heap type can be
363 // asserted to be this type.
364 static GenCollectedHeap* heap();
365
366 void set_par_threads(uint t);
367 void set_n_termination(uint t);
368
369 // Invoke the "do_oop" method of one of the closures "not_older_gens"
370 // or "older_gens" on root locations for the generation at
371 // "level". (The "older_gens" closure is used for scanning references
372 // from older generations; "not_older_gens" is used everywhere else.)
373 // If "younger_gens_as_roots" is false, younger generations are
374 // not scanned as roots; in this case, the caller must be arranging to
375 // scan the younger generations itself. (For example, a generation might
376 // explicitly mark reachable objects in younger generations, to avoid
377 // excess storage retention.)
378 // The "so" argument determines which of the roots
379 // the closure is applied to:
380 // "SO_None" does none;
381 enum ScanningOption {
382 SO_None = 0x0,
383 SO_AllCodeCache = 0x8,
384 SO_ScavengeCodeCache = 0x10
385 };
386
387 private:
388 void process_roots(bool activate_scope,
389 ScanningOption so,
390 OopClosure* strong_roots,
391 OopClosure* weak_roots,
392 CLDClosure* strong_cld_closure,
393 CLDClosure* weak_cld_closure,
394 CodeBlobClosure* code_roots);
395
396 void gen_process_roots(int level,
397 bool younger_gens_as_roots,
398 bool activate_scope,
399 ScanningOption so,
400 OopsInGenClosure* not_older_gens,
401 OopsInGenClosure* weak_roots,
402 OopsInGenClosure* older_gens,
403 CLDClosure* cld_closure,
404 CLDClosure* weak_cld_closure,
405 CodeBlobClosure* code_closure);
406
407 public:
408 static const bool StrongAndWeakRoots = false;
409 static const bool StrongRootsOnly = true;
410
411 void gen_process_roots(int level,
412 bool younger_gens_as_roots,
413 bool activate_scope,
414 ScanningOption so,
415 bool only_strong_roots,
416 OopsInGenClosure* not_older_gens,
417 OopsInGenClosure* older_gens,
418 CLDClosure* cld_closure);
419
420 // Apply "root_closure" to all the weak roots of the system.
421 // These include JNI weak roots, string table,
422 // and referents of reachable weak refs.
423 void gen_process_weak_roots(OopClosure* root_closure);
424
425 // Set the saved marks of generations, if that makes sense.
426 // In particular, if any generation might iterate over the oops
427 // in other generations, it should call this method.
428 void save_marks();
429
430 // Apply "cur->do_oop" or "older->do_oop" to all the oops in objects
431 // allocated since the last call to save_marks in generations at or above
432 // "level". The "cur" closure is
433 // applied to references in the generation at "level", and the "older"
|
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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_GENCOLLECTEDHEAP_HPP
26 #define SHARE_VM_GC_SHARED_GENCOLLECTEDHEAP_HPP
27
28 #include "gc/shared/adaptiveSizePolicy.hpp"
29 #include "gc/shared/collectedHeap.hpp"
30 #include "gc/shared/collectorPolicy.hpp"
31 #include "gc/shared/generation.hpp"
32
33 class FlexibleWorkGang;
34 class StrongRootsScope;
35 class SubTasksDone;
36
37 // A "GenCollectedHeap" is a CollectedHeap that uses generational
38 // collection. It has two generations, young and old.
39 class GenCollectedHeap : public CollectedHeap {
40 friend class GenCollectorPolicy;
41 friend class Generation;
42 friend class DefNewGeneration;
43 friend class TenuredGeneration;
44 friend class ConcurrentMarkSweepGeneration;
45 friend class CMSCollector;
46 friend class GenMarkSweep;
47 friend class VM_GenCollectForAllocation;
48 friend class VM_GenCollectFull;
49 friend class VM_GenCollectFullConcurrent;
50 friend class VM_GC_HeapInspection;
51 friend class VM_HeapDumper;
52 friend class HeapInspection;
53 friend class GCCauseSetter;
54 friend class VMStructs;
55 public:
347 virtual void do_generation(Generation* gen) = 0;
348 };
349
350 // Apply "cl.do_generation" to all generations in the heap
351 // If "old_to_young" determines the order.
352 void generation_iterate(GenClosure* cl, bool old_to_young);
353
354 // Return "true" if all generations have reached the
355 // maximal committed limit that they can reach, without a garbage
356 // collection.
357 virtual bool is_maximal_no_gc() const;
358
359 // This function returns the "GenRemSet" object that allows us to scan
360 // generations in a fully generational heap.
361 GenRemSet* rem_set() { return _rem_set; }
362
363 // Convenience function to be used in situations where the heap type can be
364 // asserted to be this type.
365 static GenCollectedHeap* heap();
366
367 // Invoke the "do_oop" method of one of the closures "not_older_gens"
368 // or "older_gens" on root locations for the generation at
369 // "level". (The "older_gens" closure is used for scanning references
370 // from older generations; "not_older_gens" is used everywhere else.)
371 // If "younger_gens_as_roots" is false, younger generations are
372 // not scanned as roots; in this case, the caller must be arranging to
373 // scan the younger generations itself. (For example, a generation might
374 // explicitly mark reachable objects in younger generations, to avoid
375 // excess storage retention.)
376 // The "so" argument determines which of the roots
377 // the closure is applied to:
378 // "SO_None" does none;
379 enum ScanningOption {
380 SO_None = 0x0,
381 SO_AllCodeCache = 0x8,
382 SO_ScavengeCodeCache = 0x10
383 };
384
385 private:
386 void process_roots(StrongRootsScope* scope,
387 ScanningOption so,
388 OopClosure* strong_roots,
389 OopClosure* weak_roots,
390 CLDClosure* strong_cld_closure,
391 CLDClosure* weak_cld_closure,
392 CodeBlobClosure* code_roots);
393
394 public:
395 static const bool StrongAndWeakRoots = false;
396 static const bool StrongRootsOnly = true;
397
398 void gen_process_roots(StrongRootsScope* scope,
399 int level,
400 bool younger_gens_as_roots,
401 ScanningOption so,
402 bool only_strong_roots,
403 OopsInGenClosure* not_older_gens,
404 OopsInGenClosure* older_gens,
405 CLDClosure* cld_closure);
406
407 // Apply "root_closure" to all the weak roots of the system.
408 // These include JNI weak roots, string table,
409 // and referents of reachable weak refs.
410 void gen_process_weak_roots(OopClosure* root_closure);
411
412 // Set the saved marks of generations, if that makes sense.
413 // In particular, if any generation might iterate over the oops
414 // in other generations, it should call this method.
415 void save_marks();
416
417 // Apply "cur->do_oop" or "older->do_oop" to all the oops in objects
418 // allocated since the last call to save_marks in generations at or above
419 // "level". The "cur" closure is
420 // applied to references in the generation at "level", and the "older"
|