Thu, 13 Feb 2014 17:44:39 +0100
8034761: Remove the do_code_roots parameter from process_strong_roots
Reviewed-by: tschatzl, mgerdin, jmasa
1 /*
2 * Copyright (c) 2002, 2014, 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 */
25 #include "precompiled.hpp"
26 #include "gc_implementation/shared/spaceDecorator.hpp"
27 #include "memory/space.inline.hpp"
28 #include "utilities/copy.hpp"
30 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
32 // Catch-all file for utility classes
34 #ifndef PRODUCT
36 // Returns true is the location q matches the mangling
37 // pattern.
38 bool SpaceMangler::is_mangled(HeapWord* q) {
39 // This test loses precision but is good enough
40 return badHeapWord == (max_juint & (uintptr_t) q->value());
41 }
44 void SpaceMangler::set_top_for_allocations(HeapWord* v) {
45 if (v < end()) {
46 assert(!CheckZapUnusedHeapArea || is_mangled(v),
47 "The high water mark is not mangled");
48 }
49 _top_for_allocations = v;
50 }
52 // Mangle only the unused space that has not previously
53 // been mangled and that has not been allocated since being
54 // mangled.
55 void SpaceMangler::mangle_unused_area() {
56 assert(ZapUnusedHeapArea, "Mangling should not be in use");
57 // Mangle between top and the high water mark. Safeguard
58 // against the space changing since top_for_allocations was
59 // set.
60 HeapWord* mangled_end = MIN2(top_for_allocations(), end());
61 if (top() < mangled_end) {
62 MemRegion mangle_mr(top(), mangled_end);
63 SpaceMangler::mangle_region(mangle_mr);
64 // Light weight check of mangling.
65 check_mangled_unused_area(end());
66 }
67 // Complete check of unused area which is functional when
68 // DEBUG_MANGLING is defined.
69 check_mangled_unused_area_complete();
70 }
72 // A complete mangle is expected in the
73 // exceptional case where top_for_allocations is not
74 // properly tracking the high water mark for mangling.
75 // This can be the case when to-space is being used for
76 // scratch space during a mark-sweep-compact. See
77 // contribute_scratch() and PSMarkSweep::allocate_stacks().
78 void SpaceMangler::mangle_unused_area_complete() {
79 assert(ZapUnusedHeapArea, "Mangling should not be in use");
80 MemRegion mangle_mr(top(), end());
81 SpaceMangler::mangle_region(mangle_mr);
82 }
84 // Simply mangle the MemRegion mr.
85 void SpaceMangler::mangle_region(MemRegion mr) {
86 assert(ZapUnusedHeapArea, "Mangling should not be in use");
87 #ifdef ASSERT
88 if(TraceZapUnusedHeapArea) {
89 gclog_or_tty->print("Mangling [0x%x to 0x%x)", mr.start(), mr.end());
90 }
91 Copy::fill_to_words(mr.start(), mr.word_size(), badHeapWord);
92 if(TraceZapUnusedHeapArea) {
93 gclog_or_tty->print_cr(" done");
94 }
95 #endif
96 }
98 // Check that top, top_for_allocations and the last
99 // word of the space are mangled. In a tight memory
100 // situation even this light weight mangling could
101 // cause paging by touching the end of the space.
102 void SpaceMangler::check_mangled_unused_area(HeapWord* limit) {
103 if (CheckZapUnusedHeapArea) {
104 // This method can be called while the spaces are
105 // being reshaped so skip the test if the end of the
106 // space is beyond the specified limit;
107 if (end() > limit) return;
109 assert(top() == end() ||
110 (is_mangled(top())), "Top not mangled");
111 assert((top_for_allocations() < top()) ||
112 (top_for_allocations() >= end()) ||
113 (is_mangled(top_for_allocations())),
114 "Older unused not mangled");
115 assert(top() == end() ||
116 (is_mangled(end() - 1)), "End not properly mangled");
117 // Only does checking when DEBUG_MANGLING is defined.
118 check_mangled_unused_area_complete();
119 }
120 }
122 #undef DEBUG_MANGLING
123 // This should only be used while debugging the mangling
124 // because of the high cost of checking the completeness.
125 void SpaceMangler::check_mangled_unused_area_complete() {
126 if (CheckZapUnusedHeapArea) {
127 assert(ZapUnusedHeapArea, "Not mangling unused area");
128 #ifdef DEBUG_MANGLING
129 HeapWord* q = top();
130 HeapWord* limit = end();
132 bool passed = true;
133 while (q < limit) {
134 if (!is_mangled(q)) {
135 passed = false;
136 break;
137 }
138 q++;
139 }
140 assert(passed, "Mangling is not complete");
141 #endif
142 }
143 }
144 #undef DEBUG_MANGLING
145 #endif // not PRODUCT