aboutsummaryrefslogtreecommitdiffstats
path: root/mjit.h
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-14 04:52:02 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-04-14 04:52:02 +0000
commit9b6b4674d77da2ef3f9f15095af9e39cc966b882 (patch)
tree526581a204348af1c910fd77638328a8cadc3a9b /mjit.h
parent088df9c8c26bcd7ad4de6637d9e734c26e7b72a0 (diff)
downloadruby-9b6b4674d77da2ef3f9f15095af9e39cc966b882.tar.gz
Recompile JIT-ed code without optimization
based on inline cache when JIT cancel happens by that. This feature was in the original MJIT implementation by Vladimir, but on merging MJIT to Ruby it was removed for simplification. This commit adds the functionality again for the following benchmark: https://github.com/benchmark-driver/misc/blob/52f05781f65467baf895bf6ba79d172c9b0826fd/concurrent-map/bench.rb (shown float is duration seconds. shorter is better) * Before ``` $ INHERIT=0 ruby -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) [x86_64-linux] -- 1.6507579649914987 $ INHERIT=0 ruby -v --jit bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) +JIT [x86_64-linux] -- 1.5091587850474752 $ INHERIT=1 ruby -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) [x86_64-linux] -- 1.6124781150138006 $ INHERIT=1 ruby --jit -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) +JIT [x86_64-linux] -- 1.7495657080435194 # <-- this ``` * After ``` $ INHERIT=0 ruby -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) [x86_64-linux] last_commit=Recompile JIT-ed code without optimization -- 1.653559010999743 $ INHERIT=0 ruby --jit -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) +JIT [x86_64-linux] last_commit=Recompile JIT-ed code without optimization -- 1.4738391840364784 $ INHERIT=1 ruby -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) [x86_64-linux] last_commit=Recompile JIT-ed code without optimization -- 1.645227018976584 $ INHERIT=1 ruby --jit -v bench.rb ruby 2.7.0dev (2019-04-13 trunk 67523) +JIT [x86_64-linux] last_commit=Recompile JIT-ed code without optimization -- 1.523708809982054 # <-- this ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'mjit.h')
-rw-r--r--mjit.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/mjit.h b/mjit.h
index 6fb15b402c..2e135287e2 100644
--- a/mjit.h
+++ b/mjit.h
@@ -55,14 +55,24 @@ struct mjit_options {
int max_cache_size;
};
+// State of optimization switches
+struct rb_mjit_compile_info {
+ // Disable getinstancevariable/setinstancevariable optimizations based on inline cache
+ bool disable_ivar_cache;
+ // Disable send/opt_send_without_block optimizations based on inline cache
+ bool disable_send_cache;
+};
+
typedef VALUE (*mjit_func_t)(rb_execution_context_t *, rb_control_frame_t *);
RUBY_SYMBOL_EXPORT_BEGIN
RUBY_EXTERN struct mjit_options mjit_opts;
RUBY_EXTERN bool mjit_call_p;
-extern void mjit_add_iseq_to_process(const rb_iseq_t *iseq);
+extern void rb_mjit_add_iseq_to_process(const rb_iseq_t *iseq);
extern VALUE mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body);
+extern struct rb_mjit_compile_info* rb_mjit_iseq_compile_info(const struct rb_iseq_constant_body *body);
+extern void rb_mjit_recompile_iseq(const rb_iseq_t *iseq);
RUBY_SYMBOL_EXPORT_END
extern bool mjit_compile(FILE *f, const rb_iseq_t *iseq, const char *funcname);
@@ -120,7 +130,7 @@ mjit_exec(rb_execution_context_t *ec)
RB_DEBUG_COUNTER_INC(mjit_exec_not_added);
if (total_calls == mjit_opts.min_calls && mjit_target_iseq_p(body)) {
RB_DEBUG_COUNTER_INC(mjit_exec_not_added_add_iseq);
- mjit_add_iseq_to_process(iseq);
+ rb_mjit_add_iseq_to_process(iseq);
if (UNLIKELY(mjit_opts.wait)) {
return mjit_wait_call(ec, body);
}