Skip to content

Commit a08ab5d

Browse files
authored
Merge branch 'openjdk:master' into backport-mrserb-762423d6-master
2 parents 1232635 + a3442fd commit a08ab5d

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,3 +1850,15 @@ void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register t
18501850
bind(profile_continue);
18511851
}
18521852
}
1853+
1854+
#ifdef ASSERT
1855+
void InterpreterMacroAssembler::verify_field_offset(Register reg) {
1856+
// Verify the field offset is not in the header, implicitly checks for 0
1857+
Label L;
1858+
subs(zr, reg, static_cast<int>(sizeof(markWord) + (UseCompressedClassPointers ? sizeof(narrowKlass) : sizeof(Klass*))));
1859+
br(Assembler::GE, L);
1860+
stop("bad field offset");
1861+
bind(L);
1862+
}
1863+
#endif
1864+

src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ class InterpreterMacroAssembler: public MacroAssembler {
292292
set_last_Java_frame(esp, rfp, (address) pc(), rscratch1);
293293
MacroAssembler::_call_Unimplemented(call_site);
294294
}
295+
296+
void verify_field_offset(Register reg) NOT_DEBUG_RETURN;
295297
};
296298

297299
#endif // CPU_AARCH64_INTERP_MASM_AARCH64_HPP

src/hotspot/cpu/aarch64/templateTable_aarch64.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
165165
Register temp_reg, bool load_bc_into_bc_reg/*=true*/,
166166
int byte_no)
167167
{
168+
assert_different_registers(bc_reg, temp_reg);
168169
if (!RewriteBytecodes) return;
169170
Label L_patch_done;
170171

@@ -222,8 +223,12 @@ void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
222223
__ bind(L_okay);
223224
#endif
224225

225-
// patch bytecode
226-
__ strb(bc_reg, at_bcp(0));
226+
// Patch bytecode with release store to coordinate with ConstantPoolCacheEntry loads
227+
// in fast bytecode codelets. The fast bytecode codelets have a memory barrier that gains
228+
// the needed ordering, together with control dependency on entering the fast codelet
229+
// itself.
230+
__ lea(temp_reg, at_bcp(0));
231+
__ stlrb(bc_reg, temp_reg);
227232
__ bind(L_patch_done);
228233
}
229234

@@ -2914,6 +2919,7 @@ void TemplateTable::fast_storefield(TosState state)
29142919

29152920
// replace index with field offset from cache entry
29162921
__ ldr(r1, Address(r2, in_bytes(base + ConstantPoolCacheEntry::f2_offset())));
2922+
__ verify_field_offset(r1);
29172923

29182924
{
29192925
Label notVolatile;
@@ -3007,6 +3013,8 @@ void TemplateTable::fast_accessfield(TosState state)
30073013

30083014
__ ldr(r1, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
30093015
ConstantPoolCacheEntry::f2_offset())));
3016+
__ verify_field_offset(r1);
3017+
30103018
__ ldrw(r3, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
30113019
ConstantPoolCacheEntry::flags_offset())));
30123020

@@ -3074,8 +3082,13 @@ void TemplateTable::fast_xaccess(TosState state)
30743082
__ ldr(r0, aaddress(0));
30753083
// access constant pool cache
30763084
__ get_cache_and_index_at_bcp(r2, r3, 2);
3085+
3086+
// Must prevent reordering of the following cp cache loads with bytecode load
3087+
__ membar(MacroAssembler::LoadLoad);
3088+
30773089
__ ldr(r1, Address(r2, in_bytes(ConstantPoolCache::base_offset() +
30783090
ConstantPoolCacheEntry::f2_offset())));
3091+
__ verify_field_offset(r1);
30793092

30803093
// 8179954: We need to make sure that the code generated for
30813094
// volatile accesses forms a sequentially-consistent set of

src/hotspot/os/posix/signals_posix.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static address get_signal_handler(const struct sigaction* action) {
770770

771771
typedef int (*os_sigaction_t)(int, const struct sigaction *, struct sigaction *);
772772

773-
static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context);
773+
static void SR_handler(int sig, siginfo_t* siginfo, void* ucVoid);
774774

775775
// Semantically compare two sigaction structures. Return true if they are referring to
776776
// the same handler, using the same flags.
@@ -1565,8 +1565,8 @@ static void resume_clear_context(OSThread *osthread) {
15651565
osthread->set_siginfo(NULL);
15661566
}
15671567

1568-
static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, ucontext_t* context) {
1569-
osthread->set_ucontext(context);
1568+
static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, void* ucVoid) {
1569+
osthread->set_ucontext((ucontext_t*)ucVoid);
15701570
osthread->set_siginfo(siginfo);
15711571
}
15721572

@@ -1583,7 +1583,7 @@ static void suspend_save_context(OSThread *osthread, siginfo_t* siginfo, ucontex
15831583
//
15841584
// Currently only ever called on the VMThread and JavaThreads (PC sampling)
15851585
//
1586-
static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
1586+
static void SR_handler(int sig, siginfo_t* siginfo, void* ucVoid) {
15871587

15881588
// Save and restore errno to avoid confusing native code with EINTR
15891589
// after sigsuspend.
@@ -1611,7 +1611,7 @@ static void SR_handler(int sig, siginfo_t* siginfo, ucontext_t* context) {
16111611
os::SuspendResume::State current = osthread->sr.state();
16121612

16131613
if (current == os::SuspendResume::SR_SUSPEND_REQUEST) {
1614-
suspend_save_context(osthread, siginfo, context);
1614+
suspend_save_context(osthread, siginfo, ucVoid);
16151615

16161616
// attempt to switch the state, we assume we had a SUSPEND_REQUEST
16171617
os::SuspendResume::State state = osthread->sr.suspended();
@@ -1680,7 +1680,7 @@ int SR_initialize() {
16801680

16811681
// Set up signal handler for suspend/resume
16821682
act.sa_flags = SA_RESTART|SA_SIGINFO;
1683-
act.sa_handler = (void (*)(int)) SR_handler;
1683+
act.sa_sigaction = SR_handler;
16841684

16851685
// SR_signum is blocked by default.
16861686
pthread_sigmask(SIG_BLOCK, NULL, &act.sa_mask);

0 commit comments

Comments
 (0)