annotate src/share/vm/gc_implementation/g1/heapRegionSets.cpp @ 3777:e8b0b0392037

7046182: G1: remove unnecessary iterations over the collection set Summary: Remove two unnecessary iterations over the collection set which are supposed to prepare the RSet's of the CSet regions for parallel iterations (we'll make sure this is done incrementally). I'll piggyback on this CR the removal of the G1_REM_SET_LOGGING code. Reviewed-by: brutisso, johnc
author tonyp
date Tue, 21 Jun 2011 15:23:07 -0400
parents 1216415d8e35
children 8aae2050e83e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
1 /*
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
4 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
7 * published by the Free Software Foundation.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
8 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
13 * accompanied this code).
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
14 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
18 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
21 * questions.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
22 *
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
23 */
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
24
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
25 #include "precompiled.hpp"
3777
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
26 #include "gc_implementation/g1/heapRegionRemSet.hpp"
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
27 #include "gc_implementation/g1/heapRegionSets.hpp"
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
28
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
29 //////////////////// FreeRegionList ////////////////////
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
30
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
31 const char* FreeRegionList::verify_region_extra(HeapRegion* hr) {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
32 if (hr->is_young()) {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
33 return "the region should not be young";
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
34 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
35 // The superclass will check that the region is empty and
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
36 // not-humongous.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
37 return HeapRegionLinkedList::verify_region_extra(hr);
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
38 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
39
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
40 //////////////////// MasterFreeRegionList ////////////////////
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
41
3777
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
42 const char* MasterFreeRegionList::verify_region_extra(HeapRegion* hr) {
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
43 // We should reset the RSet for parallel iteration before we add it
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
44 // to the master free list so that it is ready when the region is
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
45 // re-allocated.
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
46 if (!hr->rem_set()->verify_ready_for_par_iteration()) {
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
47 return "the region's RSet should be ready for parallel iteration";
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
48 }
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
49 return FreeRegionList::verify_region_extra(hr);
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
50 }
e8b0b0392037 7046182: G1: remove unnecessary iterations over the collection set
tonyp
parents: 2361
diff changeset
51
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
52 bool MasterFreeRegionList::check_mt_safety() {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
53 // Master Free List MT safety protocol:
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
54 // (a) If we're at a safepoint, operations on the master free list
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
55 // should be invoked by either the VM thread (which will serialize
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
56 // them) or by the GC workers while holding the
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
57 // FreeList_lock.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
58 // (b) If we're not at a safepoint, operations on the master free
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
59 // list should be invoked while holding the Heap_lock.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
60
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
61 guarantee((SafepointSynchronize::is_at_safepoint() &&
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
62 (Thread::current()->is_VM_thread() ||
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
63 FreeList_lock->owned_by_self())) ||
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
64 (!SafepointSynchronize::is_at_safepoint() &&
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
65 Heap_lock->owned_by_self()),
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
66 hrs_ext_msg(this, "master free list MT safety protocol"));
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
67
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
68 return FreeRegionList::check_mt_safety();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
69 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
70
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
71 //////////////////// SecondaryFreeRegionList ////////////////////
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
72
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
73 bool SecondaryFreeRegionList::check_mt_safety() {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
74 // Secondary Free List MT safety protocol:
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
75 // Operations on the secondary free list should always be invoked
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
76 // while holding the SecondaryFreeList_lock.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
77
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
78 guarantee(SecondaryFreeList_lock->owned_by_self(),
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
79 hrs_ext_msg(this, "secondary free list MT safety protocol"));
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
80
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
81 return FreeRegionList::check_mt_safety();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
82 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
83
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
84 //////////////////// HumongousRegionSet ////////////////////
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
85
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
86 const char* HumongousRegionSet::verify_region_extra(HeapRegion* hr) {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
87 if (hr->is_young()) {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
88 return "the region should not be young";
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
89 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
90 // The superclass will check that the region is not empty and
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
91 // humongous.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
92 return HeapRegionSet::verify_region_extra(hr);
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
93 }
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
94
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
95 //////////////////// MasterHumongousRegionSet ////////////////////
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
96
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
97 bool MasterHumongousRegionSet::check_mt_safety() {
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
98 // Master Humongous Set MT safety protocol:
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
99 // (a) If we're at a safepoint, operations on the master humongous
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
100 // set should be invoked by either the VM thread (which will
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
101 // serialize them) or by the GC workers while holding the
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
102 // OldSets_lock.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
103 // (b) If we're not at a safepoint, operations on the master
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
104 // humongous set should be invoked while holding the Heap_lock.
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
105
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
106 guarantee((SafepointSynchronize::is_at_safepoint() &&
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
107 (Thread::current()->is_VM_thread() ||
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
108 OldSets_lock->owned_by_self())) ||
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
109 (!SafepointSynchronize::is_at_safepoint() &&
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
110 Heap_lock->owned_by_self()),
2361
1216415d8e35 7014923: G1: code cleanup
tonyp
parents: 2152
diff changeset
111 hrs_ext_msg(this, "master humongous set MT safety protocol"));
2152
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
112 return HumongousRegionSet::check_mt_safety();
0fa27f37d4d4 6977804: G1: remove the zero-filling thread
tonyp
parents:
diff changeset
113 }