hotspot/src/share/vm/gc_implementation/g1/g1EvacFailure.cpp
author drwhite
Thu, 02 Apr 2015 16:42:24 -0400
changeset 30157 e36165b16dde
parent 29080 a16b0d9a08f5
permissions -rw-r--r--
8069004: Kitchensink hanged with 16Gb heap and GC pause >30 min Summary: Revert bug introduced a few months ago. Reviewed-by: brutisso, tschatzl, jmasa
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
/*
29080
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
     2
 * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
11451
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
29080
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
    25
#include "precompiled.hpp"
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    26
#include "gc_implementation/g1/concurrentMark.inline.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    27
#include "gc_implementation/g1/dirtyCardQueue.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    28
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
29080
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
    29
#include "gc_implementation/g1/g1EvacFailure.hpp"
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    30
#include "gc_implementation/g1/g1_globals.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    31
#include "gc_implementation/g1/g1OopClosures.inline.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    32
#include "gc_implementation/g1/heapRegion.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    33
#include "gc_implementation/g1/heapRegionRemSet.hpp"
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    34
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    35
class UpdateRSetDeferred : public OopsInHeapRegionClosure {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    36
private:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    37
  G1CollectedHeap* _g1;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    38
  DirtyCardQueue *_dcq;
20309
7445302daff6 8025305: Cleanup CardTableModRefBS usage in G1
mgerdin
parents: 11584
diff changeset
    39
  G1SATBCardTableModRefBS* _ct_bs;
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    40
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    41
public:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    42
  UpdateRSetDeferred(G1CollectedHeap* g1, DirtyCardQueue* dcq) :
20309
7445302daff6 8025305: Cleanup CardTableModRefBS usage in G1
mgerdin
parents: 11584
diff changeset
    43
    _g1(g1), _ct_bs(_g1->g1_barrier_set()), _dcq(dcq) {}
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    44
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    45
  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
    46
  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
    47
  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
    48
    assert(_from->is_in_reserved(p), "paranoia");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    49
    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
    50
        !_from->is_survivor()) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    51
      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
    52
      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
    53
        _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
    54
      }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    55
    }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    56
  }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    57
};
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    58
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    59
class RemoveSelfForwardPtrObjClosure: public ObjectClosure {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    60
private:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    61
  G1CollectedHeap* _g1;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    62
  ConcurrentMark* _cm;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    63
  HeapRegion* _hr;
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    64
  size_t _marked_bytes;
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    65
  OopsInHeapRegionClosure *_update_rset_cl;
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    66
  bool _during_initial_mark;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    67
  bool _during_conc_mark;
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
    68
  uint _worker_id;
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    69
  HeapWord* _end_of_last_gap;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    70
  HeapWord* _last_gap_threshold;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    71
  HeapWord* _last_obj_threshold;
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
    72
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    73
public:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    74
  RemoveSelfForwardPtrObjClosure(G1CollectedHeap* g1, ConcurrentMark* cm,
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    75
                                 HeapRegion* hr,
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    76
                                 OopsInHeapRegionClosure* update_rset_cl,
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    77
                                 bool during_initial_mark,
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
    78
                                 bool during_conc_mark,
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
    79
                                 uint worker_id) :
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    80
    _g1(g1), _cm(cm), _hr(hr), _marked_bytes(0),
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    81
    _update_rset_cl(update_rset_cl),
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    82
    _during_initial_mark(during_initial_mark),
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
    83
    _during_conc_mark(during_conc_mark),
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    84
    _worker_id(worker_id),
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    85
    _end_of_last_gap(hr->bottom()),
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    86
    _last_gap_threshold(hr->bottom()),
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    87
    _last_obj_threshold(hr->bottom()) { }
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    88
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    89
  size_t marked_bytes() { return _marked_bytes; }
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    90
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    91
  // <original comment>
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    92
  // 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
    93
  // 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
    94
  // 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
    95
  // |----- TLAB_1--------|----TLAB_2-~~~(partially refined part)~~~|
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    96
  // 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
    97
  // 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
    98
  // 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
    99
  // 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
   100
  // 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
   101
  // </original comment>
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   102
  //
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   103
  // 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
   104
  // 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
   105
  // 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
   106
  // 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
   107
  void do_object(oop obj) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   108
    HeapWord* obj_addr = (HeapWord*) obj;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   109
    assert(_hr->is_in(obj_addr), "sanity");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   110
    size_t obj_size = obj->size();
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   111
    HeapWord* obj_end = obj_addr + obj_size;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   112
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   113
    if (_end_of_last_gap != obj_addr) {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   114
      // there was a gap before obj_addr
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   115
      _last_gap_threshold = _hr->cross_threshold(_end_of_last_gap, obj_addr);
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   116
    }
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   117
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   118
    if (obj->is_forwarded() && obj->forwardee() == obj) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   119
      // The object failed to move.
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   120
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   121
      // We consider all objects that we find self-forwarded to be
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   122
      // live. What we'll do is that we'll update the prev marking
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   123
      // info so that they are all under PTAMS and explicitly marked.
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   124
      if (!_cm->isPrevMarked(obj)) {
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   125
        _cm->markPrev(obj);
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   126
      }
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   127
      if (_during_initial_mark) {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   128
        // For the next marking info we'll only mark the
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   129
        // self-forwarded objects explicitly if we are during
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   130
        // initial-mark (since, normally, we only mark objects pointed
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   131
        // to by roots if we succeed in copying them). By marking all
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   132
        // self-forwarded objects we ensure that we mark any that are
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   133
        // still pointed to be roots. During concurrent marking, and
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   134
        // after initial-mark, we don't need to mark any objects
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   135
        // explicitly and all objects in the CSet are considered
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   136
        // (implicitly) live. So, we won't mark them explicitly and
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   137
        // we'll leave them over NTAMS.
11584
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11583
diff changeset
   138
        _cm->grayRoot(obj, obj_size, _worker_id, _hr);
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   139
      }
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   140
      _marked_bytes += (obj_size * HeapWordSize);
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   141
      obj->set_mark(markOopDesc::prototype());
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   142
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   143
      // 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
   144
      // 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
   145
      // 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
   146
      // 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
   147
      // 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
   148
      // will be stale very soon.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   149
      // 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
   150
      // 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
   151
      // 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
   152
      // 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
   153
      // 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
   154
      // 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
   155
      obj->oop_iterate(_update_rset_cl);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   156
    } else {
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   157
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   158
      // 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
   159
      // dummy object.
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   160
      MemRegion mr(obj_addr, obj_size);
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   161
      CollectedHeap::fill_with_object(mr);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   162
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   163
      // must nuke all dead objects which we skipped when iterating over the region
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   164
      _cm->clearRangePrevBitmap(MemRegion(_end_of_last_gap, obj_end));
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   165
    }
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   166
    _end_of_last_gap = obj_end;
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   167
    _last_obj_threshold = _hr->cross_threshold(obj_addr, obj_end);
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   168
  }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   169
};
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   170
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   171
class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   172
  G1CollectedHeap* _g1h;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   173
  ConcurrentMark* _cm;
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
   174
  uint _worker_id;
27009
e7e723732b6b 8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents: 26846
diff changeset
   175
  HeapRegionClaimer* _hrclaimer;
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   176
26701
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 26422
diff changeset
   177
  DirtyCardQueue _dcq;
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 26422
diff changeset
   178
  UpdateRSetDeferred _update_rset_cl;
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 26422
diff changeset
   179
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   180
public:
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   181
  RemoveSelfForwardPtrHRClosure(G1CollectedHeap* g1h,
27009
e7e723732b6b 8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents: 26846
diff changeset
   182
                                uint worker_id,
e7e723732b6b 8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents: 26846
diff changeset
   183
                                HeapRegionClaimer* hrclaimer) :
e7e723732b6b 8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents: 26846
diff changeset
   184
      _g1h(g1h), _dcq(&g1h->dirty_card_queue_set()), _update_rset_cl(g1h, &_dcq),
e7e723732b6b 8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents: 26846
diff changeset
   185
      _worker_id(worker_id), _cm(_g1h->concurrent_mark()), _hrclaimer(hrclaimer) {
e7e723732b6b 8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents: 26846
diff changeset
   186
  }
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   187
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   188
  bool doHeapRegion(HeapRegion *hr) {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   189
    bool during_initial_mark = _g1h->g1_policy()->during_initial_mark_pause();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   190
    bool during_conc_mark = _g1h->mark_in_progress();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   191
26846
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26701
diff changeset
   192
    assert(!hr->is_humongous(), "sanity");
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   193
    assert(hr->in_collection_set(), "bad CS");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   194
27009
e7e723732b6b 8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents: 26846
diff changeset
   195
    if (_hrclaimer->claim_region(hr->hrm_index())) {
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   196
      if (hr->evacuation_failed()) {
26701
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 26422
diff changeset
   197
        RemoveSelfForwardPtrObjClosure rspc(_g1h, _cm, hr, &_update_rset_cl,
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   198
                                            during_initial_mark,
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
   199
                                            during_conc_mark,
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
   200
                                            _worker_id);
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   201
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   202
        hr->note_self_forwarding_removal_start(during_initial_mark,
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   203
                                               during_conc_mark);
24244
2c7a1e5649bd 7132678: G1: verify that the marking bitmaps have no marks for objects over TAMS
brutisso
parents: 22234
diff changeset
   204
        _g1h->check_bitmaps("Self-Forwarding Ptr Removal", hr);
11451
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
        // 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
   207
        // 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
   208
        // 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
   209
        // 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
   210
        // 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
   211
        // 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
   212
        // 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
   213
        // 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
   214
        hr->rem_set()->reset_for_par_iteration();
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   215
        hr->reset_bot();
26701
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 26422
diff changeset
   216
        _update_rset_cl.set_region(hr);
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   217
        hr->object_iterate(&rspc);
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   218
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
   219
        hr->rem_set()->clean_strong_code_roots(hr);
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
   220
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   221
        hr->note_self_forwarding_removal_end(during_initial_mark,
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   222
                                             during_conc_mark,
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   223
                                             rspc.marked_bytes());
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   224
      }
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
    return false;
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
};
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   229
29080
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   230
G1ParRemoveSelfForwardPtrsTask::G1ParRemoveSelfForwardPtrsTask(G1CollectedHeap* g1h) :
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   231
    AbstractGangTask("G1 Remove Self-forwarding Pointers"), _g1h(g1h),
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   232
    _hrclaimer(g1h->workers()->active_workers()) {}
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   233
29080
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   234
void G1ParRemoveSelfForwardPtrsTask::work(uint worker_id) {
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   235
  RemoveSelfForwardPtrHRClosure rsfp_cl(_g1h, worker_id, &_hrclaimer);
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   236
29080
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   237
  HeapRegion* hr = _g1h->start_cset_region_for_worker(worker_id);
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   238
  _g1h->collection_set_iterate_from(hr, &rsfp_cl);
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   239
}