ruby-changes:31836
From: tarui <ko1@a...>
Date: Fri, 29 Nov 2013 20:45:47 +0900 (JST)
Subject: [ruby-changes:31836] tarui:r43915 (trunk): * compile.c : Bugsfix for dump_disasm_list.
tarui 2013-11-29 20:45:40 +0900 (Fri, 29 Nov 2013) New Revision: 43915 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43915 Log: * compile.c : Bugsfix for dump_disasm_list. rb_inspect denies a hidden object. So, insert rapper that creates the unhidden one. adjust->label is null sometimes. insn_data_line_no makes no sense at all. Modified files: trunk/ChangeLog trunk/compile.c Index: ChangeLog =================================================================== --- ChangeLog (revision 43914) +++ ChangeLog (revision 43915) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Nov 29 20:43:57 2013 Masaya Tarui <tarui@r...> + + * compile.c : Bugsfix for dump_disasm_list. + rb_inspect denies a hidden object. So, insert rapper that creates + the unhidden one. + adjust->label is null sometimes. + insn_data_line_no makes no sense at all. + Fri Nov 29 18:06:45 2013 Shota Fukumori <her@s...> * test/ruby/test_case.rb (test_method_missing): Test for r43913. Index: compile.c =================================================================== --- compile.c (revision 43914) +++ compile.c (revision 43915) @@ -324,7 +324,6 @@ static void debug_list(ISEQ_ARG_DECLARE https://github.com/ruby/ruby/blob/trunk/compile.c#L324 static void dump_disasm_list(LINK_ELEMENT *elem); static int insn_data_length(INSN *iobj); -static int insn_data_line_no(INSN *iobj); static int calc_sp_depth(int depth, INSN *iobj); static INSN *new_insn_body(rb_iseq_t *iseq, int line_no, int insn_id, int argc, ...); @@ -5394,16 +5393,29 @@ calc_sp_depth(int depth, INSN *insn) https://github.com/ruby/ruby/blob/trunk/compile.c#L5393 return insn_stack_increase(depth, insn->insn_id, insn->operands); } -static int -insn_data_line_no(INSN *iobj) +static VALUE +opobj_inspect(VALUE obj) { - return insn_len(iobj->line_no); + struct RBasic *r = (struct RBasic *) obj; + if (!SPECIAL_CONST_P(r) && r->klass == 0) { + switch (BUILTIN_TYPE(r)) { + case T_STRING: + obj = rb_str_new_cstr(RSTRING_PTR(obj)); + break; + case T_ARRAY: + obj = rb_ary_dup(obj); + break; + } + } + return rb_inspect(obj); } + + static VALUE insn_data_to_s_detail(INSN *iobj) { - VALUE str = rb_sprintf("%-16s", insn_name(iobj->insn_id)); + VALUE str = rb_sprintf("%-20s ", insn_name(iobj->insn_id)); if (iobj->operands) { const char *types = insn_op_types(iobj->insn_id); @@ -5411,7 +5423,6 @@ insn_data_to_s_detail(INSN *iobj) https://github.com/ruby/ruby/blob/trunk/compile.c#L5423 for (j = 0; types[j]; j++) { char type = types[j]; - printf("str: %"PRIxVALUE", type: %c\n", str, type); switch (type) { case TS_OFFSET: /* label(destination position) */ @@ -5428,7 +5439,7 @@ insn_data_to_s_detail(INSN *iobj) https://github.com/ruby/ruby/blob/trunk/compile.c#L5439 if (0 && iseq) { /* TODO: invalidate now */ val = iseq->self; } - rb_str_concat(str, rb_inspect(val)); + rb_str_concat(str, opobj_inspect(val)); } break; case TS_LINDEX: @@ -5436,11 +5447,11 @@ insn_data_to_s_detail(INSN *iobj) https://github.com/ruby/ruby/blob/trunk/compile.c#L5447 case TS_VALUE: /* VALUE */ { VALUE v = OPERAND_AT(iobj, j); - rb_str_concat(str, rb_inspect(v)); + rb_str_concat(str, opobj_inspect(v)); break; } case TS_ID: /* ID */ - rb_str_concat(str, rb_inspect(OPERAND_AT(iobj, j))); + rb_str_concat(str, opobj_inspect(OPERAND_AT(iobj, j))); break; case TS_GENTRY: { @@ -5489,7 +5500,7 @@ dump_disasm_list(struct iseq_link_elemen https://github.com/ruby/ruby/blob/trunk/compile.c#L5500 { iobj = (INSN *)link; str = insn_data_to_s_detail(iobj); - printf("%04d %-65s(%4d)\n", pos, StringValueCStr(str), insn_data_line_no(iobj)); + printf("%04d %-65s(%4d)\n", pos, StringValueCStr(str), iobj->line_no); pos += insn_data_length(iobj); break; } @@ -5507,7 +5518,7 @@ dump_disasm_list(struct iseq_link_elemen https://github.com/ruby/ruby/blob/trunk/compile.c#L5518 case ISEQ_ELEMENT_ADJUST: { ADJUST *adjust = (ADJUST *)link; - printf("adjust: [label: %d]\n", adjust->label->label_no); + printf("adjust: [label: %d]\n", adjust->label ? adjust->label->label_no : -1); break; } default: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/