author | kbarrett |
Tue, 21 Apr 2015 10:29:35 -0400 | |
changeset 30274 | 0942042b7d7c |
permissions | -rw-r--r-- |
30274
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
1 |
/* |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
2 |
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
4 |
* |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
8 |
* |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
13 |
* accompanied this code). |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
14 |
* |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
18 |
* |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
21 |
* questions. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
22 |
* |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
23 |
*/ |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
24 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
25 |
#ifndef SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
26 |
#define SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
27 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
28 |
#include "gc_implementation/shared/gcUtil.hpp" |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
29 |
#include "memory/allocation.hpp" |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
30 |
#include "runtime/atomic.hpp" |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
31 |
#include "utilities/globalDefinitions.hpp" |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
32 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
33 |
// Forward declarations. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
34 |
class PLABStats; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
35 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
36 |
// A per-thread allocation buffer used during GC. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
37 |
class ParGCAllocBuffer: public CHeapObj<mtGC> { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
38 |
protected: |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
39 |
char head[32]; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
40 |
size_t _word_sz; // In HeapWord units |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
41 |
HeapWord* _bottom; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
42 |
HeapWord* _top; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
43 |
HeapWord* _end; // Last allocatable address + 1 |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
44 |
HeapWord* _hard_end; // _end + AlignmentReserve |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
45 |
// In support of ergonomic sizing of PLAB's |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
46 |
size_t _allocated; // in HeapWord units |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
47 |
size_t _wasted; // in HeapWord units |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
48 |
char tail[32]; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
49 |
static size_t AlignmentReserve; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
50 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
51 |
// Force future allocations to fail and queries for contains() |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
52 |
// to return false. Returns the amount of unused space in this PLAB. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
53 |
size_t invalidate() { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
54 |
_end = _hard_end; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
55 |
size_t remaining = pointer_delta(_end, _top); // Calculate remaining space. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
56 |
_top = _end; // Force future allocations to fail. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
57 |
_bottom = _end; // Force future contains() queries to return false. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
58 |
return remaining; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
59 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
60 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
61 |
// Fill in remaining space with a dummy object and invalidate the PLAB. Returns |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
62 |
// the amount of remaining space. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
63 |
size_t retire_internal(); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
64 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
65 |
public: |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
66 |
// Initializes the buffer to be empty, but with the given "word_sz". |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
67 |
// Must get initialized with "set_buf" for an allocation to succeed. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
68 |
ParGCAllocBuffer(size_t word_sz); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
69 |
virtual ~ParGCAllocBuffer() {} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
70 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
71 |
// Minimum PLAB size. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
72 |
static size_t min_size(); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
73 |
// Maximum PLAB size. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
74 |
static size_t max_size(); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
75 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
76 |
// If an allocation of the given "word_sz" can be satisfied within the |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
77 |
// buffer, do the allocation, returning a pointer to the start of the |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
78 |
// allocated block. If the allocation request cannot be satisfied, |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
79 |
// return NULL. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
80 |
HeapWord* allocate(size_t word_sz) { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
81 |
HeapWord* res = _top; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
82 |
if (pointer_delta(_end, _top) >= word_sz) { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
83 |
_top = _top + word_sz; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
84 |
return res; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
85 |
} else { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
86 |
return NULL; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
87 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
88 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
89 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
90 |
// Allocate the object aligned to "alignment_in_bytes". |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
91 |
HeapWord* allocate_aligned(size_t word_sz, unsigned short alignment_in_bytes); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
92 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
93 |
// Undo the last allocation in the buffer, which is required to be of the |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
94 |
// "obj" of the given "word_sz". |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
95 |
void undo_allocation(HeapWord* obj, size_t word_sz) { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
96 |
assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo"); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
97 |
assert(pointer_delta(_top, obj) == word_sz, "Bad undo"); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
98 |
_top = obj; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
99 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
100 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
101 |
// The total (word) size of the buffer, including both allocated and |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
102 |
// unallocated space. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
103 |
size_t word_sz() { return _word_sz; } |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
104 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
105 |
// Should only be done if we are about to reset with a new buffer of the |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
106 |
// given size. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
107 |
void set_word_size(size_t new_word_sz) { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
108 |
assert(new_word_sz > AlignmentReserve, "Too small"); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
109 |
_word_sz = new_word_sz; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
110 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
111 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
112 |
// The number of words of unallocated space remaining in the buffer. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
113 |
size_t words_remaining() { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
114 |
assert(_end >= _top, "Negative buffer"); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
115 |
return pointer_delta(_end, _top, HeapWordSize); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
116 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
117 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
118 |
bool contains(void* addr) { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
119 |
return (void*)_bottom <= addr && addr < (void*)_hard_end; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
120 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
121 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
122 |
// Sets the space of the buffer to be [buf, space+word_sz()). |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
123 |
virtual void set_buf(HeapWord* buf) { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
124 |
_bottom = buf; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
125 |
_top = _bottom; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
126 |
_hard_end = _bottom + word_sz(); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
127 |
_end = _hard_end - AlignmentReserve; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
128 |
assert(_end >= _top, "Negative buffer"); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
129 |
// In support of ergonomic sizing |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
130 |
_allocated += word_sz(); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
131 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
132 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
133 |
// Flush allocation statistics into the given PLABStats supporting ergonomic |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
134 |
// sizing of PLAB's and retire the current buffer. To be called at the end of |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
135 |
// GC. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
136 |
void flush_and_retire_stats(PLABStats* stats); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
137 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
138 |
// Fills in the unallocated portion of the buffer with a garbage object and updates |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
139 |
// statistics. To be called during GC. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
140 |
virtual void retire(); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
141 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
142 |
void print() PRODUCT_RETURN; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
143 |
}; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
144 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
145 |
// PLAB book-keeping. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
146 |
class PLABStats VALUE_OBJ_CLASS_SPEC { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
147 |
size_t _allocated; // Total allocated |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
148 |
size_t _wasted; // of which wasted (internal fragmentation) |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
149 |
size_t _unused; // Unused in last buffer |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
150 |
size_t _desired_plab_sz;// Output of filter (below), suitably trimmed and quantized |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
151 |
AdaptiveWeightedAverage |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
152 |
_filter; // Integrator with decay |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
153 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
154 |
void reset() { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
155 |
_allocated = 0; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
156 |
_wasted = 0; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
157 |
_unused = 0; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
158 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
159 |
public: |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
160 |
PLABStats(size_t desired_plab_sz_, unsigned wt) : |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
161 |
_allocated(0), |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
162 |
_wasted(0), |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
163 |
_unused(0), |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
164 |
_desired_plab_sz(desired_plab_sz_), |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
165 |
_filter(wt) |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
166 |
{ } |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
167 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
168 |
static const size_t min_size() { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
169 |
return ParGCAllocBuffer::min_size(); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
170 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
171 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
172 |
static const size_t max_size() { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
173 |
return ParGCAllocBuffer::max_size(); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
174 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
175 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
176 |
size_t desired_plab_sz() { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
177 |
return _desired_plab_sz; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
178 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
179 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
180 |
// Updates the current desired PLAB size. Computes the new desired PLAB size, |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
181 |
// updates _desired_plab_sz and clears sensor accumulators. |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
182 |
void adjust_desired_plab_sz(uint no_of_gc_workers); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
183 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
184 |
void add_allocated(size_t v) { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
185 |
Atomic::add_ptr(v, &_allocated); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
186 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
187 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
188 |
void add_unused(size_t v) { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
189 |
Atomic::add_ptr(v, &_unused); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
190 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
191 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
192 |
void add_wasted(size_t v) { |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
193 |
Atomic::add_ptr(v, &_wasted); |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
194 |
} |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
195 |
}; |
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
196 |
|
0942042b7d7c
8078193: BACKOUT: Rename and clean up the ParGCAllocBuffer class
kbarrett
parents:
diff
changeset
|
197 |
#endif // SHARE_VM_GC_IMPLEMENTATION_PARNEW_PARGCALLOCBUFFER_HPP |