Skip to content

Commit e2bb112

Browse files
author
Datadog Syncup Service
committed
Merge branch 'upstream-master'
2 parents 6b95517 + 423e8e0 commit e2bb112

File tree

10 files changed

+1095
-360
lines changed

10 files changed

+1095
-360
lines changed

src/hotspot/share/gc/parallel/psParallelCompact.cpp

Lines changed: 383 additions & 324 deletions
Large diffs are not rendered by default.

src/hotspot/share/gc/parallel/psParallelCompact.hpp

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -116,51 +116,45 @@ class SplitInfo
116116
// Return true if this split info is valid (i.e., if a split has been
117117
// recorded). The very first region cannot have a partial object and thus is
118118
// never split, so 0 is the 'invalid' value.
119-
bool is_valid() const { return _src_region_idx > 0; }
119+
bool is_valid() const { return _split_region_idx > 0; }
120120

121121
// Return true if this split holds data for the specified source region.
122-
inline bool is_split(size_t source_region) const;
122+
inline bool is_split(size_t region_idx) const;
123123

124-
// The index of the split region, the size of the partial object on that
125-
// region and the destination of the partial object.
126-
size_t partial_obj_size() const { return _partial_obj_size; }
127-
HeapWord* destination() const { return _destination; }
124+
// Obj at the split point doesn't fit the previous space and will be relocated to the next space.
125+
HeapWord* split_point() const { return _split_point; }
128126

129-
// The destination count of the partial object referenced by this split
130-
// (either 1 or 2). This must be added to the destination count of the
131-
// remainder of the source region.
132-
unsigned int destination_count() const { return _destination_count; }
127+
// Number of live words before the split point on this region.
128+
size_t preceding_live_words() const { return _preceding_live_words; }
133129

134-
// If a word within the partial object will be written to the first word of a
135-
// destination region, this is the address of the destination region;
136-
// otherwise this is null.
137-
HeapWord* dest_region_addr() const { return _dest_region_addr; }
130+
// A split region has two "destinations", living in two spaces. This method
131+
// returns the first one -- destination for the first live word on
132+
// this split region.
133+
HeapWord* preceding_destination() const {
134+
assert(_preceding_destination != nullptr, "inv");
135+
return _preceding_destination;
136+
}
138137

139-
// If a word within the partial object will be written to the first word of a
140-
// destination region, this is the address of that word within the partial
141-
// object; otherwise this is null.
142-
HeapWord* first_src_addr() const { return _first_src_addr; }
138+
// Number of regions the preceding live words are relocated into.
139+
uint preceding_destination_count() const { return _preceding_destination_count; }
143140

144-
// Record the data necessary to split the region src_region_idx.
145-
void record(size_t src_region_idx, size_t partial_obj_size,
146-
HeapWord* destination);
141+
void record(size_t split_region_idx, HeapWord* split_point, size_t preceding_live_words);
147142

148143
void clear();
149144

150145
DEBUG_ONLY(void verify_clear();)
151146

152147
private:
153-
size_t _src_region_idx;
154-
size_t _partial_obj_size;
155-
HeapWord* _destination;
156-
unsigned int _destination_count;
157-
HeapWord* _dest_region_addr;
158-
HeapWord* _first_src_addr;
148+
size_t _split_region_idx;
149+
HeapWord* _split_point;
150+
size_t _preceding_live_words;
151+
HeapWord* _preceding_destination;
152+
uint _preceding_destination_count;
159153
};
160154

161155
inline bool SplitInfo::is_split(size_t region_idx) const
162156
{
163-
return _src_region_idx == region_idx && is_valid();
157+
return _split_region_idx == region_idx && is_valid();
164158
}
165159

