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
45 changes: 4 additions & 41 deletions class.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,6 @@ rb_module_add_to_subclasses_list(VALUE module, VALUE iclass)
}
}

void
rb_class_remove_subclass_head(VALUE klass)
{
rb_classext_t *ext = RCLASS_EXT_WRITABLE(klass);
rb_class_classext_free_subclasses(ext, klass, false);
}

static struct rb_subclass_entry *
class_get_subclasses_for_ns(struct st_table *tbl, VALUE box_id)
{
Expand Down Expand Up @@ -663,18 +656,6 @@ rb_class_remove_from_super_subclasses(VALUE klass)
RCLASSEXT_BOX_SUPER_SUBCLASSES(ext) = 0;
}

void
rb_class_remove_from_module_subclasses(VALUE klass)
{
rb_classext_t *ext = RCLASS_EXT_WRITABLE(klass);
rb_box_subclasses_t *box_subclasses = RCLASSEXT_BOX_MODULE_SUBCLASSES(ext);

if (!box_subclasses) return;
remove_class_from_subclasses(box_subclasses->tbl, box_subclasses_tbl_key(RCLASSEXT_BOX(ext)), klass);
rb_box_subclasses_ref_dec(box_subclasses);
RCLASSEXT_BOX_MODULE_SUBCLASSES(ext) = 0;
}

