Skip to content

Commit

Permalink
Merge branch 'upstream-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Datadog Syncup Service committed Nov 3, 2023
2 parents a9e649a + 1a21c1a commit 81faeb2
Show file tree
Hide file tree
Showing 141 changed files with 4,339 additions and 4,512 deletions.
23 changes: 16 additions & 7 deletions doc/testing.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,22 @@ <h3 id="common-test-groups">Common Test Groups</h3>
tier1.</p>
<p>A brief description of the tiered test groups:</p>
<ul>
<li><p><code>tier1</code>: This is the lowest test tier. Multiple
developers run these tests every day. Because of the widespread use, the
tests in <code>tier1</code> are carefully selected and optimized to run
fast, and to run in the most stable manner. The test failures in
<code>tier1</code> are usually followed up on quickly, either with
fixes, or adding relevant tests to problem list. GitHub Actions
workflows, if enabled, run <code>tier1</code> tests.</p></li>
<li><p><code>tier1</code>: This is the most fundamental test tier.
Roughly speaking, a failure of a test in this tier has the potential to
indicate a problem that would affect many Java programs. Tests in
<code>tier1</code> include tests of HotSpot, core APIs in the
<code>java.base</code> module, and the <code>javac</code> compiler.
Multiple developers run these tests every day. Because of the widespread
use, the tests in <code>tier1</code> are carefully selected and
optimized to run fast, and to run in the most stable manner. As a
guideline, nearly all individual tests in <code>tier1</code> are
expected to run to completion in ten seconds or less when run on common
configurations used for development. Long-running tests, even of core
functionality, should occur in higher tiers or be covered in other kinds
of testing. The test failures in <code>tier1</code> are usually followed
up on quickly, either with fixes, or adding relevant tests to problem
list. GitHub Actions workflows, if enabled, run <code>tier1</code>
tests.</p></li>
<li><p><code>tier2</code>: This test group covers even more ground.
These contain, among other things, tests that either run for too long to
be at <code>tier1</code>, or may require special configuration, or tests
Expand Down
21 changes: 15 additions & 6 deletions doc/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,21 @@ the first N tiers they can afford to run, but at least tier1.

A brief description of the tiered test groups:

- `tier1`: This is the lowest test tier. Multiple developers run these tests
every day. Because of the widespread use, the tests in `tier1` are
carefully selected and optimized to run fast, and to run in the most stable
manner. The test failures in `tier1` are usually followed up on quickly,
either with fixes, or adding relevant tests to problem list. GitHub Actions
workflows, if enabled, run `tier1` tests.
- `tier1`: This is the most fundamental test tier.
Roughly speaking, a failure of a test in this tier has the potential
to indicate a problem that would affect many Java programs. Tests in
`tier1` include tests of HotSpot, core APIs in the `java.base`
module, and the `javac` compiler. Multiple developers run these
tests every day. Because of the widespread use, the tests in `tier1`
are carefully selected and optimized to run fast, and to run in the
most stable manner. As a guideline, nearly all individual tests in
`tier1` are expected to run to completion in ten seconds or less
when run on common configurations used for development. Long-running
tests, even of core functionality, should occur in higher tiers or
be covered in other kinds of testing. The test failures in `tier1`
are usually followed up on quickly, either with fixes, or adding
relevant tests to problem list. GitHub Actions workflows, if
enabled, run `tier1` tests.

- `tier2`: This test group covers even more ground. These contain, among other
things, tests that either run for too long to be at `tier1`, or may require
Expand Down
4 changes: 3 additions & 1 deletion make/modules/java.desktop/lib/Awt2dLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ else
unused-result array-bounds parentheses
# noexcept-type required for GCC 7 builds. Not required for GCC 8+.
# expansion-to-defined required for GCC 9 builds. Not required for GCC 10+.
HARFBUZZ_DISABLED_WARNINGS_CXX_gcc := class-memaccess noexcept-type expansion-to-defined dangling-reference
# maybe-uninitialized required for GCC 8 builds. Not required for GCC 9+.
HARFBUZZ_DISABLED_WARNINGS_CXX_gcc := class-memaccess noexcept-type \
expansion-to-defined dangling-reference maybe-uninitialized
HARFBUZZ_DISABLED_WARNINGS_clang := missing-field-initializers range-loop-analysis
HARFBUZZ_DISABLED_WARNINGS_microsoft := 4267 4244

Expand Down
7 changes: 7 additions & 0 deletions src/hotspot/share/cds/archiveBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ void ArchiveBuilder::verify_estimate_size(size_t estimate, const char* which) {
_other_region_used_bytes = 0;
}

char* ArchiveBuilder::ro_strdup(const char* s) {
char* archived_str = ro_region_alloc((int)strlen(s) + 1);
strcpy(archived_str, s);
return archived_str;
}

