src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp
author tschatzl
Fri, 27 Apr 2018 12:06:46 +0200
changeset 49911 358be4680d12
parent 49744 5dcc893ad119
child 50113 caf115bb98ad
permissions -rw-r--r--
6672778: G1 should trim task queues more aggressively during evacuation pauses Summary: Regularly try to drain task queues. This helps memory usage and performance during garbage collection. Reviewed-by: sjohanss, sangheki
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
     1
/*
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49592
diff changeset
     2
 * Copyright (c) 2014, 2018, 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
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    26
#define SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30566
diff changeset
    28
#include "gc/g1/g1ParScanThreadState.hpp"
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    29
#include "gc/g1/g1RemSet.hpp"
49592
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49337
diff changeset
    30
#include "oops/access.inline.hpp"
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    31
#include "oops/oop.inline.hpp"
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
    32
#include "utilities/ticks.inline.hpp"
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    33
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
    34
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
    35
  // Reference should not be NULL here as such are never pushed to the task queue.
77fb0be7d19f 8199946: Move load/store and encode/decode out of oopDesc
stefank
parents: 49337
diff changeset
    36
  oop obj = RawAccess<OOP_NOT_NULL>::oop_load(p);
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    37
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    38
  // Although we never intentionally push references outside of the collection
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    39
  // 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
    40
  // 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
    41
  // 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
    42
  // So we need to redo this check.
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    43
  const InCSetState in_cset_state = _g1h->in_cset_state(obj);
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    44
  if (in_cset_state.is_in_cset()) {
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 49592
diff changeset
    45
    markOop m = obj->mark_raw();
27682
dbd1c3f92130 8064473: Improved handling of age during object copy in G1
sfriberg
parents: 26701
diff changeset
    46
    if (m->is_marked()) {
34622
12a738c34eb9 8144315: update_rs is passed wrong object
ehelin
parents: 34616
diff changeset
    47
      obj = (oop) m->decode_pointer();
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    48
    } else {
34622
12a738c34eb9 8144315: update_rs is passed wrong object
ehelin
parents: 34616
diff changeset
    49
      obj = copy_to_survivor_space(in_cset_state, obj, m);
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    50
    }
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
    51
    RawAccess<OOP_NOT_NULL>::oop_store(p, obj);
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    52
  } else if (in_cset_state.is_humongous()) {
25889
221296ac4359 8027959: Early reclamation of large objects in G1
tschatzl
parents: 25483
diff changeset
    53
    _g1h->set_humongous_is_live(obj);
221296ac4359 8027959: Early reclamation of large objects in G1
tschatzl
parents: 25483
diff changeset
    54
  } else {
49337
e4fdca451542 8197847: Remove unused file g1ParScanThreadState_ext.cpp
ehelin
parents: 47885
diff changeset
    55
    assert(in_cset_state.is_default(),
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
    56
           "In_cset_state must be NotInCSet here, but is " CSETSTATE_FORMAT, in_cset_state.value());
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    57
  }
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    58
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    59
  assert(obj != NULL, "Must be");
46646
5165b3a5b44a 8183397: Ensure consistent closure filtering during evacuation
tschatzl
parents: 35191
diff changeset
    60
  if (!HeapRegion::is_in_same_region(p, obj)) {
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
    61
    HeapRegion* from = _g1h->heap_region_containing(p);
46646
5165b3a5b44a 8183397: Ensure consistent closure filtering during evacuation
tschatzl
parents: 35191
diff changeset
    62
    update_rs(from, p, obj);
5165b3a5b44a 8183397: Ensure consistent closure filtering during evacuation
tschatzl
parents: 35191
diff changeset
    63
  }
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    64
}
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
    65
30566
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 30173
diff changeset
    66
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
    67
  assert(verify_ref(ref), "sanity");
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 30173
diff changeset
    68
  _refs->push(ref);
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 30173
diff changeset
    69
}
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 30173
diff changeset
    70
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    71
inline void G1ParScanThreadState::do_oop_partial_array(oop* p) {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    72
  assert(has_partial_array_mask(p), "invariant");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    73
  oop from_obj = clear_partial_array_mask(p);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    74
30173
13cf7580b000 8077413: Avoid use of Universe::heap() inside collectors
pliden
parents: 28213
diff changeset
    75
  assert(_g1h->is_in_reserved(from_obj), "must be in heap.");
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    76
  assert(from_obj->is_objArray(), "must be obj array");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    77
  objArrayOop from_obj_array = objArrayOop(from_obj);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    78
  // The from-space object contains the real length.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    79
  int length                 = from_obj_array->length();
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    80
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    81
  assert(from_obj->is_forwarded(), "must be forwarded");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    82
  oop to_obj                 = from_obj->forwardee();
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    83
  assert(from_obj != to_obj, "should not be chunking self-forwarded objects");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    84
  objArrayOop to_obj_array   = objArrayOop(to_obj);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    85
  // 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
    86
  // to-space object.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    87
  int next_index             = to_obj_array->length();
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    88
  assert(0 <= next_index && next_index < length,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32187
diff changeset
    89
         "invariant, next index: %d, length: %d", next_index, length);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    90
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    91
  int start                  = next_index;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    92
  int end                    = length;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    93
  int remainder              = end - start;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    94
  // 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
    95
  if (remainder > 2 * ParGCArrayScanChunk) {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    96
    end = start + ParGCArrayScanChunk;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    97
    to_obj_array->set_length(end);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    98
    // Push the remainder before we process the range in case another
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    99
    // worker has run out of things to do and can steal it.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   100
    oop* from_obj_p = set_partial_array_mask(from_obj);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   101
    push_on_queue(from_obj_p);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   102
  } else {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   103
    assert(length == end, "sanity");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   104
    // We'll process the final range for this object. Restore the length
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   105
    // so that the heap remains parsable in case of evacuation failure.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   106
    to_obj_array->set_length(end);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   107
  }
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33224
diff changeset
   108
  _scanner.set_region(_g1h->heap_region_containing(to_obj));
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   109
  // Process indexes [start,end). It will also process the header
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   110
  // along with the first chunk (i.e., the chunk with start == 0).
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   111
  // 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
   112
  // 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
   113
  // start index. oop_iterate_range() (thankfully!) ignores the length
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   114
  // field and only relies on the start / end parameters.  It does
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   115
  // however return the size of the object which will be incorrect. So
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   116
  // we have to ignore it even if we wanted to use it.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   117
  to_obj_array->oop_iterate_range(&_scanner, start, end);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   118
}
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   119
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   120
inline void G1ParScanThreadState::deal_with_reference(oop* ref_to_scan) {
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   121
  if (!has_partial_array_mask(ref_to_scan)) {
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   122
    do_oop_evac(ref_to_scan);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   123
  } else {
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   124
    do_oop_partial_array(ref_to_scan);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   125
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   126
}
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   127
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   128
inline void G1ParScanThreadState::deal_with_reference(narrowOop* ref_to_scan) {
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   129
  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
   130
  do_oop_evac(ref_to_scan);
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   131
}
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49722
diff changeset
   132
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   133
inline void G1ParScanThreadState::dispatch_reference(StarTask ref) {
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   134
  assert(verify_task(ref), "sanity");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   135
  if (ref.is_narrow()) {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   136
    deal_with_reference((narrowOop*)ref);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   137
  } else {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   138
    deal_with_reference((oop*)ref);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   139
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   140
}
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   141
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   142
void G1ParScanThreadState::steal_and_trim_queue(RefToScanQueueSet *task_queues) {
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   143
  StarTask stolen_task;
32187
0891f3fa84fc 8133047: Rename G1ParScanThreadState::_queue_num to _worker_id
tschatzl
parents: 30764
diff changeset
   144
  while (task_queues->steal(_worker_id, &_hash_seed, stolen_task)) {
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   145
    assert(verify_task(stolen_task), "sanity");
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   146
    dispatch_reference(stolen_task);
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   147
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   148
    // We've just processed a reference and we might have made
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   149
    // available new entries on the queues. So we have to make sure
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   150
    // we drain the queues as necessary.
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   151
    trim_queue();
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   152
  }
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   153
}
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   154
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   155
inline bool G1ParScanThreadState::needs_partial_trimming() const {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   156
  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
   157
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   158
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   159
inline bool G1ParScanThreadState::is_partially_trimmed() const {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   160
  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
   161
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   162
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   163
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
   164
  StarTask ref;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   165
  // 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
   166
  while (_refs->pop_overflow(ref)) {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   167
    if (!_refs->try_push_to_taskqueue(ref)) {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   168
      dispatch_reference(ref);
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   169
    }
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   170
  }
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
  while (_refs->pop_local(ref, threshold)) {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   173
    dispatch_reference(ref);
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   174
  }
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   175
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   176
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   177
inline void G1ParScanThreadState::trim_queue_partially() {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   178
  if (!needs_partial_trimming()) {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   179
    return;
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
  const Ticks start = Ticks::now();
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   183
  do {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   184
    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
   185
  } while (!is_partially_trimmed());
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   186
  _trim_ticks += Ticks::now() - start;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   187
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   188
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   189
inline Tickspan G1ParScanThreadState::trim_ticks() const {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   190
  return _trim_ticks;
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
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   193
inline void G1ParScanThreadState::reset_trim_ticks() {
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   194
  _trim_ticks = Tickspan();
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   195
}
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49744
diff changeset
   196
35191
da47979837b4 8145752: Fix include guards in GC code
tschatzl
parents: 35051
diff changeset
   197
#endif // SHARE_VM_GC_G1_G1PARSCANTHREADSTATE_INLINE_HPP