Skip to content

Commit ea28fd6

Browse files
committed
Merge master HEAD into openj9-staging
Signed-off-by: J9 Build <[email protected]>
2 parents 75d3ec9 + 01931d7 commit ea28fd6

File tree

86 files changed

+1974
-685
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1974
-685
lines changed

make/Images.gmk

+17-3
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,16 @@ CDS_DUMP_FLAGS = -Xmx128M -Xms128M
132132
# Helper function for creating the CDS archives for the JDK and JRE
133133
#
134134
# Param1 - VM variant (e.g., server, client, zero, ...)
135-
# Param2 - _nocoops, or empty
135+
# Param2 - _nocoops, _coh, _nocoops_coh, or empty
136136
define CreateCDSArchive
137-
$1_$2_DUMP_EXTRA_ARG := $(if $(filter _nocoops, $2), -XX:-UseCompressedOops, )
138-
$1_$2_DUMP_TYPE := $(if $(filter _nocoops, $2), -NOCOOPS, )
137+
$1_$2_COOPS_OPTION := $(if $(findstring _nocoops, $2),-XX:-UseCompressedOops)
138+
# enable and also explicitly disable coh as needed.
139+
ifeq ($(call isTargetCpuBits, 64), true)
140+
$1_$2_COH_OPTION := -XX:+UnlockExperimentalVMOptions \
141+
$(if $(findstring _coh, $2),-XX:+UseCompactObjectHeaders,-XX:-UseCompactObjectHeaders)
142+
endif
143+
$1_$2_DUMP_EXTRA_ARG := $$($1_$2_COOPS_OPTION) $$($1_$2_COH_OPTION)
144+
$1_$2_DUMP_TYPE := $(if $(findstring _nocoops, $2),-NOCOOPS,)$(if $(findstring _coh, $2),-COH,)
139145

140146
# Only G1 supports dumping the shared heap, so explicitly use G1 if the JVM supports it.
141147
$1_$2_CDS_DUMP_FLAGS := $(CDS_DUMP_FLAGS) $(if $(filter g1gc, $(JVM_FEATURES_$1)), -XX:+UseG1GC)
@@ -190,6 +196,14 @@ ifeq ($(BUILD_CDS_ARCHIVE), true)
190196
$(foreach v, $(JVM_VARIANTS), \
191197
$(eval $(call CreateCDSArchive,$v,_nocoops)) \
192198
)
199+
ifeq ($(BUILD_CDS_ARCHIVE_COH), true)
200+
$(foreach v, $(JVM_VARIANTS), \
201+
$(eval $(call CreateCDSArchive,$v,_coh)) \
202+
)
203+
$(foreach v, $(JVM_VARIANTS), \
204+
$(eval $(call CreateCDSArchive,$v,_nocoops_coh)) \
205+
)
206+
endif
193207
endif
194208
endif
195209

make/autoconf/configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST
261261
JDKOPT_EXCLUDE_TRANSLATIONS
262262
JDKOPT_ENABLE_DISABLE_MANPAGES
263263
JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE
264+
JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH
264265
JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT
265266
JDKOPT_SETUP_MACOSX_SIGNING
266267

make/autoconf/jdk-options.m4

+31
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,37 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE],
666666
AC_SUBST(BUILD_CDS_ARCHIVE)
667667
])
668668

669+
################################################################################
670+
#
671+
# Enable or disable the default CDS archive generation for Compact Object Headers
672+
#
673+
AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH],
674+
[
675+
UTIL_ARG_ENABLE(NAME: cds-archive-coh, DEFAULT: auto, RESULT: BUILD_CDS_ARCHIVE_COH,
676+
DESC: [enable generation of default CDS archives for compact object headers (requires --enable-cds-archive)],
677+
DEFAULT_DESC: [auto],
678+
CHECKING_MSG: [if default CDS archives for compact object headers should be generated],
679+
CHECK_AVAILABLE: [
680+
AC_MSG_CHECKING([if CDS archive with compact object headers is available])
681+
if test "x$BUILD_CDS_ARCHIVE" = "xfalse"; then
682+
AC_MSG_RESULT([no (CDS default archive generation is disabled)])
683+
AVAILABLE=false
684+
elif test "x$OPENJDK_TARGET_CPU" != "xx86_64" &&
685+
test "x$OPENJDK_TARGET_CPU" != "xaarch64" &&
686+
test "x$OPENJDK_TARGET_CPU" != "xppc64" &&
687+
test "x$OPENJDK_TARGET_CPU" != "xppc64le" &&
688+
test "x$OPENJDK_TARGET_CPU" != "xriscv64" &&
689+
test "x$OPENJDK_TARGET_CPU" != "xs390x"; then
690+
AC_MSG_RESULT([no (compact object headers not supported for this platform)])
691+
AVAILABLE=false
692+
else
693+
AC_MSG_RESULT([yes])
694+
AVAILABLE=true
695+
fi
696+
])
697+
AC_SUBST(BUILD_CDS_ARCHIVE_COH)
698+
])
699+
669700
################################################################################
670701
#
671702
# Enable the alternative CDS core region alignment

