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 Oct 5, 2023
2 parents 63257ae + a8eacb3 commit e35338a
Show file tree
Hide file tree
Showing 37 changed files with 696 additions and 479 deletions.
2 changes: 1 addition & 1 deletion make/RunTests.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ define SetupRunJtregTestBody
$$(RM) -r $$($1_TEST_RESULTS_DIR)

$1_COMMAND_LINE := \
$$(JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \
$$(JTREG_JAVA) $$($1_JTREG_LAUNCHER_OPTIONS) \
-Dprogram=jtreg -jar $$(JT_HOME)/lib/jtreg.jar \
$$($1_JTREG_BASIC_OPTIONS) \
-testjdk:$$(JDK_UNDER_TEST) \
Expand Down
2 changes: 2 additions & 0 deletions make/RunTestsPrebuilt.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ $(eval $(call SetupVariable,JT_HOME))
$(eval $(call SetupVariable,JDK_IMAGE_DIR,$(OUTPUTDIR)/images/jdk))
$(eval $(call SetupVariable,TEST_IMAGE_DIR,$(OUTPUTDIR)/images/test))
$(eval $(call SetupVariable,SYMBOLS_IMAGE_DIR,$(OUTPUTDIR)/images/symbols,NO_CHECK))
$(eval $(call SetupVariable,JTREG_JAVA,$(BOOT_JDK)/bin/java))

# Provide default values for tools that we need
$(eval $(call SetupVariable,MAKE,make,NO_CHECK))
Expand Down Expand Up @@ -248,6 +249,7 @@ $(call CreateNewSpec, $(NEW_SPEC), \
TOPDIR := $(TOPDIR), \
OUTPUTDIR := $(OUTPUTDIR), \
BOOT_JDK := $(BOOT_JDK), \
JTREG_JAVA := $(FIXPATH) $(JTREG_JAVA), \
JT_HOME := $(JT_HOME), \
JDK_IMAGE_DIR := $(JDK_IMAGE_DIR), \
JCOV_IMAGE_DIR := $(JCOV_IMAGE_DIR), \
Expand Down
38 changes: 37 additions & 1 deletion make/autoconf/lib-tests.m4
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,48 @@ AC_DEFUN_ONCE([LIB_TESTS_SETUP_JTREG],
UTIL_FIXUP_PATH(JT_HOME)
AC_SUBST(JT_HOME)
# Specify a JDK for running jtreg. Defaults to the BOOT_JDK.
AC_ARG_WITH(jtreg-jdk, [AS_HELP_STRING([--with-jdk],
[path to JDK for running jtreg @<:@BOOT_JDK@:>@])])
AC_MSG_CHECKING([for jtreg jdk])
if test "x${with_jtreg_jdk}" != x; then
if test "x${with_jtreg_jdk}" = xno; then
AC_MSG_RESULT([no, jtreg jdk not specified])
elif test "x${with_jtreg_jdk}" = xyes; then
AC_MSG_RESULT([not specified])
AC_MSG_ERROR([--with-jtreg-jdk needs a value])
else
JTREG_JDK="${with_jtreg_jdk}"
AC_MSG_RESULT([$JTREG_JDK])
UTIL_FIXUP_PATH(JTREG_JDK)
if test ! -f "$JTREG_JDK/bin/java"; then
AC_MSG_ERROR([Could not find jtreg java at $JTREG_JDK/bin/java])
fi
fi
else
JTREG_JDK="${BOOT_JDK}"
AC_MSG_RESULT([no, using BOOT_JDK])
fi
JTREG_JAVA="$JTREG_JDK/bin/java"
UTIL_FIXUP_PATH(JTREG_JAVA)
JTREG_JAVA="$FIXPATH $JTREG_JAVA"
AC_SUBST([JTREG_JAVA])
# Verify jtreg version
if test "x$JT_HOME" != x; then
AC_MSG_CHECKING([jtreg jar existence])
if test ! -f "$JT_HOME/lib/jtreg.jar"; then
AC_MSG_ERROR([Could not find jtreg jar at $JT_HOME/lib/jtreg.jar])
fi
AC_MSG_CHECKING([jtreg version number])
# jtreg -version looks like this: "jtreg 6.1+1-19"
# Extract actual version part ("6.1" in this case)
jtreg_version_full=`$JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2`
jtreg_version_full=$($JTREG_JAVA -jar $JT_HOME/lib/jtreg.jar -version | $HEAD -n 1 | $CUT -d ' ' -f 2)
jtreg_version=${jtreg_version_full/%+*}
AC_MSG_RESULT([$jtreg_version])
Expand Down
2 changes: 2 additions & 0 deletions make/autoconf/spec.gmk.in
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@ JAVA_FLAGS_SMALL:=@JAVA_FLAGS_SMALL@
BUILDJDK_JAVA_FLAGS_SMALL:=@BUILDJDK_JAVA_FLAGS_SMALL@
JAVA_TOOL_FLAGS_SMALL:=@JAVA_TOOL_FLAGS_SMALL@

JTREG_JAVA:=@JTREG_JAVA@

# The *_CMD variables are defined separately to be easily overridden in bootcycle-spec.gmk
# for bootcycle-images build. Make sure to keep them in sync. Do not use the *_CMD
# versions of the variables directly.
Expand Down
20 changes: 6 additions & 14 deletions src/hotspot/cpu/ppc/continuationFreezeThaw_ppc.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ void FreezeBase::adjust_interpreted_frame_unextended_sp(frame& f) {
// nothing to do
}

static inline void relativize_one(intptr_t* const vfp, intptr_t* const hfp, int offset) {
assert(*(hfp + offset) == *(vfp + offset), "");
intptr_t* addr = hfp + offset;
intptr_t value = *(intptr_t**)addr - vfp;
*addr = value;
}

inline void FreezeBase::relativize_interpreted_frame_metadata(const frame& f, const frame& hf) {
intptr_t* vfp = f.fp();
intptr_t* hfp = hf.fp();
Expand All @@ -90,7 +83,9 @@ inline void FreezeBase::relativize_interpreted_frame_metadata(const frame& f, co
// Make sure that monitors is already relativized.
assert(hf.at_absolute(ijava_idx(monitors)) <= -(frame::ijava_state_size / wordSize), "");

relativize_one(vfp, hfp, ijava_idx(esp));
// Make sure that esp is already relativized.
assert(hf.at_absolute(ijava_idx(esp)) <= hf.at_absolute(ijava_idx(monitors)), "");

// top_frame_sp is already relativized

// hfp == hf.sp() + (f.fp() - f.sp()) is not true on ppc because the stack frame has room for
Expand Down Expand Up @@ -536,18 +531,15 @@ inline intptr_t* ThawBase::align(const frame& hf, intptr_t* frame_sp, frame& cal
return nullptr;
}

static inline void derelativize_one(intptr_t* const fp, int offset) {
intptr_t* addr = fp + offset;
*addr = (intptr_t)(fp + *addr);
}

inline void ThawBase::derelativize_interpreted_frame_metadata(const frame& hf, const frame& f) {
intptr_t* vfp = f.fp();

// Make sure that monitors is still relativized.
assert(f.at_absolute(ijava_idx(monitors)) <= -(frame::ijava_state_size / wordSize), "");

derelativize_one(vfp, ijava_idx(esp));
// Make sure that esp is still relativized.
assert(f.at_absolute(ijava_idx(esp)) <= f.at_absolute(ijava_idx(monitors)), "");

// Keep top_frame_sp relativized.
}

Expand Down
11 changes: 8 additions & 3 deletions src/hotspot/cpu/ppc/frame_ppc.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ inline oop* frame::interpreter_frame_temp_oop_addr() const {
}

inline intptr_t* frame::interpreter_frame_esp() const {
return (intptr_t*) at(ijava_idx(esp));
return (intptr_t*) at_relative(ijava_idx(esp));
}

// Convenient setters
Expand All @@ -235,7 +235,12 @@ inline void frame::interpreter_frame_set_monitor_end(BasicObjectLock* end) {
}

inline void frame::interpreter_frame_set_cpcache(ConstantPoolCache* cp) { *interpreter_frame_cache_addr() = cp; }
inline void frame::interpreter_frame_set_esp(intptr_t* esp) { get_ijava_state()->esp = (intptr_t) esp; }

inline void frame::interpreter_frame_set_esp(intptr_t* esp) {
assert(is_interpreted_frame(), "interpreted frame expected");
// set relativized esp
get_ijava_state()->esp = (intptr_t) (esp - fp());
}

inline void frame::interpreter_frame_set_top_frame_sp(intptr_t* top_frame_sp) {
assert(is_interpreted_frame(), "interpreted frame expected");
Expand All @@ -252,7 +257,7 @@ inline intptr_t* frame::interpreter_frame_expression_stack() const {

// top of expression stack
inline intptr_t* frame::interpreter_frame_tos_address() const {
return (intptr_t*)at(ijava_idx(esp)) + Interpreter::stackElementWords;
return interpreter_frame_esp() + Interpreter::stackElementWords;
}

inline int frame::interpreter_frame_monitor_size() {
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,9 @@ void InterpreterMacroAssembler::call_VM(Register oop_result, address entry_point

void InterpreterMacroAssembler::save_interpreter_state(Register scratch) {
ld(scratch, 0, R1_SP);
std(R15_esp, _ijava_state_neg(esp), scratch);
subf(R0, scratch, R15_esp);
sradi(R0, R0, Interpreter::logStackElementSize);
std(R0, _ijava_state_neg(esp), scratch);
std(R14_bcp, _ijava_state_neg(bcp), scratch);
subf(R0, scratch, R26_monitor);
sradi(R0, R0, Interpreter::logStackElementSize);
Expand Down Expand Up @@ -2245,7 +2247,10 @@ void InterpreterMacroAssembler::restore_interpreter_state(Register scratch, bool
ld(R19_method, _ijava_state_neg(method), scratch);
ld(R27_constPoolCache, _ijava_state_neg(cpoolCache), scratch);
// Following ones are stack addresses and don't require reload.
// Derelativize esp
ld(R15_esp, _ijava_state_neg(esp), scratch);
sldi(R15_esp, R15_esp, Interpreter::logStackElementSize);
add(R15_esp, R15_esp, scratch);
ld(R18_locals, _ijava_state_neg(locals), scratch);
sldi(R18_locals, R18_locals, Interpreter::logStackElementSize);
add(R18_locals, R18_locals, scratch);
Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/cpu/ppc/templateInterpreterGenerator_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,9 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist
__ std(R12_scratch2, _ijava_state_neg(monitors), R1_SP);
__ std(R14_bcp, _ijava_state_neg(bcp), R1_SP);
if (ProfileInterpreter) { __ std(R28_mdx, _ijava_state_neg(mdx), R1_SP); }
__ std(R15_esp, _ijava_state_neg(esp), R1_SP);
__ sub(R12_scratch2, R15_esp, R1_SP);
__ sradi(R12_scratch2, R12_scratch2, Interpreter::logStackElementSize);
__ std(R12_scratch2, _ijava_state_neg(esp), R1_SP);
__ std(R0, _ijava_state_neg(oop_tmp), R1_SP); // only used for native_call

// Store sender's SP and this frame's top SP.
Expand Down
23 changes: 12 additions & 11 deletions src/hotspot/share/interpreter/oopMapCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class OopMapCacheEntry: private InterpreterOopMap {
// Deallocate bit masks and initialize fields
void flush();

static void deallocate(OopMapCacheEntry* const entry);

private:
void allocate_bit_mask(); // allocates the bit mask on C heap f necessary
void deallocate_bit_mask(); // allocates the bit mask on C heap f necessary
Expand Down Expand Up @@ -401,6 +403,10 @@ void OopMapCacheEntry::flush() {
initialize();
}

void OopMapCacheEntry::deallocate(OopMapCacheEntry* const entry) {
entry->flush();
FREE_C_HEAP_OBJ(entry);
}

// Implementation of OopMapCache

Expand Down Expand Up @@ -476,8 +482,7 @@ void OopMapCache::flush() {
OopMapCacheEntry* entry = _array[i];
if (entry != nullptr) {
_array[i] = nullptr; // no barrier, only called in OopMapCache destructor
entry->flush();
FREE_C_HEAP_OBJ(entry);
OopMapCacheEntry::deallocate(entry);
}
}
}
Expand All @@ -496,8 +501,7 @@ void OopMapCache::flush_obsolete_entries() {
entry->method()->name()->as_C_string(), entry->method()->signature()->as_C_string(), i);
}
_array[i] = nullptr;
entry->flush();
FREE_C_HEAP_OBJ(entry);
OopMapCacheEntry::deallocate(entry);
}
}
}
Expand Down Expand Up @@ -544,8 +548,7 @@ void OopMapCache::lookup(const methodHandle& method,
// at this time. We give the caller of lookup() a copy of the
// interesting info via parameter entry_for, but we don't add it to
// the cache. See the gory details in Method*.cpp.
tmp->flush();
FREE_C_HEAP_OBJ(tmp);
OopMapCacheEntry::deallocate(tmp);
return;
}

Expand All @@ -568,7 +571,7 @@ void OopMapCache::lookup(const methodHandle& method,
if (put_at(probe + 0, tmp, old)) {
enqueue_for_cleanup(old);
} else {
enqueue_for_cleanup(tmp);
OopMapCacheEntry::deallocate(tmp);
}

assert(!entry_for->is_empty(), "A non-empty oop map should be returned");
Expand Down Expand Up @@ -603,8 +606,7 @@ void OopMapCache::cleanup_old_entries() {
entry->method()->name_and_sig_as_C_string(), entry->bci());
}
OopMapCacheEntry* next = entry->_next;
entry->flush();
FREE_C_HEAP_OBJ(entry);
OopMapCacheEntry::deallocate(entry);
entry = next;
}
}
Expand All @@ -617,6 +619,5 @@ void OopMapCache::compute_one_oop_map(const methodHandle& method, int bci, Inter
if (tmp->has_valid_mask()) {
entry->resource_copy(tmp);
}
tmp->flush();
FREE_C_HEAP_OBJ(tmp);
OopMapCacheEntry::deallocate(tmp);
}
18 changes: 12 additions & 6 deletions src/hotspot/share/memory/classLoaderMetaspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "memory/metaspace/metaspaceStatistics.hpp"
#include "memory/metaspace/runningCounters.hpp"
#include "memory/metaspaceTracer.hpp"
#include "runtime/mutexLocker.hpp"
#include "utilities/debug.hpp"

using metaspace::ChunkManager;
Expand All @@ -60,7 +61,6 @@ ClassLoaderMetaspace::ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType
_non_class_space_arena = new MetaspaceArena(
non_class_cm,
ArenaGrowthPolicy::policy_for_space_type(space_type, false),
lock,
RunningCounters::used_nonclass_counter(),
"non-class sm");

Expand All @@ -71,7 +71,6 @@ ClassLoaderMetaspace::ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType
_class_space_arena = new MetaspaceArena(
class_cm,
ArenaGrowthPolicy::policy_for_space_type(space_type, true),
lock,
RunningCounters::used_class_counter(),
"class sm");
}
Expand All @@ -82,14 +81,15 @@ ClassLoaderMetaspace::ClassLoaderMetaspace(Mutex* lock, Metaspace::MetaspaceType

ClassLoaderMetaspace::~ClassLoaderMetaspace() {
UL(debug, "dies.");

MutexLocker fcl(lock(), Mutex::_no_safepoint_check_flag);
delete _non_class_space_arena;
delete _class_space_arena;

}

// Allocate word_size words from Metaspace.
MetaWord* ClassLoaderMetaspace::allocate(size_t word_size, Metaspace::MetadataType mdType) {
MutexLocker fcl(lock(), Mutex::_no_safepoint_check_flag);
if (Metaspace::is_class_space_allocation(mdType)) {
return class_space_arena()->allocate(word_size);
} else {
Expand Down Expand Up @@ -131,6 +131,7 @@ MetaWord* ClassLoaderMetaspace::expand_and_allocate(size_t word_size, Metaspace:
// Prematurely returns a metaspace allocation to the _block_freelists
// because it is not needed anymore.
void ClassLoaderMetaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) {
MutexLocker fcl(lock(), Mutex::_no_safepoint_check_flag);
if (Metaspace::using_class_space() && is_class) {
class_space_arena()->deallocate(ptr, word_size);
} else {
Expand All @@ -141,6 +142,7 @@ void ClassLoaderMetaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_c

// Update statistics. This walks all in-use chunks.
void ClassLoaderMetaspace::add_to_statistics(metaspace::ClmsStats* out) const {
MutexLocker fcl(lock(), Mutex::_no_safepoint_check_flag);
if (non_class_space_arena() != nullptr) {
non_class_space_arena()->add_to_statistics(&out->_arena_stats_nonclass);
}
Expand All @@ -151,6 +153,7 @@ void ClassLoaderMetaspace::add_to_statistics(metaspace::ClmsStats* out) const {

#ifdef ASSERT
void ClassLoaderMetaspace::verify() const {
MutexLocker fcl(lock(), Mutex::_no_safepoint_check_flag);
if (non_class_space_arena() != nullptr) {
non_class_space_arena()->verify();
}
Expand All @@ -172,10 +175,13 @@ void ClassLoaderMetaspace::usage_numbers(Metaspace::MetadataType mdType, size_t*
void ClassLoaderMetaspace::usage_numbers(size_t* p_used_words, size_t* p_committed_words,
size_t* p_capacity_words) const {
size_t used_nc, comm_nc, cap_nc;
usage_numbers(Metaspace::MetadataType::NonClassType, &used_nc, &comm_nc, &cap_nc);
size_t used_c = 0, comm_c = 0, cap_c = 0;
if (Metaspace::using_class_space()) {
usage_numbers(Metaspace::MetadataType::ClassType, &used_c, &comm_c, &cap_c);
{
MutexLocker fcl(lock(), Mutex::_no_safepoint_check_flag);
usage_numbers(Metaspace::MetadataType::NonClassType, &used_nc, &comm_nc, &cap_nc);
if (Metaspace::using_class_space()) {
usage_numbers(Metaspace::MetadataType::ClassType, &used_c, &comm_c, &cap_c);
}
}
if (p_used_words != nullptr) {
(*p_used_words) = used_nc + used_c;
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/memory/metaspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ void Metaspace::global_initialize() {

// ...failing that, reserve anywhere, but let platform do optimized placement:
if (!rs.is_reserved()) {
log_info(metaspace)("Reserving compressed class space anywhere");
rs = Metaspace::reserve_address_space_for_compressed_classes(size, true);
}

Expand Down
Loading

0 comments on commit e35338a

Please sign in to comment.