Support tracing of struct member accessor methods

This follows the same approach used for attr_reader/attr_writer in
2d98593bf5, skipping the checking for
tracing after the first call using the call cache, and clearing the
call cache when tracing is turned on/off.

Fixes [Bug #18886]
This commit is contained in:
Jeremy Evans 2023-10-26 17:03:17 -07:00
parent 1721bb9dc6
commit 3081c83169
5 changed files with 118 additions and 22 deletions

View file

@ -299,11 +299,15 @@ vm_call0_body(rb_execution_context_t *ec, struct rb_calling_info *calling, const
}
case OPTIMIZED_METHOD_TYPE_STRUCT_AREF:
vm_call_check_arity(calling, 0, argv);
ret = vm_call_opt_struct_aref0(ec, calling);
VM_CALL_METHOD_ATTR(ret,
vm_call_opt_struct_aref0(ec, calling),
(void)0);
goto success;
case OPTIMIZED_METHOD_TYPE_STRUCT_ASET:
vm_call_check_arity(calling, 1, argv);
ret = vm_call_opt_struct_aset0(ec, calling, argv[0]);
VM_CALL_METHOD_ATTR(ret,
vm_call_opt_struct_aset0(ec, calling, argv[0]),
(void)0);
goto success;
default:
rb_bug("vm_call0: unsupported optimized method type (%d)", vm_cc_cme(cc)->def->body.optimized.type);