< prev index next >

src/hotspot/share/gc/serial/defNewGeneration.cpp

Print this page




  39 #include "gc/shared/generationSpec.hpp"
  40 #include "gc/shared/preservedMarks.inline.hpp"
  41 #include "gc/shared/referencePolicy.hpp"
  42 #include "gc/shared/space.inline.hpp"
  43 #include "gc/shared/spaceDecorator.hpp"
  44 #include "gc/shared/strongRootsScope.hpp"
  45 #include "gc/shared/weakProcessor.hpp"
  46 #include "logging/log.hpp"
  47 #include "memory/iterator.hpp"
  48 #include "memory/resourceArea.hpp"
  49 #include "oops/instanceRefKlass.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "runtime/atomic.hpp"
  52 #include "runtime/java.hpp"
  53 #include "runtime/prefetch.inline.hpp"
  54 #include "runtime/thread.inline.hpp"
  55 #include "utilities/align.hpp"
  56 #include "utilities/copy.hpp"
  57 #include "utilities/globalDefinitions.hpp"
  58 #include "utilities/stack.inline.hpp"
  59 #if INCLUDE_ALL_GCS
  60 #include "gc/cms/parOopClosures.hpp"
  61 #endif
  62 
  63 //
  64 // DefNewGeneration functions.
  65 
  66 // Methods of protected closure types.
  67 
  68 DefNewGeneration::IsAliveClosure::IsAliveClosure(Generation* young_gen) : _young_gen(young_gen) {
  69   assert(_young_gen->kind() == Generation::ParNew ||
  70          _young_gen->kind() == Generation::DefNew, "Expected the young generation here");
  71 }
  72 
  73 bool DefNewGeneration::IsAliveClosure::do_object_b(oop p) {
  74   return (HeapWord*)p >= _young_gen->reserved().end() || p->is_forwarded();
  75 }
  76 
  77 DefNewGeneration::KeepAliveClosure::
  78 KeepAliveClosure(ScanWeakRefClosure* cl) : _cl(cl) {
  79   _rs = GenCollectedHeap::heap()->rem_set();


 989 }
 990 
 991 
 992 const char* DefNewGeneration::name() const {
 993   return "def new generation";
 994 }
 995 
 996 // Moved from inline file as they are not called inline
 997 CompactibleSpace* DefNewGeneration::first_compaction_space() const {
 998   return eden();
 999 }
