ruby-changes:49102
From: k0kubun <ko1@a...>
Date: Thu, 14 Dec 2017 01:07:56 +0900 (JST)
Subject: [ruby-changes:49102] k0kubun:r61217 (trunk): iseq.c: dump type of branchiftype on disasm
k0kubun 2017-12-14 01:07:52 +0900 (Thu, 14 Dec 2017) New Revision: 61217 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61217 Log: iseq.c: dump type of branchiftype on disasm This makes easier to debug scripts related to r59950. * before $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype 5, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave * after $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype T_STRING, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave Modified files: trunk/internal.h trunk/iseq.c trunk/vm_eval.c Index: iseq.c =================================================================== --- iseq.c (revision 61216) +++ iseq.c (revision 61217) @@ -1344,7 +1344,15 @@ rb_insn_operand_intern(const rb_iseq_t * https://github.com/ruby/ruby/blob/trunk/iseq.c#L1344 break; case TS_NUM: /* ULONG */ - ret = rb_sprintf("%"PRIuVALUE, op); + { + const char *type_str; + if (insn == BIN(branchiftype) && (type_str = rb_type_str((enum ruby_value_type)op)) != NULL) { + ret = rb_str_new_cstr(type_str); + } + else { + ret = rb_sprintf("%"PRIuVALUE, op); + } + } break; case TS_LINDEX:{ Index: vm_eval.c =================================================================== --- vm_eval.c (revision 61216) +++ vm_eval.c (revision 61217) @@ -440,7 +440,7 @@ rb_check_funcall_with_hook(VALUE recv, I https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L440 return vm_call0(ec, recv, mid, argc, argv, me); } -static const char * +const char * rb_type_str(enum ruby_value_type type) { #define type_case(t) case t: return #t; Index: internal.h =================================================================== --- internal.h (revision 61216) +++ internal.h (revision 61217) @@ -1842,6 +1842,7 @@ VALUE rb_check_block_call(VALUE, ID, int https://github.com/ruby/ruby/blob/trunk/internal.h#L1842 typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE); VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv, rb_check_funcall_hook *hook, VALUE arg); +const char *rb_type_str(enum ruby_value_type type); VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE); VALUE rb_yield_1(VALUE val); VALUE rb_yield_force_blockarg(VALUE values); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/