src/hotspot/share/gc/g1/g1EvacFailure.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 57785 8d9362f3b8aa
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
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
/*
53747
13acc8e38a29 8218089: Rename DirtyCardQueue et al to follow usual G1 naming conventions
kbarrett
parents: 52875
diff changeset
     2
 * Copyright (c) 2012, 2019, 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"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29080
diff changeset
    26
#include "gc/g1/g1CollectedHeap.inline.hpp"
31331
a7c714b6cfb3 7097567: G1: abstract and encapsulate collector phases and transitions between them
drwhite
parents: 30764
diff changeset
    27
#include "gc/g1/g1CollectorState.hpp"
35943
e726308008c0 8148973: Rename g1/concurrentMark.{hpp,cpp,inline.hpp} to g1/g1ConcurrentMark.{hpp,cpp,inline.hpp}
ehelin
parents: 35851
diff changeset
    28
#include "gc/g1/g1ConcurrentMark.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29080
diff changeset
    29
#include "gc/g1/g1EvacFailure.hpp"
35851
5451ff646f8e 8147814: Move verification code out of g1collectedheap
david
parents: 34614
diff changeset
    30
#include "gc/g1/g1HeapVerifier.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29080
diff changeset
    31
#include "gc/g1/g1OopClosures.inline.hpp"
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
    32
#include "gc/g1/g1RedirtyCardsQueue.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29080
diff changeset
    33
#include "gc/g1/heapRegion.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29080
diff changeset
    34
#include "gc/g1/heapRegionRemSet.hpp"
38081
a3bcb7197d45 8151556: Use the PreservedMarks* classes for the G1 preserved mark stacks
tonyp
parents: 37988
diff changeset
    35
#include "gc/shared/preservedMarks.inline.hpp"
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49164
diff changeset
    36
#include "oops/access.inline.hpp"
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49164
diff changeset
    37
#include "oops/compressedOops.inline.hpp"
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49643
diff changeset
    38
#include "oops/oop.inline.hpp"
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    39
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    40
class UpdateLogBuffersDeferred : public BasicOopIterateClosure {
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    41
private:
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49722
diff changeset
    42
  G1CollectedHeap* _g1h;
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
    43
  G1RedirtyCardsQueue* _rdcq;
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48969
diff changeset
    44
  G1CardTable*    _ct;
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    45
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    46
  // Remember the last enqueued card to avoid enqueuing the same card over and over;
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    47
  // since we only ever handle a card once, this is sufficient.
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    48
  size_t _last_enqueued_card;
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    49
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    50
public:
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
    51
  UpdateLogBuffersDeferred(G1RedirtyCardsQueue* rdcq) :
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
    52
    _g1h(G1CollectedHeap::heap()), _rdcq(rdcq), _ct(_g1h->card_table()), _last_enqueued_card(SIZE_MAX) {}
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    53
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    54
  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
    55
  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
    56
  template <class T> void do_oop_work(T* p) {
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49722
diff changeset
    57
    assert(_g1h->heap_region_containing(p)->is_in_reserved(p), "paranoia");
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49722
diff changeset
    58
    assert(!_g1h->heap_region_containing(p)->is_survivor(), "Unexpected evac failure in survivor region");
34614
5f1e98f98bb7 8144040: UpdateRSetDeferred in G1EvacFailure will never visit survivor regions
ehelin
parents: 34311
diff changeset
    59
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49164
diff changeset
    60
    T const o = RawAccess<>::oop_load(p);
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49164
diff changeset
    61
    if (CompressedOops::is_null(o)) {
46634
f0fb6b3c47d2 8183127: UpdateRSetDeferred should not enqueue cards for NULL references
tschatzl
parents: 46590
diff changeset
    62
      return;
f0fb6b3c47d2 8183127: UpdateRSetDeferred should not enqueue cards for NULL references
tschatzl
parents: 46590
diff changeset
    63
    }
f0fb6b3c47d2 8183127: UpdateRSetDeferred should not enqueue cards for NULL references
tschatzl
parents: 46590
diff changeset
    64
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49164
diff changeset
    65
    if (HeapRegion::is_in_same_region(p, CompressedOops::decode(o))) {
46634
f0fb6b3c47d2 8183127: UpdateRSetDeferred should not enqueue cards for NULL references
tschatzl
parents: 46590
diff changeset
    66
      return;
f0fb6b3c47d2 8183127: UpdateRSetDeferred should not enqueue cards for NULL references
tschatzl
parents: 46590
diff changeset
    67
    }
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48969
diff changeset
    68
    size_t card_index = _ct->index_for(p);
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    69
    if (card_index != _last_enqueued_card) {
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
    70
      _rdcq->enqueue(_ct->byte_for_index(card_index));
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    71
      _last_enqueued_card = card_index;
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    72
    }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    73
  }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    74
};
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    75
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    76
class RemoveSelfForwardPtrObjClosure: public ObjectClosure {
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49722
diff changeset
    77
  G1CollectedHeap* _g1h;
35943
e726308008c0 8148973: Rename g1/concurrentMark.{hpp,cpp,inline.hpp} to g1/g1ConcurrentMark.{hpp,cpp,inline.hpp}
ehelin
parents: 35851
diff changeset
    78
  G1ConcurrentMark* _cm;
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    79
  HeapRegion* _hr;
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    80
  size_t _marked_bytes;
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    81
  UpdateLogBuffersDeferred* _log_buffer_cl;
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    82
  bool _during_initial_mark;
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
    83
  uint _worker_id;
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
    84
  HeapWord* _last_forwarded_object_end;
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
    85
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    86
public:
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
    87
  RemoveSelfForwardPtrObjClosure(HeapRegion* hr,
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    88
                                 UpdateLogBuffersDeferred* log_buffer_cl,
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    89
                                 bool during_initial_mark,
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
    90
                                 uint worker_id) :
49806
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49722
diff changeset
    91
    _g1h(G1CollectedHeap::heap()),
2d62570a615c 8200426: Make G1 code use _g1h members
tschatzl
parents: 49722
diff changeset
    92
    _cm(_g1h->concurrent_mark()),
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
    93
    _hr(hr),
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
    94
    _marked_bytes(0),
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
    95
    _log_buffer_cl(log_buffer_cl),
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
    96
    _during_initial_mark(during_initial_mark),
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    97
    _worker_id(worker_id),
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
    98
    _last_forwarded_object_end(hr->bottom()) { }
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
    99
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   100
  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
   101
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   102
  // Iterate over the live objects in the region to find self-forwarded objects
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   103
  // that need to be kept live. We need to update the remembered sets of these
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   104
  // objects. Further update the BOT and marks.
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   105
  // We can coalesce and overwrite the remaining heap contents with dummy objects
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   106
  // as they have either been dead or evacuated (which are unreferenced now, i.e.
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   107
  // dead too) already.
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   108
  void do_object(oop obj) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   109
    HeapWord* obj_addr = (HeapWord*) obj;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   110
    assert(_hr->is_in(obj_addr), "sanity");
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   111
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   112
    if (obj->is_forwarded() && obj->forwardee() == obj) {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   113
      // The object failed to move.
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   114
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   115
      zap_dead_objects(_last_forwarded_object_end, obj_addr);
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   116
      // 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
   117
      // 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
   118
      // info so that they are all under PTAMS and explicitly marked.
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47216
diff changeset
   119
      if (!_cm->is_marked_in_prev_bitmap(obj)) {
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47216
diff changeset
   120
        _cm->mark_in_prev_bitmap(obj);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   121
      }
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   122
      if (_during_initial_mark) {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   123
        // 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
   124
        // 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
   125
        // 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
   126
        // 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
   127
        // 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
   128
        // 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
   129
        // 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
   130
        // 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
   131
        // (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
   132
        // we'll leave them over NTAMS.
52875
bb051ca06e9e 8159440: Move marking of promoted objects during initial mark into the concurrent phase
tschatzl
parents: 51332
diff changeset
   133
        _cm->mark_in_next_bitmap(_worker_id, _hr, obj);
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   134
      }
37413
2f71679d06dd 8077144: Concurrent mark initialization takes too long
tschatzl
parents: 35943
diff changeset
   135
      size_t obj_size = obj->size();
2f71679d06dd 8077144: Concurrent mark initialization takes too long
tschatzl
parents: 35943
diff changeset
   136
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   137
      _marked_bytes += (obj_size * HeapWordSize);
38081
a3bcb7197d45 8151556: Use the PreservedMarks* classes for the G1 preserved mark stacks
tonyp
parents: 37988
diff changeset
   138
      PreservedMarks::init_forwarded_mark(obj);
11451
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
      // 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
   141
      // 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
   142
      // 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
   143
      // 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
   144
      // 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
   145
      // will be stale very soon.
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   146
      // 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
   147
      // 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
   148
      // 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
   149
      // 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
   150
      // 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
   151
      // the collection set. So, we'll recreate such entries now.
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   152
      obj->oop_iterate(_log_buffer_cl);
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   153
37413
2f71679d06dd 8077144: Concurrent mark initialization takes too long
tschatzl
parents: 35943
diff changeset
   154
      HeapWord* obj_end = obj_addr + obj_size;
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   155
      _last_forwarded_object_end = obj_end;
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   156
      _hr->cross_threshold(obj_addr, obj_end);
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   157
    }
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   158
  }
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   159
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   160
  // Fill the memory area from start to end with filler objects, and update the BOT
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   161
  // and the mark bitmap accordingly.
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   162
  void zap_dead_objects(HeapWord* start, HeapWord* end) {
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   163
    if (start == end) {
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   164
      return;
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   165
    }
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   166
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   167
    size_t gap_size = pointer_delta(end, start);
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   168
    MemRegion mr(start, gap_size);
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   169
    if (gap_size >= CollectedHeap::min_fill_size()) {
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   170
      CollectedHeap::fill_with_objects(start, gap_size);
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   171
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   172
      HeapWord* end_first_obj = start + ((oop)start)->size();
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   173
      _hr->cross_threshold(start, end_first_obj);
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   174
      // Fill_with_objects() may have created multiple (i.e. two)
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   175
      // objects, as the max_fill_size() is half a region.
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   176
      // After updating the BOT for the first object, also update the
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   177
      // BOT for the second object to make the BOT complete.
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   178
      if (end_first_obj != end) {
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   179
        _hr->cross_threshold(end_first_obj, end);
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   180
#ifdef ASSERT
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   181
        size_t size_second_obj = ((oop)end_first_obj)->size();
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   182
        HeapWord* end_of_second_obj = end_first_obj + size_second_obj;
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   183
        assert(end == end_of_second_obj,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31631
diff changeset
   184
               "More than two objects were used to fill the area from " PTR_FORMAT " to " PTR_FORMAT ", "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31631
diff changeset
   185
               "second objects size " SIZE_FORMAT " ends at " PTR_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31631
diff changeset
   186
               p2i(start), p2i(end), size_second_obj, p2i(end_of_second_obj));
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   187
#endif
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   188
      }
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   189
    }
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47216
diff changeset
   190
    _cm->clear_range_in_prev_bitmap(mr);
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   191
  }
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   192
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   193
  void zap_remainder() {
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   194
    zap_dead_objects(_last_forwarded_object_end, _hr->top());
11451
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
class RemoveSelfForwardPtrHRClosure: public HeapRegionClosure {
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   199
  G1CollectedHeap* _g1h;
11583
83a7383de44c 6484965: G1: piggy-back liveness accounting phase on marking
johnc
parents: 11455
diff changeset
   200
  uint _worker_id;
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   201
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
   202
  G1RedirtyCardsQueue _rdcq;
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   203
  UpdateLogBuffersDeferred _log_buffer_cl;
26701
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 26422
diff changeset
   204
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   205
public:
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 55752
diff changeset
   206
  RemoveSelfForwardPtrHRClosure(G1RedirtyCardsQueueSet* rdcqs, uint worker_id) :
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   207
    _g1h(G1CollectedHeap::heap()),
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 50752
diff changeset
   208
    _worker_id(worker_id),
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 55752
diff changeset
   209
    _rdcq(rdcqs),
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
   210
    _log_buffer_cl(&_rdcq) {
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   211
  }
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   212
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   213
  size_t remove_self_forward_ptr_by_walking_hr(HeapRegion* hr,
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   214
                                               bool during_initial_mark) {
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   215
    RemoveSelfForwardPtrObjClosure rspc(hr,
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   216
                                        &_log_buffer_cl,
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   217
                                        during_initial_mark,
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   218
                                        _worker_id);
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   219
    hr->object_iterate(&rspc);
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   220
    // Need to zap the remainder area of the processed region.
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   221
    rspc.zap_remainder();
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   222
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   223
    return rspc.marked_bytes();
27009
e7e723732b6b 8058298: Separate heap region iterator claim values from the data structures iterated over
mlarsson
parents: 26846
diff changeset
   224
  }
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   225
48969
jwilhelm
parents: 48890
diff changeset
   226
  bool do_heap_region(HeapRegion *hr) {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31631
diff changeset
   227
    assert(!hr->is_pinned(), "Unexpected pinned region at index %u", hr->hrm_index());
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   228
    assert(hr->in_collection_set(), "bad CS");
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   229
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   230
    if (hr->evacuation_failed()) {
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   231
      hr->clear_index_in_opt_cset();
54465
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 54110
diff changeset
   232
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   233
      bool during_initial_mark = _g1h->collector_state()->in_initial_mark_gc();
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   234
      bool during_conc_mark = _g1h->collector_state()->mark_or_rebuild_in_progress();
46258
d26ebd7e2f10 8142749: HeapRegion::_predicted_bytes_to_copy is unused and can be removed
fzhinkin
parents: 39698
diff changeset
   235
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   236
      hr->note_self_forwarding_removal_start(during_initial_mark,
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   237
                                               during_conc_mark);
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   238
      _g1h->verifier()->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
   239
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   240
      hr->reset_bot();
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   241
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   242
      size_t live_bytes = remove_self_forward_ptr_by_walking_hr(hr, during_initial_mark);
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
   243
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   244
      hr->rem_set()->clean_strong_code_roots(hr);
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   245
      hr->rem_set()->clear_locked(true);
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   246
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   247
      hr->note_self_forwarding_removal_end(live_bytes);
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   248
    }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   249
    return false;
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   250
  }
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   251
};
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   252
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 55752
diff changeset
   253
G1ParRemoveSelfForwardPtrsTask::G1ParRemoveSelfForwardPtrsTask(G1RedirtyCardsQueueSet* rdcqs) :
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   254
  AbstractGangTask("G1 Remove Self-forwarding Pointers"),
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   255
  _g1h(G1CollectedHeap::heap()),
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 55752
diff changeset
   256
  _rdcqs(rdcqs),
31631
4536cf7bc89f 8129558: Coalesce dead objects during removal of self-forwarded pointers
tschatzl
parents: 31346
diff changeset
   257
  _hrclaimer(_g1h->workers()->active_workers()) { }
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   258
29080
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   259
void G1ParRemoveSelfForwardPtrsTask::work(uint worker_id) {
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 55752
diff changeset
   260
  RemoveSelfForwardPtrHRClosure rsfp_cl(_rdcqs, worker_id);
11451
9c9aa4d85660 7121496: G1: do the per-region evacuation failure handling work in parallel
johnc
parents:
diff changeset
   261
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54982
diff changeset
   262
  _g1h->collection_set_iterate_increment_from(&rsfp_cl, &_hrclaimer, worker_id);
29080
a16b0d9a08f5 8072910: Move the g1EvacFailure.hpp implementation to g1EvacFailure.cpp
stefank
parents: 27009
diff changeset
   263
}