aboutsummaryrefslogtreecommitdiffstats
path: root/mjit_compile.c
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 /mjit_compile.c
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 ```
Diffstat (limited to 'mjit_compile.c')
-rw-r--r--mjit_compile.c3
1 files changed, 3 insertions, 0 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;
}