From c0cabc0a699b2c8b0fded6d0ed85aff4bf102c03 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 23 Jan 2024 14:54:39 -0800 Subject: [PATCH] Dump annotations on RubyVM::ISeq.disasm (#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. --- iseq.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/iseq.c b/iseq.c index babc7948de..87cca58468 100644 --- a/iseq.c +++ b/iseq.c @@ -2526,6 +2526,15 @@ rb_iseq_disasm_recursive(const rb_iseq_t *iseq, VALUE indent) rb_str_modify_expand(str, header_minlen - l); memset(RSTRING_END(str), '=', header_minlen - l); } + if (iseq->body->builtin_attrs) { +#define disasm_builtin_attr(str, iseq, attr) \ + if (iseq->body->builtin_attrs & BUILTIN_ATTR_ ## attr) { \ + rb_str_cat2(str, " " #attr); \ + } + disasm_builtin_attr(str, iseq, LEAF); + disasm_builtin_attr(str, iseq, SINGLE_NOARG_LEAF); + disasm_builtin_attr(str, iseq, INLINE_BLOCK); + } rb_str_cat2(str, "\n"); /* show catch table information */