src/hotspot/share/gc/g1/g1ParScanThreadState.hpp
author sangheki
Wed, 13 Nov 2019 10:49:32 -0800
changeset 59061 df6f2350edfa
parent 57802 854e828d6b5b
child 59062 6530de931b8e
permissions -rw-r--r--
8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/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_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
    26
#define SHARE_GC_G1_G1PARSCANTHREADSTATE_HPP
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    27
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49323
diff changeset
    28
#include "gc/g1/g1CardTable.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30568
diff changeset
    29
#include "gc/g1/g1CollectedHeap.hpp"
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
    30
#include "gc/g1/g1RedirtyCardsQueue.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30568
diff changeset
    31
#include "gc/g1/g1OopClosures.hpp"
37985
539c597ee0fa 8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents: 36369
diff changeset
    32
#include "gc/g1/g1Policy.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30568
diff changeset
    33
#include "gc/g1/g1RemSet.hpp"
49633
29ad59abc54a 8197928: Only enqueue deferred cards with references into regions that have a tracked remembered set during GC
tschatzl
parents: 49347
diff changeset
    34
#include "gc/g1/heapRegionRemSet.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30568
diff changeset
    35
#include "gc/shared/ageTable.hpp"
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    36
#include "memory/allocation.hpp"
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    37
#include "oops/oop.hpp"
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
    38
#include "utilities/ticks.hpp"
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    39
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
    40
class G1OopStarChunkedList;
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 32377
diff changeset
    41
class G1PLABAllocator;
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 33105
diff changeset
    42
class G1EvacuationRootClosures;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    43
class HeapRegion;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    44
class outputStream;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    45
32381
b750fd963056 8040162: Avoid reallocating PLABs between GC phases in G1
tschatzl
parents: 32378
diff changeset
    46
