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 Jun 1, 2024
2 parents e49e81c + 2453002 commit 6a9e9a4
Show file tree
Hide file tree
Showing 61 changed files with 887 additions and 341 deletions.
2 changes: 1 addition & 1 deletion make/modules/java.base/Java.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# new warning is added to javac, it can be temporarily added to the
# disabled warnings list.
#
DISABLED_WARNINGS_java += dangling-doc-comments
# DISABLED_WARNINGS_java +=

DOCLINT += -Xdoclint:all/protected \
'-Xdoclint/package:java.*,javax.*'
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8464,6 +8464,7 @@ class StubGenerator: public StubCodeGenerator {

#endif // LINUX

#ifdef COMPILER2
if (UseSecondarySupersTable) {
StubRoutines::_lookup_secondary_supers_table_slow_path_stub = generate_lookup_secondary_supers_table_slow_path_stub();
if (! InlineSecondarySupersTest) {
Expand All @@ -8473,6 +8474,7 @@ class StubGenerator: public StubCodeGenerator {
}
}
}
#endif

StubRoutines::_upcall_stub_exception_handler = generate_upcall_stub_exception_handler();

Expand Down
36 changes: 29 additions & 7 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,23 @@ void MacroAssembler::movptr(Register Rd, address addr, int32_t &offset, Register

void MacroAssembler::movptr1(Register Rd, uint64_t imm64, int32_t &offset) {
// Load upper 31 bits
//
// In case of 11th bit of `lower` is 0, it's straightforward to understand.
// In case of 11th bit of `lower` is 1, it's a bit tricky, to help understand,
// imagine divide both `upper` and `lower` into 2 parts respectively, i.e.
// [upper_20, upper_12], [lower_20, lower_12], they are the same just before
// `lower = (lower << 52) >> 52;`.
// After `upper -= lower;`,
// upper_20' = upper_20 - (-1) == upper_20 + 1
// upper_12 = 0x000
// After `lui(Rd, upper);`, `Rd` = upper_20' << 12
// Also divide `Rd` into 2 parts [Rd_20, Rd_12],
// Rd_20 == upper_20'
// Rd_12 == 0x000
// After `addi(Rd, Rd, lower);`,
// Rd_20 = upper_20' + (-1) == upper_20 + 1 - 1 = upper_20
// Rd_12 = lower_12
// So, finally Rd == [upper_20, lower_12]
int64_t imm = imm64 >> 17;
int64_t upper = imm, lower = imm;
lower = (lower << 52) >> 52;
Expand All @@ -1700,18 +1717,23 @@ void MacroAssembler::movptr1(Register Rd, uint64_t imm64, int32_t &offset) {
void MacroAssembler::movptr2(Register Rd, uint64_t addr, int32_t &offset, Register tmp) {
assert_different_registers(Rd, tmp, noreg);

uint32_t upper18 = (addr >> 30ull);
int32_t lower30 = (addr & 0x3fffffffu);
int32_t low12 = (lower30 << 20) >> 20;
int32_t mid18 = ((lower30 - low12) >> 12);
// addr: [upper18, lower30[mid18, lower12]]

int64_t upper18 = addr >> 18;
lui(tmp, upper18);

lui(tmp, upper18 << 12);
lui(Rd, mid18 << 12);
int64_t lower30 = addr & 0x3fffffff;
int64_t mid18 = lower30, lower12 = lower30;
lower12 = (lower12 << 52) >> 52;
// For this tricky part (`mid18 -= lower12;` + `offset = lower12;`),
// please refer to movptr1 above.
mid18 -= (int32_t)lower12;
lui(Rd, mid18);

slli(tmp, tmp, 18);
add(Rd, Rd, tmp);

offset = low12;
offset = lower12;
}

void MacroAssembler::add(Register Rd, Register Rn, int64_t increment, Register temp) {
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/memory/metaspace/runningCounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ size_t RunningCounters::reserved_words_class() {
}

size_t RunningCounters::reserved_words_nonclass() {
assert(VirtualSpaceList::vslist_nonclass() != nullptr, "Metaspace not yet initialized");
return VirtualSpaceList::vslist_nonclass()->reserved_words();
}

Expand All @@ -59,6 +60,7 @@ size_t RunningCounters::committed_words_class() {
}

size_t RunningCounters::committed_words_nonclass() {
assert(VirtualSpaceList::vslist_nonclass() != nullptr, "Metaspace not yet initialized");
return VirtualSpaceList::vslist_nonclass()->committed_words();
}

Expand Down Expand Up @@ -90,6 +92,7 @@ size_t RunningCounters::free_chunks_words_class() {
}

size_t RunningCounters::free_chunks_words_nonclass() {
assert(ChunkManager::chunkmanager_nonclass() != nullptr, "Metaspace not yet initialized");
return ChunkManager::chunkmanager_nonclass()->total_word_size();
}

Expand Down
7 changes: 7 additions & 0 deletions src/hotspot/share/nmt/memReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,13 @@ void MemSummaryReporter::report_summary_of_type(MEMFLAGS flag,
}

void MemSummaryReporter::report_metadata(Metaspace::MetadataType type) const {

// NMT reports may be triggered (as part of error handling) very early. Make sure
// Metaspace is already initialized.
if (!Metaspace::initialized()) {
return;
}

assert(type == Metaspace::NonClassType || type == Metaspace::ClassType,
"Invalid metadata type");
const char* name = (type == Metaspace::NonClassType) ?
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/prims/jvmtiEnvBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec
owning_thread = ObjectSynchronizer::get_lock_owner(tlh.list(), hobj);
if (owning_thread != nullptr) {
oop thread_oop = get_vthread_or_thread_oop(owning_thread);
bool is_virtual = java_lang_VirtualThread::is_instance(thread_oop);
bool is_virtual = thread_oop->is_a(vmClasses::BaseVirtualThread_klass());
if (is_virtual) {
thread_oop = nullptr;
}
Expand Down Expand Up @@ -1522,7 +1522,7 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec
waiter = mon->next_waiter(waiter)) {
JavaThread *w = mon->thread_of_waiter(waiter);
oop thread_oop = get_vthread_or_thread_oop(w);
if (java_lang_VirtualThread::is_instance(thread_oop)) {
if (thread_oop->is_a(vmClasses::BaseVirtualThread_klass())) {
skipped++;
}
nWait++;
Expand Down Expand Up @@ -1572,9 +1572,9 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec
for (int i = 0; i < nWait; i++) {
JavaThread *w = mon->thread_of_waiter(waiter);
oop thread_oop = get_vthread_or_thread_oop(w);
bool is_virtual = java_lang_VirtualThread::is_instance(thread_oop);
bool is_virtual = thread_oop->is_a(vmClasses::BaseVirtualThread_klass());
assert(w != nullptr, "sanity check");
if (java_lang_VirtualThread::is_instance(thread_oop)) {
if (is_virtual) {
skipped++;
} else {
// If the thread was found on the ObjectWaiter list, then
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
if (!p->can_call_java()) continue;

oop thread_oop = JvmtiEnvBase::get_vthread_or_thread_oop(p);
if (java_lang_VirtualThread::is_instance(thread_oop)) {
if (thread_oop->is_a(vmClasses::BaseVirtualThread_klass())) {
continue;
}
// The first stage of async deflation does not affect any field
Expand Down
19 changes: 12 additions & 7 deletions src/hotspot/share/services/heapDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,21 @@ class DumpWriter : public AbstractDumpWriter {
DumpWriter(const char* path, bool overwrite, AbstractCompressor* compressor);
~DumpWriter();
julong bytes_written() const override { return (julong) _bytes_written; }
void set_bytes_written(julong bytes_written) { _bytes_written = bytes_written; }
char const* error() const override { return _error; }
void set_error(const char* error) { _error = (char*)error; }
bool has_error() const { return _error != nullptr; }
const char* get_file_path() const { return _writer->get_file_path(); }
AbstractCompressor* compressor() { return _compressor; }
void set_compressor(AbstractCompressor* p) { _compressor = p; }
bool is_overwrite() const { return _writer->is_overwrite(); }
int get_fd() const { return _writer->get_fd(); }

void flush() override;

private:
// internals for DumpMerger
friend class DumpMerger;
void set_bytes_written(julong bytes_written) { _bytes_written = bytes_written; }
int get_fd() const { return _writer->get_fd(); }
void set_compressor(AbstractCompressor* p) { _compressor = p; }
};

DumpWriter::DumpWriter(const char* path, bool overwrite, AbstractCompressor* compressor) :
Expand Down Expand Up @@ -2126,13 +2130,14 @@ void DumpMerger::merge_file(const char* path) {

jlong total = 0;
size_t cnt = 0;
char read_buf[4096];
while ((cnt = segment_fs.read(read_buf, 1, 4096)) != 0) {
_writer->write_raw(read_buf, cnt);

// Use _writer buffer for reading.
while ((cnt = segment_fs.read(_writer->buffer(), 1, _writer->buffer_size())) != 0) {
_writer->set_position(cnt);
_writer->flush();
total += cnt;
}

_writer->flush();
if (segment_fs.fileSize() != total) {
set_error("Merged heap dump is incomplete");
}
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/services/heapDumperCompression.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -49,11 +49,11 @@ FileWriter::~FileWriter() {
}
}

char const* FileWriter::write_buf(char* buf, ssize_t size) {
char const* FileWriter::write_buf(char* buf, size_t size) {
assert(_fd >= 0, "Must be open");
assert(size > 0, "Must write at least one byte");

if (!os::write(_fd, buf, (size_t)size)) {
if (!os::write(_fd, buf, size)) {
return os::strerror(errno);
}

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/services/heapDumperCompression.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2020 SAP SE. All rights reserved.
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 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 @@ -54,7 +54,7 @@ class AbstractWriter : public CHeapObj<mtInternal> {
virtual char const* open_writer() = 0;

// Does the write. Returns null on success and a static error message otherwise.
virtual char const* write_buf(char* buf, ssize_t size) = 0;
virtual char const* write_buf(char* buf, size_t size) = 0;
};


Expand All @@ -74,7 +74,7 @@ class FileWriter : public AbstractWriter {
virtual char const* open_writer();

// Does the write. Returns null on success and a static error message otherwise.
virtual char const* write_buf(char* buf, ssize_t size);
virtual char const* write_buf(char* buf, size_t size);

const char* get_file_path() { return _path; }

Expand Down
12 changes: 6 additions & 6 deletions src/java.base/share/classes/java/lang/ClassValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ public void remove(Class<?> type) {
map.changeEntry(this, value);
}

/// --------
/// Implementation...
/// --------
//| --------
//| Implementation...
//| --------

/** Return the cache, if it exists, else a dummy empty cache. */
private static Entry<?>[] getCacheCarefully(Class<?> type) {
Expand Down Expand Up @@ -535,9 +535,9 @@ <T> void changeEntry(ClassValue<T> classValue, T value) {
addToCache(classValue, e);
}

/// --------
/// Cache management.
/// --------
//| --------
//| Cache management.
//| --------

// Statics do not need synchronization.

Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ private static byte[] encode8859_1(byte coder, byte[] val, boolean doReplace) {
return Arrays.copyOf(dst, dp);
}

//////////////////////////////// utf8 ////////////////////////////////////
//------------------------------ utf8 ------------------------------------

/**
* Decodes ASCII from the source byte array into the destination
Expand Down Expand Up @@ -4806,7 +4806,7 @@ static void repeatCopyRest(byte[] buffer, int offset, int limit, int copied) {
System.arraycopy(buffer, offset, buffer, offset + copied, limit - copied);
}

////////////////////////////////////////////////////////////////
//--------------------------------------------------------------

/**
* Copy character bytes from this string into dst starting at dstBegin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
*/
// public
interface ConstantGroup {
/// Access
//--- Access

/**
* Returns the number of constants in this group.
Expand Down Expand Up @@ -148,7 +148,7 @@ interface ConstantGroup {
*/
boolean isPresent(int index);

/// Views
//--- Views

/**
* Create a view on this group as a {@link List} view.
Expand Down Expand Up @@ -182,7 +182,7 @@ default ConstantGroup subGroup(int start, int end) {
return new AbstractConstantGroup.SubGroup(this, start, end);
}

/// Bulk operations
//--- Bulk operations

/**
* Copy a sequence of constant values into a given buffer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ class MethodHandleNatives {

private MethodHandleNatives() { } // static only

/// MemberName support
//--- MemberName support

static native void init(MemberName self, Object ref);
static native void expand(MemberName self);
static native MemberName resolve(MemberName self, Class<?> caller, int lookupMode,
boolean speculativeResolve) throws LinkageError, ClassNotFoundException;

/// Field layout queries parallel to jdk.internal.misc.Unsafe:
//--- Field layout queries parallel to jdk.internal.misc.Unsafe:
static native long objectFieldOffset(MemberName self); // e.g., returns vmindex
static native long staticFieldOffset(MemberName self); // e.g., returns vmindex
static native Object staticFieldBase(MemberName self); // e.g., returns clazz
static native Object getMemberVMInfo(MemberName self); // returns {vmindex,vmtarget}

/// CallSite support
//--- CallSite support

/** Tell the JVM that we need to change the target of a CallSite. */
static native void setCallSiteTargetNormal(CallSite site, MethodHandle target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private MethodHandles() { } // do not instantiate

// See IMPL_LOOKUP below.

//// Method handle creation from ordinary methods.
//--- Method handle creation from ordinary methods.

/**
* Returns a {@link Lookup lookup object} with
Expand Down Expand Up @@ -3745,7 +3745,7 @@ public MethodHandleInfo revealDirect(MethodHandle target) {
return new InfoFromMemberName(this, member, refKind);
}

/// Helper methods, all package-private.
//--- Helper methods, all package-private.

MemberName resolveOrFail(byte refKind, Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
checkSymbolicClass(refc); // do this before attempting to resolve
Expand Down Expand Up @@ -4639,7 +4639,7 @@ public static VarHandle byteBufferViewVarHandle(Class<?> viewArrayClass,
}


/// method handle invocation (reflective style)
//--- method handle invocation (reflective style)

/**
* Produces a method handle which will invoke any method handle of the
Expand Down Expand Up @@ -4822,7 +4822,7 @@ static MethodHandle basicInvoker(MethodType type) {
return type.invokers().basicInvoker();
}

/// method handle modification (creation from other method handles)
//--- method handle modification (creation from other method handles)

/**
* Produces a method handle which adapts the type of the
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/invoke/MethodType.java
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ static boolean canConvert(Class<?> src, Class<?> dst) {
}
}

/// Queries which have to do with the bytecode architecture
//--- Queries which have to do with the bytecode architecture

/** Reports the number of JVM stack slots required to invoke a method
* of this type. Note that (for historical reasons) the JVM requires
Expand Down Expand Up @@ -1302,7 +1302,7 @@ public Optional<MethodTypeDesc> describeConstable() {
}
}

/// Serialization.
//--- Serialization.

/**
* There are no serializable fields for {@code MethodType}.
Expand Down
Loading

0 comments on commit 6a9e9a4

Please sign in to comment.