aboutsummaryrefslogtreecommitdiffstats
path: root/vm.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2023-08-22 07:46:03 +0200
committerJean Boussier <jean.boussier@gmail.com>2023-08-23 20:20:17 +0200
commitcedb333063694f2ac87baeb5c49a81c26e0ddebf (patch)
tree57824ae640f0eee524f2e068553708a57e39843d /vm.c
parent24bcd494735fe88537851ea096e6b14104f9032f (diff)
downloadruby-cedb333063694f2ac87baeb5c49a81c26e0ddebf.tar.gz
Stop incrementing `jit_entry_calls` once threshold is hit
Otherwise the ISeq page will constantly be written into preventing it from being shared.
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/vm.c b/vm.c
index 106155b50f..ad1520b55c 100644
--- a/vm.c
+++ b/vm.c
@@ -381,19 +381,16 @@ static VALUE vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, VALUE s
static inline rb_jit_func_t
jit_compile(rb_execution_context_t *ec)
{
- // Increment the ISEQ's call counter
const rb_iseq_t *iseq = ec->cfp->iseq;
struct rb_iseq_constant_body *body = ISEQ_BODY(iseq);
bool yjit_enabled = rb_yjit_compile_new_iseqs();
- if (yjit_enabled || rb_rjit_call_p) {
- body->jit_entry_calls++;
- }
- else {
+ if (!(yjit_enabled || rb_rjit_call_p)) {
return NULL;
}
- // Trigger JIT compilation if not compiled
+ // Increment the ISEQ's call counter and trigger JIT compilation if not compiled
if (body->jit_entry == NULL) {
+ body->jit_entry_calls++;
if (yjit_enabled) {
if (rb_yjit_threshold_hit(iseq, body->jit_entry_calls)) {
rb_yjit_compile_iseq(iseq, ec, false);
@@ -436,19 +433,18 @@ jit_exec(rb_execution_context_t *ec)
static inline rb_jit_func_t
jit_compile_exception(rb_execution_context_t *ec)
{
- // Increment the ISEQ's call counter
const rb_iseq_t *iseq = ec->cfp->iseq;
struct rb_iseq_constant_body *body = ISEQ_BODY(iseq);
- if (rb_yjit_compile_new_iseqs()) {
- body->jit_exception_calls++;
- }
- else {
+ if (!rb_yjit_compile_new_iseqs()) {
return NULL;
}
- // Trigger JIT compilation if not compiled
- if (body->jit_exception == NULL && rb_yjit_threshold_hit(iseq, body->jit_exception_calls)) {
- rb_yjit_compile_iseq(iseq, ec, true);
+ // Increment the ISEQ's call counter and trigger JIT compilation if not compiled
+ if (body->jit_exception == NULL) {
+ body->jit_exception_calls++;
+ if (rb_yjit_threshold_hit(iseq, body->jit_exception_calls)) {
+ rb_yjit_compile_iseq(iseq, ec, true);
+ }
}
return body->jit_exception;
}