Skip to content

Commit 10e3841

Browse files
committed
community
1 parent 9927ec0 commit 10e3841

File tree

110 files changed

+2724
-1332
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+2724
-1332
lines changed

src/hotspot/cpu/aarch64/frame_aarch64.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,6 @@ void JavaFrameAnchor::make_walkable() {
828828
// already walkable?
829829
if (walkable()) return;
830830
vmassert(last_Java_sp() != nullptr, "not called from Java code?");
831-
vmassert(last_Java_pc() == nullptr, "already walkable");
832831
_last_Java_pc = (address)_last_Java_sp[-1];
833832
vmassert(walkable(), "something went wrong");
834833
}

src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -35,6 +35,53 @@
3535

3636
// Inline functions for AArch64 frames:
3737

38+
#if INCLUDE_JFR
39+
40+
// Static helper routines
41+
42+
inline address frame::interpreter_bcp(const intptr_t* fp) {
43+
assert(fp != nullptr, "invariant");
44+
return reinterpret_cast<address>(fp[frame::interpreter_frame_bcp_offset]);
45+
}
46+
47+
inline address frame::interpreter_return_address(const intptr_t* fp) {
48+
assert(fp != nullptr, "invariant");
49+
return reinterpret_cast<address>(fp[frame::return_addr_offset]);
50+
}
51+
52+
inline intptr_t* frame::interpreter_sender_sp(const intptr_t* fp) {
53+
assert(fp != nullptr, "invariant");
54+
return reinterpret_cast<intptr_t*>(fp[frame::interpreter_frame_sender_sp_offset]);
55+
}
56+
57+
inline bool frame::is_interpreter_frame_setup_at(const intptr_t* fp, const void* sp) {
58+
assert(fp != nullptr, "invariant");
59+
assert(sp != nullptr, "invariant");
60+
return sp <= fp + frame::interpreter_frame_initial_sp_offset;
61+
}
62+
63+
inline intptr_t* frame::sender_sp(intptr_t* fp) {
64+
assert(fp != nullptr, "invariant");
65+
return fp + frame::sender_sp_offset;
66+
}
67+
68+
inline intptr_t* frame::link(const intptr_t* fp) {
69+
assert(fp != nullptr, "invariant");
70+
return reinterpret_cast<intptr_t*>(fp[frame::link_offset]);
71+
}
72+
73+
inline address frame::return_address(const intptr_t* sp) {
74+
assert(sp != nullptr, "invariant");
75+
return reinterpret_cast<address>(sp[-1]);
76+
}
77+
78+
inline intptr_t* frame::fp(const intptr_t* sp) {
79+
assert(sp != nullptr, "invariant");
80+
return reinterpret_cast<intptr_t*>(sp[-2]);
81+
}
82+
83+
#endif // INCLUDE_JFR
84+
3885
// Constructors:
3986

