Skip to content

Commit

Permalink
Merge master HEAD into openj9-staging
Browse files Browse the repository at this point in the history
Signed-off-by: J9 Build <[email protected]>
  • Loading branch information
j9build committed Nov 9, 2024
2 parents 75d3ec9 + 01931d7 commit ea28fd6
Show file tree
Hide file tree
Showing 86 changed files with 1,974 additions and 685 deletions.
20 changes: 17 additions & 3 deletions make/Images.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,16 @@ CDS_DUMP_FLAGS = -Xmx128M -Xms128M
# Helper function for creating the CDS archives for the JDK and JRE
#
# Param1 - VM variant (e.g., server, client, zero, ...)
# Param2 - _nocoops, or empty
# Param2 - _nocoops, _coh, _nocoops_coh, or empty
define CreateCDSArchive
$1_$2_DUMP_EXTRA_ARG := $(if $(filter _nocoops, $2), -XX:-UseCompressedOops, )
$1_$2_DUMP_TYPE := $(if $(filter _nocoops, $2), -NOCOOPS, )
$1_$2_COOPS_OPTION := $(if $(findstring _nocoops, $2),-XX:-UseCompressedOops)
# enable and also explicitly disable coh as needed.
ifeq ($(call isTargetCpuBits, 64), true)
$1_$2_COH_OPTION := -XX:+UnlockExperimentalVMOptions \
$(if $(findstring _coh, $2),-XX:+UseCompactObjectHeaders,-XX:-UseCompactObjectHeaders)
endif
$1_$2_DUMP_EXTRA_ARG := $$($1_$2_COOPS_OPTION) $$($1_$2_COH_OPTION)
$1_$2_DUMP_TYPE := $(if $(findstring _nocoops, $2),-NOCOOPS,)$(if $(findstring _coh, $2),-COH,)

# Only G1 supports dumping the shared heap, so explicitly use G1 if the JVM supports it.
$1_$2_CDS_DUMP_FLAGS := $(CDS_DUMP_FLAGS) $(if $(filter g1gc, $(JVM_FEATURES_$1)), -XX:+UseG1GC)
Expand Down Expand Up @@ -190,6 +196,14 @@ ifeq ($(BUILD_CDS_ARCHIVE), true)
$(foreach v, $(JVM_VARIANTS), \
$(eval $(call CreateCDSArchive,$v,_nocoops)) \
)
ifeq ($(BUILD_CDS_ARCHIVE_COH), true)
$(foreach v, $(JVM_VARIANTS), \
$(eval $(call CreateCDSArchive,$v,_coh)) \
)
$(foreach v, $(JVM_VARIANTS), \
$(eval $(call CreateCDSArchive,$v,_nocoops_coh)) \
)
endif
endif
endif

Expand Down
1 change: 1 addition & 0 deletions make/autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST
JDKOPT_EXCLUDE_TRANSLATIONS
JDKOPT_ENABLE_DISABLE_MANPAGES
JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE
JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH
JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT
JDKOPT_SETUP_MACOSX_SIGNING

Expand Down
31 changes: 31 additions & 0 deletions make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,37 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE],
AC_SUBST(BUILD_CDS_ARCHIVE)
])

################################################################################
#
# Enable or disable the default CDS archive generation for Compact Object Headers
#
AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH],
[
UTIL_ARG_ENABLE(NAME: cds-archive-coh, DEFAULT: auto, RESULT: BUILD_CDS_ARCHIVE_COH,
DESC: [enable generation of default CDS archives for compact object headers (requires --enable-cds-archive)],
DEFAULT_DESC: [auto],
CHECKING_MSG: [if default CDS archives for compact object headers should be generated],
CHECK_AVAILABLE: [
AC_MSG_CHECKING([if CDS archive with compact object headers is available])
if test "x$BUILD_CDS_ARCHIVE" = "xfalse"; then
AC_MSG_RESULT([no (CDS default archive generation is disabled)])
AVAILABLE=false
elif test "x$OPENJDK_TARGET_CPU" != "xx86_64" &&
test "x$OPENJDK_TARGET_CPU" != "xaarch64" &&
test "x$OPENJDK_TARGET_CPU" != "xppc64" &&
test "x$OPENJDK_TARGET_CPU" != "xppc64le" &&
test "x$OPENJDK_TARGET_CPU" != "xriscv64" &&
test "x$OPENJDK_TARGET_CPU" != "xs390x"; then
AC_MSG_RESULT([no (compact object headers not supported for this platform)])
AVAILABLE=false
else
AC_MSG_RESULT([yes])
AVAILABLE=true
fi
])
AC_SUBST(BUILD_CDS_ARCHIVE_COH)
])

