diff options
author | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-19 13:25:22 +0000 |
---|---|---|
committer | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-19 13:25:22 +0000 |
commit | c86fc2bba5db7b5fc38714deeec29fd2948cc786 (patch) | |
tree | f170a966368c5e9948e10084c7488b199ca64942 /mjit_compile.c | |
parent | 33f2c8940e3bb044489fd8ec0dec2eb47ffc0b3c (diff) | |
download | bundler-c86fc2bba5db7b5fc38714deeec29fd2948cc786.tar.gz |
mjit_compile.c: reduce sp motion on JIT
This retries r62655, which was reverted at r63863 for r63763.
tool/ruby_vm/views/_mjit_compile_insn.erb: revert the revert.
tool/ruby_vm/views/_mjit_compile_insn_body.erb: ditto.
tool/ruby_vm/views/_mjit_compile_pc_and_sp.erb: ditto.
tool/ruby_vm/views/_mjit_compile_send.erb: ditto.
tool/ruby_vm/views/mjit_compile.inc.erb: ditto.
tool/ruby_vm/views/_insn_entry.erb: revert half of r63763. The commit
was originally reverted since changing pc motion was bad for tracing,
but changing sp motion was totally fine. For JIT, I wanna resurrect
the sp motion change in r62051.
tool/ruby_vm/models/bare_instructions.rb: ditto.
insns.def: ditto.
vm_insnhelper.c: ditto.
vm_insnhelper.h: ditto.
* benchmark
$ benchmark-driver benchmark.yml --rbenv 'before;after;before --jit;after --jit' --repeat-count 12 -v
before: ruby 2.6.0dev (2018-07-19 trunk 63998) [x86_64-linux]
after: ruby 2.6.0dev (2018-07-19 add-sp 63998) [x86_64-linux]
last_commit=mjit_compile.c: reduce sp motion on JIT
before --jit: ruby 2.6.0dev (2018-07-19 trunk 63998) +JIT [x86_64-linux]
after --jit: ruby 2.6.0dev (2018-07-19 add-sp 63998) +JIT [x86_64-linux]
last_commit=mjit_compile.c: reduce sp motion on JIT
Calculating -------------------------------------
before after before --jit after --jit
Optcarrot Lan_Master.nes 51.354 50.238 70.010 72.139 fps
Comparison:
Optcarrot Lan_Master.nes
after --jit: 72.1 fps
before --jit: 70.0 fps - 1.03x slower
before: 51.4 fps - 1.40x slower
after: 50.2 fps - 1.44x slower
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'mjit_compile.c')
-rw-r--r-- | mjit_compile.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/mjit_compile.c b/mjit_compile.c index 1f92834853..5eafd72329 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -24,6 +24,9 @@ struct compile_status { int success; /* has TRUE if compilation has had no issue */ int *stack_size_for_pos; /* stack_size_for_pos[pos] has stack size for the position (otherwise -1) */ + /* If TRUE, JIT-ed code will use local variables to store pushed values instead of + using VM's stack and moving stack pointer. */ + int local_stack_p; }; /* Storage to keep data which is consistent in each conditional branch. @@ -172,7 +175,13 @@ compile_insns(FILE *f, const struct rb_iseq_constant_body *body, unsigned int st static void compile_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct compile_status *status) { + unsigned int i; fprintf(f, "\ncancel:\n"); + if (status->local_stack_p) { + for (i = 0; i < body->stack_max; i++) { + fprintf(f, " *((VALUE *)reg_cfp->bp + %d) = stack[%d];\n", i + 1, i); + } + } fprintf(f, " return Qundef;\n"); } @@ -182,6 +191,7 @@ mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *func { struct compile_status status; status.success = TRUE; + status.local_stack_p = !body->catch_except_p; status.stack_size_for_pos = ALLOC_N(int, body->iseq_size); memset(status.stack_size_for_pos, NOT_COMPILED_STACK_SIZE, sizeof(int) * body->iseq_size); @@ -195,7 +205,12 @@ mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *func fprintf(f, "__declspec(dllexport)\n"); #endif 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"); + if (status.local_stack_p) { + fprintf(f, " VALUE stack[%d];\n", body->stack_max); + } + else { + fprintf(f, " VALUE *stack = reg_cfp->sp;\n"); + } fprintf(f, " static const VALUE *const original_body_iseq = (VALUE *)0x%"PRIxVALUE";\n", (VALUE)body->iseq_encoded); |