[前][次][番号順一覧][スレッド一覧]

ruby-changes:50236

From: nobu <ko1@a...>
Date: Sun, 11 Feb 2018 11:41:55 +0900 (JST)
Subject: [ruby-changes:50236] nobu:r62354 (trunk): _mjit_compile_insn.erb: comment_id

nobu	2018-02-11 11:41:50 +0900 (Sun, 11 Feb 2018)

  New Revision: 62354

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62354

  Log:
    _mjit_compile_insn.erb: comment_id
    
    * tool/ruby_vm/views/_mjit_compile_insn.erb: comment ID of
      constant, calling method, and Symbol literal.

  Modified files:
    trunk/mjit_compile.c
    trunk/tool/ruby_vm/views/_mjit_compile_insn.erb
Index: mjit_compile.c
===================================================================
--- mjit_compile.c	(revision 62353)
+++ mjit_compile.c	(revision 62354)
@@ -75,6 +75,28 @@ compile_case_dispatch_each(VALUE key, VA https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L75
     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);
 
Index: tool/ruby_vm/views/_mjit_compile_insn.erb
===================================================================
--- tool/ruby_vm/views/_mjit_compile_insn.erb	(revision 62353)
+++ tool/ruby_vm/views/_mjit_compile_insn.erb	(revision 62354)
@@ -40,7 +40,16 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_insn.erb#L40
 %
 % # 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]