mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 3e02cd518f: [Backport #17149]
Trace :return of builtin methods using opt_invokebuiltin_delegate_leave insn. Since Ruby 2.7, :return of methods using builtin have not been traced properly.
This commit is contained in:
parent
e778de2c82
commit
3fef159f81
4 changed files with 21 additions and 3 deletions
|
|
@ -1508,7 +1508,7 @@ opt_invokebuiltin_delegate_leave
|
|||
val = vm_invoke_builtin_delegate(ec, reg_cfp, bf, (unsigned int)index);
|
||||
|
||||
/* leave fastpath */
|
||||
/* TracePoint/return should fallback this insn to opt_invokebuiltin_delegate */
|
||||
/* TracePoint/return fallbacks this insn to opt_invokebuiltin_delegate */
|
||||
if (vm_pop_frame(ec, GET_CFP(), GET_EP())) {
|
||||
#if OPT_CALL_THREADED_CODE
|
||||
rb_ec_thread_ptr(ec)->retval = val;
|
||||
|
|
|
|||
6
iseq.c
6
iseq.c
|
|
@ -3094,8 +3094,12 @@ rb_vm_encoded_insn_data_table_init(void)
|
|||
encoded_insn_data = st_init_numtable_with_size(VM_INSTRUCTION_SIZE / 2);
|
||||
|
||||
for (insn = 0; insn < VM_INSTRUCTION_SIZE/2; insn++) {
|
||||
int traced_insn = insn;
|
||||
if (traced_insn == BIN(opt_invokebuiltin_delegate_leave)) {
|
||||
traced_insn = BIN(opt_invokebuiltin_delegate); // to dispatch :return from leave
|
||||
}
|
||||
st_data_t key1 = (st_data_t)INSN_CODE(insn);
|
||||
st_data_t key2 = (st_data_t)INSN_CODE(insn + VM_INSTRUCTION_SIZE/2);
|
||||
st_data_t key2 = (st_data_t)INSN_CODE(traced_insn + VM_INSTRUCTION_SIZE/2);
|
||||
|
||||
insn_data[insn].insn = (int)insn;
|
||||
insn_data[insn].insn_len = insn_len(insn);
|
||||
|
|
|
|||
|
|
@ -2279,4 +2279,18 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||
def test_stat_exists
|
||||
assert_instance_of Hash, TracePoint.stat
|
||||
end
|
||||
|
||||
def test_tracepoint_opt_invokebuiltin_delegate_leave
|
||||
code = 'puts RubyVM::InstructionSequence.of("\x00".method(:unpack)).disasm'
|
||||
out, _err, _status = EnvUtil.invoke_ruby(['-e', code], '', true)
|
||||
assert_match /^0000 opt_invokebuiltin_delegate_leave /, out
|
||||
|
||||
events = []
|
||||
TracePoint.new(:return) do |tp|
|
||||
events << [tp.event, tp.method_id]
|
||||
end.enable do
|
||||
"\x00".unpack("c")
|
||||
end
|
||||
assert_equal [[:return, :unpack]], events
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||
#define RUBY_VERSION_TEENY 1
|
||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||
#define RUBY_PATCHLEVEL 120
|
||||
#define RUBY_PATCHLEVEL 121
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2020
|
||||
#define RUBY_RELEASE_MONTH 9
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue