Skip to content

Commit 789b1bc

Browse files
authored
Merge branch 'master' into goetz_backport_8295005
2 parents a545351 + 4dceddf commit 789b1bc

File tree

35 files changed

+537
-836
lines changed

35 files changed

+537
-836
lines changed

src/hotspot/share/opto/stringopts.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,12 +1004,21 @@ bool StringConcat::validate_control_flow() {
10041004
continue;
10051005
}
10061006

1007-
// A test which leads to an uncommon trap which should be safe.
1008-
// Later this trap will be converted into a trap that restarts
1007+
// A test which leads to an uncommon trap. It is safe to convert the trap
1008+
// into a trap that restarts at the beginning as long as its test does not
1009+
// depend on intermediate results of the candidate chain.
10091010
// at the beginning.
10101011
if (otherproj->outcnt() == 1) {
10111012
CallStaticJavaNode* call = otherproj->unique_out()->isa_CallStaticJava();
10121013
if (call != nullptr && call->_name != nullptr && strcmp(call->_name, "uncommon_trap") == 0) {
1014+
// First check for dependency on a toString that is going away during stacked concats.
1015+
if (_multiple &&
1016+
((v1->is_Proj() && is_SB_toString(v1->in(0)) && ctrl_path.member(v1->in(0))) ||
1017+
(v2->is_Proj() && is_SB_toString(v2->in(0)) && ctrl_path.member(v2->in(0))))) {
1018+
// iftrue -> if -> bool -> cmpp -> resproj -> tostring
1019+
fail = true;
1020+
break;
1021+
}
10131022
// control flow leads to uct so should be ok
10141023
_uncommon_traps.push(call);
10151024
ctrl_path.push(call);

src/java.desktop/share/classes/java/awt/image/ColorConvertOp.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ public BufferedImage createCompatibleDestImage (BufferedImage src,
622622
"Destination ColorSpace is undefined");
623623
}
624624
ICC_Profile destProfile = profileList[nProfiles - 1];
625-
cs = new ICC_ColorSpace(destProfile);
625+
cs = createCompatibleColorSpace(destProfile);
626626
} else {
627627
/* non-ICC case */
628628
int nSpaces = CSList.length;
@@ -632,6 +632,25 @@ public BufferedImage createCompatibleDestImage (BufferedImage src,
632632
return createCompatibleDestImage(src, destCM, cs);
633633
}
634634

635+
private static ColorSpace createCompatibleColorSpace(ICC_Profile profile) {
636+
if (profile == ICC_Profile.getInstance(ColorSpace.CS_sRGB)) {
637+
return ColorSpace.getInstance(ColorSpace.CS_sRGB);
638+
}
639+
if (profile == ICC_Profile.getInstance(ColorSpace.CS_LINEAR_RGB)) {
640+
return ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
641+
}
642+
if (profile == ICC_Profile.getInstance(ColorSpace.CS_CIEXYZ)) {
643+
return ColorSpace.getInstance(ColorSpace.CS_CIEXYZ);
644+
}
645+
if (profile == ICC_Profile.getInstance(ColorSpace.CS_PYCC)) {
646+
return ColorSpace.getInstance(ColorSpace.CS_PYCC);
647+
}
648+
if (profile == ICC_Profile.getInstance(ColorSpace.CS_GRAY)) {
649+
return ColorSpace.getInstance(ColorSpace.CS_GRAY);
650+
}
651+
return new ICC_ColorSpace(profile);
652+
}
653+
635654
private BufferedImage createCompatibleDestImage(BufferedImage src,
636655
ColorModel destCM,
637656
ColorSpace destCS) {

src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -755,7 +755,7 @@ socketTransport_startListening(jdwpTransportEnv* env, const char* address,
755755

756756
if (isEqualIPv6Addr(listenAddr, mappedAny)) {
757757
for (ai = addrInfo; ai != NULL; ai = ai->ai_next) {
758-
if (isEqualIPv6Addr(listenAddr, in6addr_any)) {
758+
if (isEqualIPv6Addr(ai, in6addr_any)) {
759759
listenAddr = ai;
760760
break;
761761
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2025, 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+
24+
/*
25+
* @test
26+
* @bug 8357105
27+
* @summary Test stacked string concatenations where the toString result
28+
* of the first StringBuilder chain is wired into an uncommon trap
29+
* located in the second one.
30+
* @run main/othervm compiler.stringopts.TestStackedConcatsAppendUncommonTrap
31+
* @run main/othervm -XX:-TieredCompilation -Xbatch
32+
* -XX:CompileOnly=compiler.stringopts.TestStackedConcatsAppendUncommonTrap::*
33+
* compiler.stringopts.TestStackedConcatsAppendUncommonTrap
34+
*/
35+
36+
package compiler.stringopts;
37+
38+
public class TestStackedConcatsAppendUncommonTrap {
39+
40+
public static void main (String... args) {
41+
for (int i = 0; i < 10000; i++) {
42+
String s = f(" ");
43+
if (!s.equals(" ")) {
44+
throw new RuntimeException("wrong result.");
45+
}
46+
}
47+
}
48+
49+
static String f(String c) {
50+
String s = " ";
51+
s = new StringBuilder().append(s).append(s).toString();
52+
s = new StringBuilder().append(s).append(s == c ? s : " ").toString();
53+
return s;
54+
}
55+
}

test/hotspot/jtreg/vmTestbase/gc/gctests/PhantomReference/PhantomReferenceEvilTest/PhantomReferenceEvilTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,10 @@
3939
*
4040
* @library /vmTestbase
4141
* /test/lib
42+
* @build jdk.test.whitebox.WhiteBox
43+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
4244
* @run main/othervm
43-
* -XX:-UseGCOverheadLimit
45+
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
4446
* gc.gctests.PhantomReference.PhantomReferenceEvilTest.PhantomReferenceEvilTest
4547
*/
4648

@@ -52,11 +54,12 @@
5254
import java.util.ArrayList;
5355
import java.util.Random;
5456
import java.util.HashMap;
57+
58+
import jdk.test.whitebox.WhiteBox;
5559
import nsk.share.TestFailure;
5660
import nsk.share.gc.GC;
5761
import nsk.share.gc.GCTestBase;
5862
import nsk.share.gc.Memory;
59-
import nsk.share.gc.gp.GarbageUtils;
6063
import nsk.share.test.Stresser;
6164

6265
/**
@@ -152,7 +155,7 @@ public final void run() {
152155

153156
Stresser stresser = new Stresser(runParams.getStressOptions());
154157
stresser.start(0);
155-
GarbageUtils.eatMemory(stresser);
158+
WhiteBox.getWhiteBox().fullGC();
156159
if (!stresser.continueExecution()) {
157160
return; //we couldn't be sure that FullGC is triggered
158161
}

test/hotspot/jtreg/vmTestbase/gc/gctests/PhantomReference/PhantomReferenceTest/PhantomReferenceTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,10 @@
3636
*
3737
* @library /vmTestbase
3838
* /test/lib
39+
* @build jdk.test.whitebox.WhiteBox
40+
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
3941
* @run main/othervm
40-
* -XX:-UseGCOverheadLimit
42+
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
4143
* gc.gctests.PhantomReference.PhantomReferenceTest.PhantomReferenceTest
4244
*/
4345

@@ -49,6 +51,8 @@
4951
import java.util.ArrayList;
5052
import java.util.HashMap;
5153
import java.util.Random;
54+
55+
import jdk.test.whitebox.WhiteBox;
5256
import nsk.share.TestFailure;
5357
import nsk.share.gc.GC;
5458
import nsk.share.gc.GCTestBase;
@@ -109,7 +113,7 @@ public final void run() {
109113

110114
Stresser stresser = new Stresser(runParams.getStressOptions());
111115
stresser.start(0);
112-
GarbageUtils.eatMemory(stresser);
116+
WhiteBox.getWhiteBox().fullGC();
113117
if (!stresser.continueExecution()) {
114118
return; //we couldn't be sure that FullGC is triggered
115119
}

0 commit comments

Comments
 (0)