bytecode rewrite and breakpoint

San Hong Li sherrylso at
Tue Jan 6 14:18:47 UTC 2015

Hi All:

For the bytecode patch path, the  interpreter does have some special
handling for breakpoint bytecode, that is,  if a breakpoint is present
at_bcp(0),   the bytecode patching will be skipped and  handled by
breakpoint table later.

The related implementation is in  TemplateTable::patch_bytecode:

  if (JvmtiExport::can_post_breakpoint()) {
    Label L_fast_patch;
    // if a breakpoint is present we can't rewrite the stream directly
    __ movzbl(temp_reg, at_bcp(0));
    __ cmpl(temp_reg, Bytecodes::_breakpoint);
    __ jcc(Assembler::notEqual, L_fast_patch);
    __ get_method(temp_reg);
    // Let breakpoint table handling rewrite to quicker bytecode
    __ call_VM(noreg, CAST_FROM_FN_PTR(address,
InterpreterRuntime::set_original_bytecode_at), temp_reg, r13, bc_reg);
#ifndef ASSERT
    __ jmpb(L_patch_done);
    __ jmp(L_patch_done);
    __ bind(L_fast_patch);

My understanding is the breakpoint can only be set in safepoint,
when the interpreter thread resumes from safepoint, because it will
retrieve the next bytecode for executing again,the breakpoint bytecode
which is set in safepoint before will get chance to be executed. I can not
imagine when the bcp(0) could be changed as breakpoint in above code?

So I am curious whether the above code is already dead?
If not,  anyone can help to me to clarify that  how the bytecode which is
currently executed by interpreter could be replaced with breakpoint?
which case could trigger  the
"InterpreterRuntime::set_original_bytecode_at" to be called?

Appreciated for your help in advance.

More information about the hotspot-runtime-dev mailing list