author | eosterlund |
Tue, 12 Nov 2019 20:01:23 +0000 | |
changeset 59039 | c60978f87d45 |
parent 58237 | 944b58cbaf93 |
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:
50975
diff
changeset
|
2 |
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. |
50975 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
50525
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" |
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
25 |
#include "gc/z/zAddress.inline.hpp" |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
26 |
#include "gc/z/zForwarding.inline.hpp" |
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
27 |
#include "gc/z/zGlobals.hpp" |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
28 |
#include "gc/z/zPage.inline.hpp" |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
29 |
#include "unittest.hpp" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
30 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
31 |
using namespace testing; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
32 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
33 |
#define CAPTURE_DELIM "\n" |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
34 |
#define CAPTURE1(expression) #expression << " evaluates to " << expression |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
35 |
#define CAPTURE2(e0, e1) CAPTURE1(e0) << CAPTURE_DELIM << CAPTURE1(e1) |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
36 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
37 |
#define CAPTURE(expression) CAPTURE1(expression) |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
38 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
39 |
class ZForwardingTest : public Test { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
40 |
public: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
41 |
// Helper functions |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
42 |
|
58237 | 43 |
static bool is_power_of_2(size_t value) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
44 |
return ::is_power_of_2((intptr_t)value); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
45 |
} |
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 |
class SequenceToFromIndex : AllStatic { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
48 |
public: |
58237 | 49 |
static uintptr_t even(size_t sequence_number) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
50 |
return sequence_number * 2; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
51 |
} |
58237 | 52 |
static uintptr_t odd(size_t sequence_number) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
53 |
return even(sequence_number) + 1; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
54 |
} |
58237 | 55 |
static uintptr_t one_to_one(size_t sequence_number) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
56 |
return sequence_number; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
57 |
} |
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 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
60 |
// Test functions |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
61 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
62 |
static void setup(ZForwarding* forwarding) { |
54172
f92f1f1045ad
8220597: ZGC: Convert ZForwarding to use ZAttachedArray
pliden
parents:
54169
diff
changeset
|
63 |
EXPECT_PRED1(is_power_of_2, forwarding->_entries.length()) << CAPTURE(forwarding->_entries.length()); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
64 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
65 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
66 |
static void find_empty(ZForwarding* forwarding) { |
58237 | 67 |
size_t size = forwarding->_entries.length(); |
68 |
size_t entries_to_check = size * 2; |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
69 |
|
58237 | 70 |
for (size_t i = 0; i < entries_to_check; i++) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
71 |
uintptr_t from_index = SequenceToFromIndex::one_to_one(i); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
72 |
|
54330
69e80a82db9a
8221540: ZGC: Reduce width of zForwardingEntry::from_index field
pliden
parents:
54172
diff
changeset
|
73 |
EXPECT_FALSE(forwarding->find(from_index).populated()) << CAPTURE2(from_index, size); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
74 |
} |
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:
50975
diff
changeset
|
77 |
static void find_full(ZForwarding* forwarding) { |
58237 | 78 |
size_t size = forwarding->_entries.length(); |
79 |
size_t entries_to_populate = size; |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
80 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
81 |
// Populate |
58237 | 82 |
for (size_t i = 0; i < entries_to_populate; i++) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
83 |
uintptr_t from_index = SequenceToFromIndex::one_to_one(i); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
84 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
85 |
ZForwardingCursor cursor; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
86 |
ZForwardingEntry entry = forwarding->find(from_index, &cursor); |
54330
69e80a82db9a
8221540: ZGC: Reduce width of zForwardingEntry::from_index field
pliden
parents:
54172
diff
changeset
|
87 |
ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
88 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
89 |
forwarding->insert(from_index, from_index, &cursor); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
90 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
91 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
92 |
// Verify |
58237 | 93 |
for (size_t i = 0; i < entries_to_populate; i++) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
94 |
uintptr_t from_index = SequenceToFromIndex::one_to_one(i); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
95 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
96 |
ZForwardingEntry entry = forwarding->find(from_index); |
54330
69e80a82db9a
8221540: ZGC: Reduce width of zForwardingEntry::from_index field
pliden
parents:
54172
diff
changeset
|
97 |
ASSERT_TRUE(entry.populated()) << CAPTURE2(from_index, size); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
98 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
99 |
ASSERT_EQ(entry.from_index(), from_index) << CAPTURE(size); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
100 |
ASSERT_EQ(entry.to_offset(), from_index) << CAPTURE(size); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
101 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
102 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
103 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
104 |
static void find_every_other(ZForwarding* forwarding) { |
58237 | 105 |
size_t size = forwarding->_entries.length(); |
106 |
size_t entries_to_populate = size / 2; |
|
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
107 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
108 |
// Populate even from indices |
58237 | 109 |
for (size_t i = 0; i < entries_to_populate; i++) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
110 |
uintptr_t from_index = SequenceToFromIndex::even(i); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
111 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
112 |
ZForwardingCursor cursor; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
113 |
ZForwardingEntry entry = forwarding->find(from_index, &cursor); |
54330
69e80a82db9a
8221540: ZGC: Reduce width of zForwardingEntry::from_index field
pliden
parents:
54172
diff
changeset
|
114 |
ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
115 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
116 |
forwarding->insert(from_index, from_index, &cursor); |
50525
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 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
119 |
// Verify populated even indices |
58237 | 120 |
for (size_t i = 0; i < entries_to_populate; i++) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
121 |
uintptr_t from_index = SequenceToFromIndex::even(i); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
122 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
123 |
ZForwardingCursor cursor; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
124 |
ZForwardingEntry entry = forwarding->find(from_index, &cursor); |
54330
69e80a82db9a
8221540: ZGC: Reduce width of zForwardingEntry::from_index field
pliden
parents:
54172
diff
changeset
|
125 |
ASSERT_TRUE(entry.populated()) << CAPTURE2(from_index, size); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
126 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
127 |
ASSERT_EQ(entry.from_index(), from_index) << CAPTURE(size); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
128 |
ASSERT_EQ(entry.to_offset(), from_index) << CAPTURE(size); |
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 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
131 |
// Verify empty odd indices |
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 |
// This check could be done on a larger range of sequence numbers, |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
134 |
// but currently entries_to_populate is used. |
58237 | 135 |
for (size_t i = 0; i < entries_to_populate; i++) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
136 |
uintptr_t from_index = SequenceToFromIndex::odd(i); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
137 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
138 |
ZForwardingEntry entry = forwarding->find(from_index); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
139 |
|
54330
69e80a82db9a
8221540: ZGC: Reduce width of zForwardingEntry::from_index field
pliden
parents:
54172
diff
changeset
|
140 |
ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
141 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
142 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
143 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
144 |
static void test(void (*function)(ZForwarding*), uint32_t size) { |
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
145 |
// Create page |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
146 |
const ZVirtualMemory vmem(0, ZPageSizeSmall); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
147 |
const ZPhysicalMemory pmem(ZPhysicalMemorySegment(0, ZPageSizeSmall)); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
148 |
ZPage page(ZPageTypeSmall, vmem, pmem); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
149 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
150 |
page.reset(); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
151 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
152 |
const size_t object_size = 16; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
153 |
const uintptr_t object = page.alloc_object(object_size); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
154 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
155 |
ZGlobalSeqNum++; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
156 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
157 |
bool dummy = false; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
158 |
page.mark_object(ZAddress::marked(object), dummy, dummy); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
159 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
160 |
const uint32_t live_objects = size; |
58237 | 161 |
const size_t live_bytes = live_objects * object_size; |
59039
c60978f87d45
8233797: ZGC: Unify naming convention for functions using atomics
eosterlund
parents:
58237
diff
changeset
|
162 |
page.inc_live(live_objects, live_bytes); |
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
163 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
164 |
// Setup forwarding |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
165 |
ZForwarding* const forwarding = ZForwarding::create(&page); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
166 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
167 |
// Actual test function |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
168 |
(*function)(forwarding); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
169 |
|
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
170 |
// Teardown forwarding |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
171 |
ZForwarding::destroy(forwarding); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
172 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
173 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
174 |
// Run the given function with a few different input values. |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
175 |
static void test(void (*function)(ZForwarding*)) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
176 |
test(function, 1); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
177 |
test(function, 2); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
178 |
test(function, 3); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
179 |
test(function, 4); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
180 |
test(function, 7); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
181 |
test(function, 8); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
182 |
test(function, 1023); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
183 |
test(function, 1024); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
184 |
test(function, 1025); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
185 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
186 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
187 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
188 |
TEST_F(ZForwardingTest, setup) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
189 |
test(&ZForwardingTest::setup); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
190 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
191 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
192 |
TEST_F(ZForwardingTest, find_empty) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
193 |
test(&ZForwardingTest::find_empty); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
194 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
195 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
196 |
TEST_F(ZForwardingTest, find_full) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
197 |
test(&ZForwardingTest::find_full); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
198 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
199 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
200 |
TEST_F(ZForwardingTest, find_every_other) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
201 |
test(&ZForwardingTest::find_every_other); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
202 |
} |