aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-11-27 00:36:02 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2020-11-27 00:42:42 -0800
commitd40983772966938828a28c6e89752a3e76447b9e (patch)
tree027fc5cfbbc4178a4b75637535dd2bd49099cea5
parent5496415d3165e57e3ade16238a4cc9ec2c3a81f6 (diff)
downloadruby-d40983772966938828a28c6e89752a3e76447b9e.tar.gz
Cache access to reg_cfp->self on JIT
``` $ benchmark-driver -v --rbenv 'before --jit;after --jit' --repeat-count=12 --alternate --output=all benchmark.yml before --jit: ruby 3.0.0dev (2020-11-27T06:41:15Z master 8ce1711c25) +JIT [x86_64-linux] after --jit: ruby 3.0.0dev (2020-11-27T08:36:02Z master 2c592126b9) +JIT [x86_64-linux] last_commit=Cache access to reg_cfp->self on JIT Calculating ------------------------------------- before --jit after --jit Optcarrot Lan_Master.nes 82.40522392468650 82.66023870551237 fps 82.67998539899482 83.08660305312587 85.51280693947453 87.09311989553235 86.32925337181406 87.16115255191410 87.35617494926235 87.30699391518075 87.91865339426212 88.47590342996875 88.11573661006648 88.64778616696353 88.16060826662158 88.67015079203991 88.21639244865058 89.19630739497482 88.47241577897603 89.23443637947730 89.37087287229809 89.57052723997015 89.46969964699964 89.97803363889025 ```
-rw-r--r--mjit_compile.c3
-rw-r--r--tool/ruby_vm/views/mjit_compile.inc.erb2
2 files changed, 4 insertions, 1 deletions
diff --git a/mjit_compile.c b/mjit_compile.c
index c1d8f3468a..8591b5c5d6 100644
--- a/mjit_compile.c
+++ b/mjit_compile.c
@@ -348,6 +348,8 @@ mjit_compile_body(FILE *f, const rb_iseq_t *iseq, struct compile_status *status)
fprintf(f, " static const rb_iseq_t *original_iseq = (const rb_iseq_t *)0x%"PRIxVALUE";\n", (VALUE)iseq);
fprintf(f, " static const VALUE *const original_body_iseq = (VALUE *)0x%"PRIxVALUE";\n",
(VALUE)body->iseq_encoded);
+ fprintf(f, " VALUE cfp_self = reg_cfp->self;\n"); // cache self across the method
+ fprintf(f, "#define GET_SELF() cfp_self\n");
// Generate merged ivar guards first if needed
if (!status->compile_info->disable_ivar_cache && status->merge_ivar_guards_p) {
@@ -379,6 +381,7 @@ mjit_compile_body(FILE *f, const rb_iseq_t *iseq, struct compile_status *status)
compile_insns(f, body, 0, 0, status);
compile_cancel_handler(f, body, status);
+ fprintf(f, "#undef GET_SELF");
return status->success;
}
diff --git a/tool/ruby_vm/views/mjit_compile.inc.erb b/tool/ruby_vm/views/mjit_compile.inc.erb
index 6836d59a4f..32fd65ad6c 100644
--- a/tool/ruby_vm/views/mjit_compile.inc.erb
+++ b/tool/ruby_vm/views/mjit_compile.inc.erb
@@ -35,7 +35,7 @@
% # GET_CFP(): refers to `reg_cfp`
% # GET_EP(): refers to `reg_cfp->ep`
% # GET_SP(): refers to `reg_cfp->sp`, or `(stack + stack_size)` if local_stack_p
-% # GET_SELF(): refers to `reg_cfp->self`
+% # GET_SELF(): refers to `cfp_self`
% # GET_LEP(): refers to `VM_EP_LEP(reg_cfp->ep)`
% # EXEC_EC_CFP(): refers to `val = vm_exec(ec, TRUE)` with frame setup
% # CALL_METHOD(): using `GET_CFP()` and `EXEC_EC_CFP()`