src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp
author sangheki
Wed, 13 Nov 2019 10:51:41 -0800
changeset 59062 6530de931b8e
parent 57777 90ead0febf56
permissions -rw-r--r--
8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3) Reviewed-by: kbarrett, sjohanss, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     4
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     8
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    14
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    18
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    21
 * questions.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    22
 *
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    23
 */
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
    25
#ifndef SHARE_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
    26
#define SHARE_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    27
52210
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    28
#include "gc/g1/g1CollectedHeap.inline.hpp"
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
    29
#include "gc/g1/g1OopStarChunkedList.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    30
#include "gc/g1/g1ParScanThreadState.hpp"
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    31
#include "gc/g1/g1RemSet.hpp"
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49337
diff changeset
    32
#include "oops/access.inline.hpp"
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    33
#include "oops/oop.inline.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    34
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
    35
template <class T> void G1ParScanThreadState::do_oop_evac(T* p) {
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49337
diff changeset
    36
  // Reference should not be NULL here as such are never pushed to the task queue.
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50113
diff changeset
    37
  oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    38
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    39
  // Although we never intentionally push references outside of the collection
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    40
  // set, due to (benign) races in the claim mechanism during RSet scanning more
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    41
  // than one thread might claim the same card. So the same card may be
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
    42
  // processed multiple times, and so we might get references into old gen here.
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
    43
  // So we need to redo this check.
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53244
diff changeset
    44
  const G1HeapRegionAttr region_attr = _g1h->region_attr(obj);
52210
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    45
  // References pushed onto the work stack should never point to a humongous region
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    46
  // as they are not added to the collection set due to above precondition.
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53244
diff changeset
    47
  assert(!region_attr.is_humongous(),
52210
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    48
         "Obj " PTR_FORMAT " should not refer to humongous region %u from " PTR_FORMAT,
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    49
         p2i(obj), _g1h->addr_to_region((HeapWord*)obj), p2i(p));
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    50
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53244
diff changeset
    51
  if (!region_attr.is_in_cset()) {
52210
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    52
    // In this case somebody else already did all the work.
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    53
    return;
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    54
  }
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    55
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 54934
diff changeset
    56
  markWord m = obj->mark_raw();
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 54934
diff changeset
    57
  if (m.is_marked()) {
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 54934
diff changeset
    58
    obj = (oop) m.decode_pointer();
25889
221296ac4359 8027959: Early reclamation of large objects in G1
tschatzl
parents: 25483
diff changeset
    59
  } else {
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53244
diff changeset
    60
    obj = copy_to_survivor_space(region_attr, obj, m);
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    61
  }
52210
f59960ebed20 8211853: Avoid additional duplicate work when a reference in the task queue has already been evacuated
tschatzl
parents: 51292
diff changeset
    62
  RawAccess<IS_NOT_NULL>::oop_store(p, obj);
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    63
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    64
  assert(obj != NULL, "Must be");
52348
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 52210
diff changeset
    65
  if (HeapRegion::is_in_same_region(p, obj)) {
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 52210
diff changeset
    66
    return;
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 52210
diff changeset
    67
  }
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 52210
diff changeset
    68
  HeapRegion* from = _g1h->heap_region_containing(p);
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 52210
diff changeset
    69
  if (!from->is_young()) {
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53244
diff changeset
    70
    enqueue_card_if_tracked(_g1h->region_attr(obj), p, obj);
46646
5165b3a5b44a 8183397: Ensure consistent closure filtering during evacuation
tschatzl
parents: 35191
diff changeset
    71
  }
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    72
}
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    73
30566
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 30173
diff changeset
    74
