Skip to content

Commit

Permalink
Merge branch 'master' into JDK-8327370
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuch committed Jun 20, 2024
2 parents 33ed282 + 6420846 commit 1616b32
Show file tree
Hide file tree
Showing 64 changed files with 11,256 additions and 1,889 deletions.
12 changes: 6 additions & 6 deletions make/autoconf/flags-cflags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,12 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
elif test "x$TOOLCHAIN_TYPE" = xclang; then
ALWAYS_DEFINES_JVM="-D_GNU_SOURCE"
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
# Access APIs for Windows 8 and above
# see https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
ALWAYS_DEFINES_JDK="-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0602 \
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -DWIN32 -DIAL"
ALWAYS_DEFINES_JVM="-DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0602 \
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE"
# _WIN32_WINNT=0x0602 means access APIs for Windows 8 and above. See
# https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
ALWAYS_DEFINES="-DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0602 \
-D_CRT_DECLARE_NONSTDC_NAMES -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS"
ALWAYS_DEFINES_JDK="$ALWAYS_DEFINES -DWIN32 -DIAL"
ALWAYS_DEFINES_JVM="$ALWAYS_DEFINES -DNOMINMAX"
fi
###############################################################################
Expand Down
31 changes: 3 additions & 28 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1914,13 +1914,16 @@ bool Matcher::match_rule_supported(int opcode) {
case Op_PopCountL:
return UsePopCountInstruction;

case Op_ReverseBytesI:
case Op_ReverseBytesL:
case Op_RotateRight:
case Op_RotateLeft:
case Op_CountLeadingZerosI:
case Op_CountLeadingZerosL:
case Op_CountTrailingZerosI:
case Op_CountTrailingZerosL:
return UseZbb;

case Op_FmaF:
case Op_FmaD:
case Op_FmaVF:
Expand Down Expand Up @@ -7856,34 +7859,6 @@ instruct xorL_reg_imm(iRegLNoSp dst, iRegL src1, immLAdd src2) %{
// ============================================================================
// BSWAP Instructions

instruct bytes_reverse_int(iRegINoSp dst, iRegIorL2I src, rFlagsReg cr) %{
match(Set dst (ReverseBytesI src));
effect(KILL cr);

ins_cost(ALU_COST * 13);
format %{ "revb_w_w $dst, $src\t#@bytes_reverse_int" %}

ins_encode %{
__ revb_w_w(as_Register($dst$$reg), as_Register($src$$reg));
%}

ins_pipe(pipe_class_default);
%}

instruct bytes_reverse_long(iRegLNoSp dst, iRegL src, rFlagsReg cr) %{
match(Set dst (ReverseBytesL src));
effect(KILL cr);

ins_cost(ALU_COST * 29);
format %{ "revb $dst, $src\t#@bytes_reverse_long" %}

ins_encode %{
__ revb(as_Register($dst$$reg), as_Register($src$$reg));
%}

ins_pipe(pipe_class_default);
%}

instruct bytes_reverse_unsigned_short(iRegINoSp dst, iRegIorL2I src) %{
match(Set dst (ReverseBytesUS src));

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/riscv/riscv_b.ad
Original file line number Diff line number Diff line change
Expand Up @@ -178,27 +178,27 @@ instruct convI2UL_reg_reg_b(iRegLNoSp dst, iRegIorL2I src, immL_32bits mask) %{

// BSWAP instructions
instruct bytes_reverse_int_b(iRegINoSp dst, iRegIorL2I src) %{
predicate(UseZbb);
match(Set dst (ReverseBytesI src));

ins_cost(ALU_COST * 2);
format %{ "revb_w_w $dst, $src\t#@bytes_reverse_int_b" %}

ins_encode %{
assert(UseZbb, "must be");
__ revb_w_w(as_Register($dst$$reg), as_Register($src$$reg));
%}

ins_pipe(ialu_reg);
%}

instruct bytes_reverse_long_b(iRegLNoSp dst, iRegL src) %{
predicate(UseZbb);
match(Set dst (ReverseBytesL src));

ins_cost(ALU_COST);
format %{ "rev8 $dst, $src\t#@bytes_reverse_long_b" %}

ins_encode %{
assert(UseZbb, "must be");
__ rev8(as_Register($dst$$reg), as_Register($src$$reg));
%}

Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/os/linux/globals_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
product(bool, UseMadvPopulateWrite, true, DIAGNOSTIC, \
"Use MADV_POPULATE_WRITE in os::pd_pretouch_memory.") \
\

product(bool, PrintMemoryMapAtExit, false, DIAGNOSTIC, \
"Print an annotated memory map at exit") \
\
// end of RUNTIME_OS_FLAGS

//
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/cds/archiveHeapLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "memory/iterator.inline.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "sanitizers/ub.hpp"
#include "utilities/bitMap.inline.hpp"
#include "utilities/copy.hpp"

Expand Down Expand Up @@ -61,9 +62,7 @@ ptrdiff_t ArchiveHeapLoader::_mapped_heap_delta = 0;

// Every mapped region is offset by _mapped_heap_delta from its requested address.
// See FileMapInfo::heap_region_requested_address().
#if defined(__clang__) || defined(__GNUC__)
__attribute__((no_sanitize("undefined")))
#endif
ATTRIBUTE_NO_UBSAN
void ArchiveHeapLoader::init_mapped_heap_info(address mapped_heap_bottom, ptrdiff_t delta, int dumptime_oop_shift) {
assert(!_mapped_heap_relocation_initialized, "only once");
if (!UseCompressedOops) {
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/gc/z/zDirector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ static bool rule_major_allocation_rate(const ZDirectorStats& stats) {
}

static double calculate_young_to_old_worker_ratio(const ZDirectorStats& stats) {
if (!stats._old_stats._cycle._is_time_trustable) {
return 1.0;
}

const double young_gc_time = gc_time(stats._young_stats);
const double old_gc_time = gc_time(stats._old_stats);
const size_t reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg;
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/jfr/jni/jfrJniMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "jfr/recorder/jfrRecorder.hpp"
#include "jfr/recorder/checkpoint/jfrMetadataEvent.hpp"
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp"
#include "jfr/recorder/repository/jfrChunk.hpp"
#include "jfr/recorder/repository/jfrRepository.hpp"
#include "jfr/recorder/repository/jfrChunkRotation.hpp"
#include "jfr/recorder/repository/jfrChunkWriter.hpp"
Expand Down Expand Up @@ -425,3 +426,7 @@ JVM_END
JVM_ENTRY_NO_ENV(void, jfr_unregister_stack_filter(JNIEnv* env, jclass jvm, jlong id))
JfrStackFilterRegistry::remove(id);
JVM_END

NO_TRANSITION(jlong, jfr_nanos_now(JNIEnv* env, jclass jvm))
return JfrChunk::nanos_now();
NO_TRANSITION_END
2 changes: 2 additions & 0 deletions src/hotspot/share/jfr/jni/jfrJniMethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ jlong JNICALL jfr_register_stack_filter(JNIEnv* env, jclass jvm, jobjectArray cl

jlong JNICALL jfr_unregister_stack_filter(JNIEnv* env, jclass jvm, jlong id);

jlong JNICALL jfr_nanos_now(JNIEnv* env, jclass jvm);

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ JfrJniMethodRegistration::JfrJniMethodRegistration(JNIEnv* env) {
(char*)"hostTotalSwapMemory", (char*)"()J", (void*) jfr_host_total_swap_memory,
(char*)"emitDataLoss", (char*)"(J)V", (void*)jfr_emit_data_loss,
(char*)"registerStackFilter", (char*)"([Ljava/lang/String;[Ljava/lang/String;)J", (void*)jfr_register_stack_filter,
(char*)"unregisterStackFilter", (char*)"(J)V", (void*)jfr_unregister_stack_filter
(char*)"unregisterStackFilter", (char*)"(J)V", (void*)jfr_unregister_stack_filter,
(char*)"nanosNow", (char*)"()J", (void*)jfr_nanos_now
};

const size_t method_array_length = sizeof(method) / sizeof(JNINativeMethod);
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/jfr/recorder/repository/jfrChunk.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -35,7 +35,7 @@ static const u2 JFR_VERSION_MAJOR = 2;
static const u2 JFR_VERSION_MINOR = 1;

// strictly monotone
static jlong nanos_now() {
jlong JfrChunk::nanos_now() {
static jlong last = 0;

jlong seconds;
Expand Down Expand Up @@ -147,7 +147,7 @@ void JfrChunk::update_start_ticks() {
}

void JfrChunk::update_start_nanos() {
const jlong now = nanos_now();
const jlong now = JfrChunk::nanos_now();
assert(now >= _start_nanos, "invariant");
assert(now >= _last_update_nanos, "invariant");
_start_nanos = _last_update_nanos = now;
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/jfr/recorder/repository/jfrChunk.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -34,6 +34,8 @@ const u1 PAD = 0;
class JfrChunk : public JfrCHeapObj {
friend class JfrChunkWriter;
friend class JfrChunkHeadWriter;
public:
static jlong nanos_now();
private:
char* _path;
int64_t _start_ticks;
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/jfr/support/jfrIntrinsics.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -47,13 +47,13 @@ class JfrIntrinsicSupport : AllStatic {
#define JFR_HAVE_INTRINSICS

#define JFR_TEMPLATES(template) \
template(jdk_jfr_internal_HiddenWait, "jdk/jfr/internal/HiddenWait") \
template(jdk_jfr_internal_JVM, "jdk/jfr/internal/JVM") \
template(jdk_jfr_internal_event_EventWriterFactory, "jdk/jfr/internal/event/EventWriterFactory") \
template(jdk_jfr_internal_event_EventConfiguration_signature, "Ljdk/jfr/internal/event/EventConfiguration;") \
template(getEventWriter_signature, "()Ljdk/jfr/internal/event/EventWriter;") \
template(eventConfiguration_name, "eventConfiguration") \
template(commit_name, "commit") \
template(jfr_chunk_rotation_monitor, "jdk/jfr/internal/JVM$ChunkRotationMonitor") \

#define JFR_INTRINSICS(do_intrinsic, do_class, do_name, do_signature, do_alias) \
do_intrinsic(_counterTime, jdk_jfr_internal_JVM, counterTime_name, void_long_signature, F_SN) \
Expand Down
11 changes: 7 additions & 4 deletions src/hotspot/share/nmt/memMapPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@
#include "logging/logAsyncWriter.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "memory/universe.hpp"
#include "memory/resourceArea.hpp"
#include "nmt/memflags.hpp"
#include "nmt/memFlagBitmap.hpp"
#include "nmt/memMapPrinter.hpp"
#include "nmt/memTracker.hpp"
#include "nmt/virtualMemoryTracker.hpp"
#include "runtime/nonJavaThread.hpp"
#include "runtime/osThread.hpp"
#include "runtime/thread.hpp"
#include "runtime/threadSMR.hpp"
#include "runtime/vmThread.hpp"
#include "nmt/memFlagBitmap.hpp"
#include "nmt/memMapPrinter.hpp"
#include "nmt/memTracker.hpp"
#include "nmt/virtualMemoryTracker.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/growableArray.hpp"
#include "utilities/ostream.hpp"
Expand Down Expand Up @@ -203,6 +204,8 @@ static void print_thread_details(uintx thread_id, const char* name, outputStream
// Given a region [from, to), if it intersects a known thread stack, print detail infos about that thread.
static void print_thread_details_for_supposed_stack_address(const void* from, const void* to, outputStream* st) {

ResourceMark rm;

#define HANDLE_THREAD(T) \
if (T != nullptr && vma_touches_thread_stack(from, to, T)) { \
print_thread_details((uintx)(T->osthread()->thread_id()), T->name(), st); \
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/opto/loopPredicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ IfProjNode* PhaseIdealLoop::clone_assertion_predicate_for_unswitched_loops(IfNod
ParsePredicateSuccessProj* parse_predicate_proj) {
TemplateAssertionPredicateExpression template_assertion_predicate_expression(
template_assertion_predicate->in(1)->as_Opaque4());
Opaque4Node* cloned_opaque4_node = template_assertion_predicate_expression.clone(parse_predicate_proj, this);
Opaque4Node* cloned_opaque4_node = template_assertion_predicate_expression.clone(parse_predicate_proj->in(0)->in(0), this);
IfProjNode* if_proj = create_new_if_for_predicate(parse_predicate_proj, nullptr, reason, template_assertion_predicate->Opcode(), false);
_igvn.replace_input_of(if_proj->in(0), 1, cloned_opaque4_node);
_igvn.replace_input_of(parse_predicate_proj->in(0), 0, if_proj);
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/prims/unsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "runtime/threadSMR.hpp"
#include "runtime/vmOperations.hpp"
#include "runtime/vm_version.hpp"
#include "sanitizers/ub.hpp"
#include "services/threadService.hpp"
#include "utilities/align.hpp"
#include "utilities/copy.hpp"
Expand Down Expand Up @@ -244,9 +245,7 @@ class MemoryAccess : StackObj {

// we use this method at some places for writing to 0 e.g. to cause a crash;
// ubsan does not know that this is the desired behavior
#if defined(__clang__) || defined(__GNUC__)
__attribute__((no_sanitize("undefined")))
#endif
ATTRIBUTE_NO_UBSAN
void put(T x) {
GuardUnsafeAccess guard(_thread);
*addr() = normalize_for_write(x);
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/runtime/java.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "nmt/memMapPrinter.hpp"
#include "nmt/memTracker.hpp"
#include "oops/constantPool.hpp"
#include "oops/generateOopMap.hpp"
Expand Down Expand Up @@ -485,6 +486,9 @@ void before_exit(JavaThread* thread, bool halt) {
if (DumpPerfMapAtExit) {
CodeCache::write_perf_map();
}
if (PrintMemoryMapAtExit) {
MemMapPrinter::print_all_mappings(tty, false);
}
#endif

if (JvmtiExport::should_post_thread_life()) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/objectMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ bool ObjectMonitor::check_owner(TRAPS) {
static inline bool is_excluded(const Klass* monitor_klass) {
assert(monitor_klass != nullptr, "invariant");
NOT_JFR_RETURN_(false);
JFR_ONLY(return vmSymbols::jfr_chunk_rotation_monitor() == monitor_klass->name();)
JFR_ONLY(return vmSymbols::jdk_jfr_internal_HiddenWait() == monitor_klass->name();)
}

static void post_monitor_wait_event(EventJavaMonitorWait* event,
Expand Down
43 changes: 43 additions & 0 deletions src/hotspot/share/sanitizers/ub.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024 SAP SE. 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.
*
*/

#ifndef SHARE_SANITIZERS_UB_HPP
#define SHARE_SANITIZERS_UB_HPP

// ATTRIBUTE_NO_UBSAN
//
// Function attribute which informs the compiler to disable UBSan checks in the
// following function or method.
// Useful if the function or method is known to do something special or even 'dangerous', for
// example causing desired signals/crashes.
#if defined(__clang__) || defined(__GNUC__)
#define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize("undefined")))
#endif

#ifndef ATTRIBUTE_NO_UBSAN
#define ATTRIBUTE_NO_UBSAN
#endif

#endif // SHARE_SANITIZERS_UB_HPP
6 changes: 3 additions & 3 deletions src/hotspot/share/services/diagnosticCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,11 +1203,11 @@ SystemDumpMapDCmd::SystemDumpMapDCmd(outputStream* output, bool heap) :
void SystemDumpMapDCmd::execute(DCmdSource source, TRAPS) {
stringStream defaultname;
const char* name = nullptr;
if (::strcmp(default_filename, _filename.value()) == 0) {
if (_filename.is_set()) {
name = _filename.value();
} else {
defaultname.print("vm_memory_map_%d.txt", os::current_process_id());
name = defaultname.base();
} else {
name = _filename.value();
}
fileStream fs(name);
if (fs.is_open()) {
Expand Down
Loading

0 comments on commit 1616b32

Please sign in to comment.