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 */
24
25 #include "precompiled.hpp"
26 #include "gc/shared/collectedHeap.hpp"
27 #include "gc/shared/plab.inline.hpp"
28 #include "gc/shared/threadLocalAllocBuffer.hpp"
29 #include "logging/log.hpp"
30 #include "oops/arrayOop.hpp"
31 #include "oops/oop.inline.hpp"
32
33 size_t PLAB::min_size() {
34 // Make sure that we return something that is larger than AlignmentReserve
35 return align_object_size(MAX2(MinTLABSize / HeapWordSize, (size_t)oopDesc::header_size())) + AlignmentReserve;
36 }
37
38 size_t PLAB::max_size() {
39 return ThreadLocalAllocBuffer::max_size();
40 }
41
42 PLAB::PLAB(size_t desired_plab_sz_) :
43 _word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL),
44 _end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0)
45 {
46 // ArrayOopDesc::header_size depends on command line initialization.
47 AlignmentReserve = oopDesc::header_size() > MinObjAlignment ? align_object_size(arrayOopDesc::header_size(T_INT)) : 0;
48 assert(min_size() > AlignmentReserve,
49 "Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " "
50 "to be able to contain objects", min_size(), AlignmentReserve);
51 }
52
53 // If the minimum object size is greater than MinObjAlignment, we can
54 // end up with a shard at the end of the buffer that's smaller than
55 // the smallest object. We can't allow that because the buffer must
56 // look like it's full of objects when we retire it, so we make
57 // sure we have enough space for a filler int array object.
58 size_t PLAB::AlignmentReserve;
59
60 void PLAB::flush_and_retire_stats(PLABStats* stats) {
61 // Retire the last allocation buffer.
62 size_t unused = retire_internal();
63
64 // Now flush the statistics.
65 stats->add_allocated(_allocated);
66 stats->add_wasted(_wasted);
67 stats->add_undo_wasted(_undo_wasted);
|
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 */
24
25 #include "precompiled.hpp"
26 #include "gc/shared/collectedHeap.hpp"
27 #include "gc/shared/plab.inline.hpp"
28 #include "gc/shared/threadLocalAllocBuffer.hpp"
29 #include "logging/log.hpp"
30 #include "oops/oop.inline.hpp"
31
32 size_t PLAB::min_size() {
33 // Make sure that we return something that is larger than AlignmentReserve
34 return align_object_size(MAX2(MinTLABSize / HeapWordSize, (size_t)oopDesc::header_size())) + AlignmentReserve;
35 }
36
37 size_t PLAB::max_size() {
38 return ThreadLocalAllocBuffer::max_size();
39 }
40
41 PLAB::PLAB(size_t desired_plab_sz_) :
42 _word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL),
43 _end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0)
44 {
45 AlignmentReserve = Universe::heap()->tlab_alloc_reserve();
46 assert(min_size() > AlignmentReserve,
47 "Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " "
48 "to be able to contain objects", min_size(), AlignmentReserve);
49 }
50
51 // If the minimum object size is greater than MinObjAlignment, we can
52 // end up with a shard at the end of the buffer that's smaller than
53 // the smallest object. We can't allow that because the buffer must
54 // look like it's full of objects when we retire it, so we make
55 // sure we have enough space for a filler int array object.
56 size_t PLAB::AlignmentReserve;
57
58 void PLAB::flush_and_retire_stats(PLABStats* stats) {
59 // Retire the last allocation buffer.
60 size_t unused = retire_internal();
61
62 // Now flush the statistics.
63 stats->add_allocated(_allocated);
64 stats->add_wasted(_wasted);
65 stats->add_undo_wasted(_undo_wasted);
|