################################################################################
#
# Enable the alternative CDS core region alignment
Expand Down
1 change: 1 addition & 0 deletions make/autoconf/spec.gmk.template
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ EXCLUDE_TRANSLATIONS := @EXCLUDE_TRANSLATIONS@
BUILD_MANPAGES := @BUILD_MANPAGES@

BUILD_CDS_ARCHIVE := @BUILD_CDS_ARCHIVE@
BUILD_CDS_ARCHIVE_COH := @BUILD_CDS_ARCHIVE_COH@

ENABLE_COMPATIBLE_CDS_ALIGNMENT := @ENABLE_COMPATIBLE_CDS_ALIGNMENT@

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/include/jvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ JVM_FindPrimitiveClass(JNIEnv *env, const char *utf);


/*
* Find a class from a boot class loader. Returns NULL if class not found.
* Find a class from a boot class loader. Returns null if class not found.
*/
JNIEXPORT jclass JNICALL
JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
Expand Down
14 changes: 2 additions & 12 deletions src/java.base/macosx/native/libjli/java_md_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ static void MacOSXStartup(int argc, char *argv[]) {
{
char libjava[MAXPATHLEN];

JLI_TraceLauncher("Attempt to get JDK installation root from launcher executable path\n");

if (GetApplicationHome(path, pathsize)) {
/* Is the JDK co-located with the application? */
if (JLI_IsStaticallyLinked()) {
Expand All @@ -429,18 +431,6 @@ static void MacOSXStartup(int argc, char *argv[]) {
return JNI_TRUE;
}
}
/* ensure storage for path + /jre + NULL */
if ((JLI_StrLen(path) + 4 + 1) > (size_t) pathsize) {
JLI_TraceLauncher("Insufficient space to store JRE path\n");
return JNI_FALSE;
}
/* Does the app ship a private JRE in <apphome>/jre directory? */
JLI_Snprintf(libjava, sizeof(libjava), "%s/jre/lib/" JAVA_DLL, path);
if (access(libjava, F_OK) == 0) {
JLI_StrCat(path, "/jre");
JLI_TraceLauncher("JRE path is %s\n", path);
return JNI_TRUE;
}
}

/* try to find ourselves instead */
Expand Down
3 changes: 3 additions & 0 deletions src/java.base/share/classes/sun/launcher/LauncherHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeSet;
import java.util.function.Function;
import java.util.jar.Attributes;
Expand Down Expand Up @@ -318,6 +319,8 @@ private static void printLocale(boolean verbose) {
Locale.getDefault(Category.DISPLAY).getDisplayName());
ostream.println(INDENT + "default format locale = " +
Locale.getDefault(Category.FORMAT).getDisplayName());
ostream.println(INDENT + "default timezone = " +
TimeZone.getDefault().getID());
ostream.println(INDENT + "tzdata version = " +
ZoneInfoFile.getVersion());
if (verbose) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void removeNotificationListener(ObjectName name,
} catch (Exception e) {
// Give back the first exception
//
if (re != null) {
if (re == null) {
re = e;
}
}
Expand Down
58 changes: 35 additions & 23 deletions src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -1672,39 +1672,51 @@ public boolean isCastable(Type t, Type s, Warner warn) {
// where
class DisjointChecker {
Set<Pair<ClassSymbol, ClassSymbol>> pairsSeen = new HashSet<>();
/* there are three cases for ts and ss:
* - one is a class and the other one is an interface (case I)
* - both are classes (case II)
* - both are interfaces (case III)
* all those cases are covered in JLS 23, section: "5.1.6.1 Allowed Narrowing Reference Conversion"
*/
private boolean areDisjoint(ClassSymbol ts, ClassSymbol ss) {
Pair<ClassSymbol, ClassSymbol> newPair = new Pair<>(ts, ss);
/* if we are seeing the same pair again then there is an issue with the sealed hierarchy
* bail out, a detailed error will be reported downstream
*/
if (!pairsSeen.add(newPair))
return false;
if (isSubtype(erasure(ts.type), erasure(ss.type))) {
return false;
}
// if both are classes or both are interfaces, shortcut
if (ts.isInterface() == ss.isInterface() && isSubtype(erasure(ss.type), erasure(ts.type))) {
return false;
}
if (ts.isInterface() && !ss.isInterface()) {
/* so ts is interface but ss is a class
* an interface is disjoint from a class if the class is disjoint form the interface
*/
return areDisjoint(ss, ts);
}
// a final class that is not subtype of ss is disjoint
if (!ts.isInterface() && ts.isFinal()) {
return true;
}
// if at least one is sealed
if (ts.isSealed() || ss.isSealed()) {
// permitted subtypes have to be disjoint with the other symbol
ClassSymbol sealedOne = ts.isSealed() ? ts : ss;
ClassSymbol other = sealedOne == ts ? ss : ts;
return sealedOne.getPermittedSubclasses().stream().allMatch(type -> areDisjoint((ClassSymbol)type.tsym, other));

if (ts.isInterface() != ss.isInterface()) { // case I: one is a class and the other one is an interface
ClassSymbol isym = ts.isInterface() ? ts : ss; // isym is the interface and csym the class
ClassSymbol csym = isym == ts ? ss : ts;
if (!isSubtype(erasure(csym.type), erasure(isym.type))) {
if (csym.isFinal()) {
return true;
} else if (csym.isSealed()) {
return areDisjoint(isym, csym.getPermittedSubclasses());
} else if (isym.isSealed()) {
// if the class is not final and not sealed then it has to be freely extensible
return areDisjoint(csym, isym.getPermittedSubclasses());
}
} // now both are classes or both are interfaces
} else if (!ts.isInterface()) { // case II: both are classes
return !isSubtype(erasure(ss.type), erasure(ts.type)) && !isSubtype(erasure(ts.type), erasure(ss.type));
} else { // case III: both are interfaces
if (!isSubtype(erasure(ts.type), erasure(ss.type)) && !isSubtype(erasure(ss.type), erasure(ts.type))) {
if (ts.isSealed()) {
return areDisjoint(ss, ts.getPermittedSubclasses());
} else if (ss.isSealed()) {
return areDisjoint(ts, ss.getPermittedSubclasses());
}
}
}
// at this point we haven't been able to statically prove that the classes or interfaces are disjoint
return false;
}

boolean areDisjoint(ClassSymbol csym, List<Type> permittedSubtypes) {
return permittedSubtypes.stream().allMatch(psubtype -> areDisjoint(csym, (ClassSymbol) psubtype.tsym));
}
}

private TypeRelation isCastable = new TypeRelation() {
Expand Down
69 changes: 29 additions & 40 deletions test/hotspot/gtest/gc/shared/test_preservedMarks.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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 All @@ -23,66 +23,55 @@

#include "precompiled.hpp"
#include "gc/shared/preservedMarks.inline.hpp"
#include "gc/shared/fullGCForwarding.inline.hpp"
#include "oops/oop.inline.hpp"
#include "unittest.hpp"

// Class to create a "fake" oop with a mark that will
// return true for calls to must_be_preserved().
class FakeOop {
oopDesc _oop;

public:
FakeOop() : _oop() { _oop.set_mark(originalMark()); }

oop get_oop() { return &_oop; }
markWord mark() { return _oop.mark(); }
void set_mark(markWord m) { _oop.set_mark(m); }
void forward_to(oop obj) {
markWord m = markWord::encode_pointer_as_mark(obj);
_oop.set_mark(m);
}

static markWord originalMark() { return markWord(markWord::lock_mask_in_place); }
static markWord changedMark() { return markWord(0x4711); }
};
static markWord originalMark() { return markWord(markWord::lock_mask_in_place); }
static markWord changedMark() { return markWord(0x4711); }

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

TEST_VM(PreservedMarks, iterate_and_restore) {
PreservedMarks pm;
FakeOop o1;
FakeOop o2;
FakeOop o3;
FakeOop o4;

HeapWord fakeheap[32] = { nullptr };
HeapWord* heap = align_up(fakeheap, 8 * sizeof(HeapWord));
FullGCForwarding::initialize(MemRegion(&heap[0], &heap[16]));

oop o1 = cast_to_oop(&heap[0]); o1->set_mark(originalMark());
oop o2 = cast_to_oop(&heap[2]); o2->set_mark(originalMark());
oop o3 = cast_to_oop(&heap[4]); o3->set_mark(originalMark());
oop o4 = cast_to_oop(&heap[6]); o4->set_mark(originalMark());

// Make sure initial marks are correct.
ASSERT_MARK_WORD_EQ(o1.mark(), FakeOop::originalMark());
ASSERT_MARK_WORD_EQ(o2.mark(), FakeOop::originalMark());
ASSERT_MARK_WORD_EQ(o3.mark(), FakeOop::originalMark());
ASSERT_MARK_WORD_EQ(o4.mark(), FakeOop::originalMark());
ASSERT_MARK_WORD_EQ(o1->mark(), originalMark());
ASSERT_MARK_WORD_EQ(o2->mark(), originalMark());
ASSERT_MARK_WORD_EQ(o3->mark(), originalMark());
ASSERT_MARK_WORD_EQ(o4->mark(), originalMark());

// Change the marks and verify change.
o1.set_mark(FakeOop::changedMark());
o2.set_mark(FakeOop::changedMark());
ASSERT_MARK_WORD_EQ(o1.mark(), FakeOop::changedMark());
ASSERT_MARK_WORD_EQ(o2.mark(), FakeOop::changedMark());
o1->set_mark(changedMark());
o2->set_mark(changedMark());
ASSERT_MARK_WORD_EQ(o1->mark(), changedMark());
ASSERT_MARK_WORD_EQ(o2->mark(), changedMark());

// Push o1 and o2 to have their marks preserved.
pm.push_if_necessary(o1.get_oop(), o1.mark());
pm.push_if_necessary(o2.get_oop(), o2.mark());
pm.push_if_necessary(o1, o1->mark());
pm.push_if_necessary(o2, o2->mark());

// Fake a move from o1->o3 and o2->o4.
o1.forward_to(o3.get_oop());
o2.forward_to(o4.get_oop());
ASSERT_EQ(o1.get_oop()->forwardee(), o3.get_oop());
ASSERT_EQ(o2.get_oop()->forwardee(), o4.get_oop());
FullGCForwarding::forward_to(o1, o3);
FullGCForwarding::forward_to(o2, o4);
ASSERT_EQ(FullGCForwarding::forwardee(o1), o3);
ASSERT_EQ(FullGCForwarding::forwardee(o2), o4);
// Adjust will update the PreservedMarks stack to
// make sure the mark is updated at the new location.
pm.adjust_during_full_gc();

// Restore all preserved and verify that the changed
// mark is now present at o3 and o4.
pm.restore();
ASSERT_MARK_WORD_EQ(o3.mark(), FakeOop::changedMark());
ASSERT_MARK_WORD_EQ(o4.mark(), FakeOop::changedMark());
ASSERT_MARK_WORD_EQ(o3->mark(), changedMark());
ASSERT_MARK_WORD_EQ(o4->mark(), changedMark());
}
8 changes: 6 additions & 2 deletions test/hotspot/gtest/metaspace/metaspaceGtestContexts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ using metaspace::chunklevel_t;
using namespace metaspace::chunklevel;

class MetaspaceGtestContext : public metaspace::MetaspaceTestContext {
int _num_arenas_created;
public:
MetaspaceGtestContext(size_t commit_limit = 0, size_t reserve_limit = 0) :
metaspace::MetaspaceTestContext("gtest-metaspace-context", commit_limit, reserve_limit)
{}
metaspace::MetaspaceTestContext("gtest-metaspace-context", commit_limit, reserve_limit),
_num_arenas_created(0) {}

int num_arenas_created() const { return _num_arenas_created; }
void inc_num_arenas_created() { _num_arenas_created ++; }
};

class ChunkGtestContext : public MetaspaceGtestContext {
Expand Down
Loading

0 comments on commit ea28fd6

Please sign in to comment.