author | pliden |
Mon, 18 Mar 2019 11:50:40 +0100 | |
changeset 54172 | f92f1f1045ad |
parent 54163 | 790679f86a51 |
child 54330 | 69e80a82db9a |
permissions | -rw-r--r-- |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
50875
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
4 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
8 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
13 |
* accompanied this code). |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
14 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
18 |
* |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
21 |
* questions. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
22 |
*/ |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
23 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
24 |
#ifndef SHARE_GC_Z_ZFORWARDING_INLINE_HPP |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
25 |
#define SHARE_GC_Z_ZFORWARDING_INLINE_HPP |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
26 |
|
54172
f92f1f1045ad
8220597: ZGC: Convert ZForwarding to use ZAttachedArray
pliden
parents:
54163
diff
changeset
|
27 |
#include "gc/z/zAttachedArray.inline.hpp" |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
28 |
#include "gc/z/zForwarding.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
29 |
#include "gc/z/zGlobals.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
30 |
#include "gc/z/zHash.inline.hpp" |
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
31 |
#include "gc/z/zHeap.hpp" |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
32 |
#include "gc/z/zVirtualMemory.inline.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
33 |
#include "runtime/atomic.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
34 |
#include "utilities/debug.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
35 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
36 |
inline uintptr_t ZForwarding::start() const { |
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
37 |
return _virtual.start(); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
38 |
} |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
39 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
40 |
inline size_t ZForwarding::size() const { |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
41 |
return _virtual.size(); |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
42 |
} |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
43 |
|
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
44 |
inline size_t ZForwarding::object_alignment_shift() const { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
45 |
return _object_alignment_shift; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
46 |
} |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
47 |
|
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
48 |
inline ZPage* ZForwarding::page() const { |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
49 |
return _page; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
50 |
} |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
51 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
52 |
inline bool ZForwarding::is_pinned() const { |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
53 |
return Atomic::load(&_pinned); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
54 |
} |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
55 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
56 |
inline void ZForwarding::set_pinned() { |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
57 |
Atomic::store(true, &_pinned); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
58 |
} |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
59 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
60 |
inline bool ZForwarding::inc_refcount() { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
61 |
uint32_t refcount = Atomic::load(&_refcount); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
62 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
63 |
while (refcount > 0) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
64 |
const uint32_t old_refcount = refcount; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
65 |
const uint32_t new_refcount = old_refcount + 1; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
66 |
const uint32_t prev_refcount = Atomic::cmpxchg(new_refcount, &_refcount, old_refcount); |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
67 |
if (prev_refcount == old_refcount) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
68 |
return true; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
69 |
} |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
70 |
|
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
71 |
refcount = prev_refcount; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
72 |
} |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
73 |
|
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
74 |
return false; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
75 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
76 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
77 |
inline bool ZForwarding::dec_refcount() { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
78 |
assert(_refcount > 0, "Invalid state"); |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
79 |
return Atomic::sub(1u, &_refcount) == 0u; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
80 |
} |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
81 |
|
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
82 |
inline bool ZForwarding::retain_page() { |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
83 |
return inc_refcount(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
84 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
85 |
|
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
86 |
inline void ZForwarding::release_page() { |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
87 |
if (dec_refcount()) { |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
88 |
ZHeap::heap()->free_page(_page, true /* reclaimed */); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
89 |
_page = NULL; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
90 |
} |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
91 |
} |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
92 |
|
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
93 |
inline ZForwardingEntry* ZForwarding::entries() const { |
54172
f92f1f1045ad
8220597: ZGC: Convert ZForwarding to use ZAttachedArray
pliden
parents:
54163
diff
changeset
|
94 |
return _entries(this); |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
95 |
} |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
96 |
|
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
97 |
inline ZForwardingEntry ZForwarding::at(ZForwardingCursor* cursor) const { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
98 |
return Atomic::load(entries() + *cursor); |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
99 |
} |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
100 |
|
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
101 |
inline ZForwardingEntry ZForwarding::first(uintptr_t from_index, ZForwardingCursor* cursor) const { |
54172
f92f1f1045ad
8220597: ZGC: Convert ZForwarding to use ZAttachedArray
pliden
parents:
54163
diff
changeset
|
102 |
const uint32_t mask = _entries.length() - 1; |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
103 |
const uint32_t hash = ZHash::uint32_to_uint32((uint32_t)from_index); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
104 |
*cursor = hash & mask; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
105 |
return at(cursor); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
106 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
107 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
108 |
inline ZForwardingEntry ZForwarding::next(ZForwardingCursor* cursor) const { |
54172
f92f1f1045ad
8220597: ZGC: Convert ZForwarding to use ZAttachedArray
pliden
parents:
54163
diff
changeset
|
109 |
const uint32_t mask = _entries.length() - 1; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
110 |
*cursor = (*cursor + 1) & mask; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
111 |
return at(cursor); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
112 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
113 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
114 |
inline ZForwardingEntry ZForwarding::find(uintptr_t from_index) const { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
115 |
ZForwardingCursor dummy; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
116 |
return find(from_index, &dummy); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
117 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
118 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
119 |
inline ZForwardingEntry ZForwarding::find(uintptr_t from_index, ZForwardingCursor* cursor) const { |
50875
2217b2fc29ea
8205993: ZGC: Fix typos and incorrect indentations
pliden
parents:
50525
diff
changeset
|
120 |
// Reading entries in the table races with the atomic CAS done for |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
121 |
// insertion into the table. This is safe because each entry is at |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
122 |
// most updated once (from -1 to something else). |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
123 |
ZForwardingEntry entry = first(from_index, cursor); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
124 |
while (!entry.is_empty()) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
125 |
if (entry.from_index() == from_index) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
126 |
// Match found, return matching entry |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
127 |
return entry; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
128 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
129 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
130 |
entry = next(cursor); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
131 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
132 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
133 |
// Match not found, return empty entry |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
134 |
return entry; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
135 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
136 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
137 |
inline uintptr_t ZForwarding::insert(uintptr_t from_index, uintptr_t to_offset, ZForwardingCursor* cursor) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
138 |
const ZForwardingEntry new_entry(from_index, to_offset); |
54172
f92f1f1045ad
8220597: ZGC: Convert ZForwarding to use ZAttachedArray
pliden
parents:
54163
diff
changeset
|
139 |
const ZForwardingEntry old_entry; // Empty |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
140 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
141 |
for (;;) { |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
142 |
const ZForwardingEntry prev_entry = Atomic::cmpxchg(new_entry, entries() + *cursor, old_entry); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
143 |
if (prev_entry.is_empty()) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
144 |
// Success |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
145 |
return to_offset; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
146 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
147 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
148 |
// Find next empty or matching entry |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
149 |
ZForwardingEntry entry = at(cursor); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
150 |
while (!entry.is_empty()) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
151 |
if (entry.from_index() == from_index) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
152 |
// Match found, return already inserted address |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
153 |
return entry.to_offset(); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
154 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
155 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
156 |
entry = next(cursor); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
157 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
158 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
159 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
160 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
53244
diff
changeset
|
161 |
#endif // SHARE_GC_Z_ZFORWARDING_INLINE_HPP |