src/hotspot/share/gc/shared/cardTableModRefBSForCTRS.cpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 32596 hotspot/src/share/vm/gc/shared/cardTableModRefBSForCTRS.cpp@8feecdee3156
child 48961 120b61d50f85
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31964
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
     1
/*
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
     4
 *
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
     8
 *
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    13
 * accompanied this code).
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    14
 *
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    18
 *
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    21
 * questions.
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    22
 *
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    23
 */
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    24
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    25
#include "precompiled.hpp"
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    26
#include "gc/shared/cardTableModRefBS.inline.hpp"
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    27
#include "gc/shared/cardTableRS.hpp"
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    28
#include "memory/allocation.inline.hpp"
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    29
#include "gc/shared/space.inline.hpp"
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    30
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    31
CardTableModRefBSForCTRS::CardTableModRefBSForCTRS(MemRegion whole_heap) :
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    32
  CardTableModRefBS(
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    33
    whole_heap,
32596
8feecdee3156 8072817: CardTableExtension kind() should be BarrierSet::CardTableExtension
kbarrett
parents: 31964
diff changeset
    34
    BarrierSet::FakeRtti(BarrierSet::CardTableForRS)),
31964
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    35
  // LNC functionality
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    36
  _lowest_non_clean(NULL),
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    37
  _lowest_non_clean_chunk_size(NULL),
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    38
  _lowest_non_clean_base_chunk_index(NULL),
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    39
  _last_LNC_resizing_collection(NULL)
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    40
{ }
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    41
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    42
void CardTableModRefBSForCTRS::initialize() {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    43
  CardTableModRefBS::initialize();
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    44
  _lowest_non_clean =
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    45
    NEW_C_HEAP_ARRAY(CardArr, _max_covered_regions, mtGC);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    46
  _lowest_non_clean_chunk_size =
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    47
    NEW_C_HEAP_ARRAY(size_t, _max_covered_regions, mtGC);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    48
  _lowest_non_clean_base_chunk_index =
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    49
    NEW_C_HEAP_ARRAY(uintptr_t, _max_covered_regions, mtGC);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    50
  _last_LNC_resizing_collection =
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    51
    NEW_C_HEAP_ARRAY(int, _max_covered_regions, mtGC);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    52
  if (_lowest_non_clean == NULL
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    53
      || _lowest_non_clean_chunk_size == NULL
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    54
      || _lowest_non_clean_base_chunk_index == NULL
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    55
      || _last_LNC_resizing_collection == NULL)
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    56
    vm_exit_during_initialization("couldn't allocate an LNC array.");
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    57
  for (int i = 0; i < _max_covered_regions; i++) {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    58
    _lowest_non_clean[i] = NULL;
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    59
    _lowest_non_clean_chunk_size[i] = 0;
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    60
    _last_LNC_resizing_collection[i] = -1;
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    61
  }
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    62
}
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    63
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    64
CardTableModRefBSForCTRS::~CardTableModRefBSForCTRS() {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    65
  if (_lowest_non_clean) {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    66
    FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    67
    _lowest_non_clean = NULL;
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    68
  }
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    69
  if (_lowest_non_clean_chunk_size) {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    70
    FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    71
    _lowest_non_clean_chunk_size = NULL;
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    72
  }
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    73
  if (_lowest_non_clean_base_chunk_index) {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    74
    FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    75
    _lowest_non_clean_base_chunk_index = NULL;
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    76
  }
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    77
  if (_last_LNC_resizing_collection) {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    78
    FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    79
    _last_LNC_resizing_collection = NULL;
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    80
  }
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    81
}
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    82
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    83
bool CardTableModRefBSForCTRS::card_will_be_scanned(jbyte cv) {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    84
  return
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    85
    card_is_dirty_wrt_gen_iter(cv) ||
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    86
    _rs->is_prev_nonclean_card_val(cv);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    87
}
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    88
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    89
bool CardTableModRefBSForCTRS::card_may_have_been_dirty(jbyte cv) {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    90
  return
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    91
    cv != clean_card &&
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    92
    (card_is_dirty_wrt_gen_iter(cv) ||
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    93
     CardTableRS::youngergen_may_have_been_dirty(cv));
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    94
}
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    95
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    96
void CardTableModRefBSForCTRS::non_clean_card_iterate_possibly_parallel(
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    97
  Space* sp,
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    98
  MemRegion mr,
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
    99
  OopsInGenClosure* cl,
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   100
  CardTableRS* ct,
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   101
  uint n_threads)
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   102
{
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   103
  if (!mr.is_empty()) {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   104
    if (n_threads > 0) {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   105
#if INCLUDE_ALL_GCS
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   106
      non_clean_card_iterate_parallel_work(sp, mr, cl, ct, n_threads);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   107
#else  // INCLUDE_ALL_GCS
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   108
      fatal("Parallel gc not supported here.");
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   109
#endif // INCLUDE_ALL_GCS
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   110
    } else {
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   111
      // clear_cl finds contiguous dirty ranges of cards to process and clear.
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   112
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   113
      // This is the single-threaded version used by DefNew.
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   114
      const bool parallel = false;
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   115
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   116
      DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision(), cl->gen_boundary(), parallel);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   117
      ClearNoncleanCardWrapper clear_cl(dcto_cl, ct, parallel);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   118
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   119
      clear_cl.do_MemRegion(mr);
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   120
    }
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   121
  }
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   122
}
d34ad1715d96 8130931: Refactor CardTableModRefBS[ForCTRS]
kbarrett
parents:
diff changeset
   123