ruby-changes:50137
From: k0kubun <ko1@a...>
Date: Tue, 6 Feb 2018 23:27:20 +0900 (JST)
Subject: [ruby-changes:50137] k0kubun:r62255 (trunk): mjit_compile.c: fix inconsistent indentation
k0kubun 2018-02-06 23:27:15 +0900 (Tue, 06 Feb 2018) New Revision: 62255 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62255 Log: mjit_compile.c: fix inconsistent indentation and style of generated code. I've used 2-space indentation at first but at some moment I started to use insns.def contents for generated code. So the 4-space indentation was introduced. But it does no longer make sense. Modified files: trunk/mjit_compile.c trunk/tool/ruby_vm/views/mjit_compile.inc.erb Index: mjit_compile.c =================================================================== --- mjit_compile.c (revision 62254) +++ mjit_compile.c (revision 62255) @@ -137,29 +137,29 @@ mjit_compile(FILE *f, const struct rb_is https://github.com/ruby/ruby/blob/trunk/mjit_compile.c#L137 status.success = TRUE; status.compiled_for_pos = ZALLOC_N(int, body->iseq_size); - fprintf(f, "VALUE %s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp) {\n", funcname); - fprintf(f, " VALUE *stack = reg_cfp->sp;\n"); + fprintf(f, "VALUE\n%s(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp)\n{\n", funcname); + fprintf(f, " VALUE *stack = reg_cfp->sp;\n"); /* Simulate `opt_pc` in setup_parameters_complex */ if (body->param.flags.has_opt) { int i; fprintf(f, "\n"); - fprintf(f, " switch (reg_cfp->pc - reg_cfp->iseq->body->iseq_encoded) {\n"); + fprintf(f, " switch (reg_cfp->pc - reg_cfp->iseq->body->iseq_encoded) {\n"); for (i = 0; i <= body->param.opt_num; i++) { VALUE pc_offset = body->param.opt_table[i]; - fprintf(f, " case %"PRIdVALUE":\n", pc_offset); - fprintf(f, " goto label_%"PRIdVALUE";\n", pc_offset); + fprintf(f, " case %"PRIdVALUE":\n", pc_offset); + fprintf(f, " goto label_%"PRIdVALUE";\n", pc_offset); } - fprintf(f, " }\n"); + fprintf(f, " }\n"); } /* ISeq might be used for catch table too. For that usage, this code cancels JIT execution. */ - fprintf(f, " if (reg_cfp->pc != 0x%"PRIxVALUE") {\n", (VALUE)body->iseq_encoded); - fprintf(f, " return Qundef;\n"); - fprintf(f, " }\n"); + fprintf(f, " if (reg_cfp->pc != 0x%"PRIxVALUE") {\n", (VALUE)body->iseq_encoded); + fprintf(f, " return Qundef;\n"); + fprintf(f, " }\n"); compile_insns(f, body, 0, 0, &status); - fprintf(f, "}\n"); + fprintf(f, "\n} /* end of %s */\n", funcname); xfree(status.compiled_for_pos); return status.success; Index: tool/ruby_vm/views/mjit_compile.inc.erb =================================================================== --- tool/ruby_vm/views/mjit_compile.inc.erb (revision 62254) +++ tool/ruby_vm/views/mjit_compile.inc.erb (revision 62255) @@ -63,4 +63,4 @@ switch (insn) { https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/mjit_compile.inc.erb#L63 /* if next_pos is already compiled, next instruction won't be compiled in C code and needs `goto`. */ if ((next_pos < body->iseq_size && status->compiled_for_pos[next_pos])) - fprintf(f, " goto label_%d;\n", next_pos); + fprintf(f, "goto label_%d;\n", next_pos); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/