author | pliden |
Mon, 18 Mar 2019 11:50:39 +0100 | |
changeset 54162 | f344a0c6e19e |
parent 52799 | cd19c580ba9c |
child 54163 | 790679f86a51 |
permissions | -rw-r--r-- |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
1 |
/* |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
2 |
* Copyright (c) 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 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
24 |
#include "precompiled.hpp" |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
25 |
#include "gc/z/zForwarding.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
26 |
#include "gc/z/zForwardingTable.inline.hpp" |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
27 |
#include "gc/z/zGranuleMap.inline.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
28 |
#include "utilities/debug.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
29 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
30 |
ZForwardingTable::ZForwardingTable() : |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
31 |
_map() {} |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
32 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
33 |
void ZForwardingTable::insert(uintptr_t start, |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
34 |
size_t size, |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
35 |
size_t object_alignment_shift, |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
36 |
uint32_t live_objects) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
37 |
// Allocate forwarding |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
38 |
ZForwarding* const forwarding = ZForwarding::create(start, |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
39 |
object_alignment_shift, |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
40 |
live_objects); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
41 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
42 |
// Insert into forwarding table |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
43 |
const uintptr_t addr = ZAddress::good(start); |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
44 |
assert(get(addr) == NULL, "Invalid entry"); |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
45 |
_map.put(addr, size, forwarding); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
46 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
47 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
48 |
void ZForwardingTable::clear() { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
49 |
ZForwarding* prev_forwarding = NULL; |
52799
cd19c580ba9c
8214377: ZGC: Don't use memset to initialize array of ZForwardingTableEntry
pliden
parents:
50875
diff
changeset
|
50 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
51 |
// Clear and destroy all non-NULL entries |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
52 |
ZGranuleMapIterator<ZForwarding*> iter(&_map); |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
53 |
for (ZForwarding** entry; iter.next(&entry);) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
54 |
ZForwarding* const forwarding = *entry; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
55 |
if (forwarding == NULL) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
56 |
// Skip entry |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
57 |
continue; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
58 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
59 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
60 |
// Clear entry |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
61 |
*entry = NULL; |
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:
52799
diff
changeset
|
63 |
// More than one entry can point to the same |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
64 |
// forwarding. Make sure we only destroy it once. |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
65 |
if (forwarding != prev_forwarding) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
66 |
ZForwarding::destroy(forwarding); |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
52799
diff
changeset
|
67 |
prev_forwarding = forwarding; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
68 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
69 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
70 |
} |