template <class T> inline void G1ParScanThreadState::push_on_queue(T* ref) {
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 30173
diff changeset
    75
  assert(verify_ref(ref), "sanity");
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 30173
diff changeset
    76
  _refs->push(ref);
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 30173
diff changeset
    77
}
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 30173
diff changeset
    78
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    79
inline void G1ParScanThreadState::do_oop_partial_array(oop* p) {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    80
  assert(has_partial_array_mask(p), "invariant");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    81
  oop from_obj = clear_partial_array_mask(p);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    82
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 28213
diff changeset
    83
  assert(_g1h->is_in_reserved(from_obj), "must be in heap.");
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    84
  assert(from_obj->is_objArray(), "must be obj array");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    85
  objArrayOop from_obj_array = objArrayOop(from_obj);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    86
  // The from-space object contains the real length.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    87
  int length                 = from_obj_array->length();
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    88
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    89
  assert(from_obj->is_forwarded(), "must be forwarded");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    90
  oop to_obj                 = from_obj->forwardee();
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    91
  assert(from_obj != to_obj, "should not be chunking self-forwarded objects");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    92
  objArrayOop to_obj_array   = objArrayOop(to_obj);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    93
  // We keep track of the next start index in the length field of the
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    94
  // to-space object.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    95
  int next_index             = to_obj_array->length();
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    96
  assert(0 <= next_index && next_index < length,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32187
diff changeset
    97
         "invariant, next index: %d, length: %d", next_index, length);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    98
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    99
  int start                  = next_index;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   100
  int end                    = length;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   101
  int remainder              = end - start;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   102
  // We'll try not to push a range that's smaller than ParGCArrayScanChunk.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   103
  if (remainder > 2 * ParGCArrayScanChunk) {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   104
    end = start + ParGCArrayScanChunk;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   105
    to_obj_array->set_length(end);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   106
    // Push the remainder before we process the range in case another
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   107
    // worker has run out of things to do and can steal it.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   108
    oop* from_obj_p = set_partial_array_mask(from_obj);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   109
    push_on_queue(from_obj_p);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   110
  } else {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   111
    assert(length == end, "sanity");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   112
    // We'll process the final range for this object. Restore the length
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   113
    // so that the heap remains parsable in case of evacuation failure.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   114
    to_obj_array->set_length(end);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   115
  }
52348
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 52210
diff changeset
   116
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 52210
diff changeset
   117
  HeapRegion* hr = _g1h->heap_region_containing(to_obj);
52349
f34a2e0069c7 8213142: Use RAII to set the scanning source in G1ScanEvacuatedObjClosure
tschatzl
parents: 52348
diff changeset
   118
  G1ScanInYoungSetter x(&_scanner, hr->is_young());
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   119
  // Process indexes [start,end). It will also process the header
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   120
  // along with the first chunk (i.e., the chunk with start == 0).
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   121
  // Note that at this point the length field of to_obj_array is not
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   122
  // correct given that we are using it to keep track of the next
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   123
  // start index. oop_iterate_range() (thankfully!) ignores the length
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   124
  // field and only relies on the start / end parameters.  It does
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   125
  // however return the size of the object which will be incorrect. So
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   126
  // we have to ignore it even if we wanted to use it.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   127
  to_obj_array->oop_iterate_range(&_scanner, start, end);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   128
}
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   129
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   130
inline void G1ParScanThreadState::deal_with_reference(oop* ref_to_scan) {
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   131
  if (!has_partial_array_mask(ref_to_scan)) {
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   132
    do_oop_evac(ref_to_scan);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   133
  } else {
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   134
    do_oop_partial_array(ref_to_scan);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   135
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   136
}
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   137
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   138
inline void G1ParScanThreadState::deal_with_reference(narrowOop* ref_to_scan) {
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   139
  assert(!has_partial_array_mask(ref_to_scan), "NarrowOop* elements should never be partial arrays.");
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   140
  do_oop_evac(ref_to_scan);
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   141
}
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   142
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   143
inline void G1ParScanThreadState::dispatch_reference(StarTask ref) {
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   144
  assert(verify_task(ref), "sanity");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   145
  if (ref.is_narrow()) {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   146
    deal_with_reference((narrowOop*)ref);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   147
  } else {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   148
    deal_with_reference((oop*)ref);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   149
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   150
}
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   151
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   152
void G1ParScanThreadState::steal_and_trim_queue(RefToScanQueueSet *task_queues) {
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   153
  StarTask stolen_task;
51292
0538a5cdb474 8205921: Optimizing best-of-2 work stealing queue selection
zgu
parents: 50728
diff changeset
   154
  while (task_queues->steal(_worker_id, stolen_task)) {
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   155
    assert(verify_task(stolen_task), "sanity");
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   156
    dispatch_reference(stolen_task);
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   157
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   158
    // We've just processed a reference and we might have made
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   159
    // available new entries on the queues. So we have to make sure
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   160
    // we drain the queues as necessary.
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   161
    trim_queue();
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   162
  }
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   163
}
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   164
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   165
inline bool G1ParScanThreadState::needs_partial_trimming() const {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   166
  return !_refs->overflow_empty() || _refs->size() > _stack_trim_upper_threshold;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   167
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   168
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   169
inline bool G1ParScanThreadState::is_partially_trimmed() const {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   170
  return _refs->overflow_empty() && _refs->size() <= _stack_trim_lower_threshold;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   171
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   172
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   173
inline void G1ParScanThreadState::trim_queue_to_threshold(uint threshold) {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   174
  StarTask ref;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   175
  // Drain the overflow stack first, so other threads can potentially steal.
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   176
  while (_refs->pop_overflow(ref)) {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   177
    if (!_refs->try_push_to_taskqueue(ref)) {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   178
      dispatch_reference(ref);
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   179
    }
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   180
  }
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   181
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   182
  while (_refs->pop_local(ref, threshold)) {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   183
    dispatch_reference(ref);
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   184
  }
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   185
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   186
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   187
inline void G1ParScanThreadState::trim_queue_partially() {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   188
  if (!needs_partial_trimming()) {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   189
    return;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   190
  }
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   191
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   192
  const Ticks start = Ticks::now();
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   193
  do {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   194
    trim_queue_to_threshold(_stack_trim_lower_threshold);
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   195
  } while (!is_partially_trimmed());
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   196
  _trim_ticks += Ticks::now() - start;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   197
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   198
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   199
inline Tickspan G1ParScanThreadState::trim_ticks() const {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   200
  return _trim_ticks;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   201
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   202
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   203
inline void G1ParScanThreadState::reset_trim_ticks() {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   204
  _trim_ticks = Tickspan();
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   205
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   206
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   207
template <typename T>
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   208
inline void G1ParScanThreadState::remember_root_into_optional_region(T* p) {
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   209
  oop o = RawAccess<IS_NOT_NULL>::oop_load(p);
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   210
  uint index = _g1h->heap_region_containing(o)->index_in_opt_cset();
54934
39814e0a8964 8222492: G1 unnecessarily scans remembered set cards for regions that already have been evacuated
tschatzl
parents: 54843
diff changeset
   211
  assert(index < _num_optional_regions,
39814e0a8964 8222492: G1 unnecessarily scans remembered set cards for regions that already have been evacuated
tschatzl
parents: 54843
diff changeset
   212
         "Trying to access optional region idx %u beyond " SIZE_FORMAT, index, _num_optional_regions);
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   213
  _oops_into_optional_regions[index].push_root(p);
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   214
}
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   215
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   216
template <typename T>
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   217
inline void G1ParScanThreadState::remember_reference_into_optional_region(T* p) {
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   218
  oop o = RawAccess<IS_NOT_NULL>::oop_load(p);
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   219
  uint index = _g1h->heap_region_containing(o)->index_in_opt_cset();
54934
39814e0a8964 8222492: G1 unnecessarily scans remembered set cards for regions that already have been evacuated
tschatzl
parents: 54843
diff changeset
   220
  assert(index < _num_optional_regions,
39814e0a8964 8222492: G1 unnecessarily scans remembered set cards for regions that already have been evacuated
tschatzl
parents: 54843
diff changeset
   221
         "Trying to access optional region idx %u beyond " SIZE_FORMAT, index, _num_optional_regions);
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   222
  _oops_into_optional_regions[index].push_oop(p);
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   223
  DEBUG_ONLY(verify_ref(p);)
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   224
}
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   225
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   226
G1OopStarChunkedList* G1ParScanThreadState::oops_into_optional_region(const HeapRegion* hr) {
54934
39814e0a8964 8222492: G1 unnecessarily scans remembered set cards for regions that already have been evacuated
tschatzl
parents: 54843
diff changeset
   227
  assert(hr->index_in_opt_cset() < _num_optional_regions,
39814e0a8964 8222492: G1 unnecessarily scans remembered set cards for regions that already have been evacuated
tschatzl
parents: 54843
diff changeset
   228
         "Trying to access optional region idx %u beyond " SIZE_FORMAT " " HR_FORMAT,
39814e0a8964 8222492: G1 unnecessarily scans remembered set cards for regions that already have been evacuated
tschatzl
parents: 54843
diff changeset
   229
         hr->index_in_opt_cset(), _num_optional_regions, HR_FORMAT_PARAMS(hr));
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   230
  return &_oops_into_optional_regions[hr->index_in_opt_cset()];
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   231
}
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52349
diff changeset
   232
59062
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   233
void G1ParScanThreadState::initialize_numa_stats() {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   234
  if (_numa->is_enabled()) {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   235
    LogTarget(Info, gc, heap, numa) lt;
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   236
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   237
    if (lt.is_enabled()) {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   238
      uint num_nodes = _numa->num_active_nodes();
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   239
      // Record only if there are multiple active nodes.
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   240
      _obj_alloc_stat = NEW_C_HEAP_ARRAY(size_t, num_nodes, mtGC);
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   241
      memset(_obj_alloc_stat, 0, sizeof(size_t) * num_nodes);
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   242
    }
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   243
  }
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   244
}
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   245
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   246
void G1ParScanThreadState::flush_numa_stats() {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   247
  if (_obj_alloc_stat != NULL) {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   248
    uint node_index = _numa->index_of_current_thread();
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   249
    _numa->copy_statistics(G1NUMAStats::LocalObjProcessAtCopyToSurv, node_index, _obj_alloc_stat);
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   250
  }
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   251
}
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   252
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   253
void G1ParScanThreadState::update_numa_stats(uint node_index) {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   254
  if (_obj_alloc_stat != NULL) {
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   255
    _obj_alloc_stat[node_index]++;
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   256
  }
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   257
}
6530de931b8e 8220312: Implementation: NUMA-Aware Memory Allocation for G1, Logging (3/3)
sangheki
parents: 57777
diff changeset
   258
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
   259
#endif // SHARE_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP