109 // Callback from VM_GenCollectForAllocation operation. 110 // This function does everything necessary/possible to satisfy an 111 // allocation request that failed in the youngest generation that should 112 // have handled it (including collection, expansion, etc.) 113 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab); 114 115 // Callback from VM_GenCollectFull operation. 116 // Perform a full collection of the first max_level+1 generations. 117 virtual void do_full_collection(bool clear_all_soft_refs); 118 void do_full_collection(bool clear_all_soft_refs, GenerationType max_generation); 119 120 // Does the "cause" of GC indicate that 121 // we absolutely __must__ clear soft refs? 122 bool must_clear_all_soft_refs(); 123 124 public: 125 GenCollectedHeap(GenCollectorPolicy *policy); 126 127 WorkGang* workers() const { return _workers; } 128 129 GCStats* gc_stats(Generation* generation) const; 130 131 // Returns JNI_OK on success 132 virtual jint initialize(); 133 134 // Reserve aligned space for the heap as needed by the contained generations. 135 char* allocate(size_t alignment, ReservedSpace* heap_rs); 136 137 // Does operations required after initialization has been done. 138 void post_initialize(); 139 140 // Initialize ("weak") refs processing support 141 virtual void ref_processing_init(); 142 143 virtual Name kind() const { 144 return CollectedHeap::GenCollectedHeap; 145 } 146 147 Generation* young_gen() const { return _young_gen; } 148 Generation* old_gen() const { return _old_gen; } 149 150 bool is_young_gen(const Generation* gen) const { return gen == _young_gen; } 365 // generations in a fully generational heap. 366 GenRemSet* rem_set() { return _rem_set; } 367 368 // Convenience function to be used in situations where the heap type can be 369 // asserted to be this type. 370 static GenCollectedHeap* heap(); 371 372 // Invoke the "do_oop" method of one of the closures "not_older_gens" 373 // or "older_gens" on root locations for the generations depending on 374 // the type. (The "older_gens" closure is used for scanning references 375 // from older generations; "not_older_gens" is used everywhere else.) 376 // If "younger_gens_as_roots" is false, younger generations are 377 // not scanned as roots; in this case, the caller must be arranging to 378 // scan the younger generations itself. (For example, a generation might 379 // explicitly mark reachable objects in younger generations, to avoid 380 // excess storage retention.) 381 // The "so" argument determines which of the roots 382 // the closure is applied to: 383 // "SO_None" does none; 384 enum ScanningOption { 385 SO_None = 0x0, 386 SO_AllCodeCache = 0x8, 387 SO_ScavengeCodeCache = 0x10 388 }; 389 390 private: 391 void process_roots(StrongRootsScope* scope, 392 ScanningOption so, 393 OopClosure* strong_roots, 394 OopClosure* weak_roots, 395 CLDClosure* strong_cld_closure, 396 CLDClosure* weak_cld_closure, 397 CodeBlobClosure* code_roots); 398 399 public: 400 static const bool StrongAndWeakRoots = false; 401 static const bool StrongRootsOnly = true; 402 403 void gen_process_roots(StrongRootsScope* scope, 404 GenerationType type, 405 bool young_gen_as_roots, 406 ScanningOption so, 407 bool only_strong_roots, 408 OopsInGenClosure* not_older_gens, 409 OopsInGenClosure* older_gens, 410 CLDClosure* cld_closure); 411 412 // Apply "root_closure" to all the weak roots of the system. 413 // These include JNI weak roots, string table, 414 // and referents of reachable weak refs. 415 void gen_process_weak_roots(OopClosure* root_closure); 416 417 // Set the saved marks of generations, if that makes sense. 418 // In particular, if any generation might iterate over the oops 419 // in other generations, it should call this method. 420 void save_marks(); 421 422 // Apply "cur->do_oop" or "older->do_oop" to all the oops in objects 423 // allocated since the last call to save_marks in generations at or above 424 // "level". The "cur" closure is 425 // applied to references in the generation at "level", and the "older" 426 // closure to older generations. 427 #define GCH_SINCE_SAVE_MARKS_ITERATE_DECL(OopClosureType, nv_suffix) \ 428 void oop_since_save_marks_iterate(GenerationType start_gen, \ 429 OopClosureType* cur, \ | 109 // Callback from VM_GenCollectForAllocation operation. 110 // This function does everything necessary/possible to satisfy an 111 // allocation request that failed in the youngest generation that should 112 // have handled it (including collection, expansion, etc.) 113 HeapWord* satisfy_failed_allocation(size_t size, bool is_tlab); 114 115 // Callback from VM_GenCollectFull operation. 116 // Perform a full collection of the first max_level+1 generations. 117 virtual void do_full_collection(bool clear_all_soft_refs); 118 void do_full_collection(bool clear_all_soft_refs, GenerationType max_generation); 119 120 // Does the "cause" of GC indicate that 121 // we absolutely __must__ clear soft refs? 122 bool must_clear_all_soft_refs(); 123 124 public: 125 GenCollectedHeap(GenCollectorPolicy *policy); 126 127 WorkGang* workers() const { return _workers; } 128 129 // Returns JNI_OK on success 130 virtual jint initialize(); 131 132 // Reserve aligned space for the heap as needed by the contained generations. 133 char* allocate(size_t alignment, ReservedSpace* heap_rs); 134 135 // Does operations required after initialization has been done. 136 void post_initialize(); 137 138 // Initialize ("weak") refs processing support 139 virtual void ref_processing_init(); 140 141 virtual Name kind() const { 142 return CollectedHeap::GenCollectedHeap; 143 } 144 145 Generation* young_gen() const { return _young_gen; } 146 Generation* old_gen() const { return _old_gen; } 147 148 bool is_young_gen(const Generation* gen) const { return gen == _young_gen; } 363 // generations in a fully generational heap. 364 GenRemSet* rem_set() { return _rem_set; } 365 366 // Convenience function to be used in situations where the heap type can be 367 // asserted to be this type. 368 static GenCollectedHeap* heap(); 369 370 // Invoke the "do_oop" method of one of the closures "not_older_gens" 371 // or "older_gens" on root locations for the generations depending on 372 // the type. (The "older_gens" closure is used for scanning references 373 // from older generations; "not_older_gens" is used everywhere else.) 374 // If "younger_gens_as_roots" is false, younger generations are 375 // not scanned as roots; in this case, the caller must be arranging to 376 // scan the younger generations itself. (For example, a generation might 377 // explicitly mark reachable objects in younger generations, to avoid 378 // excess storage retention.) 379 // The "so" argument determines which of the roots 380 // the closure is applied to: 381 // "SO_None" does none; 382 enum ScanningOption { 383 SO_None = 0x00, 384 SO_AllCodeCache = 0x08, 385 SO_ScavengeCodeCache = 0x10 386 }; 387 388 private: 389 void process_roots(StrongRootsScope* scope, 390 ScanningOption so, 391 OopClosure* strong_roots, 392 OopClosure* weak_roots, 393 CLDClosure* strong_cld_closure, 394 CLDClosure* weak_cld_closure, 395 CodeBlobClosure* code_roots); 396 397 public: 398 void young_process_roots(StrongRootsScope* scope, 399 OopsInGenClosure* not_older_gens, 400 OopsInGenClosure* older_gens, 401 CLDClosure* cld_closure); 402 403 void old_process_roots(StrongRootsScope* scope, 404 bool young_gen_as_roots, 405 ScanningOption so, 406 bool only_strong_roots, 407 OopsInGenClosure* not_older_gens, 408 CLDClosure* cld_closure); 409 410 // Apply "root_closure" to all the weak roots of the system. 411 // These include JNI weak roots, string table, 412 // and referents of reachable weak refs. 413 void gen_process_weak_roots(OopClosure* root_closure); 414 415 // Set the saved marks of generations, if that makes sense. 416 // In particular, if any generation might iterate over the oops 417 // in other generations, it should call this method. 418 void save_marks(); 419 420 // Apply "cur->do_oop" or "older->do_oop" to all the oops in objects 421 // allocated since the last call to save_marks in generations at or above 422 // "level". The "cur" closure is 423 // applied to references in the generation at "level", and the "older" 424 // closure to older generations. 425 #define GCH_SINCE_SAVE_MARKS_ITERATE_DECL(OopClosureType, nv_suffix) \ 426 void oop_since_save_marks_iterate(GenerationType start_gen, \ 427 OopClosureType* cur, \ |