Skip to content

Commit 496c112

Browse files
committed
Merge master jdk-17.0.12+7 into openj9-staging
Signed-off-by: J9 Build <[email protected]>
2 parents 85d4362 + 95c0260 commit 496c112

File tree

8 files changed

+161
-33
lines changed

8 files changed

+161
-33
lines changed

make/conf/version-numbers.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2011, 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
@@ -39,4 +39,4 @@ DEFAULT_VERSION_CLASSFILE_MINOR=0
3939
DEFAULT_VERSION_DOCS_API_SINCE=11
4040
DEFAULT_ACCEPTABLE_BOOT_VERSIONS="16 17"
4141
DEFAULT_JDK_SOURCE_TARGET_VERSION=17
42-
DEFAULT_PROMOTED_VERSION_PRE=ea
42+
DEFAULT_PROMOTED_VERSION_PRE=

src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1996, 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
@@ -2151,27 +2151,33 @@ private void doCopyArea(int x, int y, int w, int h, int dx, int dy) {
21512151
}
21522152

21532153
Blit ob = lastCAblit;
2154-
if (dy == 0 && dx > 0 && dx < w) {
2155-
while (w > 0) {
2156-
int partW = Math.min(w, dx);
2157-
w -= partW;
2158-
int sx = x + w;
2159-
ob.Blit(theData, theData, comp, clip,
2160-
sx, y, sx+dx, y+dy, partW, h);
2154+
try {
2155+
if (dy == 0 && dx > 0 && dx < w) {
2156+
while (w > 0) {
2157+
int partW = Math.min(w, dx);
2158+
w -= partW;
2159+
int sx = Math.addExact(x, w);
2160+
ob.Blit(theData, theData, comp, clip,
2161+
sx, y, sx+dx, y+dy, partW, h);
2162+
}
2163+
return;
21612164
}
2162-
return;
2163-
}
2164-
if (dy > 0 && dy < h && dx > -w && dx < w) {
2165-
while (h > 0) {
2166-
int partH = Math.min(h, dy);
2167-
h -= partH;
2168-
int sy = y + h;
2169-
ob.Blit(theData, theData, comp, clip,
2170-
x, sy, x+dx, sy+dy, w, partH);
2165+
if (dy > 0 && dy < h && dx > -w && dx < w) {
2166+
while (h > 0) {
2167+
int partH = Math.min(h, dy);
2168+
h -= partH;
2169+
int sy = Math.addExact(y, h);
2170+
ob.Blit(theData, theData, comp, clip,
2171+
x, sy, Math.addExact(x, dx), sy+dy, w, partH);
2172+
}
2173+
return;
21712174
}
2175+
ob.Blit(theData, theData, comp, clip, x, y,
2176+
Math.addExact(x, dx), Math.addExact(y, dy), w, h);
2177+
} catch (ArithmeticException ex) {
2178+
// We are hitting integer overflow in Math.addExact()
21722179
return;
21732180
}
2174-
ob.Blit(theData, theData, comp, clip, x, y, x+dx, y+dy, w, h);
21752181
}
21762182

21772183
/*

src/java.desktop/share/classes/sun/java2d/pipe/DrawImage.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2001, 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
@@ -369,6 +369,13 @@ protected void renderImageXform(SunGraphics2D sg, Image img,
369369
final AffineTransform itx;
370370
try {
371371
itx = tx.createInverse();
372+
double[] mat = new double[6];
373+
itx.getMatrix(mat);
374+
for (double d : mat) {
375+
if (!Double.isFinite(d)) {
376+
return;
377+
}
378+
}
372379
} catch (final NoninvertibleTransformException ignored) {
373380
// Non-invertible transform means no output
374381
return;

src/java.desktop/share/native/libawt/java2d/SurfaceData.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 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
@@ -32,6 +32,7 @@
3232
#define _Included_SurfaceData
3333

3434
#include <jni.h>
35+
#include <limits.h>
3536

3637
#ifdef __cplusplus
3738
extern "C" {
@@ -53,6 +54,14 @@ typedef struct {
5354

5455
#define SD_RASINFO_PRIVATE_SIZE 64
5556

57+
#define UNSAFE_TO_ADD(a, b) \
58+
(((a >= 0) && (b >= 0) && (a > (INT_MAX - b))) || \
59+
((a < 0) && (b < 0) && (a < (INT_MIN - b)))) \
60+
61+
#define UNSAFE_TO_SUB(a, b) \
62+
(((b >= 0) && (a < 0) && (a < (INT_MIN + b))) || \
63+
((b < 0) && (a >= 0) && (-b > (INT_MAX - a)))) \
64+
5665
/*
5766
* The SurfaceDataRasInfo structure is used to pass in and return various
5867
* pieces of information about the destination drawable. In particular:

src/java.desktop/share/native/libawt/java2d/loops/MaskBlit.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 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
@@ -68,14 +68,28 @@ Java_sun_java2d_loops_MaskBlit_MaskBlit
6868
return;
6969
}
7070

71+
if (width <= 0 || height <= 0) {
72+
return;
73+
}
74+
7175
srcInfo.bounds.x1 = srcx;
7276
srcInfo.bounds.y1 = srcy;
77+
if (UNSAFE_TO_ADD(srcx, width) ||
78+
UNSAFE_TO_ADD(srcy, height) ||
79+
UNSAFE_TO_ADD(dstx, width) ||
80+
UNSAFE_TO_ADD(dsty, height)) {
81+
return;
82+
}
7383
srcInfo.bounds.x2 = srcx + width;
7484
srcInfo.bounds.y2 = srcy + height;
7585
dstInfo.bounds.x1 = dstx;
7686
dstInfo.bounds.y1 = dsty;
7787
dstInfo.bounds.x2 = dstx + width;
7888
dstInfo.bounds.y2 = dsty + height;
89+
if (UNSAFE_TO_SUB(srcx, dstx) ||
90+
UNSAFE_TO_SUB(srcy, dsty)) {
91+
return;
92+
}
7993
srcx -= dstx;
8094
srcy -= dsty;
8195
SurfaceData_IntersectBounds(&dstInfo.bounds, &clipInfo.bounds);

src/java.desktop/share/native/libawt/java2d/loops/MaskFill.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 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
@@ -467,7 +467,7 @@ storePgram(EdgeInfo *pLeftEdge, EdgeInfo *pRightEdge,
467467
#define INSERT_ACCUM(pACCUM, IMIN, IMAX, X0, Y0, X1, Y1, CX1, CX2, MULT) \
468468
do { \
469469
jdouble xmid = ((X0) + (X1)) * 0.5; \
470-
if (xmid <= (CX2)) { \
470+
if (xmid < (CX2)) { \
471471
jdouble sliceh = ((Y1) - (Y0)); \
472472
jdouble slicearea; \
473473
jint i; \
@@ -556,7 +556,7 @@ fillAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
556556
jint cy2 = pRasInfo->bounds.y2;
557557
jint width = cx2 - cx1;
558558
EdgeInfo edges[4];
559-
jfloat localaccum[MASK_BUF_LEN + 1];
559+
jfloat localaccum[MASK_BUF_LEN + 2];
560560
jfloat *pAccum;
561561

562562
if (!storePgram(edges + 0, edges + 2,
@@ -568,12 +568,12 @@ fillAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
568568
}
569569

570570
pAccum = ((width > MASK_BUF_LEN)
571-
? malloc((width + 1) * sizeof(jfloat))
571+
? malloc((width + 2) * sizeof(jfloat))
572572
: localaccum);
573573
if (pAccum == NULL) {
574574
return;
575575
}
576-
memset(pAccum, 0, (width+1) * sizeof(jfloat));
576+
memset(pAccum, 0, (width + 2) * sizeof(jfloat));
577577

578578
while (cy1 < cy2) {
579579
jint lmin, lmax, rmin, rmax;
@@ -794,7 +794,7 @@ drawAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
794794
jint cy2 = pRasInfo->bounds.y2;
795795
jint width = cx2 - cx1;
796796
EdgeInfo edges[8];
797-
jfloat localaccum[MASK_BUF_LEN + 1];
797+
jfloat localaccum[MASK_BUF_LEN + 2];
798798
jfloat *pAccum;
799799

800800
if (!storePgram(edges + 0, edges + 6,
@@ -815,12 +815,12 @@ drawAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
815815
JNI_TRUE);
816816

817817
pAccum = ((width > MASK_BUF_LEN)
818-
? malloc((width + 1) * sizeof(jfloat))
818+
? malloc((width + 2) * sizeof(jfloat))
819819
: localaccum);
820820
if (pAccum == NULL) {
821821
return;
822822
}
823-
memset(pAccum, 0, (width+1) * sizeof(jfloat));
823+
memset(pAccum, 0, (width + 2) * sizeof(jfloat));
824824

825825
while (cy1 < cy2) {
826826
jint lmin, lmax, rmin, rmax;

src/java.desktop/share/native/libawt/java2d/loops/TransformHelper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 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
@@ -120,7 +120,7 @@ TransformInterpFunc *pBicubicFunc = BicubicInterp;
120120
/* We reject coordinates not less than 1<<30 so that the distance between */
121121
/* any 2 of them is less than 1<<31 which would overflow into the sign */
122122
/* bit of a signed long value used to represent fixed point coordinates. */
123-
#define TX_FIXED_UNSAFE(v) (fabs(v) >= (1<<30))
123+
#define TX_FIXED_UNSAFE(v) (isinf(v) || isnan(v) || fabs(v) >= (1<<30))
124124
static jboolean
125125
checkOverflow(jint dxoff, jint dyoff,
126126
SurfaceDataBounds *pBounds,
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2023, 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 id=test1
26+
* @bug 8298935
27+
* @summary CMoveI for underflow protection of the limit did not compute a type that was precise enough.
28+
* This lead to dead data but zero-trip-guard control did not die -> "malformed control flow".
29+
* @requires vm.compiler2.enabled
30+
* @run main/othervm
31+
* -XX:CompileCommand=compileonly,compiler.loopopts.TestUnrollLimitPreciseType::test1
32+
* -XX:CompileCommand=dontinline,compiler.loopopts.TestUnrollLimitPreciseType::*
33+
* -XX:MaxVectorSize=64
34+
* -Xcomp
35+
* -XX:+UnlockExperimentalVMOptions -XX:PerMethodSpecTrapLimit=0 -XX:PerMethodTrapLimit=0
36+
* compiler.loopopts.TestUnrollLimitPreciseType test1
37+
*/
38+
39+
/*
40+
* @test id=test2
41+
* @bug 8298935
42+
* @summary CMoveI for underflow protection of the limit did not compute a type that was precise enough.
43+
* This lead to dead data but zero-trip-guard control did not die -> "malformed control flow".
44+
* @requires vm.compiler2.enabled
45+
* @run main/othervm
46+
* -XX:CompileCommand=compileonly,compiler.loopopts.TestUnrollLimitPreciseType::*
47+
* -Xcomp
48+
* compiler.loopopts.TestUnrollLimitPreciseType test2
49+
*/
50+
51+
52+
package compiler.loopopts;
53+
54+
public class TestUnrollLimitPreciseType {
55+
static final int RANGE = 512;
56+
57+
public static void main(String args[]) {
58+
if (args.length != 1) {
59+
throw new RuntimeException("Need exactly one argument.");
60+
}
61+
if (args[0].equals("test1")) {
62+
byte[] data = new byte[RANGE];
63+
test1(data);
64+
} else if (args[0].equals("test2")) {
65+
test2();
66+
} else {
67+
throw new RuntimeException("Do not have: " + args[0]);
68+
}
69+
}
70+
71+
public static void test1(byte[] data) {
72+
// Did not fully analyze this. But it is also unrolled, SuperWorded,
73+
// and further unrolled with vectorlized post loop.
74+
// Only seems to reproduce with avx512, and not with avx2.
75+
for (int j = 192; j < RANGE; j++) {
76+
data[j - 192] = (byte)(data[j] * 11);
77+
}
78+
}
79+
80+
static void test2() {
81+
// Loop is SuperWord'ed.
82+
// We unroll more afterwards, and so add vectorized post loop.
83+
// But it turns out that the vectorized post loop is never entered.
84+
// This lead to assert, because the zero-trip-guard did not collaspse,
85+
// but the CastII with the trip count did die.
86+
// Only seems to reproduce with avx512, and not with avx2.
87+
double dArr[][] = new double[100][100];
88+
for (int i = 2, j = 2; j < 68; j++) {
89+
dArr[i][j] = 8;
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)