Skip to content

Commit c0cabc0

Browse files
authored
Dump annotations on RubyVM::ISeq.disasm (ruby#9667)
Make it easier to check what annotations an ISEQ has. SINGLE_NOARG_LEAF is added automatically, so it's hard to be sure about the annotation by just reading code. It's also unclear to me what happens to it with Primitive.mandatory_only?, but this at least explains that LEAF annotation is not added to the non-mandatory_only ISEQ.
1 parent 909a710 commit c0cabc0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

iseq.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,6 +2526,15 @@ rb_iseq_disasm_recursive(const rb_iseq_t *iseq, VALUE indent)
25262526
rb_str_modify_expand(str, header_minlen - l);
25272527
memset(RSTRING_END(str), '=', header_minlen - l);
25282528
}
2529+
if (iseq->body->builtin_attrs) {
2530+
#define disasm_builtin_attr(str, iseq, attr) \
2531+
if (iseq->body->builtin_attrs & BUILTIN_ATTR_ ## attr) { \
2532+
rb_str_cat2(str, " " #attr); \
2533+
}
2534+
disasm_builtin_attr(str, iseq, LEAF);
2535+
disasm_builtin_attr(str, iseq, SINGLE_NOARG_LEAF);
2536+
disasm_builtin_attr(str, iseq, INLINE_BLOCK);
2537+
}
25292538
rb_str_cat2(str, "\n");
25302539

25312540
/* show catch table information */

0 commit comments

Comments
 (0)