Print this page


Split Split Close
Expand all
Collapse all
          --- old/src/share/vm/memory/defNewGeneration.cpp
          +++ new/src/share/vm/memory/defNewGeneration.cpp
↓ open down ↓ 996 lines elided ↑ open up ↑
 997  997  
 998  998  HeapWord* DefNewGeneration::allocate(size_t word_size,
 999  999                                       bool is_tlab) {
1000 1000    // This is the slow-path allocation for the DefNewGeneration.
1001 1001    // Most allocations are fast-path in compiled code.
1002 1002    // We try to allocate from the eden.  If that works, we are happy.
1003 1003    // Note that since DefNewGeneration supports lock-free allocation, we
1004 1004    // have to use it here, as well.
1005 1005    HeapWord* result = eden()->par_allocate(word_size);
1006 1006    if (result != NULL) {
     1007 +    if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
     1008 +      _next_gen->sample_eden_chunk();
     1009 +    }
1007 1010      return result;
1008 1011    }
1009 1012    do {
1010 1013      HeapWord* old_limit = eden()->soft_end();
1011 1014      if (old_limit < eden()->end()) {
1012 1015        // Tell the next generation we reached a limit.
1013 1016        HeapWord* new_limit =
1014 1017          next_gen()->allocation_limit_reached(eden(), eden()->top(), word_size);
1015 1018        if (new_limit != NULL) {
1016 1019          Atomic::cmpxchg_ptr(new_limit, eden()->soft_end_addr(), old_limit);
↓ open down ↓ 10 lines elided ↑ open up ↑
1027 1030      // Try to allocate until succeeded or the soft limit can't be adjusted
1028 1031      result = eden()->par_allocate(word_size);
1029 1032    } while (result == NULL);
1030 1033  
1031 1034    // If the eden is full and the last collection bailed out, we are running
1032 1035    // out of heap space, and we try to allocate the from-space, too.
1033 1036    // allocate_from_space can't be inlined because that would introduce a
1034 1037    // circular dependency at compile time.
1035 1038    if (result == NULL) {
1036 1039      result = allocate_from_space(word_size);
     1040 +  } else if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
     1041 +    _next_gen->sample_eden_chunk();
1037 1042    }
1038 1043    return result;
1039 1044  }
1040 1045  
1041 1046  HeapWord* DefNewGeneration::par_allocate(size_t word_size,
1042 1047                                           bool is_tlab) {
1043      -  return eden()->par_allocate(word_size);
     1048 +  HeapWord* res = eden()->par_allocate(word_size);
     1049 +  if (CMSEdenChunksRecordAlways && _next_gen != NULL) {
     1050 +    _next_gen->sample_eden_chunk();
     1051 +  }
     1052 +  return res;
1044 1053  }
1045 1054  
1046 1055  void DefNewGeneration::gc_prologue(bool full) {
1047 1056    // Ensure that _end and _soft_end are the same in eden space.
1048 1057    eden()->set_soft_end(eden()->end());
1049 1058  }
1050 1059  
1051 1060  size_t DefNewGeneration::tlab_capacity() const {
1052 1061    return eden()->capacity();
1053 1062  }
1054 1063  
1055 1064  size_t DefNewGeneration::unsafe_max_tlab_alloc() const {
1056 1065    return unsafe_max_alloc_nogc();
1057 1066  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX