author | mr |
Tue, 29 Oct 2019 13:52:04 -0700 | |
changeset 58850 | f4290bf1cc21 |
parent 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
27247
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
27247
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
4 |
* |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
8 |
* |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
13 |
* accompanied this code). |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
14 |
* |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
18 |
* |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
21 |
* questions. |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
22 |
* |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
23 |
*/ |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
24 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47216
diff
changeset
|
25 |
#ifndef SHARE_UTILITIES_CHUNKEDLIST_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47216
diff
changeset
|
26 |
#define SHARE_UTILITIES_CHUNKEDLIST_HPP |
27247
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
27 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
28 |
#include "memory/allocation.hpp" |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
29 |
#include "utilities/debug.hpp" |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
30 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
31 |
template <class T, MEMFLAGS F> class ChunkedList : public CHeapObj<F> { |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
32 |
template <class U> friend class TestChunkedList; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
33 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
34 |
static const size_t BufferSize = 64; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
35 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
36 |
T _values[BufferSize]; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
37 |
T* _top; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
38 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
39 |
ChunkedList<T, F>* _next_used; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
40 |
ChunkedList<T, F>* _next_free; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
41 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
42 |
T const * end() const { |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
43 |
return &_values[BufferSize]; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
44 |
} |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
45 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
46 |
public: |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
47 |
ChunkedList<T, F>() : _top(_values), _next_used(NULL), _next_free(NULL) {} |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
48 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
49 |
bool is_full() const { |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
50 |
return _top == end(); |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
51 |
} |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
52 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
53 |
void clear() { |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
54 |
_top = _values; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
55 |
// Don't clear the next pointers since that would interfere |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
56 |
// with other threads trying to iterate through the lists. |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
57 |
} |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
58 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
59 |
void push(T m) { |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
60 |
assert(!is_full(), "Buffer is full"); |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
61 |
*_top = m; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
62 |
_top++; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
63 |
} |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
64 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
65 |
void set_next_used(ChunkedList<T, F>* buffer) { _next_used = buffer; } |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
66 |
void set_next_free(ChunkedList<T, F>* buffer) { _next_free = buffer; } |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
67 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
68 |
ChunkedList<T, F>* next_used() const { return _next_used; } |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
69 |
ChunkedList<T, F>* next_free() const { return _next_free; } |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
70 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
71 |
size_t size() const { |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
72 |
return pointer_delta(_top, _values, sizeof(T)); |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
73 |
} |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
74 |
|
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
75 |
T at(size_t i) { |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
27247
diff
changeset
|
76 |
assert(i < size(), "IOOBE i: " SIZE_FORMAT " size(): " SIZE_FORMAT, i, size()); |
27247
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
77 |
return _values[i]; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
78 |
} |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
79 |
}; |
99db666dbe8e
8056240: Investigate increased GC remark time after class unloading changes in CRM Fuse
stefank
parents:
diff
changeset
|
80 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
47216
diff
changeset
|
81 |
#endif // SHARE_UTILITIES_CHUNKEDLIST_HPP |