author | pliden |
Mon, 18 Mar 2019 11:50:40 +0100 | |
changeset 54172 | f92f1f1045ad |
parent 54169 | 5748eae24183 |
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 |
/* |
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 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
43 |
static bool is_power_of_2(uint32_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: |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
49 |
static uintptr_t even(uint32_t sequence_number) { |
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 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
52 |
static uintptr_t odd(uint32_t sequence_number) { |
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 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
55 |
static uintptr_t one_to_one(uint32_t sequence_number) { |
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) { |
54172
f92f1f1045ad
8220597: ZGC: Convert ZForwarding to use ZAttachedArray
pliden
parents:
54169
diff
changeset
|
67 |
uint32_t size = forwarding->_entries.length(); |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
68 |
uint32_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 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
70 |
for (uint32_t i = 0; i < entries_to_check; i++) { |
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 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
73 |
EXPECT_TRUE(forwarding->find(from_index).is_empty()) << 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 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
76 |
EXPECT_TRUE(forwarding->find(uintptr_t(-1)).is_empty()) << CAPTURE(size); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
77 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
78 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
79 |
static void find_full(ZForwarding* forwarding) { |
54172
f92f1f1045ad
8220597: ZGC: Convert ZForwarding to use ZAttachedArray
pliden
parents:
54169
diff
changeset
|
80 |
uint32_t size = forwarding->_entries.length(); |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
81 |
uint32_t entries_to_populate = size; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
82 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
83 |
// Populate |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
84 |
for (uint32_t i = 0; i < entries_to_populate; i++) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
85 |
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
|
86 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
87 |
ZForwardingCursor cursor; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
88 |
ZForwardingEntry entry = forwarding->find(from_index, &cursor); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
89 |
ASSERT_TRUE(entry.is_empty()) << CAPTURE2(from_index, size); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
90 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
91 |
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
|
92 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
93 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
94 |
// Verify |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
95 |
for (uint32_t i = 0; i < entries_to_populate; i++) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
96 |
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
|
97 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
98 |
ZForwardingEntry entry = forwarding->find(from_index); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
99 |
ASSERT_FALSE(entry.is_empty()) << CAPTURE2(from_index, size); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
100 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
101 |
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
|
102 |
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
|
103 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
104 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
105 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
106 |
static void find_every_other(ZForwarding* forwarding) { |
54172
f92f1f1045ad
8220597: ZGC: Convert ZForwarding to use ZAttachedArray
pliden
parents:
54169
diff
changeset
|
107 |
uint32_t size = forwarding->_entries.length(); |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
108 |
uint32_t entries_to_populate = size / 2; |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
109 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
110 |
// Populate even from indices |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
111 |
for (uint32_t i = 0; i < entries_to_populate; i++) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
112 |
uintptr_t from_index = SequenceToFromIndex::even(i); |
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:
50975
diff
changeset
|
114 |
ZForwardingCursor cursor; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
115 |
ZForwardingEntry entry = forwarding->find(from_index, &cursor); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
116 |
ASSERT_TRUE(entry.is_empty()) << CAPTURE2(from_index, size); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
117 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
118 |
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
|
119 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
120 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
121 |
// Verify populated even indices |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
122 |
for (uint32_t i = 0; i < entries_to_populate; i++) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
123 |
uintptr_t from_index = SequenceToFromIndex::even(i); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
124 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
125 |
ZForwardingCursor cursor; |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
126 |
ZForwardingEntry entry = forwarding->find(from_index, &cursor); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
127 |
ASSERT_FALSE(entry.is_empty()) << CAPTURE2(from_index, size); |
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 |
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
|
130 |
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
|
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 |
// Verify empty odd indices |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
134 |
// |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
135 |
// 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
|
136 |
// but currently entries_to_populate is used. |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
137 |
for (uint32_t i = 0; i < entries_to_populate; i++) { |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
138 |
uintptr_t from_index = SequenceToFromIndex::odd(i); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
139 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
140 |
ZForwardingEntry entry = forwarding->find(from_index); |
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 |
ASSERT_TRUE(entry.is_empty()) << CAPTURE2(from_index, size); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
143 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
144 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
145 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
146 |
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
|
147 |
// Create page |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
148 |
const ZVirtualMemory vmem(0, ZPageSizeSmall); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
149 |
const ZPhysicalMemory pmem(ZPhysicalMemorySegment(0, ZPageSizeSmall)); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
150 |
ZPage page(ZPageTypeSmall, vmem, pmem); |
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 |
page.reset(); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
153 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
154 |
const size_t object_size = 16; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
155 |
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
|
156 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
157 |
ZGlobalSeqNum++; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
158 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
159 |
bool dummy = false; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
160 |
page.mark_object(ZAddress::marked(object), dummy, dummy); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
161 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
162 |
const uint32_t live_objects = size; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
163 |
const uint32_t live_bytes = live_objects * object_size; |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
164 |
page.inc_live_atomic(live_objects, live_bytes); |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
165 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
166 |
// Setup forwarding |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
167 |
ZForwarding* const forwarding = ZForwarding::create(&page); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
168 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
169 |
// Actual test function |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
170 |
(*function)(forwarding); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
171 |
|
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
172 |
// Teardown forwarding |
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
173 |
ZForwarding::destroy(forwarding); |
54163
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
174 |
|
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
175 |
// Teardown page |
790679f86a51
8220588: ZGC: Convert ZRelocationSet to hold ZForwardings instead of ZPages
pliden
parents:
54162
diff
changeset
|
176 |
page.physical_memory().clear(); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
177 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
178 |
|
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
179 |
// 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
|
180 |
static void test(void (*function)(ZForwarding*)) { |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
181 |
test(function, 1); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
182 |
test(function, 2); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
183 |
test(function, 3); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
184 |
test(function, 4); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
185 |
test(function, 7); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
186 |
test(function, 8); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
187 |
test(function, 1023); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
188 |
test(function, 1024); |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
189 |
test(function, 1025); |
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 |
}; |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
192 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
193 |
TEST_F(ZForwardingTest, setup) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
194 |
test(&ZForwardingTest::setup); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
195 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
196 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
197 |
TEST_F(ZForwardingTest, find_empty) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
198 |
test(&ZForwardingTest::find_empty); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
199 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
200 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
201 |
TEST_F(ZForwardingTest, find_full) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
202 |
test(&ZForwardingTest::find_full); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
203 |
} |
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
204 |
|
54162
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
205 |
TEST_F(ZForwardingTest, find_every_other) { |
f344a0c6e19e
8220587: ZGC: Break out forwarding information from ZPage
pliden
parents:
50975
diff
changeset
|
206 |
test(&ZForwardingTest::find_every_other); |
50525
767cdb97f103
8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff
changeset
|
207 |
} |