src/share/vm/memory/defNewGeneration.inline.hpp

changeset 548
ba764ed4b6f2
parent 435
a61af66fc99e
child 631
d1605aabd0a1
     1.1 --- a/src/share/vm/memory/defNewGeneration.inline.hpp	Fri Apr 11 09:56:35 2008 -0400
     1.2 +++ b/src/share/vm/memory/defNewGeneration.inline.hpp	Sun Apr 13 17:43:42 2008 -0400
     1.3 @@ -22,67 +22,60 @@
     1.4   *
     1.5   */
     1.6  
     1.7 -CompactibleSpace* DefNewGeneration::first_compaction_space() const {
     1.8 -  return eden();
     1.9 +// Methods of protected closure types
    1.10 +
    1.11 +template <class T>
    1.12 +inline void DefNewGeneration::KeepAliveClosure::do_oop_work(T* p) {
    1.13 +#ifdef ASSERT
    1.14 +  {
    1.15 +    // We never expect to see a null reference being processed
    1.16 +    // as a weak reference.
    1.17 +    assert (!oopDesc::is_null(*p), "expected non-null ref");
    1.18 +    oop obj = oopDesc::load_decode_heap_oop_not_null(p);
    1.19 +    assert (obj->is_oop(), "expected an oop while scanning weak refs");
    1.20 +  }
    1.21 +#endif // ASSERT
    1.22 +
    1.23 +  _cl->do_oop_nv(p);
    1.24 +
    1.25 +  // Card marking is trickier for weak refs.
    1.26 +  // This oop is a 'next' field which was filled in while we
    1.27 +  // were discovering weak references. While we might not need
    1.28 +  // to take a special action to keep this reference alive, we
    1.29 +  // will need to dirty a card as the field was modified.
    1.30 +  //
    1.31 +  // Alternatively, we could create a method which iterates through
    1.32 +  // each generation, allowing them in turn to examine the modified
    1.33 +  // field.
    1.34 +  //
    1.35 +  // We could check that p is also in an older generation, but
    1.36 +  // dirty cards in the youngest gen are never scanned, so the
    1.37 +  // extra check probably isn't worthwhile.
    1.38 +  if (Universe::heap()->is_in_reserved(p)) {
    1.39 +    oop obj = oopDesc::load_decode_heap_oop_not_null(p);
    1.40 +    _rs->inline_write_ref_field_gc(p, obj);
    1.41 +  }
    1.42  }
    1.43  
    1.44 -HeapWord* DefNewGeneration::allocate(size_t word_size,
    1.45 -                                     bool is_tlab) {
    1.46 -  // This is the slow-path allocation for the DefNewGeneration.
    1.47 -  // Most allocations are fast-path in compiled code.
    1.48 -  // We try to allocate from the eden.  If that works, we are happy.
    1.49 -  // Note that since DefNewGeneration supports lock-free allocation, we
    1.50 -  // have to use it here, as well.
    1.51 -  HeapWord* result = eden()->par_allocate(word_size);
    1.52 -  if (result != NULL) {
    1.53 -    return result;
    1.54 +template <class T>
    1.55 +inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) {
    1.56 +#ifdef ASSERT
    1.57 +  {
    1.58 +    // We never expect to see a null reference being processed
    1.59 +    // as a weak reference.
    1.60 +    assert (!oopDesc::is_null(*p), "expected non-null ref");
    1.61 +    oop obj = oopDesc::load_decode_heap_oop_not_null(p);
    1.62 +    assert (obj->is_oop(), "expected an oop while scanning weak refs");
    1.63    }
    1.64 -  do {
    1.65 -    HeapWord* old_limit = eden()->soft_end();
    1.66 -    if (old_limit < eden()->end()) {
    1.67 -      // Tell the next generation we reached a limit.
    1.68 -      HeapWord* new_limit =
    1.69 -        next_gen()->allocation_limit_reached(eden(), eden()->top(), word_size);
    1.70 -      if (new_limit != NULL) {
    1.71 -        Atomic::cmpxchg_ptr(new_limit, eden()->soft_end_addr(), old_limit);
    1.72 -      } else {
    1.73 -        assert(eden()->soft_end() == eden()->end(),
    1.74 -               "invalid state after allocation_limit_reached returned null");
    1.75 -      }
    1.76 -    } else {
    1.77 -      // The allocation failed and the soft limit is equal to the hard limit,
    1.78 -      // there are no reasons to do an attempt to allocate
    1.79 -      assert(old_limit == eden()->end(), "sanity check");
    1.80 -      break;
    1.81 -    }
    1.82 -    // Try to allocate until succeeded or the soft limit can't be adjusted
    1.83 -    result = eden()->par_allocate(word_size);
    1.84 -  } while (result == NULL);
    1.85 +#endif // ASSERT
    1.86  
    1.87 -  // If the eden is full and the last collection bailed out, we are running
    1.88 -  // out of heap space, and we try to allocate the from-space, too.
    1.89 -  // allocate_from_space can't be inlined because that would introduce a
    1.90 -  // circular dependency at compile time.
    1.91 -  if (result == NULL) {
    1.92 -    result = allocate_from_space(word_size);
    1.93 +  _cl->do_oop_nv(p);
    1.94 +
    1.95 +  // Optimized for Defnew generation if it's the youngest generation:
    1.96 +  // we set a younger_gen card if we have an older->youngest
    1.97 +  // generation pointer.
    1.98 +  oop obj = oopDesc::load_decode_heap_oop_not_null(p);
    1.99 +  if (((HeapWord*)obj < _boundary) && Universe::heap()->is_in_reserved(p)) {
   1.100 +    _rs->inline_write_ref_field_gc(p, obj);
   1.101    }
   1.102 -  return result;
   1.103  }
   1.104 -
   1.105 -HeapWord* DefNewGeneration::par_allocate(size_t word_size,
   1.106 -                                         bool is_tlab) {
   1.107 -  return eden()->par_allocate(word_size);
   1.108 -}
   1.109 -
   1.110 -void DefNewGeneration::gc_prologue(bool full) {
   1.111 -  // Ensure that _end and _soft_end are the same in eden space.
   1.112 -  eden()->set_soft_end(eden()->end());
   1.113 -}
   1.114 -
   1.115 -size_t DefNewGeneration::tlab_capacity() const {
   1.116 -  return eden()->capacity();
   1.117 -}
   1.118 -
   1.119 -size_t DefNewGeneration::unsafe_max_tlab_alloc() const {
   1.120 -  return unsafe_max_alloc_nogc();
   1.121 -}

mercurial