1000 
1001 HeapWord* DefNewGeneration::allocate(size_t word_size, bool is_tlab) {
1002   // This is the slow-path allocation for the DefNewGeneration.
1003   // Most allocations are fast-path in compiled code.
1004   // We try to allocate from the eden.  If that works, we are happy.
1005   // Note that since DefNewGeneration supports lock-free allocation, we
1006   // have to use it here, as well.
1007   HeapWord* result = eden()->par_allocate(word_size);
1008   if (result != NULL) {
1009 #if INCLUDE_ALL_GCS
1010     if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
1011       _old_gen->sample_eden_chunk();
1012     }
1013 #endif
1014   } else {
1015     // If the eden is full and the last collection bailed out, we are running
1016     // out of heap space, and we try to allocate the from-space, too.
1017     // allocate_from_space can't be inlined because that would introduce a
1018     // circular dependency at compile time.
1019     result = allocate_from_space(word_size);
1020   }
1021   return result;
1022 }
1023 
1024 HeapWord* DefNewGeneration::par_allocate(size_t word_size,
1025                                          bool is_tlab) {
1026   HeapWord* res = eden()->par_allocate(word_size);
1027 #if INCLUDE_ALL_GCS
1028   if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
1029     _old_gen->sample_eden_chunk();
1030   }
1031 #endif
1032   return res;
1033 }
1034 
1035 size_t DefNewGeneration::tlab_capacity() const {
1036   return eden()->capacity();
1037 }
1038 
1039 size_t DefNewGeneration::tlab_used() const {
1040   return eden()->used();
1041 }
1042 
1043 size_t DefNewGeneration::unsafe_max_tlab_alloc() const {
1044   return unsafe_max_alloc_nogc();
1045 }


  39 #include "gc/shared/generationSpec.hpp"
  40 #include "gc/shared/preservedMarks.inline.hpp"
  41 #include "gc/shared/referencePolicy.hpp"
  42 #include "gc/shared/space.inline.hpp"
  43 #include "gc/shared/spaceDecorator.hpp"
  44 #include "gc/shared/strongRootsScope.hpp"
  45 #include "gc/shared/weakProcessor.hpp"
  46 #include "logging/log.hpp"
  47 #include "memory/iterator.hpp"
  48 #include "memory/resourceArea.hpp"
  49 #include "oops/instanceRefKlass.hpp"
  50 #include "oops/oop.inline.hpp"
  51 #include "runtime/atomic.hpp"
  52 #include "runtime/java.hpp"
  53 #include "runtime/prefetch.inline.hpp"
  54 #include "runtime/thread.inline.hpp"
  55 #include "utilities/align.hpp"
  56 #include "utilities/copy.hpp"
  57 #include "utilities/globalDefinitions.hpp"
  58 #include "utilities/stack.inline.hpp"
  59 #if INCLUDE_CMSGC
  60 #include "gc/cms/parOopClosures.hpp"
  61 #endif
  62 
  63 //
  64 // DefNewGeneration functions.
  65 
  66 // Methods of protected closure types.
  67 
  68 DefNewGeneration::IsAliveClosure::IsAliveClosure(Generation* young_gen) : _young_gen(young_gen) {
  69   assert(_young_gen->kind() == Generation::ParNew ||
  70          _young_gen->kind() == Generation::DefNew, "Expected the young generation here");
  71 }
  72 
  73 bool DefNewGeneration::IsAliveClosure::do_object_b(oop p) {
  74   return (HeapWord*)p >= _young_gen->reserved().end() || p->is_forwarded();
  75 }
  76 
  77 DefNewGeneration::KeepAliveClosure::
  78 KeepAliveClosure(ScanWeakRefClosure* cl) : _cl(cl) {
  79   _rs = GenCollectedHeap::heap()->rem_set();


 989 }
 990 
 991 
 992 const char* DefNewGeneration::name() const {
 993   return "def new generation";
 994 }
 995 
 996 // Moved from inline file as they are not called inline
 997 CompactibleSpace* DefNewGeneration::first_compaction_space() const {
 998   return eden();
 999 }
1000 
1001 HeapWord* DefNewGeneration::allocate(size_t word_size, bool is_tlab) {
1002   // This is the slow-path allocation for the DefNewGeneration.
1003   // Most allocations are fast-path in compiled code.
1004   // We try to allocate from the eden.  If that works, we are happy.
1005   // Note that since DefNewGeneration supports lock-free allocation, we
1006   // have to use it here, as well.
1007   HeapWord* result = eden()->par_allocate(word_size);
1008   if (result != NULL) {
1009 #if INCLUDE_CMSGC
1010     if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
1011       _old_gen->sample_eden_chunk();
1012     }
1013 #endif
1014   } else {
1015     // If the eden is full and the last collection bailed out, we are running
1016     // out of heap space, and we try to allocate the from-space, too.
1017     // allocate_from_space can't be inlined because that would introduce a
1018     // circular dependency at compile time.
1019     result = allocate_from_space(word_size);
1020   }
1021   return result;
1022 }
1023 
1024 HeapWord* DefNewGeneration::par_allocate(size_t word_size,
1025                                          bool is_tlab) {
1026   HeapWord* res = eden()->par_allocate(word_size);
1027 #if INCLUDE_CMSGC
1028   if (CMSEdenChunksRecordAlways && _old_gen != NULL) {
1029     _old_gen->sample_eden_chunk();
1030   }
1031 #endif
1032   return res;
1033 }
1034 
1035 size_t DefNewGeneration::tlab_capacity() const {
1036   return eden()->capacity();
1037 }
1038 
1039 size_t DefNewGeneration::tlab_used() const {
1040   return eden()->used();
1041 }
1042 
1043 size_t DefNewGeneration::unsafe_max_tlab_alloc() const {
1044   return unsafe_max_alloc_nogc();
1045 }
< prev index next >