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