From 8d590c99edf990db574bd5be087b96ab021cef51 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 11 Feb 2018 02:41:50 +0000 Subject: _mjit_compile_insn.erb: comment_id * tool/ruby_vm/views/_mjit_compile_insn.erb: comment ID of constant, calling method, and Symbol literal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- mjit_compile.c | 22 ++++++++++++++++++++++ tool/ruby_vm/views/_mjit_compile_insn.erb | 11 ++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/mjit_compile.c b/mjit_compile.c index 4e4ca39e7f..c00ca85338 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -75,6 +75,28 @@ compile_case_dispatch_each(VALUE key, VALUE value, VALUE arg) return ST_CONTINUE; } +static void +comment_id(FILE *f, ID id) +{ + VALUE name = rb_id2str(id); + const char *p, *e; + char c, prev = '\0'; + + if (!name) return; + p = RSTRING_PTR(name); + e = RSTRING_END(name); + fputs("/* :\"", f); + for (; p < e; ++p) { + switch (c = *p) { + case '*': case '/': if (prev != (c ^ ('/' ^ '*'))) break; + case '\\': case '"': fputc('\\', f); + } + fputc(c, f); + prev = c; + } + fputs("\" */", f); +} + static void compile_insns(FILE *f, const struct rb_iseq_constant_body *body, unsigned int stack_size, unsigned int pos, struct compile_status *status); diff --git a/tool/ruby_vm/views/_mjit_compile_insn.erb b/tool/ruby_vm/views/_mjit_compile_insn.erb index 0b3f1b56e4..8821ad7747 100644 --- a/tool/ruby_vm/views/_mjit_compile_insn.erb +++ b/tool/ruby_vm/views/_mjit_compile_insn.erb @@ -40,7 +40,16 @@ % % # JIT: Initialize operands % insn.opes.each_with_index do |ope, i| - fprintf(f, " <%= ope.fetch(:name) %> = (<%= ope.fetch(:type) %>)0x%"PRIxVALUE";\n", operands[<%= i %>]); + fprintf(f, " <%= ope.fetch(:name) %> = (<%= ope.fetch(:type) %>)0x%"PRIxVALUE";", operands[<%= i %>]); +% case ope.fetch(:type) +% when 'ID' + comment_id(f, (ID)operands[<%= i %>]); +% when 'CALL_INFO' + comment_id(f, ((CALL_INFO)operands[<%= i %>])->mid); +% when 'VALUE' + if (SYMBOL_P((VALUE)operands[<%= i %>])) comment_id(f, SYM2ID((VALUE)operands[<%= i %>])); +% end + fprintf(f, "\n"); % end % % # JIT: Initialize popped values -- cgit v1.2.3