hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.hpp
author johnc
Fri, 23 Dec 2011 11:14:18 -0800
changeset 11451 9c9aa4d85660
child 11455 a6ab3d8b9a4c
permissions -rw-r--r--
7121496: G1: do the per-region evacuation failure handling work in parallel Summary: Parallelize the removal of self forwarding pointers etc. by wrapping in a HeapRegion closure, which is then wrapped inside an AbstractGangTask. Reviewed-by: tonyp, iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
     1
/*
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
     4
 *
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
     8
 *
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    13
 * accompanied this code).
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    14
 *
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    18
 *
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    21
 * questions.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    22
 *
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    23
 */
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    24
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1EVACFAILURE_HPP
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_G1_G1EVACFAILURE_HPP
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    27
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    28
#include "gc_implementation/g1/concurrentMark.inline.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    29
#include "gc_implementation/g1/dirtyCardQueue.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    30
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    31
#include "gc_implementation/g1/g1_globals.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    32
#include "gc_implementation/g1/g1OopClosures.inline.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    33
#include "gc_implementation/g1/heapRegion.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    34
#include "gc_implementation/g1/heapRegionRemSet.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    35
#include "utilities/workgroup.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    36
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    37
// Closures and tasks associated with any self-forwarding pointers
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    38
// installed as a result of an evacuation failure.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    39
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    40
class UpdateRSetDeferred : public OopsInHeapRegionClosure {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    41
private:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    42
  G1CollectedHeap* _g1;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    43
  DirtyCardQueue *_dcq;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    44
  CardTableModRefBS* _ct_bs;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    45
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    46
public:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    47
  UpdateRSetDeferred(G1CollectedHeap* g1, DirtyCardQueue* dcq) :
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    48
    _g1(g1), _ct_bs((CardTableModRefBS*)_g1->barrier_set()), _dcq(dcq) {}
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    49
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    50
  virtual void do_oop(narrowOop* p) { do_oop_work(p); }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    51
  virtual void do_oop(      oop* p) { do_oop_work(p); }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    52
  template <class T> void do_oop_work(T* p) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    53
    assert(_from->is_in_reserved(p), "paranoia");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    54
    if (!_from->is_in_reserved(oopDesc::load_decode_heap_oop(p)) &&
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    55
        !_from->is_survivor()) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    56
      size_t card_index = _ct_bs->index_for(p);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    57
      if (_ct_bs->mark_card_deferred(card_index)) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    58
        _dcq->enqueue((jbyte*)_ct_bs->byte_for_index(card_index));
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    59
      }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    60
    }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    61
  }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    62
};
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    63
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    64
class RemoveSelfForwardPtrObjClosure: public ObjectClosure {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    65
private:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    66
  G1CollectedHeap* _g1;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    67
  ConcurrentMark* _cm;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    68
  HeapRegion* _hr;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    69
  size_t _prev_marked_bytes;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    70
  size_t _next_marked_bytes;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    71
  OopsInHeapRegionClosure *_update_rset_cl;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    72
public:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    73
  RemoveSelfForwardPtrObjClosure(G1CollectedHeap* g1, ConcurrentMark* cm,
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    74
                                 HeapRegion* hr,
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    75
                                 OopsInHeapRegionClosure* update_rset_cl) :
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    76
    _g1(g1), _cm(cm), _hr(hr),
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    77
    _update_rset_cl(update_rset_cl),
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    78
    _prev_marked_bytes(0), _next_marked_bytes(0) {}
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    79
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    80
  size_t prev_marked_bytes() { return _prev_marked_bytes; }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    81
  size_t next_marked_bytes() { return _next_marked_bytes; }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    82
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    83
  // <original comment>
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    84
  // The original idea here was to coalesce evacuated and dead objects.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    85
  // However that caused complications with the block offset table (BOT).
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    86
  // In particular if there were two TLABs, one of them partially refined.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    87
  // |----- TLAB_1--------|----TLAB_2-~~~(partially refined part)~~~|
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    88
  // The BOT entries of the unrefined part of TLAB_2 point to the start
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    89
  // of TLAB_2. If the last object of the TLAB_1 and the first object
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    90
  // of TLAB_2 are coalesced, then the cards of the unrefined part
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    91
  // would point into middle of the filler object.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    92
  // The current approach is to not coalesce and leave the BOT contents intact.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    93
  // </original comment>
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    94
  //
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    95
  // We now reset the BOT when we start the object iteration over the
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    96
  // region and refine its entries for every object we come across. So
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    97
  // the above comment is not really relevant and we should be able
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    98
  // to coalesce dead objects if we want to.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    99
  void do_object(oop obj) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   100
    HeapWord* obj_addr = (HeapWord*) obj;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   101
    assert(_hr->is_in(obj_addr), "sanity");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   102
    size_t obj_size = obj->size();
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   103
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   104
    _hr->update_bot_for_object(obj_addr, obj_size);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   105
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   106
    if (obj->is_forwarded() && obj->forwardee() == obj) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   107
      // The object failed to move.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   108
      assert(!_g1->is_obj_dead(obj), "We should not be preserving dead objs.");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   109
      _cm->markPrev(obj);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   110
      assert(_cm->isPrevMarked(obj), "Should be marked!");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   111
      _prev_marked_bytes += (obj_size * HeapWordSize);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   112
      if (_g1->mark_in_progress() && !_g1->is_obj_ill(obj)) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   113
        _cm->markAndGrayObjectIfNecessary(obj);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   114
      }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   115
      obj->set_mark(markOopDesc::prototype());
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   116
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   117
      // While we were processing RSet buffers during the collection,
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   118
      // we actually didn't scan any cards on the collection set,
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   119
      // since we didn't want to update remembered sets with entries
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   120
      // that point into the collection set, given that live objects
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   121
      // from the collection set are about to move and such entries
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   122
      // will be stale very soon.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   123
      // This change also dealt with a reliability issue which
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   124
      // involved scanning a card in the collection set and coming
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   125
      // across an array that was being chunked and looking malformed.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   126
      // The problem is that, if evacuation fails, we might have
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   127
      // remembered set entries missing given that we skipped cards on
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   128
      // the collection set. So, we'll recreate such entries now.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   129
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   130
      obj->oop_iterate(_update_rset_cl);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   131
      assert(_cm->isPrevMarked(obj), "Should be marked!");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   132
    } else {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   133
      // The object has been either evacuated or is dead. Fill it with a
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   134
      // dummy object.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   135
      MemRegion mr((HeapWord*)obj, obj_size);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   136
      CollectedHeap::fill_with_object(mr);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   137
      _cm->clearRangeBothMaps(mr);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   138
    }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   139
  }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   140
};
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   141
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   142
class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   143
  G1CollectedHeap* _g1h;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   144
  ConcurrentMark* _cm;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   145
  OopsInHeapRegionClosure *_update_rset_cl;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   146
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   147
public:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   148
  RemoveSelfForwardPtrHRClosure(G1CollectedHeap* g1h,
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   149
                                OopsInHeapRegionClosure* update_rset_cl) :
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   150
    _g1h(g1h), _update_rset_cl(update_rset_cl),
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   151
    _cm(_g1h->concurrent_mark()) { }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   152
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   153
  bool doHeapRegion(HeapRegion *hr) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   154
    assert(!hr->isHumongous(), "sanity");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   155
    assert(hr->in_collection_set(), "bad CS");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   156
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   157
    if (hr->claimHeapRegion(HeapRegion::ParEvacFailureClaimValue)) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   158
      if (hr->evacuation_failed()) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   159
        RemoveSelfForwardPtrObjClosure rspc(_g1h, _cm, hr, _update_rset_cl);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   160
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   161
        // In the common case (i.e. when there is no evacuation
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   162
        // failure) we make sure that the following is done when
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   163
        // the region is freed so that it is "ready-to-go" when it's
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   164
        // re-allocated. However, when evacuation failure happens, a
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   165
        // region will remain in the heap and might ultimately be added
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   166
        // to a CSet in the future. So we have to be careful here and
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   167
        // make sure the region's RSet is ready for parallel iteration
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   168
        // whenever this might be required in the future.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   169
        hr->rem_set()->reset_for_par_iteration();
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   170
        hr->reset_bot();
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   171
        _update_rset_cl->set_region(hr);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   172
        hr->object_iterate(&rspc);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   173
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   174
        // A number of manipulations to make the TAMS for this region
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   175
        // be the current top, and the marked bytes be the ones observed
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   176
        // in the iteration.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   177
        if (_cm->at_least_one_mark_complete()) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   178
          // The comments below are the postconditions achieved by the
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   179
          // calls.  Note especially the last such condition, which says that
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   180
          // the count of marked bytes has been properly restored.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   181
          hr->note_start_of_marking(false);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   182
          // _next_top_at_mark_start == top, _next_marked_bytes == 0
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   183
          hr->add_to_marked_bytes(rspc.prev_marked_bytes());
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   184
          // _next_marked_bytes == prev_marked_bytes.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   185
          hr->note_end_of_marking();
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   186
          // _prev_top_at_mark_start == top(),
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   187
          // _prev_marked_bytes == prev_marked_bytes
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   188
        }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   189
        // If there is no mark in progress, we modified the _next variables
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   190
        // above needlessly, but harmlessly.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   191
        if (_g1h->mark_in_progress()) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   192
          hr->note_start_of_marking(false);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   193
          // _next_top_at_mark_start == top, _next_marked_bytes == 0
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   194
          // _next_marked_bytes == next_marked_bytes.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   195
        }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   196
      }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   197
    }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   198
    return false;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   199
  }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   200
};
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   201
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   202
class G1ParRemoveSelfForwardPtrsTask: public AbstractGangTask {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   203
protected:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   204
  G1CollectedHeap* _g1h;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   205
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   206
public:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   207
  G1ParRemoveSelfForwardPtrsTask(G1CollectedHeap* g1h) :
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   208
    AbstractGangTask("G1 Remove Self-forwarding Pointers"),
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   209
    _g1h(g1h) { }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   210
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   211
  void work(uint worker_id) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   212
    UpdateRSetImmediate immediate_update(_g1h->g1_rem_set());
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   213
    DirtyCardQueue dcq(&_g1h->dirty_card_queue_set());
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   214
    UpdateRSetDeferred deferred_update(_g1h, &dcq);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   215
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   216
    OopsInHeapRegionClosure *update_rset_cl = &deferred_update;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   217
    if (!G1DeferredRSUpdate) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   218
      update_rset_cl = &immediate_update;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   219
    }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   220
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   221
    RemoveSelfForwardPtrHRClosure rsfp_cl(_g1h, update_rset_cl);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   222
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   223
    HeapRegion* hr = _g1h->start_cset_region_for_worker(worker_id);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   224
    _g1h->collection_set_iterate_from(hr, &rsfp_cl);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   225
  }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   226
};
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   227
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   228
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1EVACFAILURE_HPP