Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions include/ruby/internal/intern/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,9 @@ void rb_must_asciicompat(VALUE obj);
VALUE rb_str_dup(VALUE str);

/**
* I guess there is no use case of this function in extension libraries, but
* this is a routine identical to rb_str_dup(), except it always creates an
* instance of ::rb_cString regardless of the given object's class. This makes
* the most sense when the passed string is formerly hidden by rb_obj_hide().
* Like rb_str_dup(), but always create an instance of ::rb_cString
* regardless of the given object's class. This makes the most sense
* when the passed string is formerly hidden by rb_obj_hide().
*
* @param[in] str A string, possibly hidden.
* @return A duplicated new instance of ::rb_cString.
Expand Down
26 changes: 26 additions & 0 deletions jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "insns_info.inc"
#include "iseq.h"
#include "internal/gc.h"
#include "vm_sync.h"

// Field offsets for the RObject struct
enum robject_offsets {
Expand Down Expand Up @@ -466,3 +467,28 @@ rb_jit_shape_too_complex_p(shape_id_t shape_id)
{
return rb_shape_too_complex_p(shape_id);
}

bool
rb_jit_multi_ractor_p(void)
{
return rb_multi_ractor_p();
}

// Acquire the VM lock and then signal all other Ruby threads (ractors) to
// contend for the VM lock, putting them to sleep. ZJIT and YJIT use this to
// evict threads running inside generated code so among other things, it can
// safely change memory protection of regions housing generated code.
void
rb_jit_vm_lock_then_barrier(unsigned int *recursive_lock_level, const char *file, int line)
{
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);
}
2 changes: 1 addition & 1 deletion spec/ruby/language/regexp/character_classes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
"\u{16EE}".match(/[[:word:]]/).to_a.should == ["\u{16EE}"]
end

ruby_bug "#19417", ""..."3.5" do
ruby_bug "#19417", ""..."3.4.6" do
it "matches Unicode join control characters with [[:word:]]" do
"\u{200C}".match(/[[:word:]]/).to_a.should == ["\u{200C}"]
"\u{200D}".match(/[[:word:]]/).to_a.should == ["\u{200D}"]
Expand Down
3 changes: 3 additions & 0 deletions tool/enc-unicode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# You can get source file for gperf. After this, simply make ruby.
# Or directly run:
# tool/enc-unicode.rb --header data_dir emoji_data_dir > enc/unicode/<VERSION>/name2ctype.h
#
# There are Makefile rules that automate steps above: `make update-unicode` and
# `make enc/unicode/<VERSION>/name2ctype.h`.

while arg = ARGV.shift
case arg
Expand Down
26 changes: 0 additions & 26 deletions yjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "builtin.h"
#include "insns.inc"
#include "insns_info.inc"
#include "vm_sync.h"
#include "yjit.h"
#include "zjit.h"
#include "vm_insnhelper.h"
Expand Down Expand Up @@ -638,12 +637,6 @@ rb_ENCODING_GET(VALUE obj)
return RB_ENCODING_GET(obj);
}

bool
rb_yjit_multi_ractor_p(void)
{
return rb_multi_ractor_p();
}

bool
rb_yjit_constcache_shareable(const struct iseq_inline_constant_cache_entry *ice)
{
Expand Down Expand Up @@ -693,25 +686,6 @@ rb_yjit_obj_written(VALUE old, VALUE young, const char *file, int line)
rb_obj_written(old, Qundef, young, file, line);
}

// Acquire the VM lock and then signal all other Ruby threads (ractors) to
// contend for the VM lock, putting them to sleep. YJIT uses this to evict
// threads running inside generated code so among other things, it can
// safely change memory protection of regions housing generated code.
void
rb_yjit_vm_lock_then_barrier(unsigned int *recursive_lock_level, const char *file, int line)
{
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_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)
{
Expand Down
6 changes: 3 additions & 3 deletions yjit/bindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,8 @@ fn main() {
.allowlist_function("rb_yjit_iseq_inspect")
.allowlist_function("rb_yjit_builtin_function")
.allowlist_function("rb_set_cfp_(pc|sp)")
.allowlist_function("rb_yjit_multi_ractor_p")
.allowlist_function("rb_c_method_tracing_currently_enabled")
.allowlist_function("rb_full_cfunc_return")
.allowlist_function("rb_yjit_vm_lock_then_barrier")
.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")
Expand All @@ -355,6 +352,9 @@ fn main() {
// From jit.c
.allowlist_function("rb_assert_holding_vm_lock")
.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
Expand Down
4 changes: 2 additions & 2 deletions yjit/src/cruby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ where
let line = loc.line;
let mut recursive_lock_level: c_uint = 0;

unsafe { rb_yjit_vm_lock_then_barrier(&mut recursive_lock_level, file, line) };
unsafe { rb_jit_vm_lock_then_barrier(&mut recursive_lock_level, file, line) };

let ret = match catch_unwind(func) {
Ok(result) => result,
Expand All @@ -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
}
Expand Down
22 changes: 11 additions & 11 deletions yjit/src/cruby_bindings.inc.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions yjit/src/invariants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub fn assume_method_basic_definition(
/// Tracks that a block is assuming it is operating in single-ractor mode.
#[must_use]
pub fn assume_single_ractor_mode(jit: &mut JITState, asm: &mut Assembler) -> bool {
if unsafe { rb_yjit_multi_ractor_p() } {
if unsafe { rb_jit_multi_ractor_p() } {
false
} else {
if jit_ensure_block_entry_exit(jit, asm).is_none() {
Expand Down Expand Up @@ -495,7 +495,7 @@ pub extern "C" fn rb_yjit_constant_ic_update(iseq: *const rb_iseq_t, ic: IC, ins
return;
};

if !unsafe { (*(*ic).entry).ic_cref }.is_null() || unsafe { rb_yjit_multi_ractor_p() } {
if !unsafe { (*(*ic).entry).ic_cref }.is_null() || unsafe { rb_jit_multi_ractor_p() } {
// We can't generate code in these situations, so no need to invalidate.
// See gen_opt_getinlinecache.
return;
Expand Down
25 changes: 0 additions & 25 deletions zjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "insns.inc"
#include "insns_info.inc"
#include "zjit.h"
#include "vm_sync.h"
#include "vm_insnhelper.h"
#include "probes.h"
#include "probes_helper.h"
Expand Down Expand Up @@ -176,25 +175,12 @@ rb_zjit_compile_iseq(const rb_iseq_t *iseq, rb_execution_context_t *ec, bool jit

extern VALUE *rb_vm_base_ptr(struct rb_control_frame_struct *cfp);

bool
rb_zjit_multi_ractor_p(void)
{
return rb_multi_ractor_p();
}

bool
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)
Expand Down Expand Up @@ -245,17 +231,6 @@ rb_zjit_icache_invalidate(void *start, void *end)
#endif
}

// Acquire the VM lock and then signal all other Ruby threads (ractors) to
// contend for the VM lock, putting them to sleep. ZJIT uses this to evict
// threads running inside generated code so among other things, it can
// safely change memory protection of regions housing generated code.
void
rb_zjit_vm_lock_then_barrier(unsigned int *recursive_lock_level, const char *file, int line)
{
rb_vm_lock_enter(recursive_lock_level, file, line);
rb_vm_barrier();
}

// Convert a given ISEQ's instructions to zjit_* instructions
void
rb_zjit_profile_enable(const rb_iseq_t *iseq)
Expand Down
6 changes: 3 additions & 3 deletions zjit/bindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +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_lock_then_barrier")
.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")
Expand All @@ -367,6 +365,9 @@ fn main() {
// From jit.c
.allowlist_function("rb_assert_holding_vm_lock")
.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
Expand Down Expand Up @@ -433,7 +434,6 @@ fn main() {
.allowlist_function("rb_get_cfp_ep")
.allowlist_function("rb_get_cfp_ep_level")
.allowlist_function("rb_get_cme_def_type")
.allowlist_function("rb_zjit_multi_ractor_p")
.allowlist_function("rb_zjit_constcache_shareable")
.allowlist_function("rb_get_cme_def_body_attr_id")
.allowlist_function("rb_get_symbol_id")
Expand Down
4 changes: 2 additions & 2 deletions zjit/src/cruby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ where
let line = loc.line;
let mut recursive_lock_level: c_uint = 0;

unsafe { rb_zjit_vm_lock_then_barrier(&mut recursive_lock_level, file, line) };
unsafe { rb_jit_vm_lock_then_barrier(&mut recursive_lock_level, file, line) };

let ret = match catch_unwind(func) {
Ok(result) => result,
Expand All @@ -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
}
Expand Down
22 changes: 11 additions & 11 deletions zjit/src/cruby_bindings.inc.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion zjit/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ impl Function {
self.push_insn_id(block, insn_id); continue;
}
let cref_sensitive = !unsafe { (*ice).ic_cref }.is_null();
let multi_ractor_mode = unsafe { rb_zjit_multi_ractor_p() };
let multi_ractor_mode = unsafe { rb_jit_multi_ractor_p() };
if cref_sensitive || multi_ractor_mode {
self.push_insn_id(block, insn_id); continue;
}
Expand Down