4087
inline frame::frame() {

src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,10 @@ void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
458458

459459
// remove activation
460460
//
461-
// Apply stack watermark barrier.
462461
// Unlock the receiver if this is a synchronized method.
463462
// Unlock any Java monitors from synchronized blocks.
463+
// Apply stack watermark barrier.
464+
// Notify JVMTI.
464465
// Remove the activation from the stack.
465466
//
466467
// If there are locked Java monitors
@@ -470,30 +471,14 @@ void InterpreterMacroAssembler::dispatch_via(TosState state, address* table) {
470471
// installs IllegalMonitorStateException
471472
// Else
472473
// no error processing
473-
void InterpreterMacroAssembler::remove_activation(
474-
TosState state,
475-
bool throw_monitor_exception,
476-
bool install_monitor_exception,
477-
bool notify_jvmdi) {
474+
void InterpreterMacroAssembler::remove_activation(TosState state,
475+
bool throw_monitor_exception,
476+
bool install_monitor_exception,
477+
bool notify_jvmdi) {
478478
// Note: Registers r3 xmm0 may be in use for the
479479
// result check if synchronized method
480480
Label unlocked, unlock, no_unlock;
481481

482-
// The below poll is for the stack watermark barrier. It allows fixing up frames lazily,
483-
// that would normally not be safe to use. Such bad returns into unsafe territory of
484-
// the stack, will call InterpreterRuntime::at_unwind.
485-
Label slow_path;
486-
Label fast_path;
487-
safepoint_poll(slow_path, true /* at_return */, false /* acquire */, false /* in_nmethod */);
488-
br(Assembler::AL, fast_path);
489-
bind(slow_path);
490-
push(state);
491-
set_last_Java_frame(esp, rfp, (address)pc(), rscratch1);
492-
super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::at_unwind), rthread);
493-
reset_last_Java_frame(true);
494-
pop(state);
495-
bind(fast_path);
496-
497482
// get the value of _do_not_unlock_if_synchronized into r3
498483
const Address do_not_unlock_if_synchronized(rthread,
499484
in_bytes(JavaThread::do_not_unlock_if_synchronized_offset()));
@@ -611,7 +596,24 @@ void InterpreterMacroAssembler::remove_activation(
611596

612597
bind(no_unlock);
613598

614-
// jvmti support
599+
JFR_ONLY(enter_jfr_critical_section();)
600+
601+
// The below poll is for the stack watermark barrier. It allows fixing up frames lazily,
602+
// that would normally not be safe to use. Such bad returns into unsafe territory of
603+
// the stack, will call InterpreterRuntime::at_unwind.
604+
Label slow_path;
605+
Label fast_path;
606+
safepoint_poll(slow_path, true /* at_return */, false /* acquire */, false /* in_nmethod */);
607+
br(Assembler::AL, fast_path);
608+
bind(slow_path);
609+
push(state);
610+
set_last_Java_frame(esp, rfp, pc(), rscratch1);
611+
super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::at_unwind), rthread);
612+
reset_last_Java_frame(true);
613+
pop(state);
614+
bind(fast_path);
615+
616+
// JVMTI support. Make sure the safepoint poll test is issued prior.
615617
if (notify_jvmdi) {
616618
notify_method_exit(state, NotifyJVMTI); // preserve TOSCA
617619
} else {
@@ -638,6 +640,8 @@ void InterpreterMacroAssembler::remove_activation(
638640
cmp(rscratch2, rscratch1);
639641
br(Assembler::LS, no_reserved_zone_enabling);
640642

643+
JFR_ONLY(leave_jfr_critical_section();)
644+
641645
call_VM_leaf(
642646
CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), rthread);
643647
call_VM(noreg, CAST_FROM_FN_PTR(address,
@@ -647,17 +651,34 @@ void InterpreterMacroAssembler::remove_activation(
647651
bind(no_reserved_zone_enabling);
648652
}
649653

650-
// restore sender esp
651-
mov(esp, rscratch2);
652654
// remove frame anchor
653655
leave();
656+
657+
JFR_ONLY(leave_jfr_critical_section();)
658+
659+
// restore sender esp
660+
mov(esp, rscratch2);
661+
654662
// If we're returning to interpreted code we will shortly be
655663
// adjusting SP to allow some space for ESP. If we're returning to
656664
// compiled code the saved sender SP was saved in sender_sp, so this
657665
// restores it.
658666
andr(sp, esp, -16);
659667
}
660668

669+
#if INCLUDE_JFR
670+
void InterpreterMacroAssembler::enter_jfr_critical_section() {
671+
const Address sampling_critical_section(rthread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
672+
mov(rscratch1, true);
673+
strb(rscratch1, sampling_critical_section);
674+
}
675+
676+
void InterpreterMacroAssembler::leave_jfr_critical_section() {
677+
const Address sampling_critical_section(rthread, in_bytes(SAMPLING_CRITICAL_SECTION_OFFSET_JFR));
678+
strb(zr, sampling_critical_section);
679+
}
680+
#endif // INCLUDE_JFR
681+
661682
// Lock object
662683
//
663684
// Args:

src/hotspot/cpu/aarch64/interp_masm_aarch64.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved.
44
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
*
@@ -310,6 +310,9 @@ class InterpreterMacroAssembler: public MacroAssembler {
310310
void notify_method_entry();
311311
void notify_method_exit(TosState state, NotifyMethodExitMode mode);
312312

313+
JFR_ONLY(void enter_jfr_critical_section();)
314+
JFR_ONLY(void leave_jfr_critical_section();)
315+
313316
virtual void _call_Unimplemented(address call_site) {
314317
save_bcp();
315318
set_last_Java_frame(esp, rfp, (address) pc(), rscratch1);

src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,23 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
19851985

19861986
__ leave();
19871987

1988+
#if INCLUDE_JFR
1989+
// We need to do a poll test after unwind in case the sampler
1990+
// managed to sample the native frame after returning to Java.
1991+
Label L_return;
1992+
__ ldr(rscratch1, Address(rthread, JavaThread::polling_word_offset()));
1993+
address poll_test_pc = __ pc();
1994+
__ relocate(relocInfo::poll_return_type);
1995+
__ tbz(rscratch1, log2i_exact(SafepointMechanism::poll_bit()), L_return);
1996+
assert(SharedRuntime::polling_page_return_handler_blob() != nullptr,
1997+
"polling page return stub not created yet");
1998+
address stub = SharedRuntime::polling_page_return_handler_blob()->entry_point();
1999+
__ adr(rscratch1, InternalAddress(poll_test_pc));
2000+
__ str(rscratch1, Address(rthread, JavaThread::saved_exception_pc_offset()));
2001+
__ far_jump(RuntimeAddress(stub));
2002+
__ bind(L_return);
2003+
#endif // INCLUDE_JFR
2004+
19882005
// Any exception pending?
19892006
__ ldr(rscratch1, Address(rthread, in_bytes(Thread::pending_exception_offset())));
19902007
__ cbnz(rscratch1, exception_pending);

src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,30 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
15931593
__ bind(L);
15941594
}
15951595

1596+
#if INCLUDE_JFR
1597+
__ enter_jfr_critical_section();
1598+
1599+
// This poll test is to uphold the invariant that a JFR sampled frame
1600+
// must not return to its caller without a prior safepoint poll check.
1601+
// The earlier poll check in this routine is insufficient for this purpose
1602+
// because the thread has transitioned back to Java.
1603+
1604+
Label slow_path;
1605+
Label fast_path;
1606+
__ safepoint_poll(slow_path, true /* at_return */, false /* acquire */, false /* in_nmethod */);
1607+
__ br(Assembler::AL, fast_path);
1608+
__ bind(slow_path);
1609+
__ push(dtos);
1610+
__ push(ltos);
1611+
__ set_last_Java_frame(esp, rfp, __ pc(), rscratch1);
1612+
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::at_unwind), rthread);
1613+
__ reset_last_Java_frame(true);
1614+
__ pop(ltos);
1615+
__ pop(dtos);
1616+
__ bind(fast_path);
1617+
1618+
#endif // INCLUDE_JFR
1619+
15961620
// jvmti support
15971621
// Note: This must happen _after_ handling/throwing any exceptions since
15981622
// the exception handler code notifies the runtime of method exits
@@ -1615,6 +1639,8 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
16151639
// remove frame anchor
16161640
__ leave();
16171641

1642+
JFR_ONLY(__ leave_jfr_critical_section();)
1643+
16181644
// restore sender sp
16191645
__ mov(sp, esp);
16201646

src/hotspot/cpu/aarch64/templateTable_aarch64.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,8 @@ void TemplateTable::branch(bool is_jsr, bool is_wide)
18901890

18911891
__ mov(r19, r0); // save the nmethod
18921892

1893+
JFR_ONLY(__ enter_jfr_critical_section();)
1894+
18931895
call_VM(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin));
18941896

18951897
// r0 is OSR buffer, move it to expected parameter location
@@ -1901,6 +1903,9 @@ void TemplateTable::branch(bool is_jsr, bool is_wide)
19011903
Address(rfp, frame::interpreter_frame_sender_sp_offset * wordSize));
19021904
// remove frame anchor
19031905
__ leave();
1906+
1907+
JFR_ONLY(__ leave_jfr_critical_section();)
1908+
19041909
// Ensure compiled code always sees stack at proper alignment
19051910
__ andr(sp, esp, -16);
19061911

src/hotspot/cpu/arm/frame_arm.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108

109109
frame(intptr_t* sp, intptr_t* fp);
110110

111+
frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc, CodeBlob* cb, bool allow_cb_null = false);
112+
113+
void setup(address pc);
111114
void init(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);
112115

113116
// accessors for the instance variables

0 commit comments

Comments
 (0)