8335946: DTrace code snippets should be generated when DTrace flags are enabled

Reviewed-by: coleenp, dholmes
This commit is contained in:
Kuai Wei 2024-07-11 02:44:25 +00:00 committed by David Holmes
parent d6c6847e32
commit b363de8c9f
12 changed files with 82 additions and 110 deletions

View File

@ -1418,8 +1418,7 @@ void InterpreterMacroAssembler::notify_method_entry() {
bind(L);
}
{
SkipIfEqual skip(this, &DTraceMethodProbes, false);
if (DTraceMethodProbes) {
get_method(c_rarg1);
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
rthread, c_rarg1);
@ -1458,8 +1457,7 @@ void InterpreterMacroAssembler::notify_method_exit(
pop(state);
}
{
SkipIfEqual skip(this, &DTraceMethodProbes, false);
if (DTraceMethodProbes) {
push(state);
get_method(c_rarg1);
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),

View File

@ -1754,11 +1754,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
__ set_last_Java_frame(sp, noreg, native_return, rscratch1);
Label dtrace_method_entry, dtrace_method_entry_done;
{
uint64_t offset;
__ adrp(rscratch1, ExternalAddress((address)&DTraceMethodProbes), offset);
__ ldrb(rscratch1, Address(rscratch1, offset));
__ cbnzw(rscratch1, dtrace_method_entry);
if (DTraceMethodProbes) {
__ b(dtrace_method_entry);
__ bind(dtrace_method_entry_done);
}
@ -1990,11 +1987,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
}
Label dtrace_method_exit, dtrace_method_exit_done;
{
uint64_t offset;
__ adrp(rscratch1, ExternalAddress((address)&DTraceMethodProbes), offset);
__ ldrb(rscratch1, Address(rscratch1, offset));
__ cbnzw(rscratch1, dtrace_method_exit);
if (DTraceMethodProbes) {
__ b(dtrace_method_exit);
__ bind(dtrace_method_exit_done);
}
@ -2138,37 +2132,38 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
}
// SLOW PATH dtrace support
{
__ block_comment("dtrace entry {");
__ bind(dtrace_method_entry);
if (DTraceMethodProbes) {
{
__ block_comment("dtrace entry {");
__ bind(dtrace_method_entry);
// We have all of the arguments setup at this point. We must not touch any register
// argument registers at this point (what if we save/restore them there are no oop?
// We have all of the arguments setup at this point. We must not touch any register
// argument registers at this point (what if we save/restore them there are no oop?
save_args(masm, total_c_args, c_arg, out_regs);
__ mov_metadata(c_rarg1, method());
__ call_VM_leaf(
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
rthread, c_rarg1);
restore_args(masm, total_c_args, c_arg, out_regs);
__ b(dtrace_method_entry_done);
__ block_comment("} dtrace entry");
save_args(masm, total_c_args, c_arg, out_regs);
__ mov_metadata(c_rarg1, method());
__ call_VM_leaf(
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
rthread, c_rarg1);
restore_args(masm, total_c_args, c_arg, out_regs);
__ b(dtrace_method_entry_done);
__ block_comment("} dtrace entry");
}
{
__ block_comment("dtrace exit {");
__ bind(dtrace_method_exit);
save_native_result(masm, ret_type, stack_slots);
__ mov_metadata(c_rarg1, method());
__ call_VM_leaf(
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
rthread, c_rarg1);
restore_native_result(masm, ret_type, stack_slots);
__ b(dtrace_method_exit_done);
__ block_comment("} dtrace exit");
}
}
{
__ block_comment("dtrace exit {");
__ bind(dtrace_method_exit);
save_native_result(masm, ret_type, stack_slots);
__ mov_metadata(c_rarg1, method());
__ call_VM_leaf(
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
rthread, c_rarg1);
restore_native_result(masm, ret_type, stack_slots);
__ b(dtrace_method_exit_done);
__ block_comment("} dtrace exit");
}
__ flush();
nmethod *nm = nmethod::new_native_nmethod(method,

View File

@ -3648,8 +3648,7 @@ void TemplateTable::_new() {
__ store_klass_gap(r0, zr); // zero klass gap for compressed oops
__ store_klass(r0, r4); // store klass last
{
SkipIfEqual skip(_masm, &DTraceAllocProbes, false);
if (DTraceAllocProbes) {
// Trigger dtrace event for fastpath
__ push(atos); // save the return value
__ call_VM_leaf(

View File

@ -3859,10 +3859,11 @@ void TemplateTable::_new() {
__ store_klass(RallocatedObject, RinstanceKlass, Rscratch); // klass (last for cms)
// Check and trigger dtrace event.
SkipIfEqualZero::skip_to_label_if_equal_zero(_masm, Rscratch, &DTraceAllocProbes, Ldone);
__ push(atos);
__ call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)));
__ pop(atos);
if (DTraceAllocProbes) {
__ push(atos);
__ call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)));
__ pop(atos);
}
__ b(Ldone);
}

View File

@ -1467,8 +1467,7 @@ void InterpreterMacroAssembler::notify_method_entry() {
bind(L);
}
{
SkipIfEqual skip(this, &DTraceMethodProbes, false);
if (DTraceMethodProbes) {
get_method(c_rarg1);
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
xthread, c_rarg1);
@ -1506,8 +1505,7 @@ void InterpreterMacroAssembler::notify_method_exit(
pop(state);
}
{
SkipIfEqual skip(this, &DTraceMethodProbes, false);
if (DTraceMethodProbes) {
push(state);
get_method(c_rarg1);
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),

View File

@ -1638,14 +1638,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
__ set_last_Java_frame(sp, noreg, native_return, t0);
Label dtrace_method_entry, dtrace_method_entry_done;
{
ExternalAddress target((address)&DTraceMethodProbes);
__ relocate(target.rspec(), [&] {
int32_t offset;
__ la(t0, target.target(), offset);
__ lbu(t0, Address(t0, offset));
});
__ bnez(t0, dtrace_method_entry);
if (DTraceMethodProbes) {
__ j(dtrace_method_entry);
__ bind(dtrace_method_entry_done);
}
@ -1861,14 +1855,8 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
}
Label dtrace_method_exit, dtrace_method_exit_done;
{
ExternalAddress target((address)&DTraceMethodProbes);
__ relocate(target.rspec(), [&] {
int32_t offset;
__ la(t0, target.target(), offset);
__ lbu(t0, Address(t0, offset));
});
__ bnez(t0, dtrace_method_exit);
if (DTraceMethodProbes) {
__ j(dtrace_method_exit);
__ bind(dtrace_method_exit_done);
}
@ -2009,34 +1997,36 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
}
// SLOW PATH dtrace support
{
__ block_comment("dtrace entry {");
__ bind(dtrace_method_entry);
if (DTraceMethodProbes) {
{
__ block_comment("dtrace entry {");
__ bind(dtrace_method_entry);
// We have all of the arguments setup at this point. We must not touch any register
// argument registers at this point (what if we save/restore them there are no oop?
// We have all of the arguments setup at this point. We must not touch any register
// argument registers at this point (what if we save/restore them there are no oop?
save_args(masm, total_c_args, c_arg, out_regs);
__ mov_metadata(c_rarg1, method());
__ call_VM_leaf(
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
xthread, c_rarg1);
restore_args(masm, total_c_args, c_arg, out_regs);
__ j(dtrace_method_entry_done);
__ block_comment("} dtrace entry");
}
save_args(masm, total_c_args, c_arg, out_regs);
__ mov_metadata(c_rarg1, method());
__ call_VM_leaf(
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
xthread, c_rarg1);
restore_args(masm, total_c_args, c_arg, out_regs);
__ j(dtrace_method_entry_done);
__ block_comment("} dtrace entry");
}
{
__ block_comment("dtrace exit {");
__ bind(dtrace_method_exit);
save_native_result(masm, ret_type, stack_slots);
__ mov_metadata(c_rarg1, method());
__ call_VM_leaf(
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
xthread, c_rarg1);
restore_native_result(masm, ret_type, stack_slots);
__ j(dtrace_method_exit_done);
__ block_comment("} dtrace exit");
{
__ block_comment("dtrace exit {");
__ bind(dtrace_method_exit);
save_native_result(masm, ret_type, stack_slots);
__ mov_metadata(c_rarg1, method());
__ call_VM_leaf(
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit),
xthread, c_rarg1);
restore_native_result(masm, ret_type, stack_slots);
__ j(dtrace_method_exit_done);
__ block_comment("} dtrace exit");
}
}
__ flush();

View File

@ -3592,8 +3592,7 @@ void TemplateTable::_new() {
__ store_klass_gap(x10, zr); // zero klass gap for compressed oops
__ store_klass(x10, x14); // store klass last
{
SkipIfEqual skip(_masm, &DTraceAllocProbes, false);
if (DTraceAllocProbes) {
// Trigger dtrace event for fastpath
__ push(atos); // save the return value
__ call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), x10);

View File

@ -3976,8 +3976,7 @@ void TemplateTable::_new() {
__ store_klass_gap(Rzero, RallocatedObject); // Zero klass gap for compressed oops.
__ store_klass(iklass, RallocatedObject); // Store klass last.
{
SkipIfEqual skip(_masm, &DTraceAllocProbes, false, Z_ARG5 /*scratch*/);
if (DTraceAllocProbes) {
// Trigger dtrace event for fastpath.
__ push(atos); // Save the return value.
__ call_VM_leaf(CAST_FROM_FN_PTR(address, static_cast<int (*)(oopDesc*)>(SharedRuntime::dtrace_object_alloc)), RallocatedObject);

View File

@ -1955,8 +1955,7 @@ void InterpreterMacroAssembler::notify_method_entry() {
bind(L);
}
{
SkipIfEqual skip(this, &DTraceMethodProbes, false, rscratch1);
if (DTraceMethodProbes) {
NOT_LP64(get_thread(rthread);)
get_method(rarg);
call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
@ -2000,8 +1999,7 @@ void InterpreterMacroAssembler::notify_method_exit(
pop(state);
}
{
SkipIfEqual skip(this, &DTraceMethodProbes, false, rscratch1);
if (DTraceMethodProbes) {
push(state);
NOT_LP64(get_thread(rthread);)
get_method(rarg);

View File

@ -1612,8 +1612,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
// We have all of the arguments setup at this point. We must not touch any register
// argument registers at this point (what if we save/restore them there are no oop?
{
SkipIfEqual skip_if(masm, &DTraceMethodProbes, 0, noreg);
if (DTraceMethodProbes) {
__ mov_metadata(rax, method());
__ call_VM_leaf(
CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry),
@ -1857,8 +1856,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
__ bind(fast_done);
}
{
SkipIfEqual skip_if(masm, &DTraceMethodProbes, 0, noreg);
if (DTraceMethodProbes) {
// Tell dtrace about this method exit
save_native_result(masm, ret_type, stack_slots);
__ mov_metadata(rax, method());

View File

@ -2200,8 +2200,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
// We have all of the arguments setup at this point. We must not touch any register
// argument registers at this point (what if we save/restore them there are no oop?
{
SkipIfEqual skip(masm, &DTraceMethodProbes, false, rscratch1);
if (DTraceMethodProbes) {
// protect the args we've loaded
save_args(masm, total_c_args, c_arg, out_regs);
__ mov_metadata(c_rarg1, method());
@ -2439,8 +2438,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm,
__ bind(fast_done);
}
{
SkipIfEqual skip(masm, &DTraceMethodProbes, false, rscratch1);
if (DTraceMethodProbes) {
save_native_result(masm, ret_type, stack_slots);
__ mov_metadata(c_rarg1, method());
__ call_VM_leaf(

View File

@ -4123,8 +4123,7 @@ void TemplateTable::_new() {
#endif
__ store_klass(rax, rcx, rscratch1); // klass
{
SkipIfEqual skip_if(_masm, &DTraceAllocProbes, 0, rscratch1);
if (DTraceAllocProbes) {
// Trigger dtrace event for fastpath
__ push(atos);
__ call_VM_leaf(