Skip to content

Commit

Permalink
Merge branch 'master' into zicond
Browse files Browse the repository at this point in the history
  • Loading branch information
robehn committed Nov 27, 2024
2 parents a65d9e2 + eb0d1ce commit 606acb0
Show file tree
Hide file tree
Showing 217 changed files with 2,326 additions and 5,699 deletions.
23 changes: 5 additions & 18 deletions src/hotspot/cpu/riscv/interp_masm_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,10 @@ void InterpreterMacroAssembler::check_and_handle_earlyret(Register java_thread)

void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, int bcp_offset) {
assert(bcp_offset >= 0, "bcp is still pointing to start of bytecode");
if (AvoidUnalignedAccesses && (bcp_offset % 2)) {
lbu(t1, Address(xbcp, bcp_offset));
lbu(reg, Address(xbcp, bcp_offset + 1));
slli(t1, t1, 8);
add(reg, reg, t1);
} else {
lhu(reg, Address(xbcp, bcp_offset));
revb_h_h_u(reg, reg);
}
lbu(t1, Address(xbcp, bcp_offset));
lbu(reg, Address(xbcp, bcp_offset + 1));
slli(t1, t1, 8);
add(reg, reg, t1);
}

void InterpreterMacroAssembler::get_dispatch() {
Expand All @@ -200,15 +195,7 @@ void InterpreterMacroAssembler::get_cache_index_at_bcp(Register index,
size_t index_size) {
assert(bcp_offset > 0, "bcp is still pointing to start of bytecode");
if (index_size == sizeof(u2)) {
if (AvoidUnalignedAccesses) {
assert_different_registers(index, tmp);
load_unsigned_byte(index, Address(xbcp, bcp_offset));
load_unsigned_byte(tmp, Address(xbcp, bcp_offset + 1));
slli(tmp, tmp, 8);
add(index, index, tmp);
} else {
load_unsigned_short(index, Address(xbcp, bcp_offset));
}
load_short_misaligned(index, Address(xbcp, bcp_offset), tmp, false);
} else if (index_size == sizeof(u4)) {
load_int_misaligned(index, Address(xbcp, bcp_offset), tmp, false);
} else if (index_size == sizeof(u1)) {
Expand Down
26 changes: 8 additions & 18 deletions src/hotspot/cpu/riscv/templateTable_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,10 @@ void TemplateTable::bipush() {

void TemplateTable::sipush() {
transition(vtos, itos);
if (AvoidUnalignedAccesses) {
__ load_signed_byte(x10, at_bcp(1));
__ load_unsigned_byte(t1, at_bcp(2));
__ slli(x10, x10, 8);
__ add(x10, x10, t1);
} else {
__ load_unsigned_short(x10, at_bcp(1));
__ revb_h_h(x10, x10); // reverse bytes in half-word and sign-extend
}
__ load_signed_byte(x10, at_bcp(1));
__ load_unsigned_byte(t1, at_bcp(2));
__ slli(x10, x10, 8);
__ add(x10, x10, t1);
}

void TemplateTable::ldc(LdcType type) {
Expand Down Expand Up @@ -1626,15 +1621,10 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) {

// load branch displacement
if (!is_wide) {
if (AvoidUnalignedAccesses) {
__ lb(x12, at_bcp(1));
__ lbu(t1, at_bcp(2));
__ slli(x12, x12, 8);
__ add(x12, x12, t1);
} else {
__ lhu(x12, at_bcp(1));
__ revb_h_h(x12, x12); // reverse bytes in half-word and sign-extend
}
__ lb(x12, at_bcp(1));
__ lbu(t1, at_bcp(2));
__ slli(x12, x12, 8);
__ add(x12, x12, t1);
} else {
__ lwu(x12, at_bcp(1));
__ revb_w_w(x12, x12); // reverse bytes in word and sign-extend
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/cpu/x86/macroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4912,6 +4912,10 @@ void MacroAssembler::population_count(Register dst, Register src,
}
bind(done);
}
#ifdef ASSERT
mov64(scratch1, 0xCafeBabeDeadBeef);
movq(scratch2, scratch1);
#endif
}

// Ensure that the inline code and the stub are using the same registers.
Expand Down Expand Up @@ -5113,6 +5117,7 @@ void MacroAssembler::lookup_secondary_supers_table_var(Register r_sub_klass,
const Register r_array_base = *available_regs++;

// Get the first array index that can contain super_klass into r_array_index.
// Note: Clobbers r_array_base and slot.
population_count(r_array_index, r_array_index, /*temp2*/r_array_base, /*temp3*/slot);

// NB! r_array_index is off by 1. It is compensated by keeping r_array_base off by 1 word.
Expand All @@ -5130,7 +5135,7 @@ void MacroAssembler::lookup_secondary_supers_table_var(Register r_sub_klass,
jccb(Assembler::equal, L_success);

// Restore slot to its true value
xorl(slot, (u1)(Klass::SECONDARY_SUPERS_TABLE_SIZE - 1)); // slot ^ 63 === 63 - slot (mod 64)
movb(slot, Address(r_super_klass, Klass::hash_slot_offset()));

// Linear probe. Rotate the bitmap so that the next bit to test is
// in Bit 1.
Expand Down
42 changes: 41 additions & 1 deletion src/hotspot/os/posix/os_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2111,7 +2111,7 @@ void os::shutdown() {
// easily trigger secondary faults in those threads. To reduce the likelihood
// of that we use _exit rather than exit, so that no atexit hooks get run.
// But note that os::shutdown() could also trigger secondary faults.
void os::abort(bool dump_core, void* siginfo, const void* context) {
void os::abort(bool dump_core, const void* siginfo, const void* context) {
os::shutdown();
if (dump_core) {
LINUX_ONLY(if (DumpPrivateMappingsInCore) ClassLoader::close_jrt_image();)
Expand Down Expand Up @@ -2186,3 +2186,43 @@ char* os::pd_map_memory(int fd, const char* unused,
bool os::pd_unmap_memory(char* addr, size_t bytes) {
return munmap(addr, bytes) == 0;
}

#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
static ucontext_t _saved_assert_context;
static bool _has_saved_context = false;
#endif // CAN_SHOW_REGISTERS_ON_ASSERT

void os::save_assert_context(const void* ucVoid) {
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
assert(ucVoid != nullptr, "invariant");
assert(!_has_saved_context, "invariant");
memcpy(&_saved_assert_context, ucVoid, sizeof(ucontext_t));
// on Linux ppc64, ucontext_t contains pointers into itself which have to be patched up
// after copying the context (see comment in sys/ucontext.h):
#if defined(PPC64)
*((void**)&_saved_assert_context.uc_mcontext.regs) = &(_saved_assert_context.uc_mcontext.gp_regs);
#elif defined(AMD64)
// In the copied version, fpregs should point to the copied contents.
// Sanity check: fpregs should point into the context.
if ((address)((const ucontext_t*)ucVoid)->uc_mcontext.fpregs > (address)ucVoid) {
size_t fpregs_offset = pointer_delta(((const ucontext_t*)ucVoid)->uc_mcontext.fpregs, ucVoid, 1);
if (fpregs_offset < sizeof(ucontext_t)) {
// Preserve the offset.
*((void**)&_saved_assert_context.uc_mcontext.fpregs) = (void*)((address)(void*)&_saved_assert_context + fpregs_offset);
}
}
#endif
_has_saved_context = true;
#endif // CAN_SHOW_REGISTERS_ON_ASSERT
}

const void* os::get_saved_assert_context(const void** sigInfo) {
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
assert(sigInfo != nullptr, "invariant");
*sigInfo = nullptr;
return _has_saved_context ? &_saved_assert_context : nullptr;
#endif
*sigInfo = nullptr;
return nullptr;
}

15 changes: 11 additions & 4 deletions src/hotspot/os/posix/signals_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,8 @@ int JVM_HANDLE_XXX_SIGNAL(int sig, siginfo_t* info,

// Handle assertion poison page accesses.
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
if (!signal_was_handled &&
((sig == SIGSEGV || sig == SIGBUS) && info != nullptr && info->si_addr == g_assert_poison)) {
signal_was_handled = handle_assert_poison_fault(ucVoid, info->si_addr);
if (VMError::was_assert_poison_crash(info)) {
signal_was_handled = handle_assert_poison_fault(ucVoid);
}
#endif

Expand Down Expand Up @@ -1136,8 +1135,16 @@ static const char* get_signal_name(int sig, char* out, size_t outlen) {
}

void os::print_siginfo(outputStream* os, const void* si0) {
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
// If we are here because of an assert/guarantee, we suppress
// printing the siginfo, because it is only an implementation
// detail capturing the context for said assert/guarantee.
if (VMError::was_assert_poison_crash(si0)) {
return;
}
#endif

const siginfo_t* const si = (const siginfo_t*) si0;
const siginfo_t* const si = (const siginfo_t*)si0;

char buf[20];
os->print("siginfo:");
Expand Down
15 changes: 13 additions & 2 deletions src/hotspot/os/posix/vmError_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ static void crash_handler(int sig, siginfo_t* info, void* context) {

// Needed because asserts may happen in error handling too.
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
if ((sig == SIGSEGV || sig == SIGBUS) && info != nullptr && info->si_addr == g_assert_poison) {
if (handle_assert_poison_fault(context, info->si_addr)) {
if (VMError::was_assert_poison_crash(info)) {
if (handle_assert_poison_fault(context)) {
return;
}
}
Expand Down Expand Up @@ -127,3 +127,14 @@ void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {
}
#endif
}

bool VMError::was_assert_poison_crash(const void* siginfo) {
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
if (siginfo == nullptr) {
return false;
}
const siginfo_t* const si = (siginfo_t*)siginfo;
return (si->si_signo == SIGSEGV || si->si_signo == SIGBUS) && si->si_addr == g_assert_poison_read_only;
#endif
return false;
}
44 changes: 43 additions & 1 deletion src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#include "services/runtimeService.hpp"
#include "symbolengine.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
#include "utilities/decoder.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/events.hpp"
Expand Down Expand Up @@ -1317,7 +1318,7 @@ void os::check_core_dump_prerequisites(char* buffer, size_t bufferSize, bool che
}
}

void os::abort(bool dump_core, void* siginfo, const void* context) {
void os::abort(bool dump_core, const void* siginfo, const void* context) {
EXCEPTION_POINTERS ep;
MINIDUMP_EXCEPTION_INFORMATION mei;
MINIDUMP_EXCEPTION_INFORMATION* pmei;
Expand Down Expand Up @@ -2112,7 +2113,17 @@ bool os::signal_sent_by_kill(const void* siginfo) {
}

void os::print_siginfo(outputStream *st, const void* siginfo) {
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
// If we are here because of an assert/guarantee, we suppress
// printing the siginfo, because it is only an implementation
// detail capturing the context for said assert/guarantee.
if (VMError::was_assert_poison_crash(siginfo)) {
return;
}
#endif

const EXCEPTION_RECORD* const er = (EXCEPTION_RECORD*)siginfo;

st->print("siginfo:");

char tmp[64];
Expand Down Expand Up @@ -2625,6 +2636,14 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
#endif
#endif

#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
if (VMError::was_assert_poison_crash(exception_record)) {
if (handle_assert_poison_fault(exceptionInfo)) {
return EXCEPTION_CONTINUE_EXECUTION;
}
}
#endif

if (t != nullptr && t->is_Java_thread()) {
JavaThread* thread = JavaThread::cast(t);
bool in_java = thread->thread_state() == _thread_in_Java;
Expand Down Expand Up @@ -6165,3 +6184,26 @@ void os::print_user_info(outputStream* st) {
void os::print_active_locale(outputStream* st) {
// not implemented yet
}

static CONTEXT _saved_assert_context;
static EXCEPTION_RECORD _saved_exception_record;
static bool _has_saved_context = false;

void os::save_assert_context(const void* ucVoid) {
assert(ucVoid != nullptr, "invariant");
assert(!_has_saved_context, "invariant");
const EXCEPTION_POINTERS* ep = static_cast<const EXCEPTION_POINTERS*>(ucVoid);
memcpy(&_saved_assert_context, ep->ContextRecord, sizeof(CONTEXT));
memcpy(&_saved_exception_record, ep->ExceptionRecord, sizeof(EXCEPTION_RECORD));
_has_saved_context = true;
}

const void* os::get_saved_assert_context(const void** sigInfo) {
assert(sigInfo != nullptr, "invariant");
if (_has_saved_context) {
*sigInfo = &_saved_exception_record;
return &_saved_assert_context;
}
*sigInfo = nullptr;
return nullptr;
}
22 changes: 18 additions & 4 deletions src/hotspot/os/windows/vmError_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "runtime/arguments.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/os.hpp"
#include "utilities/debug.hpp"
#include "utilities/vmError.hpp"

LONG WINAPI crash_handler(struct _EXCEPTION_POINTERS* exceptionInfo) {
Expand Down Expand Up @@ -67,10 +68,23 @@ void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {
void VMError::reporting_started() {}
void VMError::interrupt_reporting_thread() {}

void VMError::raise_fail_fast(void* exrecord, void* context) {
void VMError::raise_fail_fast(const void* exrecord, const void* context) {
DWORD flags = (exrecord == nullptr) ? FAIL_FAST_GENERATE_EXCEPTION_ADDRESS : 0;
RaiseFailFastException(static_cast<PEXCEPTION_RECORD>(exrecord),
static_cast<PCONTEXT>(context),
flags);
PEXCEPTION_RECORD exception_record = static_cast<PEXCEPTION_RECORD>(const_cast<void*>(exrecord));
PCONTEXT ctx = static_cast<PCONTEXT>(const_cast<void*>(context));
RaiseFailFastException(exception_record, ctx, flags);
::abort();
}

bool VMError::was_assert_poison_crash(const void* siginfo) {
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
if (siginfo == nullptr) {
return false;
}
const EXCEPTION_RECORD* const er = (EXCEPTION_RECORD*)siginfo;
if (er->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && er->NumberParameters >= 2) {
return (void*)er->ExceptionInformation[1] == g_assert_poison_read_only;
}
#endif
return false;
}
38 changes: 37 additions & 1 deletion src/hotspot/share/cds/filemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@
#include "memory/oopFactory.hpp"
#include "memory/universe.hpp"
#include "nmt/memTracker.hpp"
#include "oops/access.hpp"
#include "oops/compressedOops.hpp"
#include "oops/compressedOops.inline.hpp"
#include "oops/compressedKlass.hpp"
#include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp"
#include "oops/typeArrayKlass.hpp"
#include "prims/jvmtiExport.hpp"
#include "runtime/arguments.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.hpp"
#include "runtime/vm_version.hpp"
Expand Down Expand Up @@ -2678,11 +2681,44 @@ ClassFileStream* FileMapInfo::open_stream_for_jvmti(InstanceKlass* ik, Handle cl
const char* const file_name = ClassLoader::file_name_for_class_name(class_name,
name->utf8_length());
ClassLoaderData* loader_data = ClassLoaderData::class_loader_data(class_loader());
ClassFileStream* cfs = cpe->open_stream_for_loader(THREAD, file_name, loader_data);
ClassFileStream* cfs;
if (class_loader() != nullptr && !cpe->is_modules_image()) {
cfs = get_stream_from_class_loader(class_loader, cpe, file_name, CHECK_NULL);
} else {
cfs = cpe->open_stream_for_loader(THREAD, file_name, loader_data);
}
assert(cfs != nullptr, "must be able to read the classfile data of shared classes for built-in loaders.");
log_debug(cds, jvmti)("classfile data for %s [%d: %s] = %d bytes", class_name, path_index,
cfs->source(), cfs->length());
return cfs;
}

ClassFileStream* FileMapInfo::get_stream_from_class_loader(Handle class_loader,
ClassPathEntry* cpe,
const char* file_name,
TRAPS) {
JavaValue result(T_OBJECT);
TempNewSymbol class_name_sym = SymbolTable::new_symbol(file_name);
Handle ext_class_name = java_lang_String::externalize_classname(class_name_sym, CHECK_NULL);

// byte[] ClassLoader.getResourceAsByteArray(String name)
JavaCalls::call_virtual(&result,
class_loader,
vmClasses::ClassLoader_klass(),
vmSymbols::getResourceAsByteArray_name(),
vmSymbols::getResourceAsByteArray_signature(),
ext_class_name,
CHECK_NULL);
assert(result.get_type() == T_OBJECT, "just checking");
oop obj = result.get_oop();
assert(obj != nullptr, "ClassLoader.getResourceAsByteArray should not return null");

// copy from byte[] to a buffer
typeArrayOop ba = typeArrayOop(obj);
jint len = ba->length();
u1* buffer = NEW_RESOURCE_ARRAY(u1, len);
ArrayAccess<>::arraycopy_to_native<>(ba, typeArrayOopDesc::element_offset<jbyte>(0), buffer, len);

return new ClassFileStream(buffer, len, cpe->name());
}
#endif
Loading

0 comments on commit 606acb0

Please sign in to comment.