author | stuefe |
Fri, 01 Nov 2019 10:28:15 +0100 | |
branch | stuefe-new-metaspace-branch |
changeset 59155 | b537e6386306 |
child 59238 | 6ce12ce00d3e |
permissions | -rw-r--r-- |
59155
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
1 |
/* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, SAP SE. All rights reserved. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
3 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
5 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
9 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
14 |
* accompanied this code). |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
15 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
19 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
22 |
* questions. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
23 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
24 |
*/ |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
25 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
26 |
#ifndef SHARE_MEMORY_METASPACE_LEFTOVERBINS_HPP |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
27 |
#define SHARE_MEMORY_METASPACE_LEFTOVERBINS_HPP |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
28 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
29 |
#include "memory/allocation.hpp" |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
30 |
#include "memory/metaspace/counter.hpp" |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
31 |
#include "utilities/bitMap.hpp" |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
32 |
#include "utilities/debug.hpp" |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
33 |
#include "utilities/globalDefinitions.hpp" |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
34 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
35 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
36 |
class outputStream; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
37 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
38 |
namespace metaspace { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
39 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
40 |
// The LeftOverManager is responsible for managing small leftover- |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
41 |
// and deallocated blocks. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
42 |
// They come from two sources: |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
43 |
// a) the leftover space left in a chunk when a chunk gets retired |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
44 |
// because it cannot serve a requested allocation. These blocks |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
45 |
// can be largeish (100s - 1000s of words). |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
46 |
// b) when a metaspace allocation is deallocated prematurely - e.g. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
47 |
// due to interrupted class loading. These blocks are small or |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
48 |
// very small. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
49 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
50 |
class BinMap { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
51 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
52 |
typedef uint32_t mask_type; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
53 |
mask_type _mask; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
54 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
55 |
static mask_type mask_for_pos(int pos) { return 1 << pos; } |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
56 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
57 |
public: |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
58 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
59 |
BinMap() : _mask(0) {} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
60 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
61 |
bool all_zero() const { return _mask == 0; } |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
62 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
63 |
bool get_bit(int pos) const { return (_mask & mask_for_pos(pos)) != 0 ? true : false; } |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
64 |
void set_bit(int pos) { _mask |= mask_for_pos(pos); } |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
65 |
void clr_bit(int pos) { _mask &= ~mask_for_pos(pos); } |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
66 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
67 |
// Starting at (including) pos, find the position of the next 1 bit. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
68 |
// Return -1 if not found. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
69 |
inline int find_next_set_bit(int pos) const; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
70 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
71 |
static int size() { return sizeof(mask_type) * 8; } |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
72 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
73 |
}; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
74 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
75 |
struct block_t { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
76 |
block_t* next; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
77 |
size_t size; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
78 |
}; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
79 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
80 |
struct block_stats_t { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
81 |
size_t word_size; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
82 |
int num_blocks; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
83 |
}; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
84 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
85 |
template < |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
86 |
size_t min_word_size, |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
87 |
size_t spread, |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
88 |
int num_bins |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
89 |
> |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
90 |
class Bins { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
91 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
92 |
STATIC_ASSERT(sizeof(block_t) <= (min_word_size * BytesPerWord)); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
93 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
94 |
block_t* _bins[num_bins]; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
95 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
96 |
BinMap _mask; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
97 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
98 |
// e.g. spread = 4 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
99 |
// |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
100 |
// sz bno (put) bno (get) |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
101 |
// (guarant) |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
102 |
// 0 00 00 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
103 |
// 1 00 01 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
104 |
// 2 00 01 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
105 |
// 3 00 01 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
106 |
// 4 01 01 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
107 |
// 5 01 02 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
108 |
// 6 01 02 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
109 |
// 7 01 02 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
110 |
// 8 02 02 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
111 |
// 9 02 03 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
112 |
// 10 02 03 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
113 |
// 11 02 03 |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
114 |
// |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
115 |
// put -> no = wordsize / spread |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
116 |
// |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
117 |
// get -> no = (req_wordsize + spread - 1) / spread |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
118 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
119 |
// The bin number for a given word size. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
120 |
static int bin_for_size(size_t word_size) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
121 |
assert(word_size >= min_word_size && word_size < maximal_word_size(), |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
122 |
"Word size oob (" SIZE_FORMAT ")", word_size); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
123 |
return (word_size - min_word_size) / spread; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
124 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
125 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
126 |
// [minimal, maximal) size of blocks which are held in a bin. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
127 |
// Note that when taking a block out of the bin, only the minimum block size |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
128 |
// is guaranteed. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
129 |
static size_t minimal_word_size_in_bin(int bno) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
130 |
return min_word_size + (bno * spread); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
131 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
132 |
static size_t maximal_word_size_in_bin(int bno) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
133 |
return minimal_word_size_in_bin(bno) + spread; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
134 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
135 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
136 |
public: |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
137 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
138 |
Bins() : _mask() { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
139 |
assert(BinMap::size() >= num_bins, "mask too small"); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
140 |
::memset(_bins, 0, sizeof(_bins)); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
141 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
142 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
143 |
// [min, max) word size |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
144 |
static size_t minimal_word_size() { return min_word_size; } |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
145 |
static size_t maximal_word_size() { return min_word_size + (spread * num_bins); } |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
146 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
147 |
inline void put(MetaWord* p, size_t word_size); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
148 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
149 |
inline block_t* get(size_t word_size); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
150 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
151 |
#ifdef ASSERT |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
152 |
void verify() const; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
153 |
#endif |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
154 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
155 |
void statistics(block_stats_t* stats) const; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
156 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
157 |
void print(outputStream* st) const; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
158 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
159 |
}; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
160 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
161 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
162 |
class LeftOverManager : public CHeapObj<mtInternal> { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
163 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
164 |
typedef Bins<2, 2, 16> VerySmallBinsType; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
165 |
VerySmallBinsType _very_small_bins; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
166 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
167 |
block_t* _large_block_reserve; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
168 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
169 |
// The current large block we gnaw on |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
170 |
MetaWord* _current; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
171 |
size_t _current_size; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
172 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
173 |
SizeCounter _total_word_size; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
174 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
175 |
// Take the topmost block from the large block reserve list |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
176 |
// and make it current. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
177 |
inline void prime_current(); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
178 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
179 |
// Allocate from current block. Returns NULL if current block |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
180 |
// is too small. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
181 |
inline MetaWord* alloc_from_current(size_t word_size); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
182 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
183 |
void large_block_statistics(block_stats_t* stats) const; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
184 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
185 |
public: |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
186 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
187 |
static size_t minimal_word_size() { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
188 |
return VerySmallBinsType::minimal_word_size(); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
189 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
190 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
191 |
LeftOverManager() : |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
192 |
_very_small_bins(), |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
193 |
_large_block_reserve(NULL), |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
194 |
_current(NULL), |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
195 |
_current_size(0) |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
196 |
{} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
197 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
198 |
inline void add_block(MetaWord* p, size_t word_size); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
199 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
200 |
inline MetaWord* get_block(size_t requested_word_size); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
201 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
202 |
#ifdef ASSERT |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
203 |
void verify() const; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
204 |
#endif |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
205 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
206 |
void statistics(block_stats_t* stats) const; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
207 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
208 |
void print(outputStream* st, bool detailed = false) const; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
209 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
210 |
size_t total_word_size() const { return _total_word_size.get(); } |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
211 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
212 |
}; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
213 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
214 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
215 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
216 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
217 |
} // namespace metaspace |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
218 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
219 |
#endif // SHARE_MEMORY_METASPACE_CHUNKMANAGER_HPP |