void
rb_class_classext_free_subclasses(rb_classext_t *ext, VALUE klass, bool replacing)
{
Expand All @@ -695,14 +676,14 @@ rb_class_classext_free_subclasses(rb_classext_t *ext, VALUE klass, bool replacin
rb_box_subclasses_ref_dec(anchor->box_subclasses);
xfree(anchor);

if (!replacing && RCLASSEXT_BOX_SUPER_SUBCLASSES(ext)) {
if (RCLASSEXT_BOX_SUPER_SUBCLASSES(ext)) {
rb_box_subclasses_t *box_sub = RCLASSEXT_BOX_SUPER_SUBCLASSES(ext);
remove_class_from_subclasses(box_sub->tbl, box_id, klass);
if (!replacing) remove_class_from_subclasses(box_sub->tbl, box_id, klass);
rb_box_subclasses_ref_dec(box_sub);
}
if (!replacing && RCLASSEXT_BOX_MODULE_SUBCLASSES(ext)) {
if (RCLASSEXT_BOX_MODULE_SUBCLASSES(ext)) {
rb_box_subclasses_t *box_sub = RCLASSEXT_BOX_MODULE_SUBCLASSES(ext);
remove_class_from_subclasses(box_sub->tbl, box_id, klass);
if (!replacing) remove_class_from_subclasses(box_sub->tbl, box_id, klass);
rb_box_subclasses_ref_dec(box_sub);
}
}
Expand Down Expand Up @@ -730,24 +711,6 @@ class_detach_subclasses(VALUE klass, VALUE arg)
rb_class_remove_from_super_subclasses(klass);
}

void
rb_class_detach_subclasses(VALUE klass)
{
rb_class_foreach_subclass(klass, class_detach_subclasses, Qnil);
}

static void
class_detach_module_subclasses(VALUE klass, VALUE arg)
{
rb_class_remove_from_module_subclasses(klass);
}

void
rb_class_detach_module_subclasses(VALUE klass)
{
rb_class_foreach_subclass(klass, class_detach_module_subclasses, Qnil);
}

static void
class_switch_superclass(VALUE super, VALUE klass)
{
Expand Down
2 changes: 2 additions & 0 deletions ext/objspace/object_tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ allocation_info_tracer_compact_update_object_table_i(st_data_t key, st_data_t va
st_table *table = (st_table *)data;

if (!rb_gc_pointer_to_heap_p(key)) {
struct allocation_info *info = (struct allocation_info *)value;
xfree(info);
return ST_DELETE;
}

Expand Down
6 changes: 0 additions & 6 deletions internal/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,15 +488,9 @@ RCLASSEXT_SET_INCLUDER(rb_classext_t *ext, VALUE klass, VALUE includer)
typedef void rb_class_classext_foreach_callback_func(rb_classext_t *classext, bool is_prime, VALUE box_value, void *arg);
void rb_class_classext_foreach(VALUE klass, rb_class_classext_foreach_callback_func *func, void *arg);
void rb_class_subclass_add(VALUE super, VALUE klass);
void rb_class_remove_from_super_subclasses(VALUE);
void rb_class_remove_from_module_subclasses(VALUE);
void rb_class_classext_free_subclasses(rb_classext_t *, VALUE, bool);
void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
void rb_class_detach_subclasses(VALUE);
void rb_class_detach_module_subclasses(VALUE);
void rb_class_update_superclasses(VALUE);
size_t rb_class_superclasses_memsize(VALUE);
void rb_class_remove_subclass_head(VALUE);
int rb_singleton_class_internal_p(VALUE sklass);
VALUE rb_class_set_super(VALUE klass, VALUE super);
VALUE rb_class_boot(VALUE);
Expand Down
2 changes: 1 addition & 1 deletion ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ proc_long_options(ruby_cmdline_options_t *opt, const char *s, long argc, char **
ruby_verbose = Qtrue;
}
else if (strcmp("jit", s) == 0) {
#if USE_YJIT
#if USE_YJIT || USE_ZJIT
FEATURE_SET(opt->features, FEATURE_BIT(jit));
#else
rb_warn("Ruby was built without JIT support");
Expand Down
2 changes: 1 addition & 1 deletion vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ jit_exec(rb_execution_context_t *ec)
return Qundef;
}

#if USE_YJIT
#if USE_YJIT || USE_ZJIT
// Generate JIT code that supports the following kind of ISEQ entry:
// * The first ISEQ pushed by vm_exec_handle_exception. The frame would
// point to a location specified by a catch table, and it doesn't have
Expand Down
6 changes: 4 additions & 2 deletions zjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def stats_string
# Show fallback counters, ordered by the typical amount of fallbacks for the prefix at the time
print_counters_with_prefix(prefix: 'unspecialized_send_def_type_', prompt: 'not optimized method types for send', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'unspecialized_send_without_block_def_type_', prompt: 'not optimized method types for send_without_block', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'not_optimized_yarv_insn_', prompt: 'not optimized instructions', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'uncategorized_fallback_yarv_insn_', prompt: 'instructions with uncategorized fallback reason', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'send_fallback_', prompt: 'send fallback reasons', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'invokeblock_handler_', prompt: 'invokeblock handler', buf:, stats:, limit: 10)

Expand All @@ -172,8 +172,9 @@ def stats_string
print_counters_with_prefix(prefix: 'complex_arg_pass_', prompt: 'popular complex argument-parameter features not optimized', buf:, stats:, limit: 10)

# Show exit counters, ordered by the typical amount of exits for the prefix at the time
print_counters_with_prefix(prefix: 'unhandled_yarv_insn_', prompt: 'unhandled YARV insns', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'compile_error_', prompt: 'compile error reasons', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'unhandled_yarv_insn_', prompt: 'unhandled YARV insns', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'unhandled_hir_insn_', prompt: 'unhandled HIR insns', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'exit_', prompt: 'side exit reasons', buf:, stats:, limit: 20)

# Show no-prefix counters, having the most important stat `ratio_in_zjit` at the end
Expand All @@ -191,6 +192,7 @@ def stats_string
:dynamic_getivar_count,
:dynamic_setivar_count,

:patch_point_count,
:compiled_iseq_count,
:failed_iseq_count,

Expand Down
5 changes: 3 additions & 2 deletions zjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::invariants::{
use crate::gc::append_gc_offsets;
use crate::payload::{get_or_create_iseq_payload, get_or_create_iseq_payload_ptr, IseqCodePtrs, IseqPayload, IseqStatus};
use crate::state::ZJITState;
use crate::stats::{send_fallback_counter, exit_counter_for_compile_error, incr_counter, incr_counter_by, send_fallback_counter_for_method_type, send_without_block_fallback_counter_for_method_type, send_without_block_fallback_counter_for_optimized_method_type, send_fallback_counter_ptr_for_opcode, CompileError};
use crate::stats::{CompileError, exit_counter_for_compile_error, exit_counter_for_unhandled_hir_insn, incr_counter, incr_counter_by, send_fallback_counter, send_fallback_counter_for_method_type, send_fallback_counter_ptr_for_opcode, send_without_block_fallback_counter_for_method_type, send_without_block_fallback_counter_for_optimized_method_type};
use crate::stats::{counter_ptr, with_time_stat, Counter, Counter::{compile_time_ns, exit_compile_error}};
use crate::{asm::CodeBlock, cruby::*, options::debug, virtualmem::CodePtr};
use crate::backend::lir::{self, Assembler, C_ARG_OPNDS, C_RET_OPND, CFP, EC, NATIVE_BASE_PTR, NATIVE_STACK_PTR, Opnd, SP, SideExit, Target, asm_ccall, asm_comment};
Expand Down Expand Up @@ -280,6 +280,7 @@ fn gen_function(cb: &mut CodeBlock, iseq: IseqPtr, function: &Function) -> Resul
let insn = function.find(insn_id);
if let Err(last_snapshot) = gen_insn(cb, &mut jit, &mut asm, function, insn_id, &insn) {
debug!("ZJIT: gen_function: Failed to compile insn: {insn_id} {insn}. Generating side-exit.");
gen_incr_counter(&mut asm, exit_counter_for_unhandled_hir_insn(&insn));
gen_side_exit(&mut jit, &mut asm, &SideExitReason::UnhandledHIRInsn(insn_id), &function.frame_state(last_snapshot));
// Don't bother generating code after a side-exit. We won't run it.
// TODO(max): Generate ud2 or equivalent.
Expand Down Expand Up @@ -1828,7 +1829,7 @@ fn gen_incr_send_fallback_counter(asm: &mut Assembler, reason: SendFallbackReaso

use SendFallbackReason::*;
match reason {
NotOptimizedInstruction(opcode) => {
Uncategorized(opcode) => {
gen_incr_counter_ptr(asm, send_fallback_counter_ptr_for_opcode(opcode));
}
SendWithoutBlockNotOptimizedMethodType(method_type) => {
Expand Down
Loading