166160
class SpaceInfo
@@ -215,10 +209,18 @@ class ParallelCompactData
215209
class RegionData
216210
{
217211
public:
218-
// Destination address of the region.
212+
// Destination for the first live word in this region.
213+
// Therefore, the new addr for every live obj on this region can be calculated as:
214+
//
215+
// new_addr := _destination + live_words_offset(old_addr);
216+
//
217+
// where, live_words_offset is the number of live words accumulated from
218+
// region-start to old_addr.
219219
HeapWord* destination() const { return _destination; }
220220

221-
// The first region containing data destined for this region.
221+
// A destination region can have multiple source regions; only the first
222+
// one is recorded. Since all live objs are slided down, subsequent source
223+
// regions can be found via plain heap-region iteration.
222224
size_t source_region() const { return _source_region; }
223225

224226
// Reuse _source_region to store the corresponding shadow region index
@@ -313,9 +315,12 @@ class ParallelCompactData
313315
// Return to the normal path here
314316
inline void shadow_to_normal();
315317

316-
317318
int shadow_state() { return _shadow_state; }
318319

320+
bool is_clear();
321+
322+
void verify_clear() NOT_DEBUG_RETURN;
323+
319324
private:
320325
// The type used to represent object sizes within a region.
321326
typedef uint region_sz_t;
@@ -873,7 +878,10 @@ class MoveAndUpdateClosure: public StackObj {
873878
size_t words_remaining() const { return _words_remaining; }
874879
bool is_full() const { return _words_remaining == 0; }
875880
HeapWord* source() const { return _source; }
876-
void set_source(HeapWord* addr) { _source = addr; }
881+
void set_source(HeapWord* addr) {
882+
assert(addr != nullptr, "precondition");
883+
_source = addr;
884+
}
877885

878886
// If the object will fit (size <= words_remaining()), copy it to the current
879887
// destination, update the interior oops and the start array.
@@ -902,9 +910,8 @@ inline size_t MoveAndUpdateClosure::calculate_words_remaining(size_t region) {
902910
HeapWord* dest_addr = PSParallelCompact::summary_data().region_to_addr(region);
903911
PSParallelCompact::SpaceId dest_space_id = PSParallelCompact::space_id(dest_addr);
904912
HeapWord* new_top = PSParallelCompact::new_top(dest_space_id);
905-
assert(dest_addr < new_top, "sanity");
906-
907-
return MIN2(pointer_delta(new_top, dest_addr), ParallelCompactData::RegionSize);
913+
return MIN2(pointer_delta(new_top, dest_addr),
914+
ParallelCompactData::RegionSize);
908915
}
909916

910917
inline

test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPPadding.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static void main(String args[]) throws Exception {
5757
System.getProperty("test.provider.name", "SunJCE"));
5858
System.out.println("Testing provider " + cp.getName() + "...");
5959
Provider kfp = Security.getProvider(
60-
System.getProperty("test.providername", "SunRsaSign"));
60+
System.getProperty("test.provider.name", "SunRsaSign"));
6161
String kpgAlgorithm = "RSA";
6262
KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm, kfp);
6363
kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm));
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
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.
22+
*/
23+
import jdk.test.lib.json.JSONValue;
24+
import jtreg.SkippedException;
25+
26+
import java.nio.file.Files;
27+
import java.nio.file.Path;
28+
import java.security.Provider;
29+
import java.security.Security;
30+
31+
/*
32+
* @test
33+
* @bug 8342442
34+
* @library /test/lib
35+
*/
36+
37+
/// This test runs on `internalProjection.json`-style files generated
38+
/// by NIST's ACVP Server. See [https://github.com/usnistgov/ACVP-Server].
39+
///
40+
/// The files are either put into the `data` directory or another
41+
/// directory specified by the `test.acvp.data` test property.
42+
/// The test walks through the directory recursively and looks for
43+
/// file names equal to or ending with `internalProjection.json` and
44+
/// runs tests on them.
45+
///
46+
/// Set the `test.acvp.alg` test property to only test the specified algorithm.
47+
///
48+
/// Sample files can be downloaded from
49+
/// [https://github.com/usnistgov/ACVP-Server/tree/master/gen-val/json-files].
50+
///
51+
/// By default, the test uses system-preferred implementations.
52+
/// If you want to test a specific provider, set the
53+
/// `test.acvp.provider` test property. The provider must be
54+
/// registered.
55+
///
56+
/// Tests for each algorithm must be compliant to its specification linked from
57+
/// [https://github.com/usnistgov/ACVP?tab=readme-ov-file#supported-algorithms].
58+
///
59+
/// Example:
60+
/// ```
61+
/// jtreg -Dtest.acvp.provider=SunJCE \
62+
/// -Dtest.acvp.alg=ML-KEM \
63+
/// -Dtest.acvp.data=/path/to/json-files/ \
64+
/// -jdk:/path/to/jdk Launcher.java
65+
/// ```
66+
public class Launcher {
67+
68+
private static final String ONLY_ALG
69+
= System.getProperty("test.acvp.alg");
70+
71+
private static final Provider PROVIDER;
72+
73+
private static int count = 0;
74+
private static int invalidTest = 0;
75+
private static int unsupportedTest = 0;
76+
77+
static {
78+
var provProp = System.getProperty("test.acvp.provider");
79+
if (provProp != null) {
80+
var p = Security.getProvider(provProp);
81+
if (p == null) {
82+
System.err.println(provProp + " is not a registered provider name");
83+
throw new RuntimeException(provProp + " is not a registered provider name");
84+
}
85+
PROVIDER = p;
86+
} else {
87+
PROVIDER = null;
88+
}
89+
}
90+
91+
public static void main(String[] args) throws Exception {
92+
93+
var testDataProp = System.getProperty("test.acvp.data");
94+
Path dataPath = testDataProp != null
95+
? Path.of(testDataProp)
96+
: Path.of(System.getProperty("test.src"), "data");
97+
System.out.println("Data path: " + dataPath);
98+
99+
if (PROVIDER != null) {
100+
System.out.println("Provider: " + PROVIDER.getName());
101+
}
102+
if (ONLY_ALG != null) {
103+
System.out.println("Algorithm: " + ONLY_ALG);
104+
}
105+
106+
try (var stream = Files.walk(dataPath)) {
107+
stream.filter(Files::isRegularFile)
108+
.filter(p -> p.getFileName().toString()
109+
.endsWith("internalProjection.json"))
110+
.forEach(Launcher::run);
111+
}
112+
113+
if (count > 0) {
114+
System.out.println();
115+
System.out.println("Test completed: " + count);
116+
System.out.println("Invalid tests: " + invalidTest);
117+
System.out.println("Unsupported tests: " + unsupportedTest);
118+
} else {
119+
throw new SkippedException("No supported test found");
120+
}
121+
}
122+
123+
static void run(Path test) {
124+
try {
125+
JSONValue kat;
126+
try {
127+
kat = JSONValue.parse(Files.readString(test));
128+
} catch (Exception e) {
129+
System.out.println("Warning: cannot parse " + test + ". Skipped");
130+
invalidTest++;
131+
return;
132+
}
133+
var alg = kat.get("algorithm").asString();
134+
if (ONLY_ALG != null && !alg.equals(ONLY_ALG)) {
135+
return;
136+
}
137+
System.out.println(">>> Testing " + test + "...");
138+
switch (alg) {
139+
case "ML-DSA" -> {
140+
ML_DSA_Test.run(kat, PROVIDER);
141+
count++;
142+
}
143+
case "ML-KEM" -> {
144+
ML_KEM_Test.run(kat, PROVIDER);
145+
count++;
146+
}
147+
case "SHA2-256", "SHA2-224", "SHA3-256", "SHA3-224" -> {
148+
SHA_Test.run(kat, PROVIDER);
149+
count++;
150+
}
151+
default -> {
152+
System.out.println("Skipped unsupported algorithm: " + alg);
153+
unsupportedTest++;
154+
}
155+
}
156+
} catch (RuntimeException re) {
157+
throw re;
158+
} catch (Exception e) {
159+
throw new RuntimeException(e);
160+
}
161+
}
162+
}

0 commit comments

Comments
 (0)