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;
384 static GenCollectedHeap* heap();
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 CLDClosure* strong_cld_closure,
400 CLDClosure* weak_cld_closure,
401 CodeBlobToOopClosure* code_roots);
402
403 void process_string_table_roots(StrongRootsScope* scope,
404 OopClosure* root_closure);
405
406 // Accessor for memory state verification support
407 NOT_PRODUCT(
408 virtual size_t skip_header_HeapWords() { return 0; }
409 )
410
411 virtual void gc_prologue(bool full);
412 virtual void gc_epilogue(bool full);
413
414 public:
415 void young_process_roots(StrongRootsScope* scope,
416 OopsInGenClosure* root_closure,
417 OopsInGenClosure* old_gen_closure,
418 CLDClosure* cld_closure);
419
420 void full_process_roots(StrongRootsScope* scope,
421 bool is_adjust_phase,
422 ScanningOption so,
423 bool only_strong_roots,
424 OopsInGenClosure* root_closure,
425 CLDClosure* cld_closure);
426
427 // Apply "root_closure" to all the weak roots of the system.
428 // These include JNI weak roots, string table,
429 // and referents of reachable weak refs.
430 void gen_process_weak_roots(OopClosure* root_closure);
431
432 // Set the saved marks of generations, if that makes sense.
433 // In particular, if any generation might iterate over the oops
434 // in other generations, it should call this method.
435 void save_marks();
436
437 // Returns "true" iff no allocations have occurred since the last
438 // call to "save_marks".
439 bool no_allocs_since_save_marks();
440
441 // Returns true if an incremental collection is likely to fail.
442 // We optionally consult the young gen, if asked to do so;
443 // otherwise we base our answer on whether the previous incremental
444 // collection attempt failed with no corrective action as of yet.
445 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;
385 static GenCollectedHeap* heap();
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 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 OopStorage::ParState<false, false>* par_state_string);
407
408 // Accessor for memory state verification support
409 NOT_PRODUCT(
410 virtual size_t skip_header_HeapWords() { return 0; }
411 )
412
413 virtual void gc_prologue(bool full);
414 virtual void gc_epilogue(bool full);
415
416 public:
417 void young_process_roots(StrongRootsScope* scope,
418 OopsInGenClosure* root_closure,
419 OopsInGenClosure* old_gen_closure,
420 CLDClosure* cld_closure,
421 OopStorage::ParState<false, false>* par_state_string = NULL);
422
423 void full_process_roots(StrongRootsScope* scope,
424 bool is_adjust_phase,
425 ScanningOption so,
426 bool only_strong_roots,
427 OopsInGenClosure* root_closure,
428 CLDClosure* cld_closure,
429 OopStorage::ParState<false, false>* par_state_string = NULL);
430
431 // Apply "root_closure" to all the weak roots of the system.
432 // These include JNI weak roots, string table,
433 // and referents of reachable weak refs.
434 void gen_process_weak_roots(OopClosure* root_closure);
435
436 // Set the saved marks of generations, if that makes sense.
437 // In particular, if any generation might iterate over the oops
438 // in other generations, it should call this method.
439 void save_marks();
440
441 // Returns "true" iff no allocations have occurred since the last
442 // call to "save_marks".
443 bool no_allocs_since_save_marks();
444
445 // Returns true if an incremental collection is likely to fail.
446 // We optionally consult the young gen, if asked to do so;
447 // otherwise we base our answer on whether the previous incremental
448 // collection attempt failed with no corrective action as of yet.
449 bool incremental_collection_will_fail(bool consult_young) {
|