author | tschatzl |
Mon, 08 Apr 2019 20:37:52 +0200 | |
changeset 54465 | c4f16445675a |
parent 52897 | 495c05ee2a9a |
permissions | -rw-r--r-- |
52897
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
1 |
/* |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
4 |
* |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
8 |
* |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
13 |
* accompanied this code). |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
14 |
* |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
18 |
* |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
21 |
* questions. |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
22 |
* |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
23 |
*/ |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
24 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
25 |
#ifndef SHARE_GC_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
26 |
#define SHARE_GC_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
27 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
28 |
#include "gc/g1/g1OopStarChunkedList.hpp" |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
29 |
#include "gc/g1/g1CollectedHeap.inline.hpp" |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
30 |
#include "memory/allocation.inline.hpp" |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
31 |
#include "memory/iterator.hpp" |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
32 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
33 |
template <typename T> |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
34 |
inline void G1OopStarChunkedList::push(ChunkedList<T*, mtGC>** field, T* p) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
35 |
ChunkedList<T*, mtGC>* list = *field; |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
36 |
if (list == NULL) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
37 |
*field = new ChunkedList<T*, mtGC>(); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
38 |
_used_memory += sizeof(ChunkedList<T*, mtGC>); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
39 |
} else if (list->is_full()) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
40 |
ChunkedList<T*, mtGC>* next = new ChunkedList<T*, mtGC>(); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
41 |
next->set_next_used(list); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
42 |
*field = next; |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
43 |
_used_memory += sizeof(ChunkedList<T*, mtGC>); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
44 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
45 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
46 |
(*field)->push(p); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
47 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
48 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
49 |
inline void G1OopStarChunkedList::push_root(narrowOop* p) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
50 |
push(&_croots, p); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
51 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
52 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
53 |
inline void G1OopStarChunkedList::push_root(oop* p) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
54 |
push(&_roots, p); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
55 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
56 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
57 |
inline void G1OopStarChunkedList::push_oop(narrowOop* p) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
58 |
push(&_coops, p); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
59 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
60 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
61 |
inline void G1OopStarChunkedList::push_oop(oop* p) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
62 |
push(&_oops, p); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
63 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
64 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
65 |
template <typename T> |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
66 |
void G1OopStarChunkedList::delete_list(ChunkedList<T*, mtGC>* c) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
67 |
while (c != NULL) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
68 |
ChunkedList<T*, mtGC>* next = c->next_used(); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
69 |
delete c; |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
70 |
c = next; |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
71 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
72 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
73 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
74 |
template <typename T> |
54465
c4f16445675a
8218668: Clean up evacuation of optional collection set
tschatzl
parents:
52897
diff
changeset
|
75 |
size_t G1OopStarChunkedList::chunks_do(ChunkedList<T*, mtGC>* head, OopClosure* cl) { |
c4f16445675a
8218668: Clean up evacuation of optional collection set
tschatzl
parents:
52897
diff
changeset
|
76 |
size_t result = 0; |
52897
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
77 |
for (ChunkedList<T*, mtGC>* c = head; c != NULL; c = c->next_used()) { |
54465
c4f16445675a
8218668: Clean up evacuation of optional collection set
tschatzl
parents:
52897
diff
changeset
|
78 |
result += c->size(); |
52897
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
79 |
for (size_t i = 0; i < c->size(); i++) { |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
80 |
T* p = c->at(i); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
81 |
cl->do_oop(p); |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
82 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
83 |
} |
54465
c4f16445675a
8218668: Clean up evacuation of optional collection set
tschatzl
parents:
52897
diff
changeset
|
84 |
return result; |
52897
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
85 |
} |
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
86 |
|
495c05ee2a9a
8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents:
diff
changeset
|
87 |
#endif // SHARE_GC_G1_G1OOPSTARCHUNKEDLIST_INLINE_HPP |