Add rb_jit_vm_unlock and share it in ZJIT and YJIT

This commit is contained in:
Stan Lo 2025-08-29 19:16:43 +01:00 committed by Takashi Kokubun
parent 561050496c
commit 3f3a54efff
9 changed files with 22 additions and 29 deletions

8
jit.c
View File

@ -484,3 +484,11 @@ rb_jit_vm_lock_then_barrier(unsigned int *recursive_lock_level, const char *file
rb_vm_lock_enter(recursive_lock_level, file, line);
rb_vm_barrier();
}
// Release the VM lock. The lock level must point to the same integer used to
// acquire the lock.
void
rb_jit_vm_unlock(unsigned int *recursive_lock_level, const char *file, int line)
{
rb_vm_lock_leave(recursive_lock_level, file, line);
}

8
yjit.c
View File

@ -686,14 +686,6 @@ rb_yjit_obj_written(VALUE old, VALUE young, const char *file, int line)
rb_obj_written(old, Qundef, young, file, line);
}
// Release the VM lock. The lock level must point to the same integer used to
// acquire the lock.
void
rb_yjit_vm_unlock(unsigned int *recursive_lock_level, const char *file, int line)
{
rb_vm_lock_leave(recursive_lock_level, file, line);
}
void
rb_yjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec, bool jit_exception)
{

View File

@ -328,7 +328,6 @@ fn main() {
.allowlist_function("rb_set_cfp_(pc|sp)")
.allowlist_function("rb_c_method_tracing_currently_enabled")
.allowlist_function("rb_full_cfunc_return")
.allowlist_function("rb_yjit_vm_unlock")
.allowlist_function("rb_assert_(iseq|cme)_handle")
.allowlist_function("rb_IMEMO_TYPE_P")
.allowlist_function("rb_yjit_constcache_shareable")
@ -355,6 +354,7 @@ fn main() {
.allowlist_function("rb_jit_shape_too_complex_p")
.allowlist_function("rb_jit_multi_ractor_p")
.allowlist_function("rb_jit_vm_lock_then_barrier")
.allowlist_function("rb_jit_vm_unlock")
.allowlist_type("robject_offsets")
// from vm_sync.h

View File

@ -697,7 +697,7 @@ where
}
};
unsafe { rb_yjit_vm_unlock(&mut recursive_lock_level, file, line) };
unsafe { rb_jit_vm_unlock(&mut recursive_lock_level, file, line) };
ret
}

View File

@ -1226,11 +1226,6 @@ extern "C" {
file: *const ::std::os::raw::c_char,
line: ::std::os::raw::c_int,
);
pub fn rb_yjit_vm_unlock(
recursive_lock_level: *mut ::std::os::raw::c_uint,
file: *const ::std::os::raw::c_char,
line: ::std::os::raw::c_int,
);
pub fn rb_object_shape_count() -> VALUE;
pub fn rb_yjit_shape_obj_too_complex_p(obj: VALUE) -> bool;
pub fn rb_yjit_shape_capacity(shape_id: shape_id_t) -> attr_index_t;
@ -1328,4 +1323,9 @@ extern "C" {
file: *const ::std::os::raw::c_char,
line: ::std::os::raw::c_int,
);
pub fn rb_jit_vm_unlock(
recursive_lock_level: *mut ::std::os::raw::c_uint,
file: *const ::std::os::raw::c_char,
line: ::std::os::raw::c_int,
);
}

7
zjit.c
View File

@ -181,13 +181,6 @@ rb_zjit_constcache_shareable(const struct iseq_inline_constant_cache_entry *ice)
return (ice->flags & IMEMO_CONST_CACHE_SHAREABLE) != 0;
}
// Release the VM lock. The lock level must point to the same integer used to
// acquire the lock.
void
rb_zjit_vm_unlock(unsigned int *recursive_lock_level, const char *file, int line)
{
rb_vm_lock_leave(recursive_lock_level, file, line);
}
bool
rb_zjit_mark_writable(void *mem_block, uint32_t mem_size)

View File

@ -347,7 +347,6 @@ fn main() {
.allowlist_function("rb_set_cfp_(pc|sp)")
.allowlist_function("rb_c_method_tracing_currently_enabled")
.allowlist_function("rb_full_cfunc_return")
.allowlist_function("rb_zjit_vm_unlock")
.allowlist_function("rb_assert_(iseq|cme)_handle")
.allowlist_function("rb_IMEMO_TYPE_P")
.allowlist_function("rb_iseq_reset_jit_func")
@ -368,6 +367,7 @@ fn main() {
.allowlist_function("rb_jit_shape_too_complex_p")
.allowlist_function("rb_jit_multi_ractor_p")
.allowlist_function("rb_jit_vm_lock_then_barrier")
.allowlist_function("rb_jit_vm_unlock")
.allowlist_type("robject_offsets")
// from vm_sync.h

View File

@ -845,7 +845,7 @@ where
}
};
unsafe { rb_zjit_vm_unlock(&mut recursive_lock_level, file, line) };
unsafe { rb_jit_vm_unlock(&mut recursive_lock_level, file, line) };
ret
}

View File

@ -921,11 +921,6 @@ unsafe extern "C" {
pub fn rb_zjit_profile_disable(iseq: *const rb_iseq_t);
pub fn rb_vm_base_ptr(cfp: *mut rb_control_frame_struct) -> *mut VALUE;
pub fn rb_zjit_constcache_shareable(ice: *const iseq_inline_constant_cache_entry) -> bool;
pub fn rb_zjit_vm_unlock(
recursive_lock_level: *mut ::std::os::raw::c_uint,
file: *const ::std::os::raw::c_char,
line: ::std::os::raw::c_int,
);
pub fn rb_zjit_mark_writable(mem_block: *mut ::std::os::raw::c_void, mem_size: u32) -> bool;
pub fn rb_zjit_mark_executable(mem_block: *mut ::std::os::raw::c_void, mem_size: u32);
pub fn rb_zjit_mark_unused(mem_block: *mut ::std::os::raw::c_void, mem_size: u32) -> bool;
@ -1029,4 +1024,9 @@ unsafe extern "C" {
file: *const ::std::os::raw::c_char,
line: ::std::os::raw::c_int,
);
pub fn rb_jit_vm_unlock(
recursive_lock_level: *mut ::std::os::raw::c_uint,
file: *const ::std::os::raw::c_char,
line: ::std::os::raw::c_int,
);
}