annotate src/share/vm/gc_implementation/parallelScavenge/psVirtualspace.hpp @ 535:4e400c36026f

6783381: NUMA allocator: don't pretouch eden space with UseNUMA Summary: Moved pretouching to MutableSpace. Also MutableSpace now turns on page interleaving for the region it covers. Reviewed-by: jmasa, jcoomes
author iveresov
date Tue, 27 Jan 2009 18:13:59 -0800
parents a61af66fc99e
children 0fbdb4381b99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // VirtualSpace for the parallel scavenge collector.
a61af66fc99e Initial load
duke
parents:
diff changeset
26 //
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // VirtualSpace is data structure for committing a previously reserved address
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // range in smaller chunks.
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class PSVirtualSpace : public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // The space is committed/uncommited in chunks of size _alignment. The
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // ReservedSpace passed to initialize() must be aligned to this value.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 const size_t _alignment;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // Reserved area
a61af66fc99e Initial load
duke
parents:
diff changeset
38 char* _reserved_low_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 char* _reserved_high_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Committed area
a61af66fc99e Initial load
duke
parents:
diff changeset
42 char* _committed_low_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 char* _committed_high_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // The entire space has been committed and pinned in memory, no
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // os::commit_memory() or os::uncommit_memory().
a61af66fc99e Initial load
duke
parents:
diff changeset
47 bool _special;
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // Convenience wrapper.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 inline static size_t pointer_delta(const char* left, const char* right);
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 PSVirtualSpace(ReservedSpace rs, size_t alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 PSVirtualSpace(ReservedSpace rs);
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 ~PSVirtualSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Eventually all instances should be created with the above 1- or 2-arg
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // constructors. Then the 1st constructor below should become protected and
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // the 2nd ctor and initialize() removed.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 PSVirtualSpace(size_t alignment): _alignment(alignment) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 PSVirtualSpace();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 bool initialize(ReservedSpace rs, size_t commit_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 bool contains(void* p) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Accessors (all sizes are bytes).
a61af66fc99e Initial load
duke
parents:
diff changeset
68 size_t alignment() const { return _alignment; }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 char* reserved_low_addr() const { return _reserved_low_addr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 char* reserved_high_addr() const { return _reserved_high_addr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 char* committed_low_addr() const { return _committed_low_addr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 char* committed_high_addr() const { return _committed_high_addr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 bool special() const { return _special; }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 inline size_t committed_size() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 inline size_t reserved_size() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 inline size_t uncommitted_size() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // Operations.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 inline void set_reserved(char* low_addr, char* high_addr, bool special);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 inline void set_reserved(ReservedSpace rs);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 inline void set_committed(char* low_addr, char* high_addr);
535
4e400c36026f 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 0
diff changeset
83 virtual bool expand_by(size_t bytes);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84 virtual bool shrink_by(size_t bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 virtual size_t expand_into(PSVirtualSpace* space, size_t bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void release();
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
90 static bool is_aligned(size_t val, size_t align);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 bool is_aligned(size_t val) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 bool is_aligned(char* val) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 void print() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 virtual bool grows_up() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 bool grows_down() const { return !grows_up(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Helper class to verify a space when entering/leaving a block.
a61af66fc99e Initial load
duke
parents:
diff changeset
99 class PSVirtualSpaceVerifier: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
101 const PSVirtualSpace* const _space;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
103 PSVirtualSpaceVerifier(PSVirtualSpace* space): _space(space) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 _space->verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 ~PSVirtualSpaceVerifier() { _space->verify(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 };
a61af66fc99e Initial load
duke
parents:
diff changeset
108 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 virtual void print_space_boundaries_on(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Included for compatibility with the original VirtualSpace.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // Committed area
a61af66fc99e Initial load
duke
parents:
diff changeset
115 char* low() const { return committed_low_addr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 char* high() const { return committed_high_addr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // Reserved area
a61af66fc99e Initial load
duke
parents:
diff changeset
119 char* low_boundary() const { return reserved_low_addr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
120 char* high_boundary() const { return reserved_high_addr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 };
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // A virtual space that grows from high addresses to low addresses.
a61af66fc99e Initial load
duke
parents:
diff changeset
124 class PSVirtualSpaceHighToLow : public PSVirtualSpace {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
127 PSVirtualSpaceHighToLow(ReservedSpace rs, size_t alignment);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 PSVirtualSpaceHighToLow(ReservedSpace rs);
a61af66fc99e Initial load
duke
parents:
diff changeset
129
535
4e400c36026f 6783381: NUMA allocator: don't pretouch eden space with UseNUMA
iveresov
parents: 0
diff changeset
130 virtual bool expand_by(size_t bytes);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
131 virtual bool shrink_by(size_t bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 virtual size_t expand_into(PSVirtualSpace* space, size_t bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 virtual void print_space_boundaries_on(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
138 virtual bool grows_up() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
140 };
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 //
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // PSVirtualSpace inlines.
a61af66fc99e Initial load
duke
parents:
diff changeset
144 //
a61af66fc99e Initial load
duke
parents:
diff changeset
145 inline size_t
a61af66fc99e Initial load
duke
parents:
diff changeset
146 PSVirtualSpace::pointer_delta(const char* left, const char* right) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return ::pointer_delta((void *)left, (void*)right, sizeof(char));
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 inline size_t PSVirtualSpace::committed_size() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 return pointer_delta(committed_high_addr(), committed_low_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 inline size_t PSVirtualSpace::reserved_size() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return pointer_delta(reserved_high_addr(), reserved_low_addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 inline size_t PSVirtualSpace::uncommitted_size() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return reserved_size() - committed_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 inline void PSVirtualSpace::set_reserved(char* low_addr, char* high_addr, bool special) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 _reserved_low_addr = low_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 _reserved_high_addr = high_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 _special = special;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 inline void PSVirtualSpace::set_reserved(ReservedSpace rs) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 set_reserved(rs.base(), rs.base() + rs.size(), rs.special());
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 inline void PSVirtualSpace::set_committed(char* low_addr, char* high_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 _committed_low_addr = low_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 _committed_high_addr = high_addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }