src/hotspot/share/gc/g1/g1CodeBlobClosure.cpp
author tschatzl
Fri, 29 Nov 2019 10:20:17 +0100
changeset 59321 5775e4825e58
parent 58777 18c246ad2ff9
permissions -rw-r--r--
8233998: New young regions registered too early in collection set Reviewed-by: sangheki, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32617
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
     1
/*
46282
a001553763bc 8162104: Use in_cset() instead of obj_in_cs()
tschatzl
parents: 33786
diff changeset
     2
 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
32617
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
     4
 *
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
     8
 *
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    13
 * accompanied this code).
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    14
 *
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    18
 *
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    21
 * questions.
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    22
 *
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    23
 */
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    24
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    25
#include "precompiled.hpp"
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    26
#include "code/nmethod.hpp"
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    27
#include "gc/g1/g1CodeBlobClosure.hpp"
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    28
#include "gc/g1/g1CollectedHeap.inline.hpp"
58777
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    29
#include "gc/g1/g1ConcurrentMark.inline.hpp"
32617
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    30
#include "gc/g1/heapRegion.hpp"
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    31
#include "gc/g1/heapRegionRemSet.hpp"
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47216
diff changeset
    32
#include "oops/access.inline.hpp"
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47216
diff changeset
    33
#include "oops/compressedOops.inline.hpp"
32617
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    34
#include "oops/oop.inline.hpp"
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    35
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    36
template <typename T>
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    37
void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop_work(T* p) {
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    38
  _work->do_oop(p);
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47216
diff changeset
    39
  T oop_or_narrowoop = RawAccess<>::oop_load(p);
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47216
diff changeset
    40
  if (!CompressedOops::is_null(oop_or_narrowoop)) {
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 47216
diff changeset
    41
    oop o = CompressedOops::decode_not_null(oop_or_narrowoop);
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 32617
diff changeset
    42
    HeapRegion* hr = _g1h->heap_region_containing(o);
46282
a001553763bc 8162104: Use in_cset() instead of obj_in_cs()
tschatzl
parents: 33786
diff changeset
    43
    assert(!_g1h->is_in_cset(o) || hr->rem_set()->strong_code_roots_list_contains(_nm), "if o still in collection set then evacuation failed and nm must already be in the remset");
32617
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    44
    hr->add_strong_code_root(_nm);
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    45
  }
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    46
}
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    47
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    48
void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop(oop* o) {
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    49
  do_oop_work(o);
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    50
}
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    51
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    52
void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop(narrowOop* o) {
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    53
  do_oop_work(o);
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    54
}
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    55
58777
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    56
template<typename T>
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    57
void G1CodeBlobClosure::MarkingOopClosure::do_oop_work(T* p) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    58
  T oop_or_narrowoop = RawAccess<>::oop_load(p);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    59
  if (!CompressedOops::is_null(oop_or_narrowoop)) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    60
    oop o = CompressedOops::decode_not_null(oop_or_narrowoop);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    61
    _cm->mark_in_next_bitmap(_worker_id, o);
32617
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    62
  }
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    63
}
a59435e1fecc 8135012: Don't use G1RootProcessor when scanning remembered sets
mgerdin
parents:
diff changeset
    64
58777
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    65
G1CodeBlobClosure::MarkingOopClosure::MarkingOopClosure(uint worker_id) :
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    66
  _cm(G1CollectedHeap::heap()->concurrent_mark()), _worker_id(worker_id) { }
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    67
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    68
void G1CodeBlobClosure::MarkingOopClosure::do_oop(oop* o) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    69
  do_oop_work(o);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    70
}
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    71
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    72
void G1CodeBlobClosure::MarkingOopClosure::do_oop(narrowOop* o) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    73
  do_oop_work(o);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    74
}
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    75
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    76
void G1CodeBlobClosure::do_evacuation_and_fixup(nmethod* nm) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    77
  _oc.set_nm(nm);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    78
  nm->oops_do(&_oc);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    79
  nm->fix_oop_relocations();
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    80
}
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    81
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    82
void G1CodeBlobClosure::do_marking(nmethod* nm) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    83
  nm->oops_do(&_marking_oc);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    84
}
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    85
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    86
class G1NmethodProcessor : public nmethod::OopsDoProcessor {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    87
  G1CodeBlobClosure* _cl;
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    88
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    89
public:
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    90
  G1NmethodProcessor(G1CodeBlobClosure* cl) : _cl(cl) { }
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    91
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    92
  void do_regular_processing(nmethod* nm) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    93
    _cl->do_evacuation_and_fixup(nm);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    94
  }
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    95
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    96
  void do_remaining_strong_processing(nmethod* nm) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    97
    _cl->do_marking(nm);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    98
  }
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
    99
};
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   100
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   101
void G1CodeBlobClosure::do_code_blob(CodeBlob* cb) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   102
  nmethod* nm = cb->as_nmethod_or_null();
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   103
  if (nm == NULL) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   104
    return;
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   105
  }
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   106
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   107
  G1NmethodProcessor cl(this);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   108
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   109
  if (_strong) {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   110
    nm->oops_do_process_strong(&cl);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   111
  } else {
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   112
    nm->oops_do_process_weak(&cl);
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   113
  }
18c246ad2ff9 8230706: Waiting on completion of strong nmethod processing causes long pause times with G1
tschatzl
parents: 49592
diff changeset
   114
}