|
1 /* |
|
2 * Copyright (c) 2011, 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 * |
|
23 */ |
|
24 |
|
25 #include "precompiled.hpp" |
|
26 #include "gc_implementation/g1/heapRegionSets.hpp" |
|
27 |
|
28 //////////////////// FreeRegionList //////////////////// |
|
29 |
|
30 const char* FreeRegionList::verify_region_extra(HeapRegion* hr) { |
|
31 if (hr->is_young()) { |
|
32 return "the region should not be young"; |
|
33 } |
|
34 // The superclass will check that the region is empty and |
|
35 // not-humongous. |
|
36 return HeapRegionLinkedList::verify_region_extra(hr); |
|
37 } |
|
38 |
|
39 //////////////////// MasterFreeRegionList //////////////////// |
|
40 |
|
41 bool MasterFreeRegionList::check_mt_safety() { |
|
42 // Master Free List MT safety protocol: |
|
43 // (a) If we're at a safepoint, operations on the master free list |
|
44 // should be invoked by either the VM thread (which will serialize |
|
45 // them) or by the GC workers while holding the |
|
46 // FreeList_lock. |
|
47 // (b) If we're not at a safepoint, operations on the master free |
|
48 // list should be invoked while holding the Heap_lock. |
|
49 |
|
50 guarantee((SafepointSynchronize::is_at_safepoint() && |
|
51 (Thread::current()->is_VM_thread() || |
|
52 FreeList_lock->owned_by_self())) || |
|
53 (!SafepointSynchronize::is_at_safepoint() && |
|
54 Heap_lock->owned_by_self()), |
|
55 hrl_ext_msg(this, "master free list MT safety protocol")); |
|
56 |
|
57 return FreeRegionList::check_mt_safety(); |
|
58 } |
|
59 |
|
60 //////////////////// SecondaryFreeRegionList //////////////////// |
|
61 |
|
62 bool SecondaryFreeRegionList::check_mt_safety() { |
|
63 // Secondary Free List MT safety protocol: |
|
64 // Operations on the secondary free list should always be invoked |
|
65 // while holding the SecondaryFreeList_lock. |
|
66 |
|
67 guarantee(SecondaryFreeList_lock->owned_by_self(), |
|
68 hrl_ext_msg(this, "secondary free list MT safety protocol")); |
|
69 |
|
70 return FreeRegionList::check_mt_safety(); |
|
71 } |
|
72 |
|
73 //////////////////// HumongousRegionSet //////////////////// |
|
74 |
|
75 const char* HumongousRegionSet::verify_region_extra(HeapRegion* hr) { |
|
76 if (hr->is_young()) { |
|
77 return "the region should not be young"; |
|
78 } |
|
79 // The superclass will check that the region is not empty and |
|
80 // humongous. |
|
81 return HeapRegionSet::verify_region_extra(hr); |
|
82 } |
|
83 |
|
84 //////////////////// HumongousRegionSet //////////////////// |
|
85 |
|
86 bool MasterHumongousRegionSet::check_mt_safety() { |
|
87 // Master Humongous Set MT safety protocol: |
|
88 // (a) If we're at a safepoint, operations on the master humongous |
|
89 // set should be invoked by either the VM thread (which will |
|
90 // serialize them) or by the GC workers while holding the |
|
91 // OldSets_lock. |
|
92 // (b) If we're not at a safepoint, operations on the master |
|
93 // humongous set should be invoked while holding the Heap_lock. |
|
94 |
|
95 guarantee((SafepointSynchronize::is_at_safepoint() && |
|
96 (Thread::current()->is_VM_thread() || |
|
97 OldSets_lock->owned_by_self())) || |
|
98 (!SafepointSynchronize::is_at_safepoint() && |
|
99 Heap_lock->owned_by_self()), |
|
100 hrl_ext_msg(this, "master humongous set MT safety protocol")); |
|
101 return HumongousRegionSet::check_mt_safety(); |
|
102 } |