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
1 change: 1 addition & 0 deletions Cargo.lock

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

6 changes: 2 additions & 4 deletions ext/io/console/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -2000,14 +2000,13 @@ InitVM_console(void)
rb_define_method(rb_cIO, "ttyname", console_ttyname, 0);
rb_define_singleton_method(rb_cIO, "console", console_dev, -1);
{
/* :stopdoc: */
/* :nodoc: */
VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
/* :startdoc: */
rb_define_method(mReadable, "getch", io_getch, -1);
rb_define_method(mReadable, "getpass", io_getpass, -1);
}
{
/* :stopdoc: */
/* :nodoc: */
cConmode = rb_define_class_under(rb_cIO, "ConsoleMode", rb_cObject);
rb_define_const(cConmode, "VERSION", rb_obj_freeze(rb_str_new_cstr(IO_CONSOLE_VERSION)));
rb_define_alloc_func(cConmode, conmode_alloc);
Expand All @@ -2016,6 +2015,5 @@ InitVM_console(void)
rb_define_method(cConmode, "echo=", conmode_set_echo, 1);
rb_define_method(cConmode, "raw!", conmode_set_raw, -1);
rb_define_method(cConmode, "raw", conmode_raw_new, -1);
/* :startdoc: */
}
}
2 changes: 1 addition & 1 deletion ext/psych/lib/psych/versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module Psych
VERSION = '5.3.1'

if RUBY_ENGINE == 'jruby'
DEFAULT_SNAKEYAML_VERSION = '3.0.1'.freeze
DEFAULT_SNAKEYAML_VERSION = '2.10'.freeze
end
end
41 changes: 24 additions & 17 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,29 @@ gc_validate_pc(VALUE obj)
#endif
}

NOINLINE(static void gc_newobj_hook(VALUE obj));
static void
gc_newobj_hook(VALUE obj)
{
int lev = RB_GC_VM_LOCK_NO_BARRIER();
{
size_t slot_size = rb_gc_obj_slot_size(obj);
memset((char *)obj + sizeof(struct RBasic), 0, slot_size - sizeof(struct RBasic));

/* We must disable GC here because the callback could call xmalloc
* which could potentially trigger a GC, and a lot of code is unsafe
* to trigger a GC right after an object has been allocated because
* they perform initialization for the object and assume that the
* GC does not trigger before then. */
bool gc_disabled = RTEST(rb_gc_disable_no_rest());
{
rb_gc_event_hook(obj, RUBY_INTERNAL_EVENT_NEWOBJ);
}
if (!gc_disabled) rb_gc_enable();
}
RB_GC_VM_UNLOCK_NO_BARRIER(lev);
}

static inline VALUE
newobj_of(rb_ractor_t *cr, VALUE klass, VALUE flags, shape_id_t shape_id, bool wb_protected, size_t size)
{
Expand All @@ -1018,23 +1041,7 @@ newobj_of(rb_ractor_t *cr, VALUE klass, VALUE flags, shape_id_t shape_id, bool w
gc_validate_pc(obj);

if (UNLIKELY(rb_gc_event_hook_required_p(RUBY_INTERNAL_EVENT_NEWOBJ))) {
int lev = RB_GC_VM_LOCK_NO_BARRIER();
{
size_t slot_size = rb_gc_obj_slot_size(obj);
memset((char *)obj + sizeof(struct RBasic), 0, slot_size - sizeof(struct RBasic));

/* We must disable GC here because the callback could call xmalloc
* which could potentially trigger a GC, and a lot of code is unsafe
* to trigger a GC right after an object has been allocated because
* they perform initialization for the object and assume that the
* GC does not trigger before then. */
bool gc_disabled = RTEST(rb_gc_disable_no_rest());
{
rb_gc_event_hook(obj, RUBY_INTERNAL_EVENT_NEWOBJ);
}
if (!gc_disabled) rb_gc_enable();
}
RB_GC_VM_UNLOCK_NO_BARRIER(lev);
gc_newobj_hook(obj);
}

#if RGENGC_CHECK_MODE
Expand Down
2 changes: 1 addition & 1 deletion gems/bundled_gems
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ostruct 0.6.3 https://github.com/ruby/ostruct
pstore 0.2.1 https://github.com/ruby/pstore
benchmark 0.5.0 https://github.com/ruby/benchmark
logger 1.7.0 https://github.com/ruby/logger
rdoc 7.2.0 https://github.com/ruby/rdoc
rdoc 7.2.0 https://github.com/ruby/rdoc 911b122a587e24f05434dbeb2c3e39cea607e21f
win32ole 1.9.3 https://github.com/ruby/win32ole
irb 1.17.0 https://github.com/ruby/irb
reline 0.6.3 https://github.com/ruby/reline
Expand Down
6 changes: 3 additions & 3 deletions lib/bundled_gems.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- frozen-string-literal: true -*-

# :stopdoc:
module Gem
module Gem # :nodoc:
# TODO: the nodoc above is a workaround for RDoc's Prism parser handling stopdoc differently, we may want to use
# stopdoc/startdoc pair like before
end
# :startdoc:

module Gem::BUNDLED_GEMS # :nodoc:
SINCE = {
Expand Down
3 changes: 1 addition & 2 deletions misc/jit_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def categorize_symbol(dso, symbol):
return '[sha256]'
elif symbol.startswith('[JIT] gen_send'):
return '[JIT send]'
# TODO: Stop using zjit:: as the prefix for JIT code. Rust modules and JIT code should use different namespaces.
elif symbol.startswith('[JIT]') or (symbol.startswith('zjit::') and '@') or symbol == 'zjit::ZJIT entry trampoline':
elif symbol.startswith('[JIT]') or symbol.startswith('ZJIT: ') or dso.startswith('perf-'):
return '[JIT code]'
elif '::' in symbol or symbol.startswith('_ZN4yjit') or symbol.startswith('_ZN4zjit'):
return '[JIT compile]'
Expand Down
1 change: 1 addition & 0 deletions zjit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jit = { version = "0.1.0", path = "../jit" }
[dev-dependencies]
insta = "1.43.1"
rand = "0.9"
yjit = { path = "../yjit" }

# NOTE: Development builds select a set of these via configure.ac
# For debugging, `make V=1` shows exact cargo invocation.
Expand Down
8 changes: 0 additions & 8 deletions zjit/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,5 @@ fn main() {
println!("cargo:rustc-link-lib={lib_name}");
}
}

// When doing a combo build, there is a copy of ZJIT symbols in libruby.a
// and Cargo builds another copy for the test binary. Tell the linker to
// not complaint about duplicate symbols. For some reason, darwin doesn't
// suffer the same issue.
if env::var("TARGET").unwrap().contains("linux") {
println!("cargo:rustc-link-arg=-Wl,--allow-multiple-definition");
}
}
}
11 changes: 8 additions & 3 deletions zjit/src/backend/arm64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,13 @@ mod tests {
(asm, CodeBlock::new_dummy())
}

