Sat, 28 Mar 2009 15:47:29 -0700
6819891: ParNew: Fix work queue overflow code to deal correctly with +UseCompressedOops
Summary: When using compressed oops, rather than chaining the overflowed grey objects' pre-images through their klass words, we use GC-worker thread-local overflow stacks.
Reviewed-by: jcoomes, jmasa
1 /*
2 * Copyright 1997-2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
25 // ReservedSpace is a data structure for reserving a contiguous address range.
27 class ReservedSpace VALUE_OBJ_CLASS_SPEC {
28 friend class VMStructs;
29 private:
30 char* _base;
31 size_t _size;
32 size_t _noaccess_prefix;
33 size_t _alignment;
34 bool _special;
36 // ReservedSpace
37 ReservedSpace(char* base, size_t size, size_t alignment, bool special);
38 void initialize(size_t size, size_t alignment, bool large,
39 char* requested_address,
40 const size_t noaccess_prefix);
42 // Release parts of an already-reserved memory region [addr, addr + len) to
43 // get a new region that has "compound alignment." Return the start of the
44 // resulting region, or NULL on failure.
45 //
46 // The region is logically divided into a prefix and a suffix. The prefix
47 // starts at the result address, which is aligned to prefix_align. The suffix
48 // starts at result address + prefix_size, which is aligned to suffix_align.
49 // The total size of the result region is size prefix_size + suffix_size.
50 char* align_reserved_region(char* addr, const size_t len,
51 const size_t prefix_size,
52 const size_t prefix_align,
53 const size_t suffix_size,
54 const size_t suffix_align);
56 // Reserve memory, call align_reserved_region() to alignment it and return the
57 // result.
58 char* reserve_and_align(const size_t reserve_size,
59 const size_t prefix_size,
60 const size_t prefix_align,
61 const size_t suffix_size,
62 const size_t suffix_align);
64 protected:
65 // Create protection page at the beginning of the space.
66 void protect_noaccess_prefix(const size_t size);
68 public:
69 // Constructor
70 ReservedSpace(size_t size);
71 ReservedSpace(size_t size, size_t alignment, bool large,
72 char* requested_address = NULL,
73 const size_t noaccess_prefix = 0);
74 ReservedSpace(const size_t prefix_size, const size_t prefix_align,
75 const size_t suffix_size, const size_t suffix_align,
76 char* requested_address,
77 const size_t noaccess_prefix = 0);
79 // Accessors
80 char* base() const { return _base; }
81 size_t size() const { return _size; }
82 size_t alignment() const { return _alignment; }
83 bool special() const { return _special; }
85 size_t noaccess_prefix() const { return _noaccess_prefix; }
87 bool is_reserved() const { return _base != NULL; }
88 void release();
90 // Splitting
91 ReservedSpace first_part(size_t partition_size, size_t alignment,
92 bool split = false, bool realloc = true);
93 ReservedSpace last_part (size_t partition_size, size_t alignment);
95 // These simply call the above using the default alignment.
96 inline ReservedSpace first_part(size_t partition_size,
97 bool split = false, bool realloc = true);
98 inline ReservedSpace last_part (size_t partition_size);
100 // Alignment
101 static size_t page_align_size_up(size_t size);
102 static size_t page_align_size_down(size_t size);
103 static size_t allocation_align_size_up(size_t size);
104 static size_t allocation_align_size_down(size_t size);
105 };
107 ReservedSpace
108 ReservedSpace::first_part(size_t partition_size, bool split, bool realloc)
109 {
110 return first_part(partition_size, alignment(), split, realloc);
111 }
113 ReservedSpace ReservedSpace::last_part(size_t partition_size)
114 {
115 return last_part(partition_size, alignment());
116 }
118 // Class encapsulating behavior specific of memory space reserved for Java heap
119 class ReservedHeapSpace : public ReservedSpace {
120 public:
121 // Constructor
122 ReservedHeapSpace(size_t size, size_t forced_base_alignment,
123 bool large, char* requested_address);
124 ReservedHeapSpace(const size_t prefix_size, const size_t prefix_align,
125 const size_t suffix_size, const size_t suffix_align,
126 char* requested_address);
127 };
129 // VirtualSpace is data structure for committing a previously reserved address range in smaller chunks.
131 class VirtualSpace VALUE_OBJ_CLASS_SPEC {
132 friend class VMStructs;
133 private:
134 // Reserved area
135 char* _low_boundary;
136 char* _high_boundary;
138 // Committed area
139 char* _low;
140 char* _high;
142 // The entire space has been committed and pinned in memory, no
143 // os::commit_memory() or os::uncommit_memory().
144 bool _special;
146 // MPSS Support
147 // Each virtualspace region has a lower, middle, and upper region.
148 // Each region has an end boundary and a high pointer which is the
149 // high water mark for the last allocated byte.
150 // The lower and upper unaligned to LargePageSizeInBytes uses default page.
151 // size. The middle region uses large page size.
152 char* _lower_high;
153 char* _middle_high;
154 char* _upper_high;
156 char* _lower_high_boundary;
157 char* _middle_high_boundary;
158 char* _upper_high_boundary;
160 size_t _lower_alignment;
161 size_t _middle_alignment;
162 size_t _upper_alignment;
164 // MPSS Accessors
165 char* lower_high() const { return _lower_high; }
166 char* middle_high() const { return _middle_high; }
167 char* upper_high() const { return _upper_high; }
169 char* lower_high_boundary() const { return _lower_high_boundary; }
170 char* middle_high_boundary() const { return _middle_high_boundary; }
171 char* upper_high_boundary() const { return _upper_high_boundary; }
173 size_t lower_alignment() const { return _lower_alignment; }
174 size_t middle_alignment() const { return _middle_alignment; }
175 size_t upper_alignment() const { return _upper_alignment; }
177 public:
178 // Committed area
179 char* low() const { return _low; }
180 char* high() const { return _high; }
182 // Reserved area
183 char* low_boundary() const { return _low_boundary; }
184 char* high_boundary() const { return _high_boundary; }
186 bool special() const { return _special; }
188 public:
189 // Initialization
190 VirtualSpace();
191 bool initialize(ReservedSpace rs, size_t committed_byte_size);
193 // Destruction
194 ~VirtualSpace();
196 // Testers (all sizes are byte sizes)
197 size_t committed_size() const;
198 size_t reserved_size() const;
199 size_t uncommitted_size() const;
200 bool contains(const void* p) const;
202 // Operations
203 // returns true on success, false otherwise
204 bool expand_by(size_t bytes, bool pre_touch = false);
205 void shrink_by(size_t bytes);
206 void release();
208 void check_for_contiguity() PRODUCT_RETURN;
210 // Debugging
211 void print() PRODUCT_RETURN;
212 };