@@ -2423,42 +2423,7 @@ static void
24232423gc_event_hook_body (rb_execution_context_t * ec , rb_objspace_t * objspace , const rb_event_flag_t event , VALUE data )
24242424{
24252425 if (UNLIKELY (!ec -> cfp )) return ;
2426- const VALUE * pc = ec -> cfp -> pc ;
2427- if (pc && VM_FRAME_RUBYFRAME_P (ec -> cfp )) {
2428- int prev_opcode = rb_vm_insn_addr2opcode ((void * )* ec -> cfp -> iseq -> body -> iseq_encoded );
2429- for (const VALUE * insn = ec -> cfp -> iseq -> body -> iseq_encoded ; insn < pc ; insn += rb_insn_len (prev_opcode )) {
2430- prev_opcode = rb_vm_insn_addr2opcode ((void * )* insn );
2431- }
2432-
2433- /* If the previous instruction is a leaf instruction, then the PC is
2434- * the currently executing instruction. We should increment the PC
2435- * because the source line is calculated with PC-1 in calc_pos.
2436- *
2437- * If the previous instruction is not a leaf instruction and the
2438- * current instruction is not a leaf instruction, then the PC was
2439- * incremented before the instruction was ran (meaning the currently
2440- * executing instruction is actually the previous instruction), so we
2441- * should not increment the PC otherwise we will calculate the source
2442- * line for the next instruction.
2443- *
2444- * However, this implementation still has a bug. Consider the
2445- * following situation:
2446- *
2447- * non-leaf
2448- * leaf <-
2449- *
2450- * Where the PC currently points to a leaf instruction. We don't know
2451- * which instruction we really are at since we could be at the non-leaf
2452- * instruction (since it incremented the PC before executing the
2453- * instruction). We could also be at the leaf instruction since the PC
2454- * doesn't get incremented until the instruction finishes.
2455- */
2456- if (rb_insns_leaf_p (prev_opcode )) {
2457- ec -> cfp -> pc ++ ;
2458- }
2459- }
24602426 EXEC_EVENT_HOOK (ec , event , ec -> cfp -> self , 0 , 0 , 0 , data );
2461- ec -> cfp -> pc = pc ;
24622427}
24632428
24642429#define gc_event_hook_available_p (objspace ) ((objspace)->flags.has_hook)
0 commit comments