Skip to content

Commit 16f9d58

Browse files
committed
Move nmethod entry barrier code up in the signal handler.
1 parent cd3bd58 commit 16f9d58

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2012, 2024 SAP SE. All rights reserved.
3+
* Copyright (c) 2012, 2025 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -254,6 +254,18 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
254254
goto run_stub;
255255
}
256256

257+
// SIGTRAP-based nmethod entry barriers.
258+
else if (sig == SIGTRAP && TrapBasedNMethodEntryBarriers &&
259+
nativeInstruction_at(pc)->is_sigtrap_nmethod_entry_barrier() &&
260+
CodeCache::contains((void*) pc)) {
261+
if (TraceTraps) {
262+
tty->print_cr("trap: nmethod entry barrier at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc));
263+
}
264+
stub = StubRoutines::method_entry_barrier();
265+
uc->uc_mcontext.jmp_context.lr = (uintptr_t)(pc + BytesPerInstWord); // emulate call by setting LR
266+
goto run_stub;
267+
}
268+
257269
// SIGTRAP-based ic miss check in compiled code.
258270
else if (sig == SIGTRAP && TrapBasedICMissChecks &&
259271
nativeInstruction_at(pc)->is_sigtrap_ic_miss_check()) {
@@ -282,6 +294,7 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
282294
tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc));
283295
}
284296
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
297+
goto run_stub;
285298
}
286299

287300
#ifdef COMPILER2
@@ -296,17 +309,6 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
296309
}
297310
#endif
298311

299-
// SIGTRAP-based nmethod entry barriers.
300-
else if (sig == SIGTRAP && TrapBasedNMethodEntryBarriers &&
301-
nativeInstruction_at(pc)->is_sigtrap_nmethod_entry_barrier() &&
302-
CodeCache::contains((void*) pc)) {
303-
if (TraceTraps) {
304-
tty->print_cr("trap: nmethod entry barrier at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc));
305-
}
306-
stub = StubRoutines::method_entry_barrier();
307-
uc->uc_mcontext.jmp_context.lr = (uintptr_t)(pc + BytesPerInstWord); // emulate call by setting LR
308-
}
309-
310312
else if (sig == SIGFPE /* && info->si_code == FPE_INTDIV */) {
311313
if (TraceTraps) {
312314
tty->print_raw_cr("Fix SIGFPE handler, trying divide by zero handler.");

src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
3-
* Copyright (c) 2012, 2024 SAP SE. All rights reserved.
3+
* Copyright (c) 2012, 2025 SAP SE. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
66
* This code is free software; you can redistribute it and/or modify it
@@ -286,6 +286,17 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
286286
stub = SharedRuntime::polling_page_return_handler_blob()->entry_point();
287287
}
288288

289+
// SIGTRAP-based nmethod entry barriers.
290+
else if (sig == SIGTRAP && TrapBasedNMethodEntryBarriers &&
291+
nativeInstruction_at(pc)->is_sigtrap_nmethod_entry_barrier() &&
292+
CodeCache::contains((void*) pc)) {
293+
if (TraceTraps) {
294+
tty->print_cr("trap: nmethod entry barrier at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc));
295+
}
296+
stub = StubRoutines::method_entry_barrier();
297+
uc->uc_mcontext.regs->link = (uintptr_t)(pc + BytesPerInstWord); // emulate call by setting LR
298+
}
299+
289300
// SIGTRAP-based ic miss check in compiled code.
290301
else if (sig == SIGTRAP && TrapBasedICMissChecks &&
291302
nativeInstruction_at(pc)->is_sigtrap_ic_miss_check()) {
@@ -325,17 +336,6 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
325336
}
326337
#endif
327338

328-
// SIGTRAP-based nmethod entry barriers.
329-
else if (sig == SIGTRAP && TrapBasedNMethodEntryBarriers &&
330-
nativeInstruction_at(pc)->is_sigtrap_nmethod_entry_barrier() &&
331-
CodeCache::contains((void*) pc)) {
332-
if (TraceTraps) {
333-
tty->print_cr("trap: nmethod entry barrier at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc));
334-
}
335-
stub = StubRoutines::method_entry_barrier();
336-
uc->uc_mcontext.regs->link = (uintptr_t)(pc + BytesPerInstWord); // emulate call by setting LR
337-
}
338-
339339
// stop on request
340340
else if (sig == SIGTRAP && (stop_type = nativeInstruction_at(pc)->get_stop_type()) != -1) {
341341
bool msg_present = (stop_type & MacroAssembler::stop_msg_present);

0 commit comments

Comments
 (0)