summaryrefslogtreecommitdiff
path: root/mjit.h
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2020-10-13 11:15:22 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:25 -0400
commit8bda11f69065d08284b5990097c45a05076d36bd (patch)
tree74043f49d1534f6d7871020176a554589f1c6746 /mjit.h
parentef9eb83cbecb3d7add699c41f713a42c296fe65a (diff)
MicroJIT: compile after ten calls
Diffstat (limited to 'mjit.h')
-rw-r--r--mjit.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/mjit.h b/mjit.h
index 813ac0cf21..413e6f83cc 100644
--- a/mjit.h
+++ b/mjit.h
@@ -16,6 +16,7 @@
#include "debug_counter.h"
#include "ruby.h"
+#include "ujit_compile.h"
// Special address values of a function generated from the
// corresponding iseq by MJIT:
@@ -142,7 +143,7 @@ mjit_exec(rb_execution_context_t *ec)
const rb_iseq_t *iseq;
struct rb_iseq_constant_body *body;
- if (!mjit_call_p)
+ if (!mjit_call_p && !rb_ujit_enabled_p())
return Qundef;
RB_DEBUG_COUNTER_INC(mjit_exec);
@@ -150,6 +151,11 @@ mjit_exec(rb_execution_context_t *ec)
body = iseq->body;
body->total_calls++;
+ const int ujit_call_threashold = 10;
+ if (body->total_calls == ujit_call_threashold) {
+ rb_ujit_compile_iseq(iseq);
+ }
+
mjit_func_t func = body->jit_func;
if (UNLIKELY((uintptr_t)func <= LAST_JIT_ISEQ_FUNC)) {
# ifdef MJIT_HEADER