void ArchiveBuilder::dump_rw_metadata() {
ResourceMark rm;
log_info(cds)("Allocating RW objects ... ");
Expand Down Expand Up @@ -1133,6 +1139,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
// The address of _source_obj at runtime
oop requested_obj = ArchiveHeapWriter::source_obj_to_requested_obj(_source_obj);
// The address of this field in the requested space
assert(requested_obj != nullptr, "Attempting to load field from null oop");
address requested_field_addr = cast_from_oop<address>(requested_obj) + fd->offset();

fd->print_on(_st);
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/cds/archiveBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ class ArchiveBuilder : public StackObj {
return align_up(byte_size, SharedSpaceObjectAlignment);
}

char* ro_strdup(const char* s);

void dump_rw_metadata();
void dump_ro_metadata();
void relocate_metaspaceobj_embedded_pointers();
Expand Down
33 changes: 31 additions & 2 deletions src/hotspot/share/cds/heapShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ static ArchivableStaticFieldInfo archive_subgraph_entry_fields[] = {
// full module graph
static ArchivableStaticFieldInfo fmg_archive_subgraph_entry_fields[] = {
{"jdk/internal/loader/ArchivedClassLoaders", "archivedClassLoaders"},
{"jdk/internal/module/ArchivedBootLayer", "archivedBootLayer"},
{ARCHIVED_BOOT_LAYER_CLASS, ARCHIVED_BOOT_LAYER_FIELD},
{"java/lang/Module$ArchivedData", "archivedData"},
{nullptr, nullptr},
};
Expand Down Expand Up @@ -964,7 +964,14 @@ HeapShared::resolve_or_init_classes_for_subgraph_of(Klass* k, bool do_init, TRAP

// Initialize from archived data. Currently this is done only
// during VM initialization time. No lock is needed.
if (record != nullptr) {
if (record == nullptr) {
if (log_is_enabled(Info, cds, heap)) {
ResourceMark rm(THREAD);
log_info(cds, heap)("subgraph %s is not recorded",
k->external_name());
}
return nullptr;
} else {
if (record->is_full_module_graph() && !MetaspaceShared::use_full_module_graph()) {
if (log_is_enabled(Info, cds, heap)) {
ResourceMark rm(THREAD);
Expand Down Expand Up @@ -1751,4 +1758,26 @@ void HeapShared::print_stats() {
avg_size(_total_obj_size, _total_obj_count));
}

bool HeapShared::is_archived_boot_layer_available(JavaThread* current) {
TempNewSymbol klass_name = SymbolTable::new_symbol(ARCHIVED_BOOT_LAYER_CLASS);
InstanceKlass* k = SystemDictionary::find_instance_klass(current, klass_name, Handle(), Handle());
if (k == nullptr) {
return false;
} else {
TempNewSymbol field_name = SymbolTable::new_symbol(ARCHIVED_BOOT_LAYER_FIELD);
TempNewSymbol field_signature = SymbolTable::new_symbol("Ljdk/internal/module/ArchivedBootLayer;");
fieldDescriptor fd;
if (k->find_field(field_name, field_signature, true, &fd) != nullptr) {
oop m = k->java_mirror();
oop f = m->obj_field(fd.offset());
if (CompressedOops::is_null(f)) {
return false;
}
} else {
return false;
}
}
return true;
}

#endif // INCLUDE_CDS_JAVA_HEAP
4 changes: 4 additions & 0 deletions src/hotspot/share/cds/heapShared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class ResourceBitMap;
struct ArchivableStaticFieldInfo;
class ArchiveHeapInfo;

#define ARCHIVED_BOOT_LAYER_CLASS "jdk/internal/module/ArchivedBootLayer"
#define ARCHIVED_BOOT_LAYER_FIELD "archivedBootLayer"

// A dump time sub-graph info for Klass _k. It includes the entry points
// (static fields in _k's mirror) of the archived sub-graphs reachable
// from _k's mirror. It also contains a list of Klasses of the objects
Expand Down Expand Up @@ -160,6 +163,7 @@ class HeapShared: AllStatic {
// Scratch objects for archiving Klass::java_mirror()
static oop scratch_java_mirror(BasicType t) NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
static oop scratch_java_mirror(Klass* k) NOT_CDS_JAVA_HEAP_RETURN_(nullptr);
static bool is_archived_boot_layer_available(JavaThread* current) NOT_CDS_JAVA_HEAP_RETURN_(false);

private:
#if INCLUDE_CDS_JAVA_HEAP
Expand Down
15 changes: 11 additions & 4 deletions src/hotspot/share/cds/metaspaceShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "classfile/classLoaderExt.hpp"
#include "classfile/javaClasses.inline.hpp"
#include "classfile/loaderConstraints.hpp"
#include "classfile/modules.hpp"
#include "classfile/placeholders.hpp"
#include "classfile/stringTable.hpp"
#include "classfile/symbolTable.hpp"
Expand Down Expand Up @@ -387,6 +388,7 @@ void MetaspaceShared::serialize(SerializeClosure* soc) {
SystemDictionaryShared::serialize_vm_classes(soc);
soc->do_tag(--tag);

CDS_JAVA_HEAP_ONLY(Modules::serialize(soc);)
CDS_JAVA_HEAP_ONLY(ClassLoaderDataShared::serialize(soc);)

LambdaFormInvokers::serialize(soc);
Expand Down Expand Up @@ -479,6 +481,8 @@ char* VM_PopulateDumpSharedSpace::dump_read_only_tables() {

// Write lambform lines into archive
LambdaFormInvokers::dump_static_archive_invokers();
// Write module name into archive
CDS_JAVA_HEAP_ONLY(Modules::dump_main_module_name();)
// Write the other data to the output array.
DumpRegion* ro_region = ArchiveBuilder::current()->ro_region();
char* start = ro_region->top();
Expand Down Expand Up @@ -763,8 +767,6 @@ void MetaspaceShared::preload_and_dump_impl(TRAPS) {
log_info(cds)("Reading extra data: done.");
}

HeapShared::init_for_dumping(CHECK);

// Rewrite and link classes
log_info(cds)("Rewriting and linking classes ...");

Expand All @@ -778,6 +780,11 @@ void MetaspaceShared::preload_and_dump_impl(TRAPS) {
#if INCLUDE_CDS_JAVA_HEAP
if (CDSConfig::is_dumping_heap()) {
StringTable::allocate_shared_strings_array(CHECK);
if (!HeapShared::is_archived_boot_layer_available(THREAD)) {
log_info(cds)("archivedBootLayer not available, disabling full module graph");
disable_full_module_graph();
}
HeapShared::init_for_dumping(CHECK);
ArchiveHeapWriter::init();
if (use_full_module_graph()) {
HeapShared::reset_archived_object_states(CHECK);
Expand Down Expand Up @@ -1163,8 +1170,8 @@ MapArchiveResult MetaspaceShared::map_archives(FileMapInfo* static_mapinfo, File
static_mapinfo->map_or_load_heap_region();
}
#endif // _LP64
log_info(cds)("optimized module handling: %s", MetaspaceShared::use_optimized_module_handling() ? "enabled" : "disabled");
log_info(cds)("full module graph: %s", MetaspaceShared::use_full_module_graph() ? "enabled" : "disabled");
log_info(cds)("initial optimized module handling: %s", MetaspaceShared::use_optimized_module_handling() ? "enabled" : "disabled");
log_info(cds)("initial full module graph: %s", MetaspaceShared::use_full_module_graph() ? "enabled" : "disabled");
} else {
unmap_archive(static_mapinfo);
unmap_archive(dynamic_mapinfo);
Expand Down
44 changes: 44 additions & 0 deletions src/hotspot/share/classfile/modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

#include "precompiled.hpp"
#include "cds/archiveBuilder.hpp"
#include "cds/metaspaceShared.hpp"
#include "classfile/classFileParser.hpp"
#include "classfile/classLoader.hpp"
Expand Down Expand Up @@ -559,6 +560,49 @@ void Modules::verify_archived_modules() {
ModuleEntry::verify_archived_module_entries();
}

#if INCLUDE_CDS_JAVA_HEAP
char* Modules::_archived_main_module_name = nullptr;
#endif

void Modules::dump_main_module_name() {
const char* module_name = Arguments::get_property("jdk.module.main");
if (module_name != nullptr) {
_archived_main_module_name = ArchiveBuilder::current()->ro_strdup(module_name);
}
ArchivePtrMarker::mark_pointer(&_archived_main_module_name);
}

void Modules::serialize(SerializeClosure* soc) {
soc->do_ptr(&_archived_main_module_name);
if (soc->reading()) {
const char* runtime_main_module = Arguments::get_property("jdk.module.main");
log_info(cds)("_archived_main_module_name %s",
_archived_main_module_name != nullptr ? _archived_main_module_name : "(null)");
bool disable = false;
if (runtime_main_module == nullptr) {
if (_archived_main_module_name != nullptr) {
log_info(cds)("Module %s specified during dump time but not during runtime", _archived_main_module_name);
disable = true;
}
} else {
if (_archived_main_module_name == nullptr) {
log_info(cds)("Module %s specified during runtime but not during dump time", runtime_main_module);
disable = true;
} else if (strcmp(runtime_main_module, _archived_main_module_name) != 0) {
log_info(cds)("Mismatched modules: runtime %s dump time %s", runtime_main_module, _archived_main_module_name);
disable = true;
}
}

if (disable) {
log_info(cds)("Disabling optimized module handling");
MetaspaceShared::disable_optimized_module_handling();
}
log_info(cds)("optimized module handling: %s", MetaspaceShared::use_optimized_module_handling() ? "enabled" : "disabled");
log_info(cds)("full module graph: %s", MetaspaceShared::use_full_module_graph() ? "enabled" : "disabled");
}
}

void Modules::define_archived_modules(Handle h_platform_loader, Handle h_system_loader, TRAPS) {
assert(UseSharedSpaces && MetaspaceShared::use_full_module_graph(), "must be");

Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/classfile/modules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ class Modules : AllStatic {
static void define_archived_modules(Handle h_platform_loader, Handle h_system_loader,
TRAPS) NOT_CDS_JAVA_HEAP_RETURN;
static void verify_archived_modules() NOT_CDS_JAVA_HEAP_RETURN;
static void dump_main_module_name() NOT_CDS_JAVA_HEAP_RETURN;
static void serialize(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN;

#if INCLUDE_CDS_JAVA_HEAP
static char* _archived_main_module_name;
#endif

// Provides the java.lang.Module for the unnamed module defined
// to the boot loader.
Expand Down
16 changes: 8 additions & 8 deletions src/hotspot/share/jfr/recorder/service/jfrEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ class JfrEvent {
return JfrEventSetting::has_stacktrace(T::eventId);
}

static bool is_large() {
return JfrEventSetting::is_large(T::eventId);
}

static void set_large() {
JfrEventSetting::set_large(T::eventId);
}

static JfrEventId id() {
return T::eventId;
}
Expand Down Expand Up @@ -248,6 +240,14 @@ class JfrEvent {
return writer.end_event_write(large_size) > 0;
}

static bool is_large() {
return JfrEventSetting::is_large(T::eventId);
}

static void set_large() {
JfrEventSetting::set_large(T::eventId);
}

#ifdef ASSERT
private:
// Verification of fields.
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/jfr/recorder/stacktrace/jfrStackTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ bool JfrStackTrace::record_async(JavaThread* jt, const frame& frame) {
assert(jt != nullptr, "invariant");
assert(!_lineno, "invariant");
Thread* current_thread = Thread::current();
assert(current_thread->is_JfrSampler_thread(), "invariant");
assert(jt != current_thread, "invariant");
// Explicitly monitor the available space of the thread-local buffer used for enqueuing klasses as part of tagging methods.
// We do this because if space becomes sparse, we cannot rely on the implicit allocation of a new buffer as part of the
Expand Down Expand Up @@ -286,6 +287,7 @@ bool JfrStackTrace::record_async(JavaThread* jt, const frame& frame) {
bool JfrStackTrace::record(JavaThread* jt, const frame& frame, int skip) {
assert(jt != nullptr, "invariant");
assert(jt == Thread::current(), "invariant");
assert(jt->thread_state() != _thread_in_native, "invariant");
assert(!_lineno, "invariant");
// Must use ResetNoHandleMark here to bypass if any NoHandleMark exist on stack.
// This is because RegisterMap uses Handles to support continuations.
Expand Down
5 changes: 3 additions & 2 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2503,10 +2503,11 @@ void InstanceKlass::clean_implementors_list() {
assert (ClassUnloading, "only called for ClassUnloading");
for (;;) {
// Use load_acquire due to competing with inserts
InstanceKlass* impl = Atomic::load_acquire(adr_implementor());
InstanceKlass* volatile* iklass = adr_implementor();
assert(iklass != nullptr, "Klass must not be null");
InstanceKlass* impl = Atomic::load_acquire(iklass);
if (impl != nullptr && !impl->is_loader_alive()) {
// null this field, might be an unloaded instance klass or null
InstanceKlass* volatile* iklass = adr_implementor();
if (Atomic::cmpxchg(iklass, impl, (InstanceKlass*)nullptr) == impl) {
// Successfully unlinking implementor.
if (log_is_enabled(Trace, class, unload)) {
Expand Down
3 changes: 1 addition & 2 deletions src/hotspot/share/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,8 +1262,7 @@ bool Arguments::add_property(const char* prop, PropertyWriteable writeable, Prop
}

#if INCLUDE_CDS
if (is_internal_module_property(key) ||
strcmp(key, "jdk.module.main") == 0) {
if (is_internal_module_property(key)) {
MetaspaceShared::disable_optimized_module_handling();
log_info(cds)("optimized module handling: disabled due to incompatible property: %s=%s", key, value);
}
Expand Down
Loading

0 comments on commit 81faeb2

Please sign in to comment.