class G1ParScanThreadState : public CHeapObj<mtGC> {
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    47
  G1CollectedHeap* _g1h;
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    48
  RefToScanQueue* _refs;
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
    49
  G1RedirtyCardsQueue _rdcq;
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    50
  G1CardTable* _ct;
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 33105
diff changeset
    51
  G1EvacuationRootClosures* _closures;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    52
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    53
  G1PLABAllocator* _plab_allocator;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    54
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    55
  AgeTable _age_table;
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    56
  G1HeapRegionAttr _dest[G1HeapRegionAttr::Num];
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    57
  // Local tenuring threshold.
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    58
  uint _tenuring_threshold;
46572
fef0d64b2263 8175554: Improve G1UpdateRSOrPushRefClosure
tschatzl
parents: 46571
diff changeset
    59
  G1ScanEvacuatedObjClosure  _scanner;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    60
32187
0891f3fa84fc 8133047: Rename G1ParScanThreadState::_queue_num to _worker_id
tschatzl
parents: 32186
diff changeset
    61
  uint _worker_id;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    62
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54843
diff changeset
    63
  // Remember the last enqueued card to avoid enqueuing the same card over and over;
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54843
diff changeset
    64
  // since we only ever scan a card once, this is sufficient.
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54843
diff changeset
    65
  size_t _last_enqueued_card;
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54843
diff changeset
    66
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
    67
  // Upper and lower threshold to start and end work queue draining.
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
    68
  uint const _stack_trim_upper_threshold;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
    69
  uint const _stack_trim_lower_threshold;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
    70
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
    71
  Tickspan _trim_ticks;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    72
  // Map from young-age-index (0 == not young, 1 is youngest) to
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    73
  // surviving words. base is what we get back from the malloc call
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    74
  size_t* _surviving_young_words_base;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    75
  // this points into the array, as we use the first few entries for padding
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    76
  size_t* _surviving_young_words;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    77
32377
5ee15c417d02 8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents: 32187
diff changeset
    78
  // Indicates whether in the last generation (old) there is no more space
5ee15c417d02 8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents: 32187
diff changeset
    79
  // available for allocation.
5ee15c417d02 8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents: 32187
diff changeset
    80
  bool _old_gen_is_full;
5ee15c417d02 8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents: 32187
diff changeset
    81
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    82
#define PADDING_ELEM_NUM (DEFAULT_CACHE_LINE_SIZE / sizeof(size_t))
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    83
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
    84
  G1RedirtyCardsQueue& redirty_cards_queue()     { return _rdcq; }
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48157
diff changeset
    85
  G1CardTable* ct()                              { return _ct; }
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
    86
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    87
  G1HeapRegionAttr dest(G1HeapRegionAttr original) const {
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    88
    assert(original.is_valid(),
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    89
           "Original region attr invalid: %s", original.get_type_str());
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    90
    assert(_dest[original.type()].is_valid_gen(),
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    91
           "Dest region attr is invalid: %s", _dest[original.type()].get_type_str());
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
    92
    return _dest[original.type()];
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    93
  }
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
    94
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
    95
  size_t _num_optional_regions;
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
    96
  G1OopStarChunkedList* _oops_into_optional_regions;
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
    97
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
    98
public:
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
    99
  G1ParScanThreadState(G1CollectedHeap* g1h,
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 57777
diff changeset
   100
                       G1RedirtyCardsQueueSet* rdcqs,
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   101
                       uint worker_id,
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   102
                       size_t young_cset_length,
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   103
                       size_t optional_cset_length);
34131
d5fc001452bb 8139883: Add virtual destructor G1ParScanThreadState
ehelin
parents: 33224
diff changeset
   104
  virtual ~G1ParScanThreadState();
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   105
49827
a4672513d6e3 8201646: Introduce ReferenceDiscoverer interface
pliden
parents: 49744
diff changeset
   106
  void set_ref_discoverer(ReferenceDiscoverer* rd) { _scanner.set_ref_discoverer(rd); }
32381
b750fd963056 8040162: Avoid reallocating PLABs between GC phases in G1
tschatzl
parents: 32378
diff changeset
   107
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   108
#ifdef ASSERT
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   109
  bool queue_is_empty() const { return _refs->is_empty(); }
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   110
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   111
  bool verify_ref(narrowOop* ref) const;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   112
  bool verify_ref(oop* ref) const;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   113
  bool verify_task(StarTask ref) const;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   114
#endif // ASSERT
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   115
35051
002d874a4284 8144714: Add extension point to G1 evacuation closures
mgerdin
parents: 34617
diff changeset
   116
  template <class T> void do_oop_ext(T* ref);
30566
18eb9aa972d0 8076177: Remove usage of stack.inline.hpp functions from taskqueue.hpp
stefank
parents: 28213
diff changeset
   117
  template <class T> void push_on_queue(T* ref);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   118
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   119
  template <class T> void enqueue_card_if_tracked(G1HeapRegionAttr region_attr, T* p, oop o) {
52348
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 51292
diff changeset
   120
    assert(!HeapRegion::is_in_same_region(p, o), "Should have filtered out cross-region references already.");
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 51292
diff changeset
   121
    assert(!_g1h->heap_region_containing(p)->is_young(), "Should have filtered out from-young references already.");
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   122
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   123
#ifdef ASSERT
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   124
    HeapRegion* const hr_obj = _g1h->heap_region_containing((HeapWord*)o);
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   125
    assert(region_attr.needs_remset_update() == hr_obj->rem_set()->is_tracked(),
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   126
           "State flag indicating remset tracking disagrees (%s) with actual remembered set (%s) for region %u",
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   127
           BOOL_TO_STR(region_attr.needs_remset_update()),
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   128
           BOOL_TO_STR(hr_obj->rem_set()->is_tracked()),
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   129
           hr_obj->hrm_index());
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   130
#endif
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   131
    if (!region_attr.needs_remset_update()) {
52348
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 51292
diff changeset
   132
      return;
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 51292
diff changeset
   133
    }
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 51292
diff changeset
   134
    size_t card_index = ct()->index_for(p);
21fdf8d9a8b6 8212911: Unify and micro-optimize handling of non-in-collection set references in oop closures
tschatzl
parents: 51292
diff changeset
   135
    // If the card hasn't been added to the buffer, do it.
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54843
diff changeset
   136
    if (_last_enqueued_card != card_index) {
55752
8ae33203d600 8162929: Enqueuing dirty cards into a single DCQS during GC does not scale
kbarrett
parents: 55510
diff changeset
   137
      redirty_cards_queue().enqueue(ct()->byte_for_index(card_index));
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54843
diff changeset
   138
      _last_enqueued_card = card_index;
26701
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   139
    }
f8ff74a6c058 8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set
tschatzl
parents: 25483
diff changeset
   140
  }
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   141
33213
b937f634f56e 8138762: Refactor setup of evacuation closures in G1
mgerdin
parents: 33105
diff changeset
   142
  G1EvacuationRootClosures* closures() { return _closures; }
32187
0891f3fa84fc 8133047: Rename G1ParScanThreadState::_queue_num to _worker_id
tschatzl
parents: 32186
diff changeset
   143
  uint worker_id() { return _worker_id; }
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   144
53846
fe95464806a7 8219096: Merge print_termination_stats code with current logging
tschatzl
parents: 53747
diff changeset
   145
  size_t lab_waste_words() const;
fe95464806a7 8219096: Merge print_termination_stats code with current logging
tschatzl
parents: 53747
diff changeset
   146
  size_t lab_undo_waste_words() const;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   147
32737
f02118695c2f 8135154: Move cards scanned and surviving young words aggregation to G1ParScanThreadStateSet
mgerdin
parents: 32736
diff changeset
   148
  void flush(size_t* surviving_young_words);
32736
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   149
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   150
private:
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   151
  #define G1_PARTIAL_ARRAY_MASK 0x2
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   152
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   153
  inline bool has_partial_array_mask(oop* ref) const {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   154
    return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   155
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   156
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   157
  // We never encode partial array oops as narrowOop*, so return false immediately.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   158
  // This allows the compiler to create optimized code when popping references from
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   159
  // the work queue.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   160
  inline bool has_partial_array_mask(narrowOop* ref) const {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   161
    assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   162
    return false;
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   163
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   164
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   165
  // Only implement set_partial_array_mask() for regular oops, not for narrowOops.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   166
  // We always encode partial arrays as regular oop, to allow the
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   167
  // specialization for has_partial_array_mask() for narrowOops above.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   168
  // This means that unintentional use of this method with narrowOops are caught
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   169
  // by the compiler.
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   170
  inline oop* set_partial_array_mask(oop obj) const {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   171
    assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!");
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   172
    return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   173
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   174
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   175
  inline oop clear_partial_array_mask(oop* ref) const {
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   176
    return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   177
  }
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   178
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   179
  inline void do_oop_partial_array(oop* p);
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   180
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   181
  // This method is applied to the fields of the objects that have just been copied.
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49633
diff changeset
   182
  template <class T> inline void do_oop_evac(T* p);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   183
49744
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49633
diff changeset
   184
  inline void deal_with_reference(oop* ref_to_scan);
5dcc893ad119 8200233: Simple G1 evacuation path performance enhancements
tschatzl
parents: 49633
diff changeset
   185
  inline void deal_with_reference(narrowOop* ref_to_scan);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   186
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   187
  inline void dispatch_reference(StarTask ref);
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   188
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   189
  // Tries to allocate word_sz in the PLAB of the next "generation" after trying to
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 57802
diff changeset
   190
  // allocate into dest. Previous_plab_refill_failed indicates whether previous
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 57802
diff changeset
   191
  // PLAB refill for the original (source) object failed.
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   192
  // Returns a non-NULL pointer if successful, and updates dest if required.
32377
5ee15c417d02 8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents: 32187
diff changeset
   193
  // Also determines whether we should continue to try to allocate into the various
5ee15c417d02 8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents: 32187
diff changeset
   194
  // generations or just end trying to allocate.
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 57802
diff changeset
   195
  HeapWord* allocate_in_next_plab(G1HeapRegionAttr* dest,
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   196
                                  size_t word_sz,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 57802
diff changeset
   197
                                  bool previous_plab_refill_failed,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 57802
diff changeset
   198
                                  uint node_index);
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 27682
diff changeset
   199
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55752
diff changeset
   200
  inline G1HeapRegionAttr next_region_attr(G1HeapRegionAttr const region_attr, markWord const m, uint& age);
32608
ef2ec6fac731 8066443: Add G1 support for promotion event
sfriberg
parents: 32382
diff changeset
   201
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54110
diff changeset
   202
  void report_promotion_event(G1HeapRegionAttr const dest_attr,
32608
ef2ec6fac731 8066443: Add G1 support for promotion event
sfriberg
parents: 32382
diff changeset
   203
                              oop const old, size_t word_sz, uint age,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 57802
diff changeset
   204
                              HeapWord * const obj_ptr, uint node_index) const;
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   205
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   206
  inline bool needs_partial_trimming() const;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   207
  inline bool is_partially_trimmed() const;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   208
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   209
  inline void trim_queue_to_threshold(uint threshold);
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   210
public:
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55752
diff changeset
   211
  oop copy_to_survivor_space(G1HeapRegionAttr const region_attr, oop const obj, markWord const old_mark);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   212
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   213
  void trim_queue();
49911
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   214
  void trim_queue_partially();
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   215
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   216
  Tickspan trim_ticks() const;
358be4680d12 6672778: G1 should trim task queues more aggressively during evacuation pauses
tschatzl
parents: 49827
diff changeset
   217
  void reset_trim_ticks();
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   218
25483
962ccf95c515 8035401: Fix visibility of G1ParScanThreadState members
tschatzl
parents: 25482
diff changeset
   219
  inline void steal_and_trim_queue(RefToScanQueueSet *task_queues);
31976
da45f85bf4e1 8004687: G1: Parallelize object self-forwarding and scanning during an evacuation failure
tschatzl
parents: 30764
diff changeset
   220
da45f85bf4e1 8004687: G1: Parallelize object self-forwarding and scanning during an evacuation failure
tschatzl
parents: 30764
diff changeset
   221
  // An attempt to evacuate "obj" has failed; take necessary steps.
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 55752
diff changeset
   222
  oop handle_evacuation_failure_par(oop obj, markWord m);
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   223
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   224
  template <typename T>
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   225
  inline void remember_root_into_optional_region(T* p);
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   226
  template <typename T>
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   227
  inline void remember_reference_into_optional_region(T* p);
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   228
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   229
  inline G1OopStarChunkedList* oops_into_optional_region(const HeapRegion* hr);
25482
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   230
};
b69656f26643 8035400: Move G1ParScanThreadState into its own files
tschatzl
parents:
diff changeset
   231
32736
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   232
class G1ParScanThreadStateSet : public StackObj {
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   233
  G1CollectedHeap* _g1h;
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 57777
diff changeset
   234
  G1RedirtyCardsQueueSet* _rdcqs;
32736
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   235
  G1ParScanThreadState** _states;
32737
f02118695c2f 8135154: Move cards scanned and surviving young words aggregation to G1ParScanThreadStateSet
mgerdin
parents: 32736
diff changeset
   236
  size_t* _surviving_young_words_total;
36369
f4c151403480 8150629: Initializing all ParScanThreadStates causes significant unaccounted "Other" times
tschatzl
parents: 35492
diff changeset
   237
  size_t _young_cset_length;
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   238
  size_t _optional_cset_length;
32736
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   239
  uint _n_workers;
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   240
  bool _flushed;
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   241
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   242
 public:
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   243
  G1ParScanThreadStateSet(G1CollectedHeap* g1h,
57785
8d9362f3b8aa 8229044: G1RedirtyCardsQueueSet should be local to a collection
kbarrett
parents: 57777
diff changeset
   244
                          G1RedirtyCardsQueueSet* rdcqs,
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   245
                          uint n_workers,
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   246
                          size_t young_cset_length,
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   247
                          size_t optional_cset_length);
48157
7c4d43c26352 8192061: Clean up allocation.inline.hpp includes
stefank
parents: 47216
diff changeset
   248
  ~G1ParScanThreadStateSet();
32736
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   249
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   250
  void flush();
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52348
diff changeset
   251
  void record_unused_optional_region(HeapRegion* hr);
32736
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   252
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   253
  G1ParScanThreadState* state_for_worker(uint worker_id);
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   254
32737
f02118695c2f 8135154: Move cards scanned and surviving young words aggregation to G1ParScanThreadStateSet
mgerdin
parents: 32736
diff changeset
   255
  const size_t* surviving_young_words() const;
f02118695c2f 8135154: Move cards scanned and surviving young words aggregation to G1ParScanThreadStateSet
mgerdin
parents: 32736
diff changeset
   256
32736
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   257
 private:
32737
f02118695c2f 8135154: Move cards scanned and surviving young words aggregation to G1ParScanThreadStateSet
mgerdin
parents: 32736
diff changeset
   258
  G1ParScanThreadState* new_par_scan_state(uint worker_id, size_t young_cset_length);
32736
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   259
};
755024a84282 8135152: Create a G1ParScanThreadStateSet class for managing G1 GC per thread states
mgerdin
parents: 32608
diff changeset
   260
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
   261
#endif // SHARE_GC_G1_G1PARSCANTHREADSTATE_HPP