1 /*
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
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 *
57 // threads to locate PRTs without locking, but threads attempting to alter
58 // a bucket list obtain a lock. This means that any failing attempt to
59 // find a PRT must be retried with the lock. It might seem dangerous that
60 // a read can find a PRT that is concurrently deleted. This is all right,
61 // because:
62 //
63 // 1) We only actually free PRT's at safe points (though we reuse them at
64 // other times).
65 // 2) We find PRT's in an attempt to add entries. If a PRT is deleted,
66 // it's _coarse_map bit is set, so the that we were attempting to add
67 // is represented. If a deleted PRT is re-used, a thread adding a bit,
68 // thinking the PRT is for a different region, does no harm.
69
70 class OtherRegionsTable {
71 G1CollectedHeap* _g1h;
72 Mutex* _m;
73
74 size_t volatile _num_occupied;
75
76 // These are protected by "_m".
77 CHeapBitMap _coarse_map;
78 size_t _n_coarse_entries;
79 static jint _n_coarsenings;
80
81 PerRegionTable** _fine_grain_regions;
82 size_t _n_fine_entries;
83
84 // The fine grain remembered sets are linked together using
85 // their 'next' fields.
86 // This allows fast bulk freeing of all the fine grain remembered
87 // set entries, and fast finding of all of them without iterating
88 // over the _fine_grain_regions table.
89 PerRegionTable * _first_all_fine_prts;
90 PerRegionTable * _last_all_fine_prts;
91
92 // Used to sample a subset of the fine grain PRTs to determine which
93 // PRT to evict and coarsen.
94 size_t _fine_eviction_start;
95 static size_t _fine_eviction_stride;
96 static size_t _fine_eviction_sample_size;
97
98 SparsePRT _sparse_table;
99
|
1 /*
2 * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
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 *
57 // threads to locate PRTs without locking, but threads attempting to alter
58 // a bucket list obtain a lock. This means that any failing attempt to
59 // find a PRT must be retried with the lock. It might seem dangerous that
60 // a read can find a PRT that is concurrently deleted. This is all right,
61 // because:
62 //
63 // 1) We only actually free PRT's at safe points (though we reuse them at
64 // other times).
65 // 2) We find PRT's in an attempt to add entries. If a PRT is deleted,
66 // it's _coarse_map bit is set, so the that we were attempting to add
67 // is represented. If a deleted PRT is re-used, a thread adding a bit,
68 // thinking the PRT is for a different region, does no harm.
69
70 class OtherRegionsTable {
71 G1CollectedHeap* _g1h;
72 Mutex* _m;
73
74 size_t volatile _num_occupied;
75
76 // These are protected by "_m".
77 CHeapBitMap _coarse_map;
78 bool volatile _has_coarse_entries;
79 static jint _n_coarsenings;
80
81 PerRegionTable** _fine_grain_regions;
82 size_t _n_fine_entries;
83
84 // The fine grain remembered sets are linked together using
85 // their 'next' fields.
86 // This allows fast bulk freeing of all the fine grain remembered
87 // set entries, and fast finding of all of them without iterating
88 // over the _fine_grain_regions table.
89 PerRegionTable * _first_all_fine_prts;
90 PerRegionTable * _last_all_fine_prts;
91
92 // Used to sample a subset of the fine grain PRTs to determine which
93 // PRT to evict and coarsen.
94 size_t _fine_eviction_start;
95 static size_t _fine_eviction_stride;
96 static size_t _fine_eviction_sample_size;
97
98 SparsePRT _sparse_table;
99
|