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 Sep 3, 2024
2 parents 7696dc4 + ad40a12 commit ba5c8ce
Show file tree
Hide file tree
Showing 54 changed files with 833 additions and 447 deletions.
12 changes: 9 additions & 3 deletions make/modules/java.desktop/lib/AwtLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ ifeq ($(call isTargetOs, windows macosx), false)
$(X_CFLAGS), \
EXTRA_HEADER_DIRS := $(LIBAWT_HEADLESS_EXTRA_HEADER_DIRS), \
DISABLED_WARNINGS_gcc := unused-variable, \
DISABLED_WARNINGS_clang := unused-variable, \
DISABLED_WARNINGS_gcc_X11Renderer.c := unused-function, \
DISABLED_WARNINGS_gcc_X11SurfaceData.c := unused-function, \
DISABLED_WARNINGS_clang_X11Renderer.c := unused-function, \
DISABLED_WARNINGS_clang_X11SurfaceData.c := unused-function, \
JDK_LIBS := libawt java.base:libjava, \
LIBS_linux := $(LIBDL) $(LIBM), \
STATIC_LIB_EXCLUDE_OBJS := $(LIBAWT_HEADLESS_STATIC_EXCLUDE_OBJS), \
Expand Down Expand Up @@ -238,6 +241,7 @@ ifeq ($(call isTargetOs, windows macosx)+$(ENABLE_HEADLESS_ONLY), false+false)
CFLAGS := -DXAWT -DXAWT_HACK $(LIBAWT_XAWT_CFLAGS) \
$(FONTCONFIG_CFLAGS) $(CUPS_CFLAGS) $(X_CFLAGS), \
DISABLED_WARNINGS_gcc := int-to-pointer-cast unused-variable, \
DISABLED_WARNINGS_clang := unused-variable, \
DISABLED_WARNINGS_gcc_awt_Taskbar.c := parentheses, \
DISABLED_WARNINGS_gcc_GLXSurfaceData.c := unused-function, \
DISABLED_WARNINGS_gcc_gtk3_interface.c := parentheses type-limits \
Expand All @@ -256,20 +260,22 @@ ifeq ($(call isTargetOs, windows macosx)+$(ENABLE_HEADLESS_ONLY), false+false)
DISABLED_WARNINGS_gcc_XToolkit.c := unused-result, \
DISABLED_WARNINGS_gcc_XWindow.c := unused-function, \
DISABLED_WARNINGS_clang_awt_Taskbar.c := parentheses, \
DISABLED_WARNINGS_clang_gtk3_interface.c := parentheses, \
DISABLED_WARNINGS_clang_gtk3_interface.c := unused-function parentheses, \
DISABLED_WARNINGS_clang_GLXSurfaceData.c := unused-function, \
DISABLED_WARNINGS_clang_OGLBufImgOps.c := format-nonliteral, \
DISABLED_WARNINGS_clang_OGLPaints.c := format-nonliteral, \
DISABLED_WARNINGS_clang_screencast_pipewire.c := format-nonliteral, \
DISABLED_WARNINGS_clang_sun_awt_X11_GtkFileDialogPeer.c := parentheses, \
DISABLED_WARNINGS_clang_XWindow.c := unused-function, \
DISABLED_WARNINGS_clang_aix := deprecated-non-prototype, \
DISABLED_WARNINGS_clang_aix_awt_Taskbar.c := parentheses, \
DISABLED_WARNINGS_clang_aix_OGLPaints.c := format-nonliteral, \
DISABLED_WARNINGS_clang_aix_OGLBufImgOps.c := format-nonliteral, \
DISABLED_WARNINGS_clang_aix_gtk3_interface.c := parentheses \
DISABLED_WARNINGS_clang_aix_gtk3_interface.c := unused-function parentheses \
logical-op-parentheses, \
DISABLED_WARNINGS_clang_aix_sun_awt_X11_GtkFileDialogPeer.c := \
parentheses, \
DISABLED_WARNINGS_clang_aix_awt_InputMethod.c := sign-compare, \
DISABLED_WARNINGS_clang_aix_awt_InputMethod.c := unused-function sign-compare, \
JDK_LIBS := libawt java.base:libjava, \
LIBS_unix := $(LIBDL) $(LIBM) $(X_LIBS) -lX11 -lXext -lXi -lXrender \
-lXtst, \
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/aarch64/aarch64.ad
Original file line number Diff line number Diff line change
Expand Up @@ -2334,7 +2334,7 @@ bool Matcher::is_short_branch_offset(int rule, int br_size, int offset) {
// Vector width in bytes.
int Matcher::vector_width_in_bytes(BasicType bt) {
// The MaxVectorSize should have been set by detecting SVE max vector register size.
int size = MIN2((UseSVE > 0) ? 256 : 16, (int)MaxVectorSize);
int size = MIN2((UseSVE > 0) ? (int)FloatRegister::sve_vl_max : (int)FloatRegister::neon_vl, (int)MaxVectorSize);
// Minimum 2 values in vector
if (size < 2*type2aelembytes(bt)) size = 0;
// But never < 4
Expand Down Expand Up @@ -2373,7 +2373,7 @@ int Matcher::scalable_vector_reg_size(const BasicType bt) {

// Vector ideal reg.
uint Matcher::vector_ideal_reg(int len) {
if (UseSVE > 0 && 16 < len && len <= 256) {
if (UseSVE > 0 && FloatRegister::neon_vl < len && len <= FloatRegister::sve_vl_max) {
return Op_VecA;
}
switch(len) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/aarch64_vector.ad
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ source %{
}

int length_in_bytes = vlen * type2aelembytes(bt);
if (UseSVE == 0 && length_in_bytes > 16) {
if (UseSVE == 0 && length_in_bytes > FloatRegister::neon_vl) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/aarch64_vector_ad.m4
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ source %{
}

int length_in_bytes = vlen * type2aelembytes(bt);
if (UseSVE == 0 && length_in_bytes > 16) {
if (UseSVE == 0 && length_in_bytes > FloatRegister::neon_vl) {
return false;
}

Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6413,8 +6413,10 @@ void MacroAssembler::cache_wbsync(bool is_pre) {
}

void MacroAssembler::verify_sve_vector_length(Register tmp) {
if (!UseSVE || VM_Version::get_max_supported_sve_vector_length() == FloatRegister::sve_vl_min) {
return;
}
// Make sure that native code does not change SVE vector length.
if (!UseSVE) return;
Label verify_ok;
movw(tmp, zr);
sve_inc(tmp, B);
Expand Down
10 changes: 8 additions & 2 deletions src/hotspot/cpu/aarch64/register_aarch64.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -166,7 +166,13 @@ class FloatRegister {
max_slots_per_register = 4,
save_slots_per_register = 2,
slots_per_neon_register = 4,
extra_save_slots_per_neon_register = slots_per_neon_register - save_slots_per_register
extra_save_slots_per_neon_register = slots_per_neon_register - save_slots_per_register,
neon_vl = 16,
// VLmax: The maximum sve vector length is determined by the hardware
// sve_vl_min <= VLmax <= sve_vl_max.
sve_vl_min = 16,
// Maximum supported vector length across all CPUs
sve_vl_max = 256
};

class FloatRegisterImpl: public AbstractRegisterImpl {
Expand Down
47 changes: 28 additions & 19 deletions src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "precompiled.hpp"
#include "pauth_aarch64.hpp"
#include "register_aarch64.hpp"
#include "runtime/arguments.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"
Expand All @@ -44,6 +45,7 @@ int VM_Version::_zva_length;
int VM_Version::_dcache_line_size;
int VM_Version::_icache_line_size;
int VM_Version::_initial_sve_vector_length;
int VM_Version::_max_supported_sve_vector_length;
bool VM_Version::_rop_protection;
uintptr_t VM_Version::_pac_mask;

Expand Down Expand Up @@ -507,30 +509,37 @@ void VM_Version::initialize() {
if (UseSVE > 0) {
if (FLAG_IS_DEFAULT(MaxVectorSize)) {
MaxVectorSize = _initial_sve_vector_length;
} else if (MaxVectorSize < 16) {
warning("SVE does not support vector length less than 16 bytes. Disabling SVE.");
} else if (MaxVectorSize < FloatRegister::sve_vl_min) {
warning("SVE does not support vector length less than %d bytes. Disabling SVE.",
FloatRegister::sve_vl_min);
UseSVE = 0;
} else if ((MaxVectorSize % 16) == 0 && is_power_of_2(MaxVectorSize)) {
int new_vl = set_and_get_current_sve_vector_length(MaxVectorSize);
_initial_sve_vector_length = new_vl;
// Update MaxVectorSize to the largest supported value.
if (new_vl < 0) {
vm_exit_during_initialization(
err_msg("Current system does not support SVE vector length for MaxVectorSize: %d",
(int)MaxVectorSize));
} else if (new_vl != MaxVectorSize) {
warning("Current system only supports max SVE vector length %d. Set MaxVectorSize to %d",
new_vl, new_vl);
}
MaxVectorSize = new_vl;
} else {
} else if (!((MaxVectorSize % FloatRegister::sve_vl_min) == 0 && is_power_of_2(MaxVectorSize))) {
vm_exit_during_initialization(err_msg("Unsupported MaxVectorSize: %d", (int)MaxVectorSize));
}

if (UseSVE > 0) {
// Acquire the largest supported vector length of this machine
_max_supported_sve_vector_length = set_and_get_current_sve_vector_length(FloatRegister::sve_vl_max);

if (MaxVectorSize != _max_supported_sve_vector_length) {
int new_vl = set_and_get_current_sve_vector_length(MaxVectorSize);
if (new_vl < 0) {
vm_exit_during_initialization(
err_msg("Current system does not support SVE vector length for MaxVectorSize: %d",
(int)MaxVectorSize));
} else if (new_vl != MaxVectorSize) {
warning("Current system only supports max SVE vector length %d. Set MaxVectorSize to %d",
new_vl, new_vl);
}
MaxVectorSize = new_vl;
}
_initial_sve_vector_length = MaxVectorSize;
}
}

if (UseSVE == 0) { // NEON
int min_vector_size = 8;
int max_vector_size = 16;
int max_vector_size = FloatRegister::neon_vl;
if (!FLAG_IS_DEFAULT(MaxVectorSize)) {
if (!is_power_of_2(MaxVectorSize)) {
vm_exit_during_initialization(err_msg("Unsupported MaxVectorSize: %d", (int)MaxVectorSize));
Expand All @@ -542,11 +551,11 @@ void VM_Version::initialize() {
FLAG_SET_DEFAULT(MaxVectorSize, max_vector_size);
}
} else {
FLAG_SET_DEFAULT(MaxVectorSize, 16);
FLAG_SET_DEFAULT(MaxVectorSize, FloatRegister::neon_vl);
}
}

int inline_size = (UseSVE > 0 && MaxVectorSize >= 16) ? MaxVectorSize : 0;
int inline_size = (UseSVE > 0 && MaxVectorSize >= FloatRegister::sve_vl_min) ? MaxVectorSize : 0;
if (FLAG_IS_DEFAULT(ArrayOperationPartialInlineSize)) {
FLAG_SET_DEFAULT(ArrayOperationPartialInlineSize, inline_size);
} else if (ArrayOperationPartialInlineSize != 0 && ArrayOperationPartialInlineSize != inline_size) {
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/aarch64/vm_version_aarch64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class VM_Version : public Abstract_VM_Version {
static int _dcache_line_size;
static int _icache_line_size;
static int _initial_sve_vector_length;
static int _max_supported_sve_vector_length;
static bool _rop_protection;
static uintptr_t _pac_mask;

Expand Down Expand Up @@ -164,7 +165,8 @@ enum Ampere_CPU_Model {

static int icache_line_size() { return _icache_line_size; }
static int dcache_line_size() { return _dcache_line_size; }
static int get_initial_sve_vector_length() { return _initial_sve_vector_length; };
static int get_initial_sve_vector_length() { return _initial_sve_vector_length; };
static int get_max_supported_sve_vector_length() { return _max_supported_sve_vector_length; };

// Aarch64 supports fast class initialization checks
static bool supports_fast_class_init_checks() { return true; }
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/ppc/macroAssembler_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ void MacroAssembler::cmpxchg_generic(ConditionRegister flag, Register dest_curre

cmpxchg_loop_body(flag, dest_current_value, compare_value, exchange_value, addr_base, tmp1, tmp2,
retry, failed, cmpxchgx_hint, size);
if (!weak || use_result_reg) {
if (!weak || use_result_reg || failed_ext) {
if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
bne_predict_not_taken(CCR0, weak ? failed : retry); // StXcx_ sets CCR0.
} else {
Expand Down
17 changes: 12 additions & 5 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3530,14 +3530,18 @@ void MacroAssembler::atomic_cas(

void MacroAssembler::far_jump(const Address &entry, Register tmp) {
assert(CodeCache::find_blob(entry.target()) != nullptr,
"destination of far call not found in code cache");
"destination of far jump not found in code cache");
assert(entry.rspec().type() == relocInfo::external_word_type
|| entry.rspec().type() == relocInfo::runtime_call_type
|| entry.rspec().type() == relocInfo::none, "wrong entry relocInfo type");
// Fixed length: see MacroAssembler::far_branch_size()
// We can use auipc + jr here because we know that the total size of
// the code cache cannot exceed 2Gb.
relocate(entry.rspec(), [&] {
int32_t offset;
la(tmp, entry.target(), offset);
int64_t distance = entry.target() - pc();
int32_t offset = ((int32_t)distance << 20) >> 20;
assert(is_valid_32bit_offset(distance), "Far jump using wrong instructions.");
auipc(tmp, (int32_t)distance + 0x800);
jr(tmp, offset);
});
}
Expand All @@ -3552,8 +3556,11 @@ void MacroAssembler::far_call(const Address &entry, Register tmp) {
// We can use auipc + jalr here because we know that the total size of
// the code cache cannot exceed 2Gb.
relocate(entry.rspec(), [&] {
assert(is_valid_32bit_offset(entry.target() - pc()), "Far call using wrong instructions.");
call(entry.target(), tmp);
int64_t distance = entry.target() - pc();
int32_t offset = ((int32_t)distance << 20) >> 20;
assert(is_valid_32bit_offset(distance), "Far call using wrong instructions.");
auipc(tmp, (int32_t)distance + 0x800);
jalr(tmp, offset);
});
}

Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/cds/filemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ void FileMapHeader::print(outputStream* st) {
st->print_cr("- core_region_alignment: " SIZE_FORMAT, _core_region_alignment);
st->print_cr("- obj_alignment: %d", _obj_alignment);
st->print_cr("- narrow_oop_base: " INTPTR_FORMAT, p2i(_narrow_oop_base));
st->print_cr("- narrow_oop_base: " INTPTR_FORMAT, p2i(_narrow_oop_base));
st->print_cr("- narrow_oop_shift %d", _narrow_oop_shift);
st->print_cr("- compact_strings: %d", _compact_strings);
st->print_cr("- max_heap_size: " UINTX_FORMAT, _max_heap_size);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/code/codeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void CodeCache::initialize_heaps() {
const bool cache_size_set = FLAG_IS_CMDLINE(ReservedCodeCacheSize);
const size_t ps = page_size(false, 8);
const size_t min_size = MAX2(os::vm_allocation_granularity(), ps);
const size_t min_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3); // Make sure we have enough space for VM internal code
const size_t min_cache_size = CompilerConfig::min_code_cache_size(); // Make sure we have enough space for VM internal code
size_t cache_size = align_up(ReservedCodeCacheSize, min_size);

// Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/compiler/compilationPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ void CompilationPolicy::initialize() {
c2_size = C2Compiler::initial_code_buffer_size();
#endif
size_t buffer_size = c1_only ? c1_size : (c1_size/3 + 2*c2_size/3);
int max_count = (ReservedCodeCacheSize - (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3))) / (int)buffer_size;
int max_count = (ReservedCodeCacheSize - (int)CompilerConfig::min_code_cache_size()) / (int)buffer_size;
if (count > max_count) {
// Lower the compiler count such that all buffers fit into the code cache
count = MAX2(max_count, c1_only ? 1 : 2);
Expand Down
5 changes: 2 additions & 3 deletions src/hotspot/share/compiler/compilerDefinitions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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 @@ -475,8 +475,7 @@ void CompilerConfig::set_jvmci_specific_flags() {

bool CompilerConfig::check_args_consistency(bool status) {
// Check lower bounds of the code cache
// Template Interpreter code is approximately 3X larger in debug builds.
uint min_code_cache_size = CodeCacheMinimumUseSpace DEBUG_ONLY(* 3);
size_t min_code_cache_size = CompilerConfig::min_code_cache_size();
if (ReservedCodeCacheSize < InitialCodeCacheSize) {
jio_fprintf(defaultStream::error_stream(),
"Invalid ReservedCodeCacheSize: %dK. Must be at least InitialCodeCacheSize=%dK.\n",
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/compiler/compilerDefinitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ class CompilerConfig : public AllStatic {
inline static bool is_c2_or_jvmci_compiler_only();
inline static bool is_c2_or_jvmci_compiler_enabled();

inline static size_t min_code_cache_size();

private:
static bool is_compilation_mode_selected();
static void set_compilation_policy_flags();
Expand Down
15 changes: 15 additions & 0 deletions src/hotspot/share/compiler/compilerDefinitions.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
#ifndef SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP
#define SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP

#ifdef COMPILER1
#include "c1/c1_Compiler.hpp"
#endif
#ifdef COMPILER2
#include "opto/c2compiler.hpp"
#endif
#include "compiler/compilerDefinitions.hpp"

#include "compiler/compiler_globals.hpp"
Expand Down Expand Up @@ -132,4 +138,13 @@ inline bool CompilerConfig::is_c2_or_jvmci_compiler_enabled() {
return is_c2_enabled() || is_jvmci_compiler_enabled();
}

inline size_t CompilerConfig::min_code_cache_size() {
size_t min_code_cache_size = CodeCacheMinimumUseSpace;
// Template Interpreter code is approximately 3X larger in debug builds.
DEBUG_ONLY(min_code_cache_size *= 3);
COMPILER1_PRESENT(min_code_cache_size += Compiler::code_buffer_size());
COMPILER2_PRESENT(min_code_cache_size += C2Compiler::initial_code_buffer_size());
return min_code_cache_size;
}

#endif // SHARE_COMPILER_COMPILERDEFINITIONS_INLINE_HPP
Loading

0 comments on commit ba5c8ce

Please sign in to comment.