Skip to content

Commit

Permalink
Merge latest openjdk
Browse files Browse the repository at this point in the history
  • Loading branch information
j9build committed Nov 7, 2024
2 parents 16ba0ee + 8f4b6d2 commit 5f05133
Show file tree
Hide file tree
Showing 16 changed files with 483 additions and 71 deletions.
4 changes: 4 additions & 0 deletions make/RunTests.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,10 @@ define SetupRunJtregTestBody
JTREG_AUTO_PROBLEM_LISTS += ProblemList-zgc.txt
endif

ifneq ($$(findstring -XX:+UseShenandoahGC, $$(JTREG_ALL_OPTIONS)), )
JTREG_AUTO_PROBLEM_LISTS += ProblemList-shenandoah.txt
endif

ifneq ($$(JTREG_EXTRA_PROBLEM_LISTS), )
# Accept both absolute paths as well as relative to the current test root.
$1_JTREG_BASIC_OPTIONS += $$(addprefix $$(JTREG_PROBLEM_LIST_PREFIX), $$(wildcard \
Expand Down
61 changes: 21 additions & 40 deletions src/java.base/macosx/native/libjava/java_props_macosx.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -222,54 +222,35 @@ char *setupMacOSXLocale(int cat) {
}
}

// 10.9 SDK does not include the NSOperatingSystemVersion struct.
// For now, create our own
typedef struct {
NSInteger majorVersion;
NSInteger minorVersion;
NSInteger patchVersion;
} OSVerStruct;

void setOSNameAndVersion(java_props_t *sprops) {
// Hardcode os_name, and fill in os_version
sprops->os_name = strdup("Mac OS X");

NSString *nsVerStr = NULL;
char* osVersionCStr = NULL;
// Mac OS 10.9 includes the [NSProcessInfo operatingSystemVersion] function,
// but it's not in the 10.9 SDK. So, call it via NSInvocation.
if ([[NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion)]) {
OSVerStruct osVer;
NSMethodSignature *sig = [[NSProcessInfo processInfo] methodSignatureForSelector:
@selector(operatingSystemVersion)];
NSInvocation *invoke = [NSInvocation invocationWithMethodSignature:sig];
invoke.selector = @selector(operatingSystemVersion);
[invoke invokeWithTarget:[NSProcessInfo processInfo]];
[invoke getReturnValue:&osVer];

// Copy out the char* if running on version other than 10.16 Mac OS (10.16 == 11.x)
// or explicitly requesting version compatibility
if (!((long)osVer.majorVersion == 10 && (long)osVer.minorVersion >= 16) ||
(getenv("SYSTEM_VERSION_COMPAT") != NULL)) {
if (osVer.patchVersion == 0) { // Omit trailing ".0"
nsVerStr = [NSString stringWithFormat:@"%ld.%ld",
(long)osVer.majorVersion, (long)osVer.minorVersion];
} else {
nsVerStr = [NSString stringWithFormat:@"%ld.%ld.%ld",
(long)osVer.majorVersion, (long)osVer.minorVersion, (long)osVer.patchVersion];
}
NSOperatingSystemVersion osVer = [[NSProcessInfo processInfo] operatingSystemVersion];
// Copy out the char* if running on version other than 10.16 Mac OS (10.16 == 11.x)
// or explicitly requesting version compatibility
if (!((long)osVer.majorVersion == 10 && (long)osVer.minorVersion >= 16) ||
(getenv("SYSTEM_VERSION_COMPAT") != NULL)) {
if (osVer.patchVersion == 0) { // Omit trailing ".0"
nsVerStr = [NSString stringWithFormat:@"%ld.%ld",
(long)osVer.majorVersion, (long)osVer.minorVersion];
} else {
// Version 10.16, without explicit env setting of SYSTEM_VERSION_COMPAT
// AKA 11+ Read the *real* ProductVersion from the hidden link to avoid SYSTEM_VERSION_COMPAT
// If not found, fallback below to the SystemVersion.plist
NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile :
@"/System/Library/CoreServices/.SystemVersionPlatform.plist"];
if (version != NULL) {
nsVerStr = [version objectForKey : @"ProductVersion"];
}
nsVerStr = [NSString stringWithFormat:@"%ld.%ld.%ld",
(long)osVer.majorVersion, (long)osVer.minorVersion, (long)osVer.patchVersion];
}
} else {
// Version 10.16, without explicit env setting of SYSTEM_VERSION_COMPAT
// AKA 11+ Read the *real* ProductVersion from the hidden link to avoid SYSTEM_VERSION_COMPAT
// If not found, fallback below to the SystemVersion.plist
NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile :
@"/System/Library/CoreServices/.SystemVersionPlatform.plist"];
if (version != NULL) {
nsVerStr = [version objectForKey : @"ProductVersion"];
}
}
// Fallback if running on pre-10.9 Mac OS
// Fallback to reading the SystemVersion.plist
if (nsVerStr == NULL) {
NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile :
@"/System/Library/CoreServices/SystemVersion.plist"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,27 @@ protected TransPatterns(Context context) {

@Override
public void visitTypeTest(JCInstanceOf tree) {
if (tree.pattern instanceof JCPattern pattern) {
// Translates regular instanceof type operation to instanceof pattern operator when
// the expression was originally T but was subsequently erased to Object.
//
// $expr instanceof $primitiveType
// =>
// $expr instanceof T $temp && $temp instanceof $primitiveType
if (tree.erasedExprOriginalType!=null && !types.isSameType(tree.expr.type, tree.erasedExprOriginalType)) {
BindingSymbol temp = new BindingSymbol(Flags.FINAL | Flags.SYNTHETIC,
names.fromString("temp" + variableIndex++ + target.syntheticNameChar()),
tree.erasedExprOriginalType,
currentMethodSym);

JCVariableDecl tempDecl = make.at(tree.pos()).VarDef(temp, null);

JCTree resultExpr =
makeBinary(Tag.AND,
make.TypeTest(tree.expr, make.BindingPattern(tempDecl).setType(tree.erasedExprOriginalType)).setType(syms.booleanType),
make.TypeTest(make.Ident(tempDecl), tree.pattern).setType(syms.booleanType));

result = translate(resultExpr);
} else if (tree.pattern instanceof JCPattern pattern) {
//first, resolve any record patterns:
JCExpression extraConditions = null;
if (pattern instanceof JCRecordPattern recordPattern) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,7 @@ public void visitSwitch(JCSwitch tree) {
Type selsuper = types.supertype(tree.selector.type);
boolean enumSwitch = selsuper != null &&
selsuper.tsym == syms.enumSym;
Type target = enumSwitch ? erasure(tree.selector.type) : syms.intType;
tree.selector = translate(tree.selector, target);
tree.selector = translate(tree.selector, erasure(tree.selector.type));
tree.cases = translateCases(tree.cases);
result = tree;
}
Expand Down Expand Up @@ -852,8 +851,7 @@ public void visitSwitchExpression(JCSwitchExpression tree) {
Type selsuper = types.supertype(tree.selector.type);
boolean enumSwitch = selsuper != null &&
selsuper.tsym == syms.enumSym;
Type target = enumSwitch ? erasure(tree.selector.type) : syms.intType;
tree.selector = translate(tree.selector, target);
tree.selector = translate(tree.selector, erasure(tree.selector.type));
tree.cases = translate(tree.cases, tree.type);
tree.type = erasure(tree.type);
result = retype(tree, tree.type, pt);
Expand Down Expand Up @@ -1067,8 +1065,14 @@ public void visitTypeCast(JCTypeCast tree) {
}

public void visitTypeTest(JCInstanceOf tree) {
tree.expr = translate(tree.expr, null);
tree.pattern = translate(tree.pattern, null);
if (tree.pattern.type.isPrimitive()) {
tree.erasedExprOriginalType = erasure(tree.expr.type);
tree.expr = translate(tree.expr, null);
}
else {
tree.expr = translate(tree.expr, null);
}
result = tree;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2272,6 +2272,8 @@ public static class JCInstanceOf extends JCExpression implements InstanceOfTree
/**{@code true} if this instanceof test should have
* value {@code true} when the {@code expr} is {@code null}.*/
public boolean allowNull;
public Type erasedExprOriginalType;

protected JCInstanceOf(JCExpression expr, JCTree pattern) {
this.expr = expr;
this.pattern = pattern;
Expand Down
80 changes: 80 additions & 0 deletions test/hotspot/jtreg/compiler/c2/TestCastX2NotProcessedIGVN.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2024, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package compiler.c2;

import compiler.lib.ir_framework.*;
import jdk.internal.misc.Unsafe;

/*
* @test
* @bug 8343068
* @summary C2: CastX2P Ideal transformation not always applied
* @modules java.base/jdk.internal.misc
* @library /test/lib /
* @run driver compiler.c2.TestCastX2NotProcessedIGVN
*/

public class TestCastX2NotProcessedIGVN {
private static final Unsafe UNSAFE = Unsafe.getUnsafe();
static int size = 1024;
static long base = UNSAFE.allocateMemory(4 * size);


public static void main(String[] args) {
TestFramework.runWithFlags("--add-modules", "java.base", "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED");
}

@Test
@IR(failOn = IRNode.ADD_L, counts = {IRNode.ADD_P, "1"})
public static byte test1(long base) {
int offset = 0;
do {
offset++;
} while (offset < 100);
long longOffset = ((long) offset) * 2;
return UNSAFE.getByte(null, base + longOffset);
}

@Run(test = "test1")
public static void test1Runner() {
test1(base);
}

@Test
@IR(counts = {IRNode.LOAD_VECTOR_I, "> 1"})
public static int test2(int stop, int[] array) {
int v = 0;
stop = Math.min(stop, Integer.MAX_VALUE / 4);
for (int i = 0; i < stop; i++) {
long offset = ((long)i) * 4;
array[i] = UNSAFE.getInt(null, offset + base);
}
return v;
}

@Run(test = "test2")
public static void test2Runner() {
test2(size, new int[size]);
}
}
61 changes: 61 additions & 0 deletions test/hotspot/jtreg/compiler/c2/TestMatcherTwoImmOffsets.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8339303
* @summary Test that the matcher does not create dead nodes when matching
* address expressions with two immediate offsets.
* @requires os.maxMemory > 4G
*
* @run main/othervm -Xmx4g -Xbatch -XX:-TieredCompilation
* -XX:CompileOnly=compiler.c2.TestMatcherTwoImmOffsets::test
* compiler.c2.TestMatcherTwoImmOffsets
*/

package compiler.c2;

public class TestMatcherTwoImmOffsets {
static final int[] a1 = new int[10];
int[] a2;
static TestMatcherTwoImmOffsets o = new TestMatcherTwoImmOffsets();

public static void test() {
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 100; j++) {
int[][] nArray = new int[10][];
for (int k = 0; k < nArray.length; k++) {}
}
for (long j = 1L; j < 3L; j++) {
a1[(int) j]--;
}
o.a2 = a1;
}
}

public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
test();
}
}
}
5 changes: 5 additions & 0 deletions test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ public class IRNode {
beforeMatchingNameRegex(ADD_L, "AddL");
}

public static final String ADD_P = PREFIX + "ADD_P" + POSTFIX;
static {
beforeMatchingNameRegex(ADD_P, "AddP");
}

public static final String ADD_VD = VECTOR_PREFIX + "ADD_VD" + POSTFIX;
static {
vectorNode(ADD_VD, "AddVD", TYPE_DOUBLE);
Expand Down
48 changes: 48 additions & 0 deletions test/hotspot/jtreg/compiler/vectorization/TestReplicateAtConv.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2024, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8341834
* @summary C2 compilation fails with "bad AD file" due to Replicate
* @run main/othervm -XX:CompileCommand=compileonly,TestReplicateAtConv::test -Xcomp TestReplicateAtConv
*/

public class TestReplicateAtConv {
public static long val = 0;

public static void test() {
int array[] = new int[500];

for (int i = 0; i < 100; i++) {
for (long l = 100; l > i; l--) {
val = 42 + (l + i);
array[(int)l] = (int)l - (int)val;
}
}
}

public static void main(String[] args) {
test();
}
}
Loading

0 comments on commit 5f05133

Please sign in to comment.