Skip to content

Commit b363de8

Browse files
kuaiweiDavid Holmes
authored andcommitted
8335946: DTrace code snippets should be generated when DTrace flags are enabled
Reviewed-by: coleenp, dholmes
1 parent d6c6847 commit b363de8

12 files changed

+85
-113
lines changed

src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,8 +1418,7 @@ void InterpreterMacroAssembler::notify_method_entry() {
14181418
bind(L);
14191419
}
14201420

1421-
{
1422-
SkipIfEqual skip(this, &DTraceMethodProbes, false);
1421+
if (DTraceMethodProbes) {
14231422
get_method(c_rarg1);
14241423
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
14251424
rthread, c_rarg1);
@@ -1458,8 +1457,7 @@ void InterpreterMacroAssembler::notify_method_exit(
14581457
pop(state);
14591458
}
14601459

1461-
{
1462-
SkipIfEqual skip(this, &DTraceMethodProbes, false);
1460+
if (DTraceMethodProbes) {
14631461
push(state);
14641462
get_method(c_rarg1);
14651463
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),

src/hotspot/cpu/aarch64/sharedRuntime_aarch64.cpp

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,11 +1754,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
17541754
__ set_last_Java_frame(sp, noreg, native_return, rscratch1);
17551755

17561756
Label dtrace_method_entry, dtrace_method_entry_done;
1757-
{
1758-
uint64_t offset;
1759-
__ adrp(rscratch1, ExternalAddress((address)&DTraceMethodProbes), offset);
1760-
__ ldrb(rscratch1, Address(rscratch1, offset));
1761-
__ cbnzw(rscratch1, dtrace_method_entry);
1757+
if (DTraceMethodProbes) {
1758+
__ b(dtrace_method_entry);
17621759
__ bind(dtrace_method_entry_done);
17631760
}
17641761

@@ -1990,11 +1987,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
19901987
}
19911988

19921989
Label dtrace_method_exit, dtrace_method_exit_done;
1993-
{
1994-
uint64_t offset;
1995-
__ adrp(rscratch1, ExternalAddress((address)&DTraceMethodProbes), offset);
1996-
__ ldrb(rscratch1, Address(rscratch1, offset));
1997-
__ cbnzw(rscratch1, dtrace_method_exit);
1990+
if (DTraceMethodProbes) {
1991+
__ b(dtrace_method_exit);
19981992
__ bind(dtrace_method_exit_done);
19991993
}
20001994

@@ -2138,37 +2132,38 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
21382132
}
21392133

21402134
// SLOW PATH dtrace support
2141-
{
2142-
__ block_comment("dtrace entry {");
2143-
__ bind(dtrace_method_entry);
2144-
2145-
// We have all of the arguments setup at this point. We must not touch any register
2146-
// argument registers at this point (what if we save/restore them there are no oop?
2147-
2148-
save_args(masm, total_c_args, c_arg, out_regs);
2149-
__ mov_metadata(c_rarg1, method());
2150-
__ call_VM_leaf(
2151-
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
2152-
rthread, c_rarg1);
2153-
restore_args(masm, total_c_args, c_arg, out_regs);
2154-
__ b(dtrace_method_entry_done);
2155-
__ block_comment("} dtrace entry");
2156-
}
2135+
if (DTraceMethodProbes) {
2136+
{
2137+
__ block_comment("dtrace entry {");
2138+
__ bind(dtrace_method_entry);
2139+
2140+
// We have all of the arguments setup at this point. We must not touch any register
2141+
// argument registers at this point (what if we save/restore them there are no oop?
2142+
2143+
save_args(masm, total_c_args, c_arg, out_regs);
2144+
__ mov_metadata(c_rarg1, method());
2145+
__ call_VM_leaf(
2146+
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
2147+
rthread, c_rarg1);
2148+
restore_args(masm, total_c_args, c_arg, out_regs);
2149+
__ b(dtrace_method_entry_done);
2150+
__ block_comment("} dtrace entry");
2151+
}
21572152

2158-
{
2159-
__ block_comment("dtrace exit {");
2160-
__ bind(dtrace_method_exit);
2161-
save_native_result(masm, ret_type, stack_slots);
2162-
__ mov_metadata(c_rarg1, method());
2163-
__ call_VM_leaf(
2164-
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
2165-
rthread, c_rarg1);
2166-
restore_native_result(masm, ret_type, stack_slots);
2167-
__ b(dtrace_method_exit_done);
2168-
__ block_comment("} dtrace exit");
2153+
{
2154+
__ block_comment("dtrace exit {");
2155+
__ bind(dtrace_method_exit);
2156+
save_native_result(masm, ret_type, stack_slots);
2157+
__ mov_metadata(c_rarg1, method());
2158+
__ call_VM_leaf(
2159+
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
2160+
rthread, c_rarg1);
2161+
restore_native_result(masm, ret_type, stack_slots);
2162+
__ b(dtrace_method_exit_done);
2163+
__ block_comment("} dtrace exit");
2164+
}
21692165
}
21702166

2171-
21722167
__ flush();
21732168

21742169
nmethod *nm = nmethod::new_native_nmethod(method,

src/hotspot/cpu/aarch64/templateTable_aarch64.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3648,8 +3648,7 @@ void TemplateTable::_new() {
36483648
__ store_klass_gap(r0, zr); // zero klass gap for compressed oops
36493649
__ store_klass(r0, r4); // store klass last
36503650

3651-
{
3652-
SkipIfEqual skip(_masm, &DTraceAllocProbes, false);
3651+
if (DTraceAllocProbes) {
36533652
// Trigger dtrace event for fastpath
36543653
__ push(atos); // save the return value
36553654
__ call_VM_leaf(

src/hotspot/cpu/ppc/templateTable_ppc_64.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3859,10 +3859,11 @@ void TemplateTable::_new() {
38593859
__ store_klass(RallocatedObject, RinstanceKlass, Rscratch); // klass (last for cms)
38603860

38613861
// Check and trigger dtrace event.
3862-
SkipIfEqualZero::skip_to_label_if_equal_zero(_masm, Rscratch, &DTraceAllocProbes, Ldone);
3863-
__ push(atos);
3864-
__ call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)));
3865-
__ pop(atos);
3862+
if (DTraceAllocProbes) {
3863+
__ push(atos);
3864+
__ call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)));
3865+
__ pop(atos);
3866+
}
38663867

38673868
__ b(Ldone);
38683869
}

src/hotspot/cpu/riscv/interp_masm_riscv.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,7 @@ void InterpreterMacroAssembler::notify_method_entry() {
14671467
bind(L);
14681468
}
14691469

1470-
{
1471-
SkipIfEqual skip(this, &DTraceMethodProbes, false);
1470+
if (DTraceMethodProbes) {
14721471
get_method(c_rarg1);
14731472
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
14741473
xthread, c_rarg1);
@@ -1506,8 +1505,7 @@ void InterpreterMacroAssembler::notify_method_exit(
15061505
pop(state);
15071506
}
15081507

1509-
{
1510-
SkipIfEqual skip(this, &DTraceMethodProbes, false);
1508+
if (DTraceMethodProbes) {
15111509
push(state);
15121510
get_method(c_rarg1);
15131511
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),

src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,14 +1638,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
16381638
__ set_last_Java_frame(sp, noreg, native_return, t0);
16391639

16401640
Label dtrace_method_entry, dtrace_method_entry_done;
1641-
{
1642-
ExternalAddress target((address)&DTraceMethodProbes);
1643-
__ relocate(target.rspec(), [&] {
1644-
int32_t offset;
1645-
__ la(t0, target.target(), offset);
1646-
__ lbu(t0, Address(t0, offset));
1647-
});
1648-
__ bnez(t0, dtrace_method_entry);
1641+
if (DTraceMethodProbes) {
1642+
__ j(dtrace_method_entry);
16491643
__ bind(dtrace_method_entry_done);
16501644
}
16511645

@@ -1861,14 +1855,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
18611855
}
18621856

18631857
Label dtrace_method_exit, dtrace_method_exit_done;
1864-
{
1865-
ExternalAddress target((address)&DTraceMethodProbes);
1866-
__ relocate(target.rspec(), [&] {
1867-
int32_t offset;
1868-
__ la(t0, target.target(), offset);
1869-
__ lbu(t0, Address(t0, offset));
1870-
});
1871-
__ bnez(t0, dtrace_method_exit);
1858+
if (DTraceMethodProbes) {
1859+
__ j(dtrace_method_exit);
18721860
__ bind(dtrace_method_exit_done);
18731861
}
18741862

@@ -2009,34 +1997,36 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
20091997
}
20101998

20111999
// SLOW PATH dtrace support
2012-
{
2013-
__ block_comment("dtrace entry {");
2014-
__ bind(dtrace_method_entry);
2015-
2016-
// We have all of the arguments setup at this point. We must not touch any register
2017-
// argument registers at this point (what if we save/restore them there are no oop?
2018-
2019-
save_args(masm, total_c_args, c_arg, out_regs);
2020-
__ mov_metadata(c_rarg1, method());
2021-
__ call_VM_leaf(
2022-
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
2023-
xthread, c_rarg1);
2024-
restore_args(masm, total_c_args, c_arg, out_regs);
2025-
__ j(dtrace_method_entry_done);
2026-
__ block_comment("} dtrace entry");
2027-
}
2000+
if (DTraceMethodProbes) {
2001+
{
2002+
__ block_comment("dtrace entry {");
2003+
__ bind(dtrace_method_entry);
2004+
2005+
// We have all of the arguments setup at this point. We must not touch any register
2006+
// argument registers at this point (what if we save/restore them there are no oop?
2007+
2008+
save_args(masm, total_c_args, c_arg, out_regs);
2009+
__ mov_metadata(c_rarg1, method());
2010+
__ call_VM_leaf(
2011+
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
2012+
xthread, c_rarg1);
2013+
restore_args(masm, total_c_args, c_arg, out_regs);
2014+
__ j(dtrace_method_entry_done);
2015+
__ block_comment("} dtrace entry");
2016+
}
20282017

2029-
{
2030-
__ block_comment("dtrace exit {");
2031-
__ bind(dtrace_method_exit);
2032-
save_native_result(masm, ret_type, stack_slots);
2033-
__ mov_metadata(c_rarg1, method());
2034-
__ call_VM_leaf(
2035-
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
2036-
xthread, c_rarg1);
2037-
restore_native_result(masm, ret_type, stack_slots);
2038-
__ j(dtrace_method_exit_done);
2039-
__ block_comment("} dtrace exit");
2018+
{
2019+
__ block_comment("dtrace exit {");
2020+
__ bind(dtrace_method_exit);
2021+
save_native_result(masm, ret_type, stack_slots);
2022+
__ mov_metadata(c_rarg1, method());
2023+
__ call_VM_leaf(
2024+
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
2025+
xthread, c_rarg1);
2026+
restore_native_result(masm, ret_type, stack_slots);
2027+
__ j(dtrace_method_exit_done);
2028+
__ block_comment("} dtrace exit");
2029+
}
20402030
}
20412031

20422032
__ flush();

src/hotspot/cpu/riscv/templateTable_riscv.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3592,8 +3592,7 @@ void TemplateTable::_new() {
35923592
__ store_klass_gap(x10, zr); // zero klass gap for compressed oops
35933593
__ store_klass(x10, x14); // store klass last
35943594

3595-
{
3596-
SkipIfEqual skip(_masm, &DTraceAllocProbes, false);
3595+
if (DTraceAllocProbes) {
35973596
// Trigger dtrace event for fastpath
35983597
__ push(atos); // save the return value
35993598
__ call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), x10);

src/hotspot/cpu/s390/templateTable_s390.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3976,8 +3976,7 @@ void TemplateTable::_new() {
39763976
__ store_klass_gap(Rzero, RallocatedObject); // Zero klass gap for compressed oops.
39773977
__ store_klass(iklass, RallocatedObject); // Store klass last.
39783978

3979-
{
3980-
SkipIfEqual skip(_masm, &DTraceAllocProbes, false, Z_ARG5 /*scratch*/);
3979+
if (DTraceAllocProbes) {
39813980
// Trigger dtrace event for fastpath.
39823981
__ push(atos); // Save the return value.
39833982
__ call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), RallocatedObject);

src/hotspot/cpu/x86/interp_masm_x86.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,8 +1955,7 @@ void InterpreterMacroAssembler::notify_method_entry() {
19551955
bind(L);
19561956
}
19571957

1958-
{
1959-
SkipIfEqual skip(this, &DTraceMethodProbes, false, rscratch1);
1958+
if (DTraceMethodProbes) {
19601959
NOT_LP64(get_thread(rthread);)
19611960
get_method(rarg);
19621961
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
@@ -2000,8 +1999,7 @@ void InterpreterMacroAssembler::notify_method_exit(
20001999
pop(state);
20012000
}
20022001

2003-
{
2004-
SkipIfEqual skip(this, &DTraceMethodProbes, false, rscratch1);
2002+
if (DTraceMethodProbes) {
20052003
push(state);
20062004
NOT_LP64(get_thread(rthread);)
20072005
get_method(rarg);

src/hotspot/cpu/x86/sharedRuntime_x86_32.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,8 +1612,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
16121612
// We have all of the arguments setup at this point. We must not touch any register
16131613
// argument registers at this point (what if we save/restore them there are no oop?
16141614

1615-
{
1616-
SkipIfEqual skip_if(masm, &DTraceMethodProbes, 0, noreg);
1615+
if (DTraceMethodProbes) {
16171616
__ mov_metadata(rax, method());
16181617
__ call_VM_leaf(
16191618
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
@@ -1857,8 +1856,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
18571856
__ bind(fast_done);
18581857
}
18591858

1860-
{
1861-
SkipIfEqual skip_if(masm, &DTraceMethodProbes, 0, noreg);
1859+
if (DTraceMethodProbes) {
18621860
// Tell dtrace about this method exit
18631861
save_native_result(masm, ret_type, stack_slots);
18641862
__ mov_metadata(rax, method());

src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,8 +2200,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
22002200
// We have all of the arguments setup at this point. We must not touch any register
22012201
// argument registers at this point (what if we save/restore them there are no oop?
22022202

2203-
{
2204-
SkipIfEqual skip(masm, &DTraceMethodProbes, false, rscratch1);
2203+
if (DTraceMethodProbes) {
22052204
// protect the args we've loaded
22062205
save_args(masm, total_c_args, c_arg, out_regs);
22072206
__ mov_metadata(c_rarg1, method());
@@ -2439,8 +2438,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
24392438

24402439
__ bind(fast_done);
24412440
}
2442-
{
2443-
SkipIfEqual skip(masm, &DTraceMethodProbes, false, rscratch1);
2441+
if (DTraceMethodProbes) {
24442442
save_native_result(masm, ret_type, stack_slots);
24452443
__ mov_metadata(c_rarg1, method());
24462444
__ call_VM_leaf(

src/hotspot/cpu/x86/templateTable_x86.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4123,8 +4123,7 @@ void TemplateTable::_new() {
41234123
#endif
41244124
__ store_klass(rax, rcx, rscratch1); // klass
41254125

4126-
{
4127-
SkipIfEqual skip_if(_masm, &DTraceAllocProbes, 0, rscratch1);
4126+
if (DTraceAllocProbes) {
41284127
// Trigger dtrace event for fastpath
41294128
__ push(atos);
41304129
__ call_VM_leaf(

0 commit comments

Comments
 (0)