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 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/collectedHeap.hpp"
29 #include "gc/shared/collectorPolicy.hpp"
30 #include "gc/shared/generation.hpp"
31 #include "gc/shared/softRefGenPolicy.hpp"
32
33 class AdaptiveSizePolicy;
34 class GCPolicyCounters;
35 class GenerationSpec;
36 class StrongRootsScope;
37 class SubTasksDone;
38 class WorkGang;
39
40 // A "GenCollectedHeap" is a CollectedHeap that uses generational
41 // collection. It has two generations, young and old.
42 class GenCollectedHeap : public CollectedHeap {
43 friend class GenCollectorPolicy;
44 friend class Generation;
45 friend class DefNewGeneration;
46 friend class TenuredGeneration;
47 friend class ConcurrentMarkSweepGeneration;
48 friend class CMSCollector;
49 friend class GenMarkSweep;
50 friend class VM_GenCollectForAllocation;
385
386 // The ScanningOption determines which of the roots
387 // the closure is applied to:
388 // "SO_None" does none;
389 enum ScanningOption {
390 SO_None = 0x0,
391 SO_AllCodeCache = 0x8,
392 SO_ScavengeCodeCache = 0x10
393 };
394
395 protected:
396 void process_roots(StrongRootsScope* scope,
397 ScanningOption so,
398 OopClosure* strong_roots,
399 OopClosure* weak_roots,
400 CLDClosure* strong_cld_closure,
401 CLDClosure* weak_cld_closure,
402 CodeBlobToOopClosure* code_roots);
403
404 void process_string_table_roots(StrongRootsScope* scope,
405 OopClosure* root_closure);
406
407 // Accessor for memory state verification support
408 NOT_PRODUCT(
409 virtual size_t skip_header_HeapWords() { return 0; }
410 )
411
412 virtual void gc_prologue(bool full);
413 virtual void gc_epilogue(bool full);
414
415 public:
416 void young_process_roots(StrongRootsScope* scope,
417 OopsInGenClosure* root_closure,
418 OopsInGenClosure* old_gen_closure,
419 CLDClosure* cld_closure);
420
421 void full_process_roots(StrongRootsScope* scope,
422 bool is_adjust_phase,
423 ScanningOption so,
424 bool only_strong_roots,
425 OopsInGenClosure* root_closure,
426 CLDClosure* cld_closure);
427
428 // Apply "root_closure" to all the weak roots of the system.
429 // These include JNI weak roots, string table,
430 // and referents of reachable weak refs.
431 void gen_process_weak_roots(OopClosure* root_closure);
432
433 // Set the saved marks of generations, if that makes sense.
434 // In particular, if any generation might iterate over the oops
435 // in other generations, it should call this method.
436 void save_marks();
437
438 // Returns "true" iff no allocations have occurred since the last
439 // call to "save_marks".
440 bool no_allocs_since_save_marks();
441
442 // Returns true if an incremental collection is likely to fail.
443 // We optionally consult the young gen, if asked to do so;
444 // otherwise we base our answer on whether the previous incremental
445 // collection attempt failed with no corrective action as of yet.
446 bool incremental_collection_will_fail(bool consult_young) {
|
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 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/collectedHeap.hpp"
29 #include "gc/shared/collectorPolicy.hpp"
30 #include "gc/shared/generation.hpp"
31 #include "gc/shared/oopStorageParState.hpp"
32 #include "gc/shared/softRefGenPolicy.hpp"
33
34 class AdaptiveSizePolicy;
35 class GCPolicyCounters;
36 class GenerationSpec;
37 class StrongRootsScope;
38 class SubTasksDone;
39 class WorkGang;
40
41 // A "GenCollectedHeap" is a CollectedHeap that uses generational
42 // collection. It has two generations, young and old.
43 class GenCollectedHeap : public CollectedHeap {
44 friend class GenCollectorPolicy;
45 friend class Generation;
46 friend class DefNewGeneration;
47 friend class TenuredGeneration;
48 friend class ConcurrentMarkSweepGeneration;
49 friend class CMSCollector;
50 friend class GenMarkSweep;
51 friend class VM_GenCollectForAllocation;
386
387 // The ScanningOption determines which of the roots
388 // the closure is applied to:
389 // "SO_None" does none;
390 enum ScanningOption {
391 SO_None = 0x0,
392 SO_AllCodeCache = 0x8,
393 SO_ScavengeCodeCache = 0x10
394 };
395
396 protected:
397 void process_roots(StrongRootsScope* scope,
398 ScanningOption so,
399 OopClosure* strong_roots,
400 OopClosure* weak_roots,
401 CLDClosure* strong_cld_closure,
402 CLDClosure* weak_cld_closure,
403 CodeBlobToOopClosure* code_roots);
404
405 void process_string_table_roots(StrongRootsScope* scope,
406 OopClosure* root_closure,
407 OopStorage::ParState<false, false>* par_state_string);
408
409 // Accessor for memory state verification support
410 NOT_PRODUCT(
411 virtual size_t skip_header_HeapWords() { return 0; }
412 )
413
414 virtual void gc_prologue(bool full);
415 virtual void gc_epilogue(bool full);
416
417 public:
418 void young_process_roots(StrongRootsScope* scope,
419 OopsInGenClosure* root_closure,
420 OopsInGenClosure* old_gen_closure,
421 CLDClosure* cld_closure,
422 OopStorage::ParState<false, false>* par_state_string = NULL);
423
424 void full_process_roots(StrongRootsScope* scope,
425 bool is_adjust_phase,
426 ScanningOption so,
427 bool only_strong_roots,
428 OopsInGenClosure* root_closure,
429 CLDClosure* cld_closure,
430 OopStorage::ParState<false, false>* par_state_string = NULL);
431
432 // Apply "root_closure" to all the weak roots of the system.
433 // These include JNI weak roots, string table,
434 // and referents of reachable weak refs.
435 void gen_process_weak_roots(OopClosure* root_closure);
436
437 // Set the saved marks of generations, if that makes sense.
438 // In particular, if any generation might iterate over the oops
439 // in other generations, it should call this method.
440 void save_marks();
441
442 // Returns "true" iff no allocations have occurred since the last
443 // call to "save_marks".
444 bool no_allocs_since_save_marks();
445
446 // Returns true if an incremental collection is likely to fail.
447 // We optionally consult the young gen, if asked to do so;
448 // otherwise we base our answer on whether the previous incremental
449 // collection attempt failed with no corrective action as of yet.
450 bool incremental_collection_will_fail(bool consult_young) {
|