annotate src/share/vm/gc_implementation/shared/spaceDecorator.hpp @ 269:850fdf70db2b

Merge
author jmasa
date Mon, 28 Jul 2008 15:30:23 -0700
parents 12eea04c8b06
children 9ee9cf798b59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
263
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
1 /*
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
2 * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
4 *
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
7 * published by the Free Software Foundation.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
8 *
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
13 * accompanied this code).
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
14 *
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
18 *
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
21 * have any questions.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
22 *
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
23 */
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
24
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
25 class SpaceDecorator: public AllStatic {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
26 public:
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
27 // Initialization flags.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
28 static const bool Clear = true;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
29 static const bool DontClear = false;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
30 static const bool Mangle = true;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
31 static const bool DontMangle = false;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
32 };
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
33
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
34 // Functionality for use with class Space and class MutableSpace.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
35 // The approach taken with the mangling is to mangle all
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
36 // the space initially and then to mangle areas that have
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
37 // been allocated since the last collection. Mangling is
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
38 // done in the context of a generation and in the context
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
39 // of a space.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
40 // The space in a generation is mangled when it is first
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
41 // initialized and when the generation grows. The spaces
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
42 // are not necessarily up-to-date when this mangling occurs
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
43 // and the method mangle_region() is used.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
44 // After allocations have been done in a space, the space generally
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
45 // need to be remangled. Remangling is only done on the
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
46 // recently allocated regions in the space. Typically, that is
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
47 // the region between the new top and the top just before a
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
48 // garbage collection.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
49 // An exception to the usual mangling in a space is done when the
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
50 // space is used for an extraordinary purpose. Specifically, when
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
51 // to-space is used as scratch space for a mark-sweep-compact
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
52 // collection.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
53 // Spaces are mangled after a collection. If the generation
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
54 // grows after a collection, the added space is mangled as part of
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
55 // the growth of the generation. No additional mangling is needed when the
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
56 // spaces are resized after an expansion.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
57 // The class SpaceMangler keeps a pointer to the top of the allocated
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
58 // area and provides the methods for doing the piece meal mangling.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
59 // Methods for doing sparces and full checking of the mangling are
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
60 // included. The full checking is done if DEBUG_MANGLING is defined.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
61 // GenSpaceMangler is used with the GenCollectedHeap collectors and
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
62 // MutableSpaceMangler is used with the ParallelScavengeHeap collectors.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
63 // These subclasses abstract the differences in the types of spaces used
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
64 // by each heap.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
65
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
66 class SpaceMangler: public CHeapObj {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
67 friend class VMStructs;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
68
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
69 // High water mark for allocations. Typically, the space above
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
70 // this point have been mangle previously and don't need to be
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
71 // touched again. Space belows this point has been allocated
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
72 // and remangling is needed between the current top and this
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
73 // high water mark.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
74 HeapWord* _top_for_allocations;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
75 HeapWord* top_for_allocations() { return _top_for_allocations; }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
76
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
77 public:
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
78
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
79 // Setting _top_for_allocations to NULL at initialization
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
80 // makes it always below top so that mangling done as part
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
81 // of the initialize() call of a space does nothing (as it
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
82 // should since the mangling is done as part of the constructor
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
83 // for the space.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
84 SpaceMangler() : _top_for_allocations(NULL) {}
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
85
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
86 // Methods for top and end that delegate to the specific
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
87 // space type.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
88 virtual HeapWord* top() const = 0;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
89 virtual HeapWord* end() const = 0;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
90
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
91 // Return true if q matches the mangled pattern.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
92 static bool is_mangled(HeapWord* q) PRODUCT_RETURN0;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
93
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
94 // Used to save the an address in a space for later use during mangling.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
95 void set_top_for_allocations(HeapWord* v);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
96
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
97 // Overwrites the unused portion of this space.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
98 // Mangle only the region not previously mangled [top, top_previously_mangled)
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
99 void mangle_unused_area();
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
100 // Mangle all the unused region [top, end)
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
101 void mangle_unused_area_complete();
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
102 // Do some sparse checking on the area that should have been mangled.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
103 void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
104 // Do a complete check of the area that should be mangled.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
105 void check_mangled_unused_area_complete() PRODUCT_RETURN;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
106
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
107 // Mangle the MemRegion. This is a non-space specific mangler. It
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
108 // is used during the initial mangling of a space before the space
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
109 // is fully constructed. Also is used when a generation is expanded
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
110 // and possibly before the spaces have been reshaped to to the new
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
111 // size of the generation.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
112 static void mangle_region(MemRegion mr);
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
113 };
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
114
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
115 class ContiguousSpace;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
116
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
117 // For use with GenCollectedHeap's
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
118 class GenSpaceMangler: public SpaceMangler {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
119 ContiguousSpace* _sp;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
120
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
121 ContiguousSpace* sp() { return _sp; }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
122
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
123 HeapWord* top() const { return _sp->top(); }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
124 HeapWord* end() const { return _sp->end(); }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
125
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
126 public:
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
127 GenSpaceMangler(ContiguousSpace* sp) : SpaceMangler(), _sp(sp) {}
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
128 };
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
129
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
130 // For use with ParallelScavengeHeap's.
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
131 class MutableSpaceMangler: public SpaceMangler {
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
132 MutableSpace* _sp;
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
133
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
134 MutableSpace* sp() { return _sp; }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
135
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
136 HeapWord* top() const { return _sp->top(); }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
137 HeapWord* end() const { return _sp->end(); }
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
138
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
139 public:
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
140 MutableSpaceMangler(MutableSpace* sp) : SpaceMangler(), _sp(sp) {}
12eea04c8b06 6672698: mangle_unused_area() should not remangle the entire heap at each collection.
jmasa
parents:
diff changeset
141 };