Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Merge upstream-jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
corretto-github-robot committed Apr 23, 2024
2 parents 6fdd2c8 + a93848c commit 81b4fea
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 53 deletions.
32 changes: 17 additions & 15 deletions src/hotspot/cpu/s390/downcallLinker_s390.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, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -138,10 +138,10 @@ void DowncallLinker::StubGenerator::generate() {
locs.set(StubLocations::TARGET_ADDRESS, _abi._scratch2);

if (_captured_state_mask != 0) {
__ block_comment("{ _captured_state_mask is set");
__ block_comment("_captured_state_mask_is_set {");
locs.set_frame_data(StubLocations::CAPTURED_STATE_BUFFER, allocated_frame_size);
allocated_frame_size += BytesPerWord;
__ block_comment("} _captured_state_mask is set");
__ block_comment("} _captured_state_mask_is_set");
}

VMStorage shuffle_reg = _abi._scratch1;
Expand Down Expand Up @@ -176,7 +176,7 @@ void DowncallLinker::StubGenerator::generate() {
_frame_complete = __ pc() - start; // frame build complete.

if (_needs_transition) {
__ block_comment("{ thread java2native");
__ block_comment("thread_java2native {");
__ get_PC(Z_R1_scratch);
address the_pc = __ pc();
__ set_last_Java_frame(Z_SP, Z_R1_scratch);
Expand All @@ -186,21 +186,21 @@ void DowncallLinker::StubGenerator::generate() {

// State transition
__ set_thread_state(_thread_in_native);
__ block_comment("} thread java2native");
__ block_comment("} thread_java2native");
}
if (has_objects) {
add_offsets_to_oops(java_regs, _abi._scratch1, _abi._scratch2);
}
__ block_comment("{ argument shuffle");
__ block_comment("argument shuffle {");
arg_shuffle.generate(_masm, shuffle_reg, frame::z_jit_out_preserve_size, _abi._shadow_space_bytes);
__ block_comment("} argument shuffle");
__ block_comment("} argument_shuffle");

__ call(as_Register(locs.get(StubLocations::TARGET_ADDRESS)));

//////////////////////////////////////////////////////////////////////////////

if (_captured_state_mask != 0) {
__ block_comment("{ save thread local");
__ block_comment("save_thread_local {");

out_reg_spiller.generate_spill(_masm, spill_offset);

Expand All @@ -211,7 +211,7 @@ void DowncallLinker::StubGenerator::generate() {

out_reg_spiller.generate_fill(_masm, spill_offset);

__ block_comment("} save thread local");
__ block_comment("} save_thread_local");
}

//////////////////////////////////////////////////////////////////////////////
Expand All @@ -222,7 +222,7 @@ void DowncallLinker::StubGenerator::generate() {
Label L_after_reguard;

if (_needs_transition) {
__ block_comment("{ thread native2java");
__ block_comment("thread_native2java {");
__ set_thread_state(_thread_in_native_trans);

if (!UseSystemMemoryBarrier) {
Expand All @@ -239,10 +239,12 @@ void DowncallLinker::StubGenerator::generate() {
// change thread state
__ set_thread_state(_thread_in_Java);

__ block_comment("reguard stack check");
__ z_cli(Address(Z_thread, JavaThread::stack_guard_state_offset() + in_ByteSize(sizeof(StackOverflow::StackGuardState) - 1)),
StackOverflow::stack_guard_yellow_reserved_disabled);
__ block_comment("reguard_stack_check {");
__ z_cli(Address(Z_thread,
JavaThread::stack_guard_state_offset() + in_ByteSize(sizeof(StackOverflow::StackGuardState) - 1)),
StackOverflow::stack_guard_yellow_reserved_disabled);
__ z_bre(L_reguard);
__ block_comment("} reguard_stack_check");
__ bind(L_after_reguard);

__ reset_last_Java_frame();
Expand All @@ -256,7 +258,7 @@ void DowncallLinker::StubGenerator::generate() {
//////////////////////////////////////////////////////////////////////////////

if (_needs_transition) {
__ block_comment("{ L_safepoint_poll_slow_path");
__ block_comment("L_safepoint_poll_slow_path {");
__ bind(L_safepoint_poll_slow_path);

// Need to save the native result registers around any runtime calls.
Expand All @@ -272,7 +274,7 @@ void DowncallLinker::StubGenerator::generate() {
__ block_comment("} L_safepoint_poll_slow_path");

//////////////////////////////////////////////////////////////////////////////
__ block_comment("{ L_reguard");
__ block_comment("L_reguard {");
__ bind(L_reguard);

// Need to save the native result registers around any runtime calls.
Expand Down
20 changes: 10 additions & 10 deletions src/hotspot/cpu/s390/upcallLinker_s390.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void preserve_callee_saved_registers(MacroAssembler* _masm, const ABIDesc

int offset = reg_save_area_offset;

__ block_comment("{ preserve_callee_saved_regs ");
__ block_comment("preserve_callee_saved_regs {");
for (int i = 0; i < Register::number_of_registers; i++) {
Register reg = as_Register(i);
// Z_SP saved/restored by prologue/epilogue
Expand All @@ -82,7 +82,7 @@ static void preserve_callee_saved_registers(MacroAssembler* _masm, const ABIDesc
}
}

__ block_comment("} preserve_callee_saved_regs ");
__ block_comment("} preserve_callee_saved_regs");
}

static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescriptor& abi, int reg_save_area_offset) {
Expand All @@ -92,7 +92,7 @@ static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescr

int offset = reg_save_area_offset;

__ block_comment("{ restore_callee_saved_regs ");
__ block_comment("restore_callee_saved_regs {");
for (int i = 0; i < Register::number_of_registers; i++) {
Register reg = as_Register(i);
// Z_SP saved/restored by prologue/epilogue
Expand All @@ -111,7 +111,7 @@ static void restore_callee_saved_registers(MacroAssembler* _masm, const ABIDescr
}
}

__ block_comment("} restore_callee_saved_regs ");
__ block_comment("} restore_callee_saved_regs");
}

static const int upcall_stub_code_base_size = 1024;
Expand Down Expand Up @@ -203,7 +203,7 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
// Java methods won't preserve them, so save them here:
preserve_callee_saved_registers(_masm, abi, reg_save_area_offset);

__ block_comment("{ on_entry");
__ block_comment("on_entry {");
__ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, UpcallLinker::on_entry));
__ z_aghik(Z_ARG1, Z_SP, frame_data_offset);
__ load_const_optimized(Z_ARG2, (intptr_t)receiver);
Expand All @@ -212,13 +212,13 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,
__ block_comment("} on_entry");

arg_spiller.generate_fill(_masm, arg_save_area_offset);
__ block_comment("{ argument shuffle");
__ block_comment("argument_shuffle {");
arg_shuffle.generate(_masm, shuffle_reg, abi._shadow_space_bytes, frame::z_jit_out_preserve_size);
__ block_comment("} argument shuffle");
__ block_comment("} argument_shuffle");

__ block_comment("{ receiver ");
__ block_comment("receiver {");
__ get_vm_result(Z_ARG1);
__ block_comment("} receiver ");
__ block_comment("} receiver");

__ load_const_optimized(Z_method, (intptr_t)entry);
__ z_stg(Z_method, Address(Z_thread, in_bytes(JavaThread::callee_target_offset())));
Expand Down Expand Up @@ -254,7 +254,7 @@ address UpcallLinker::make_upcall_stub(jobject receiver, Method* entry,

result_spiller.generate_spill(_masm, res_save_area_offset);

__ block_comment("{ on_exit");
__ block_comment("on_exit {");
__ load_const_optimized(call_target_address, CAST_FROM_FN_PTR(uint64_t, UpcallLinker::on_exit));
__ z_aghik(Z_ARG1, Z_SP, frame_data_offset);
__ call(call_target_address);
Expand Down
8 changes: 5 additions & 3 deletions src/hotspot/share/gc/parallel/psScavenge.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 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 @@ -704,12 +704,14 @@ bool PSScavenge::should_attempt_scavenge() {

size_t avg_promoted = (size_t) policy->padded_average_promoted_in_bytes();
size_t promotion_estimate = MIN2(avg_promoted, young_gen->used_in_bytes());
bool result = promotion_estimate < old_gen->free_in_bytes();
// Total free size after possible old gen expansion
size_t free_in_old_gen = old_gen->max_gen_size() - old_gen->used_in_bytes();
bool result = promotion_estimate < free_in_old_gen;

log_trace(ergo)("%s scavenge: average_promoted " SIZE_FORMAT " padded_average_promoted " SIZE_FORMAT " free in old gen " SIZE_FORMAT,
result ? "Do" : "Skip", (size_t) policy->average_promoted_in_bytes(),
(size_t) policy->padded_average_promoted_in_bytes(),
old_gen->free_in_bytes());
free_in_old_gen);
if (young_gen->used_in_bytes() < (size_t) policy->padded_average_promoted_in_bytes()) {
log_trace(ergo)(" padded_promoted_average is greater than maximum promotion = " SIZE_FORMAT, young_gen->used_in_bytes());
}
Expand Down
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 @@ -201,6 +201,24 @@ protected void initLibProvidersLookup(
Map<String, ? super Object> params,
LibProvidersLookup libProvidersLookup) {

libProvidersLookup.setPackageLookup(file -> {
Path realPath = file.toRealPath();

try {
// Try the real path first as it works better on newer Ubuntu versions
return findProvidingPackages(realPath);
} catch (IOException ex) {
// Try the default path if differ
if (!realPath.toString().equals(file.toString())) {
return findProvidingPackages(file);
} else {
throw ex;
}
}
});
}

private static Stream<String> findProvidingPackages(Path file) throws IOException {
//
// `dpkg -S` command does glob pattern lookup. If not the absolute path
// to the file is specified it might return mltiple package names.
Expand Down Expand Up @@ -243,32 +261,30 @@ protected void initLibProvidersLookup(
// 4. Arch suffix should be stripped from accepted package names.
//

libProvidersLookup.setPackageLookup(file -> {
Set<String> archPackages = new HashSet<>();
Set<String> otherPackages = new HashSet<>();

Executor.of(TOOL_DPKG, "-S", file.toString())
.saveOutput(true).executeExpectSuccess()
.getOutput().forEach(line -> {
Matcher matcher = PACKAGE_NAME_REGEX.matcher(line);
if (matcher.find()) {
String name = matcher.group(1);
if (name.endsWith(":" + DEB_ARCH)) {
// Strip arch suffix
name = name.substring(0,
name.length() - (DEB_ARCH.length() + 1));
archPackages.add(name);
} else {
otherPackages.add(name);
}
Set<String> archPackages = new HashSet<>();
Set<String> otherPackages = new HashSet<>();

Executor.of(TOOL_DPKG, "-S", file.toString())
.saveOutput(true).executeExpectSuccess()
.getOutput().forEach(line -> {
Matcher matcher = PACKAGE_NAME_REGEX.matcher(line);
if (matcher.find()) {
String name = matcher.group(1);
if (name.endsWith(":" + DEB_ARCH)) {
// Strip arch suffix
name = name.substring(0,
name.length() - (DEB_ARCH.length() + 1));
archPackages.add(name);
} else {
otherPackages.add(name);
}
});
}
});

if (!archPackages.isEmpty()) {
return archPackages.stream();
}
return otherPackages.stream();
});
if (!archPackages.isEmpty()) {
return archPackages.stream();
}
return otherPackages.stream();
}

@Override
Expand Down

0 comments on commit 81b4fea

Please sign in to comment.