make/autoconf/spec.gmk.template

+1
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ EXCLUDE_TRANSLATIONS := @EXCLUDE_TRANSLATIONS@
370370
BUILD_MANPAGES := @BUILD_MANPAGES@
371371

372372
BUILD_CDS_ARCHIVE := @BUILD_CDS_ARCHIVE@
373+
BUILD_CDS_ARCHIVE_COH := @BUILD_CDS_ARCHIVE_COH@
373374

374375
ENABLE_COMPATIBLE_CDS_ALIGNMENT := @ENABLE_COMPATIBLE_CDS_ALIGNMENT@
375376

src/hotspot/share/include/jvm.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);
419419

420420

421421
/*
422-
* Find a class from a boot class loader. Returns NULL if class not found.
422+
* Find a class from a boot class loader. Returns null if class not found.
423423
*/
424424
JNIEXPORT jclass JNICALL
425425
JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);

src/java.base/macosx/native/libjli/java_md_macosx.m

+2-12
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ static void MacOSXStartup(int argc, char *argv[]) {
415415
{
416416
char libjava[MAXPATHLEN];
417417

418+
JLI_TraceLauncher("Attempt to get JDK installation root from launcher executable path\n");
419+
418420
if (GetApplicationHome(path, pathsize)) {
419421
/* Is the JDK co-located with the application? */
420422
if (JLI_IsStaticallyLinked()) {
@@ -429,18 +431,6 @@ static void MacOSXStartup(int argc, char *argv[]) {
429431
return JNI_TRUE;
430432
}
431433
}
432-
/* ensure storage for path + /jre + NULL */
433-
if ((JLI_StrLen(path) + 4 + 1) > (size_t) pathsize) {
434-
JLI_TraceLauncher("Insufficient space to store JRE path\n");
435-
return JNI_FALSE;
436-
}
437-
/* Does the app ship a private JRE in <apphome>/jre directory? */
438-
JLI_Snprintf(libjava, sizeof(libjava), "%s/jre/lib/" JAVA_DLL, path);
439-
if (access(libjava, F_OK) == 0) {
440-
JLI_StrCat(path, "/jre");
441-
JLI_TraceLauncher("JRE path is %s\n", path);
442-
return JNI_TRUE;
443-
}
444434
}
445435

446436
/* try to find ourselves instead */

src/java.base/share/classes/sun/launcher/LauncherHelper.java

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import java.util.Properties;
6464
import java.util.ResourceBundle;
6565
import java.util.Set;
66+
import java.util.TimeZone;
6667
import java.util.TreeSet;
6768
import java.util.function.Function;
6869
import java.util.jar.Attributes;
@@ -318,6 +319,8 @@ private static void printLocale(boolean verbose) {
318319
Locale.getDefault(Category.DISPLAY).getDisplayName());
319320
ostream.println(INDENT + "default format locale = " +
320321
Locale.getDefault(Category.FORMAT).getDisplayName());
322+
ostream.println(INDENT + "default timezone = " +
323+
TimeZone.getDefault().getID());
321324
ostream.println(INDENT + "tzdata version = " +
322325
ZoneInfoFile.getVersion());
323326
if (verbose) {

src/java.management/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public void removeNotificationListener(ObjectName name,
169169
} catch (Exception e) {
170170
// Give back the first exception
171171
//
172-
if (re != null) {
172+
if (re == null) {
173173
re = e;
174174
}
175175
}

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java

+35-23
Original file line numberDiff line numberDiff line change
@@ -1672,39 +1672,51 @@ public boolean isCastable(Type t, Type s, Warner warn) {
16721672
// where
16731673
class DisjointChecker {
16741674
Set<Pair<ClassSymbol, ClassSymbol>> pairsSeen = new HashSet<>();
1675+
/* there are three cases for ts and ss:
1676+
* - one is a class and the other one is an interface (case I)
1677+
* - both are classes (case II)
1678+
* - both are interfaces (case III)
1679+
* all those cases are covered in JLS 23, section: "5.1.6.1 Allowed Narrowing Reference Conversion"
1680+
*/
16751681
private boolean areDisjoint(ClassSymbol ts, ClassSymbol ss) {
16761682
Pair<ClassSymbol, ClassSymbol> newPair = new Pair<>(ts, ss);
16771683
/* if we are seeing the same pair again then there is an issue with the sealed hierarchy
16781684
* bail out, a detailed error will be reported downstream
16791685
*/
16801686
if (!pairsSeen.add(newPair))
16811687
return false;
1682-
if (isSubtype(erasure(ts.type), erasure(ss.type))) {
1683-
return false;
1684-
}
1685-
// if both are classes or both are interfaces, shortcut
1686-
if (ts.isInterface() == ss.isInterface() && isSubtype(erasure(ss.type), erasure(ts.type))) {
1687-
return false;
1688-
}
1689-
if (ts.isInterface() && !ss.isInterface()) {
1690-
/* so ts is interface but ss is a class
1691-
* an interface is disjoint from a class if the class is disjoint form the interface
1692-
*/
1693-
return areDisjoint(ss, ts);
1694-
}
1695-
// a final class that is not subtype of ss is disjoint
1696-
if (!ts.isInterface() && ts.isFinal()) {
1697-
return true;
1698-
}
1699-
// if at least one is sealed
1700-
if (ts.isSealed() || ss.isSealed()) {
1701-
// permitted subtypes have to be disjoint with the other symbol
1702-
ClassSymbol sealedOne = ts.isSealed() ? ts : ss;
1703-
ClassSymbol other = sealedOne == ts ? ss : ts;
1704-
return sealedOne.getPermittedSubclasses().stream().allMatch(type -> areDisjoint((ClassSymbol)type.tsym, other));
1688+
1689+
if (ts.isInterface() != ss.isInterface()) { // case I: one is a class and the other one is an interface
1690+
ClassSymbol isym = ts.isInterface() ? ts : ss; // isym is the interface and csym the class
1691+
ClassSymbol csym = isym == ts ? ss : ts;
1692+
if (!isSubtype(erasure(csym.type), erasure(isym.type))) {
1693+
if (csym.isFinal()) {
1694+
return true;
1695+
} else if (csym.isSealed()) {
1696+
return areDisjoint(isym, csym.getPermittedSubclasses());
1697+
} else if (isym.isSealed()) {
1698+
// if the class is not final and not sealed then it has to be freely extensible
1699+
return areDisjoint(csym, isym.getPermittedSubclasses());
1700+
}
1701+
} // now both are classes or both are interfaces
1702+
} else if (!ts.isInterface()) { // case II: both are classes
1703+
return !isSubtype(erasure(ss.type), erasure(ts.type)) && !isSubtype(erasure(ts.type), erasure(ss.type));
1704+
} else { // case III: both are interfaces
1705+
if (!isSubtype(erasure(ts.type), erasure(ss.type)) && !isSubtype(erasure(ss.type), erasure(ts.type))) {
1706+
if (ts.isSealed()) {
1707+
return areDisjoint(ss, ts.getPermittedSubclasses());
1708+
} else if (ss.isSealed()) {
1709+
return areDisjoint(ts, ss.getPermittedSubclasses());
1710+
}
1711+
}
17051712
}
1713+
// at this point we haven't been able to statically prove that the classes or interfaces are disjoint
17061714
return false;
17071715
}
1716+
1717+
boolean areDisjoint(ClassSymbol csym, List<Type> permittedSubtypes) {
1718+
return permittedSubtypes.stream().allMatch(psubtype -> areDisjoint(csym, (ClassSymbol) psubtype.tsym));
1719+
}
17081720
}
17091721

17101722
private TypeRelation isCastable = new TypeRelation() {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 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
@@ -23,66 +23,55 @@
2323

2424
#include "precompiled.hpp"
2525
#include "gc/shared/preservedMarks.inline.hpp"
26+
#include "gc/shared/fullGCForwarding.inline.hpp"
2627
#include "oops/oop.inline.hpp"
2728
#include "unittest.hpp"
2829

29-
// Class to create a "fake" oop with a mark that will
30-
// return true for calls to must_be_preserved().
31-
class FakeOop {
32-
oopDesc _oop;
33-
34-
public:
35-
FakeOop() : _oop() { _oop.set_mark(originalMark()); }
36-
37-
oop get_oop() { return &_oop; }
38-
markWord mark() { return _oop.mark(); }
39-
void set_mark(markWord m) { _oop.set_mark(m); }
40-
void forward_to(oop obj) {
41-
markWord m = markWord::encode_pointer_as_mark(obj);
42-
_oop.set_mark(m);
43-
}
44-
45-
static markWord originalMark() { return markWord(markWord::lock_mask_in_place); }
46-
static markWord changedMark() { return markWord(0x4711); }
47-
};
30+
static markWord originalMark() { return markWord(markWord::lock_mask_in_place); }
31+
static markWord changedMark() { return markWord(0x4711); }
4832

4933
#define ASSERT_MARK_WORD_EQ(a, b) ASSERT_EQ((a).value(), (b).value())
5034

5135
TEST_VM(PreservedMarks, iterate_and_restore) {
5236
PreservedMarks pm;
53-
FakeOop o1;
54-
FakeOop o2;
55-
FakeOop o3;
56-
FakeOop o4;
37+
38+
HeapWord fakeheap[32] = { nullptr };
39+
HeapWord* heap = align_up(fakeheap, 8 * sizeof(HeapWord));
40+
FullGCForwarding::initialize(MemRegion(&heap[0], &heap[16]));
41+
42+
oop o1 = cast_to_oop(&heap[0]); o1->set_mark(originalMark());
43+
oop o2 = cast_to_oop(&heap[2]); o2->set_mark(originalMark());
44+
oop o3 = cast_to_oop(&heap[4]); o3->set_mark(originalMark());
45+
oop o4 = cast_to_oop(&heap[6]); o4->set_mark(originalMark());
5746

5847
// Make sure initial marks are correct.
59-
ASSERT_MARK_WORD_EQ(o1.mark(), FakeOop::originalMark());
60-
ASSERT_MARK_WORD_EQ(o2.mark(), FakeOop::originalMark());
61-
ASSERT_MARK_WORD_EQ(o3.mark(), FakeOop::originalMark());
62-
ASSERT_MARK_WORD_EQ(o4.mark(), FakeOop::originalMark());
48+
ASSERT_MARK_WORD_EQ(o1->mark(), originalMark());
49+
ASSERT_MARK_WORD_EQ(o2->mark(), originalMark());
50+
ASSERT_MARK_WORD_EQ(o3->mark(), originalMark());
51+
ASSERT_MARK_WORD_EQ(o4->mark(), originalMark());
6352

6453
// Change the marks and verify change.
65-
o1.set_mark(FakeOop::changedMark());
66-
o2.set_mark(FakeOop::changedMark());
67-
ASSERT_MARK_WORD_EQ(o1.mark(), FakeOop::changedMark());
68-
ASSERT_MARK_WORD_EQ(o2.mark(), FakeOop::changedMark());
54+
o1->set_mark(changedMark());
55+
o2->set_mark(changedMark());
56+
ASSERT_MARK_WORD_EQ(o1->mark(), changedMark());
57+
ASSERT_MARK_WORD_EQ(o2->mark(), changedMark());
6958

7059
// Push o1 and o2 to have their marks preserved.
71-
pm.push_if_necessary(o1.get_oop(), o1.mark());
72-
pm.push_if_necessary(o2.get_oop(), o2.mark());
60+
pm.push_if_necessary(o1, o1->mark());
61+
pm.push_if_necessary(o2, o2->mark());
7362

7463
// Fake a move from o1->o3 and o2->o4.
75-
o1.forward_to(o3.get_oop());
76-
o2.forward_to(o4.get_oop());
77-
ASSERT_EQ(o1.get_oop()->forwardee(), o3.get_oop());
78-
ASSERT_EQ(o2.get_oop()->forwardee(), o4.get_oop());
64+
FullGCForwarding::forward_to(o1, o3);
65+
FullGCForwarding::forward_to(o2, o4);
66+
ASSERT_EQ(FullGCForwarding::forwardee(o1), o3);
67+
ASSERT_EQ(FullGCForwarding::forwardee(o2), o4);
7968
// Adjust will update the PreservedMarks stack to
8069
// make sure the mark is updated at the new location.
8170
pm.adjust_during_full_gc();
8271

8372
// Restore all preserved and verify that the changed
8473
// mark is now present at o3 and o4.
8574
pm.restore();
86-
ASSERT_MARK_WORD_EQ(o3.mark(), FakeOop::changedMark());
87-
ASSERT_MARK_WORD_EQ(o4.mark(), FakeOop::changedMark());
75+
ASSERT_MARK_WORD_EQ(o3->mark(), changedMark());
76+
ASSERT_MARK_WORD_EQ(o4->mark(), changedMark());
8877
}

test/hotspot/gtest/metaspace/metaspaceGtestContexts.hpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ using metaspace::chunklevel_t;
3737
using namespace metaspace::chunklevel;
3838

3939
class MetaspaceGtestContext : public metaspace::MetaspaceTestContext {
40+
int _num_arenas_created;
4041
public:
4142
MetaspaceGtestContext(size_t commit_limit = 0, size_t reserve_limit = 0) :
42-
metaspace::MetaspaceTestContext("gtest-metaspace-context", commit_limit, reserve_limit)
43-
{}
43+
metaspace::MetaspaceTestContext("gtest-metaspace-context", commit_limit, reserve_limit),
44+
_num_arenas_created(0) {}
45+
46+
int num_arenas_created() const { return _num_arenas_created; }
47+
void inc_num_arenas_created() { _num_arenas_created ++; }
4448
};
4549

4650
class ChunkGtestContext : public MetaspaceGtestContext {

0 commit comments

Comments
 (0)