push dummy frame for loading process

This patch pushes dummy frames when loading code for the
profiling purpose.

The following methods push a dummy frame:
* `Kernel#require`
* `Kernel#load`
* `RubyVM::InstructionSequence.compile_file`
* `RubyVM::InstructionSequence.load_from_binary`

https://bugs.ruby-lang.org/issues/18559
This commit is contained in:
Koichi Sasada 2022-10-17 17:50:42 +09:00
parent 7563604fb8
commit e35c528d72
Notes: git 2022-10-20 08:38:51 +00:00
10 changed files with 175 additions and 51 deletions

View file

@ -89,6 +89,9 @@ control_frame_dump(const rb_execution_context_t *ec, const rb_control_frame_t *c
case VM_FRAME_MAGIC_RESCUE:
magic = "RESCUE";
break;
case VM_FRAME_MAGIC_DUMMY:
magic = "DUMMY";
break;
case 0:
magic = "------";
break;
@ -117,12 +120,17 @@ control_frame_dump(const rb_execution_context_t *ec, const rb_control_frame_t *c
line = -1;
}
else {
iseq = cfp->iseq;
pc = cfp->pc - ISEQ_BODY(iseq)->iseq_encoded;
iseq_name = RSTRING_PTR(ISEQ_BODY(iseq)->location.label);
line = rb_vm_get_sourceline(cfp);
if (line) {
snprintf(posbuf, MAX_POSBUF, "%s:%d", RSTRING_PTR(rb_iseq_path(iseq)), line);
if (cfp->pc) {
iseq = cfp->iseq;
pc = cfp->pc - ISEQ_BODY(iseq)->iseq_encoded;
iseq_name = RSTRING_PTR(ISEQ_BODY(iseq)->location.label);
line = rb_vm_get_sourceline(cfp);
if (line) {
snprintf(posbuf, MAX_POSBUF, "%s:%d", RSTRING_PTR(rb_iseq_path(iseq)), line);
}
}
else {
iseq_name = "<dummy_frame>";
}
}
}