fn setup_asm_with_scratch_reg() -> (Assembler, CodeBlock, Opnd) {
crate::options::rb_zjit_prepare_options(); // Allow `get_option!` in Assembler
let (mut asm, scratch_reg) = Assembler::new_with_scratch_reg();
asm.new_block_without_id("test");
(asm, CodeBlock::new_dummy(), scratch_reg)
}

#[test]
fn test_lir_string() {
use crate::hir::SideExitReason;
Expand Down Expand Up @@ -2159,9 +2166,7 @@ mod tests {

#[test]
fn test_store_with_valid_scratch_reg() {
let (mut asm, scratch_reg) = Assembler::new_with_scratch_reg();
asm.new_block_without_id("test");
let mut cb = CodeBlock::new_dummy();
let (mut asm, mut cb, scratch_reg) = setup_asm_with_scratch_reg();
asm.store(Opnd::mem(64, scratch_reg, 0), 0x83902.into());

asm.compile_with_num_regs(&mut cb, 0);
Expand Down
16 changes: 14 additions & 2 deletions zjit/src/backend/lir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use std::panic;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
use crate::bitset::BitSet;
use crate::codegen::local_size_and_idx_to_ep_offset;
use crate::codegen::{local_size_and_idx_to_ep_offset, perf_symbol_range_start, perf_symbol_range_end};
use crate::cruby::{Qundef, RUBY_OFFSET_CFP_PC, RUBY_OFFSET_CFP_SP, SIZEOF_VALUE_I32, vm_stack_canary};
use crate::hir::{Invariant, SideExitReason};
use crate::hir;
use crate::options::{TraceExits, get_option};
use crate::options::{TraceExits, PerfMap, get_option};
use crate::cruby::VALUE;
use crate::payload::IseqVersionRef;
use crate::stats::{exit_counter_ptr, exit_counter_ptr_for_opcode, side_exit_counter, CompileError};
Expand Down Expand Up @@ -2675,6 +2675,13 @@ impl Assembler
// Map from SideExit to compiled Label. This table is used to deduplicate side exit code.
let mut compiled_exits: HashMap<SideExit, Label> = HashMap::new();

// Start a new perf range for side exits
let perf_symbol = if get_option!(perf) == Some(PerfMap::HIR) {
Some(perf_symbol_range_start(self, "side exit"))
} else {
None
};

// Mark the start of side-exit code so we can measure its size
if !targets.is_empty() {
self.pos_marker(move |start_pos, cb| {
Expand Down Expand Up @@ -2756,6 +2763,11 @@ impl Assembler
crate::stats::incr_counter_by(crate::stats::Counter::compile_side_exit_time_ns, nanos as u64);
}

// Close the current perf range for side exits
if let Some(perf_symbol) = &perf_symbol {
perf_symbol_range_end(self, perf_symbol);
}

// Extract exit instructions and restore the previous current block
let exit_insns = take(&mut self.basic_blocks[exit_block.0].insns);
self.set_current_block(saved_block);
Expand Down
Loading