annotate src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp @ 12146:9758d9f36299

8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced Summary: declare all user-defined operator new()s within Hotspot code with the empty throw() exception specification Reviewed-by: coleenp, twisti, dholmes, hseigel, dcubed, kvn, ccheung Contributed-by: lois.foltan@oracle.com
author coleenp
date Thu, 29 Aug 2013 18:56:29 -0400
parents 87c64c0438fb
children de6a9e811145
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6595
aaf61e68b255 6818524: G1: use ergonomic resizing of PLABs
johnc
parents: 6197
diff changeset
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/allocation.hpp"
1983
c760f78e0a53 7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents: 1972
diff changeset
29 #include "memory/blockOffsetTable.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/threadLocalAllocBuffer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // Forward decl.
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class PLABStats;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // A per-thread allocation buffer used during GC.
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1983
diff changeset
38 class ParGCAllocBuffer: public CHeapObj<mtGC> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
40 char head[32];
a61af66fc99e Initial load
duke
parents:
diff changeset
41 size_t _word_sz; // in HeapWord units
a61af66fc99e Initial load
duke
parents:
diff changeset
42 HeapWord* _bottom;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 HeapWord* _top;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 HeapWord* _end; // last allocatable address + 1
a61af66fc99e Initial load
duke
parents:
diff changeset
45 HeapWord* _hard_end; // _end + AlignmentReserve
a61af66fc99e Initial load
duke
parents:
diff changeset
46 bool _retained; // whether we hold a _retained_filler
a61af66fc99e Initial load
duke
parents:
diff changeset
47 MemRegion _retained_filler;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // In support of ergonomic sizing of PLAB's
a61af66fc99e Initial load
duke
parents:
diff changeset
49 size_t _allocated; // in HeapWord units
a61af66fc99e Initial load
duke
parents:
diff changeset
50 size_t _wasted; // in HeapWord units
a61af66fc99e Initial load
duke
parents:
diff changeset
51 char tail[32];
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
52 static size_t FillerHeaderSize;
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 0
diff changeset
53 static size_t AlignmentReserve;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
54
6756
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
55 // Flush the stats supporting ergonomic sizing of PLAB's
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
56 // Should not be called directly
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
57 void flush_stats(PLABStats* stats);
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
58
0
a61af66fc99e Initial load
duke
parents:
diff changeset
59 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Initializes the buffer to be empty, but with the given "word_sz".
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Must get initialized with "set_buf" for an allocation to succeed.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 ParGCAllocBuffer(size_t word_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 static const size_t min_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 return ThreadLocalAllocBuffer::min_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 static const size_t max_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 return ThreadLocalAllocBuffer::max_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // If an allocation of the given "word_sz" can be satisfied within the
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // buffer, do the allocation, returning a pointer to the start of the
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // allocated block. If the allocation request cannot be satisfied,
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // return NULL.
a61af66fc99e Initial load
duke
parents:
diff changeset
76 HeapWord* allocate(size_t word_sz) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 HeapWord* res = _top;
634
09f82af55c3e 6808322: ParNew, CMS, G1: ParGCAllocBuffer overflow
ysr
parents: 196
diff changeset
78 if (pointer_delta(_end, _top) >= word_sz) {
09f82af55c3e 6808322: ParNew, CMS, G1: ParGCAllocBuffer overflow
ysr
parents: 196
diff changeset
79 _top = _top + word_sz;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
80 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Undo the last allocation in the buffer, which is required to be of the
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // "obj" of the given "word_sz".
a61af66fc99e Initial load
duke
parents:
diff changeset
88 void undo_allocation(HeapWord* obj, size_t word_sz) {
634
09f82af55c3e 6808322: ParNew, CMS, G1: ParGCAllocBuffer overflow
ysr
parents: 196
diff changeset
89 assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo");
09f82af55c3e 6808322: ParNew, CMS, G1: ParGCAllocBuffer overflow
ysr
parents: 196
diff changeset
90 assert(pointer_delta(_top, obj) == word_sz, "Bad undo");
09f82af55c3e 6808322: ParNew, CMS, G1: ParGCAllocBuffer overflow
ysr
parents: 196
diff changeset
91 _top = obj;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // The total (word) size of the buffer, including both allocated and
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // unallocted space.
a61af66fc99e Initial load
duke
parents:
diff changeset
96 size_t word_sz() { return _word_sz; }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Should only be done if we are about to reset with a new buffer of the
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // given size.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void set_word_size(size_t new_word_sz) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 assert(new_word_sz > AlignmentReserve, "Too small");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 _word_sz = new_word_sz;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // The number of words of unallocated space remaining in the buffer.
a61af66fc99e Initial load
duke
parents:
diff changeset
106 size_t words_remaining() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 assert(_end >= _top, "Negative buffer");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 return pointer_delta(_end, _top, HeapWordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 bool contains(void* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return (void*)_bottom <= addr && addr < (void*)_hard_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Sets the space of the buffer to be [buf, space+word_sz()).
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void set_buf(HeapWord* buf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 _bottom = buf;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 _top = _bottom;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 _hard_end = _bottom + word_sz();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 _end = _hard_end - AlignmentReserve;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 assert(_end >= _top, "Negative buffer");
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // In support of ergonomic sizing
a61af66fc99e Initial load
duke
parents:
diff changeset
123 _allocated += word_sz();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Flush the stats supporting ergonomic sizing of PLAB's
6756
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
127 // and retire the current buffer.
6595
aaf61e68b255 6818524: G1: use ergonomic resizing of PLABs
johnc
parents: 6197
diff changeset
128 void flush_stats_and_retire(PLABStats* stats, bool end_of_gc, bool retain) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // We flush the stats first in order to get a reading of
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // unused space in the last buffer.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (ResizePLAB) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 flush_stats(stats);
6756
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
133
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
134 // Since we have flushed the stats we need to clear
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
135 // the _allocated and _wasted fields. Not doing so
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
136 // will artifically inflate the values in the stats
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
137 // to which we add them.
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
138 // The next time we flush these values, we will add
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
139 // what we have just flushed in addition to the size
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
140 // of the buffers allocated between now and then.
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
141 _allocated = 0;
b2ef234911c9 7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats
johnc
parents: 6595
diff changeset
142 _wasted = 0;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Retire the last allocation buffer.
6595
aaf61e68b255 6818524: G1: use ergonomic resizing of PLABs
johnc
parents: 6197
diff changeset
145 retire(end_of_gc, retain);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // Force future allocations to fail and queries for contains()
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // to return false
a61af66fc99e Initial load
duke
parents:
diff changeset
150 void invalidate() {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 assert(!_retained, "Shouldn't retain an invalidated buffer.");
a61af66fc99e Initial load
duke
parents:
diff changeset
152 _end = _hard_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 _wasted += pointer_delta(_end, _top); // unused space
a61af66fc99e Initial load
duke
parents:
diff changeset
154 _top = _end; // force future allocations to fail
a61af66fc99e Initial load
duke
parents:
diff changeset
155 _bottom = _end; // force future contains() queries to return false
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // Fills in the unallocated portion of the buffer with a garbage object.
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // If "end_of_gc" is TRUE, is after the last use in the GC. IF "retain"
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // is true, attempt to re-use the unused portion in the next GC.
10374
87c64c0438fb 6976350: G1: deal with fragmentation while copying objects during GC
tamao
parents: 6819
diff changeset
161 virtual void retire(bool end_of_gc, bool retain);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 void print() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 };
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // PLAB stats book-keeping
a61af66fc99e Initial load
duke
parents:
diff changeset
167 class PLABStats VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 size_t _allocated; // total allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
169 size_t _wasted; // of which wasted (internal fragmentation)
a61af66fc99e Initial load
duke
parents:
diff changeset
170 size_t _unused; // Unused in last buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
171 size_t _used; // derived = allocated - wasted - unused
a61af66fc99e Initial load
duke
parents:
diff changeset
172 size_t _desired_plab_sz;// output of filter (below), suitably trimmed and quantized
a61af66fc99e Initial load
duke
parents:
diff changeset
173 AdaptiveWeightedAverage
a61af66fc99e Initial load
duke
parents:
diff changeset
174 _filter; // integrator with decay
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
177 PLABStats(size_t desired_plab_sz_, unsigned wt) :
a61af66fc99e Initial load
duke
parents:
diff changeset
178 _allocated(0),
a61af66fc99e Initial load
duke
parents:
diff changeset
179 _wasted(0),
a61af66fc99e Initial load
duke
parents:
diff changeset
180 _unused(0),
a61af66fc99e Initial load
duke
parents:
diff changeset
181 _used(0),
a61af66fc99e Initial load
duke
parents:
diff changeset
182 _desired_plab_sz(desired_plab_sz_),
a61af66fc99e Initial load
duke
parents:
diff changeset
183 _filter(wt)
a61af66fc99e Initial load
duke
parents:
diff changeset
184 {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 size_t min_sz = min_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
186 size_t max_sz = max_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
187 size_t aligned_min_sz = align_object_size(min_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
188 size_t aligned_max_sz = align_object_size(max_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 assert(min_sz <= aligned_min_sz && max_sz >= aligned_max_sz &&
a61af66fc99e Initial load
duke
parents:
diff changeset
190 min_sz <= max_sz,
a61af66fc99e Initial load
duke
parents:
diff changeset
191 "PLAB clipping computation in adjust_desired_plab_sz()"
a61af66fc99e Initial load
duke
parents:
diff changeset
192 " may be incorrect");
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 static const size_t min_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return ParGCAllocBuffer::min_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 static const size_t max_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return ParGCAllocBuffer::max_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
a61af66fc99e Initial load
duke
parents:
diff changeset
203 size_t desired_plab_sz() {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 return _desired_plab_sz;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
6819
2e6857353b2c 8000311: G1: ParallelGCThreads==0 broken
johnc
parents: 6756
diff changeset
207 void adjust_desired_plab_sz(uint no_of_gc_workers);
2e6857353b2c 8000311: G1: ParallelGCThreads==0 broken
johnc
parents: 6756
diff changeset
208 // filter computation, latches output to
0
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // _desired_plab_sz, clears sensor accumulators
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 void add_allocated(size_t v) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 Atomic::add_ptr(v, &_allocated);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 }
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 void add_unused(size_t v) {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 Atomic::add_ptr(v, &_unused);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 void add_wasted(size_t v) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 Atomic::add_ptr(v, &_wasted);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222 };
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 class ParGCAllocBufferWithBOT: public ParGCAllocBuffer {
a61af66fc99e Initial load
duke
parents:
diff changeset
225 BlockOffsetArrayContigSpace _bt;
a61af66fc99e Initial load
duke
parents:
diff changeset
226 BlockOffsetSharedArray* _bsa;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 HeapWord* _true_end; // end of the whole ParGCAllocBuffer
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 static const size_t ChunkSizeInWords;
a61af66fc99e Initial load
duke
parents:
diff changeset
230 static const size_t ChunkSizeInBytes;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 HeapWord* allocate_slow(size_t word_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 void fill_region_with_block(MemRegion mr, bool contig);
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
236 ParGCAllocBufferWithBOT(size_t word_sz, BlockOffsetSharedArray* bsa);
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 HeapWord* allocate(size_t word_sz) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 HeapWord* res = ParGCAllocBuffer::allocate(word_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 if (res != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 _bt.alloc_block(res, word_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 res = allocate_slow(word_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 void undo_allocation(HeapWord* obj, size_t word_sz);
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 void set_buf(HeapWord* buf_start) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 ParGCAllocBuffer::set_buf(buf_start);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 _true_end = _hard_end;
a61af66fc99e Initial load
duke
parents:
diff changeset
253 _bt.set_region(MemRegion(buf_start, word_sz()));
a61af66fc99e Initial load
duke
parents:
diff changeset
254 _bt.initialize_threshold();
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 void retire(bool end_of_gc, bool retain);
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 MemRegion range() {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 return MemRegion(_top, _true_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
263
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
264 #endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP