src/hotspot/share/gc/g1/g1FromCardCache.cpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46669 hotspot/src/share/vm/gc/g1/g1FromCardCache.cpp@05296a16012a
child 49608 1852b17b0efc
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:
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
     1
/*
37228
25ea8814a824 8148099: Improve memory access to FromCardCache during GC
tschatzl
parents: 35210
diff changeset
     2
 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
     4
 *
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
     8
 *
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    14
 *
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    18
 *
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    21
 * questions.
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    22
 *
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    23
 */
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    24
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    25
#include "precompiled.hpp"
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    26
#include "gc/g1/g1FromCardCache.hpp"
35210
eb1d5c68bf64 8145672: Remove dependency of G1FromCardCache to HeapRegionRemSet
tschatzl
parents: 35200
diff changeset
    27
#include "gc/g1/g1RemSet.hpp"
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    28
#include "memory/padded.inline.hpp"
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    29
#include "utilities/debug.hpp"
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    30
35200
7802299b31e7 8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents: 35199
diff changeset
    31
int**  G1FromCardCache::_cache = NULL;
7802299b31e7 8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents: 35199
diff changeset
    32
uint   G1FromCardCache::_max_regions = 0;
7802299b31e7 8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents: 35199
diff changeset
    33
size_t G1FromCardCache::_static_mem_size = 0;
46669
05296a16012a 8184452: Add bounds checking for FromCardCache
tschatzl
parents: 37228
diff changeset
    34
#ifdef ASSERT
05296a16012a 8184452: Add bounds checking for FromCardCache
tschatzl
parents: 37228
diff changeset
    35
uint   G1FromCardCache::_max_workers = 0;
05296a16012a 8184452: Add bounds checking for FromCardCache
tschatzl
parents: 37228
diff changeset
    36
#endif
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    37
35210
eb1d5c68bf64 8145672: Remove dependency of G1FromCardCache to HeapRegionRemSet
tschatzl
parents: 35200
diff changeset
    38
void G1FromCardCache::initialize(uint num_par_rem_sets, uint max_num_regions) {
eb1d5c68bf64 8145672: Remove dependency of G1FromCardCache to HeapRegionRemSet
tschatzl
parents: 35200
diff changeset
    39
  guarantee(max_num_regions > 0, "Heap size must be valid");
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    40
  guarantee(_cache == NULL, "Should not call this multiple times");
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    41
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    42
  _max_regions = max_num_regions;
46669
05296a16012a 8184452: Add bounds checking for FromCardCache
tschatzl
parents: 37228
diff changeset
    43
#ifdef ASSERT
05296a16012a 8184452: Add bounds checking for FromCardCache
tschatzl
parents: 37228
diff changeset
    44
  _max_workers = num_par_rem_sets;
05296a16012a 8184452: Add bounds checking for FromCardCache
tschatzl
parents: 37228
diff changeset
    45
#endif
37228
25ea8814a824 8148099: Improve memory access to FromCardCache during GC
tschatzl
parents: 35210
diff changeset
    46
  _cache = Padded2DArray<int, mtGC>::create_unfreeable(_max_regions,
25ea8814a824 8148099: Improve memory access to FromCardCache during GC
tschatzl
parents: 35210
diff changeset
    47
                                                       num_par_rem_sets,
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    48
                                                       &_static_mem_size);
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    49
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    50
  invalidate(0, _max_regions);
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    51
}
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    52
35200
7802299b31e7 8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents: 35199
diff changeset
    53
void G1FromCardCache::invalidate(uint start_idx, size_t new_num_regions) {
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    54
  guarantee((size_t)start_idx + new_num_regions <= max_uintx,
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    55
            "Trying to invalidate beyond maximum region, from %u size " SIZE_FORMAT,
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    56
            start_idx, new_num_regions);
35210
eb1d5c68bf64 8145672: Remove dependency of G1FromCardCache to HeapRegionRemSet
tschatzl
parents: 35200
diff changeset
    57
  uint end_idx = (start_idx + (uint)new_num_regions);
eb1d5c68bf64 8145672: Remove dependency of G1FromCardCache to HeapRegionRemSet
tschatzl
parents: 35200
diff changeset
    58
  assert(end_idx <= _max_regions, "Must be within max.");
eb1d5c68bf64 8145672: Remove dependency of G1FromCardCache to HeapRegionRemSet
tschatzl
parents: 35200
diff changeset
    59
eb1d5c68bf64 8145672: Remove dependency of G1FromCardCache to HeapRegionRemSet
tschatzl
parents: 35200
diff changeset
    60
  for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    61
    for (uint j = start_idx; j < end_idx; j++) {
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    62
      set(i, j, InvalidCard);
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    63
    }
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    64
  }
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    65
}
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    66
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    67
#ifndef PRODUCT
35200
7802299b31e7 8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents: 35199
diff changeset
    68
void G1FromCardCache::print(outputStream* out) {
35210
eb1d5c68bf64 8145672: Remove dependency of G1FromCardCache to HeapRegionRemSet
tschatzl
parents: 35200
diff changeset
    69
  for (uint i = 0; i < G1RemSet::num_par_rem_sets(); i++) {
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    70
    for (uint j = 0; j < _max_regions; j++) {
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    71
      out->print_cr("_from_card_cache[%u][%u] = %d.",
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    72
                    i, j, at(i, j));
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    73
    }
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    74
  }
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    75
}
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    76
#endif
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    77
35200
7802299b31e7 8145671: Rename FromCardCache to G1FromCardCache
tschatzl
parents: 35199
diff changeset
    78
void G1FromCardCache::clear(uint region_idx) {
35210
eb1d5c68bf64 8145672: Remove dependency of G1FromCardCache to HeapRegionRemSet
tschatzl
parents: 35200
diff changeset
    79
  uint num_par_remsets = G1RemSet::num_par_rem_sets();
35199
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    80
  for (uint i = 0; i < num_par_remsets; i++) {
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    81
    set(i, region_idx, InvalidCard);
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    82
  }
a12e8d5aa2f7 8145667: Move FromCardCache into separate files
tschatzl
parents:
diff changeset
    83
}