Skip to content
Closed
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
9 changes: 5 additions & 4 deletions .github/workflows/zjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ jobs:

- test_task: 'zjit-bindgen'
hint: 'To fix: use patch in logs'
configure: '--enable-zjit=dev --with-gcc=clang-14'
libclang_path: '/usr/lib/llvm-14/lib/libclang.so.1'
configure: '--enable-zjit=dev --with-gcc=clang-16'
clang_path: '/usr/bin/clang-16'
runs-on: 'ubuntu-24.04' # for clang-16

- test_task: 'test-bundled-gems'
configure: '--enable-zjit=dev'
Expand All @@ -87,7 +88,7 @@ jobs:
RUST_BACKTRACE: 1
ZJIT_RB_BUG: 1

runs-on: ubuntu-22.04
runs-on: ${{ matrix.runs-on || 'ubuntu-22.04' }}

if: >-
${{!(false
Expand Down Expand Up @@ -175,7 +176,7 @@ jobs:
PRECHECK_BUNDLED_GEMS: 'no'
SYNTAX_SUGGEST_TIMEOUT: '5'
ZJIT_BINDGEN_DIFF_OPTS: '--exit-code'
LIBCLANG_PATH: ${{ matrix.libclang_path }}
CLANG_PATH: ${{ matrix.clang_path }}
TESTS: ${{ matrix.test_all_opts }}
continue-on-error: ${{ matrix.continue-on-test_task || false }}

Expand Down
1 change: 1 addition & 0 deletions insns.def
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,7 @@ opt_aref
* default_proc. This is a method call. So opt_aref is
* (surprisingly) not leaf. */
// attr bool leaf = false; /* has rb_funcall() */ /* calls #yield */
// attr bool zjit_profile = true;
{
val = vm_opt_aref(recv, obj);

Expand Down
2 changes: 1 addition & 1 deletion zjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ rb_zjit_print_exception(void)
rb_warn("Ruby error: %"PRIsVALUE"", rb_funcall(exception, rb_intern("full_message"), 0));
}

enum {
enum zjit_exported_constants {
RB_INVALID_SHAPE_ID = INVALID_SHAPE_ID,
};

Expand Down
1 change: 1 addition & 0 deletions zjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def stats_string

# Show counters independent from exit_* or dynamic_send_*
print_counters_with_prefix(prefix: 'not_inlined_cfuncs_', prompt: 'not inlined C methods', buf:, stats:, limit: 20)
print_counters_with_prefix(prefix: 'not_annotated_cfuncs_', prompt: 'not annotated C methods', buf:, stats:, limit: 20)

# Show fallback counters, ordered by the typical amount of fallbacks for the prefix at the time
print_counters_with_prefix(prefix: 'unspecialized_def_type_', prompt: 'not optimized method types', buf:, stats:, limit: 20)
Expand Down
2 changes: 1 addition & 1 deletion zjit/bindgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fn main() {
.allowlist_function("rb_zjit_insn_leaf")
.allowlist_type("robject_offsets")
.allowlist_type("rstring_offsets")
.allowlist_var("RB_INVALID_SHAPE_ID")
.allowlist_type("zjit_exported_constants")
.allowlist_function("rb_assert_holding_vm_lock")
.allowlist_function("rb_jit_shape_too_complex_p")
.allowlist_function("rb_jit_multi_ractor_p")
Expand Down
2 changes: 1 addition & 1 deletion zjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
Insn::CCallWithFrame { cd, state, args, .. } if args.len() > C_ARG_OPNDS.len() =>
gen_send_without_block(jit, asm, *cd, &function.frame_state(*state), SendFallbackReason::CCallWithFrameTooManyArgs),
Insn::CCallWithFrame { cfunc, args, cme, state, .. } => gen_ccall_with_frame(jit, asm, *cfunc, opnds!(args), *cme, &function.frame_state(*state)),
Insn::CCallVariadic { cfunc, recv, args, name: _, cme, state } => {
Insn::CCallVariadic { cfunc, recv, args, name: _, cme, state, return_type: _, elidable: _ } => {
gen_ccall_variadic(jit, asm, *cfunc, opnd!(recv), opnds!(args), *cme, &function.frame_state(*state))
}
Insn::GetIvar { self_val, id, state: _ } => gen_getivar(asm, opnd!(self_val), *id),
Expand Down
11 changes: 6 additions & 5 deletions zjit/src/cruby_bindings.inc.rs

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

20 changes: 18 additions & 2 deletions zjit/src/cruby_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ pub struct FnProperties {
pub elidable: bool,
}

/// A safe default for un-annotated Ruby methods: we can't optimize them or their returned values.
impl Default for FnProperties {
fn default() -> Self {
Self {
no_gc: false,
leaf: false,
return_type: types::BasicObject,
elidable: false,
}
}
}

impl Annotations {
/// Query about properties of a C method
pub fn get_cfunc_properties(&self, method: *const rb_callable_method_entry_t) -> Option<FnProperties> {
Expand Down Expand Up @@ -140,11 +152,12 @@ pub fn init() -> Annotations {
let builtin_funcs = &mut HashMap::new();

macro_rules! annotate {
($module:ident, $method_name:literal, $return_type:expr, $($properties:ident),+) => {
($module:ident, $method_name:literal, $return_type:expr $(, $properties:ident)*) => {
#[allow(unused_mut)]
let mut props = FnProperties { no_gc: false, leaf: false, elidable: false, return_type: $return_type };
$(
props.$properties = true;
)+
)*
annotate_c_method(cfuncs, unsafe { $module }, $method_name, props);
}
}
Expand All @@ -167,11 +180,14 @@ pub fn init() -> Annotations {

annotate!(rb_mKernel, "itself", types::BasicObject, no_gc, leaf, elidable);
annotate!(rb_cString, "bytesize", types::Fixnum, no_gc, leaf);
annotate!(rb_cString, "to_s", types::StringExact);
annotate!(rb_cModule, "name", types::StringExact.union(types::NilClass), no_gc, leaf, elidable);
annotate!(rb_cModule, "===", types::BoolExact, no_gc, leaf);
annotate!(rb_cArray, "length", types::Fixnum, no_gc, leaf, elidable);
annotate!(rb_cArray, "size", types::Fixnum, no_gc, leaf, elidable);
annotate!(rb_cArray, "empty?", types::BoolExact, no_gc, leaf, elidable);
annotate!(rb_cArray, "reverse", types::ArrayExact, leaf, elidable);
annotate!(rb_cArray, "join", types::StringExact);
annotate!(rb_cHash, "empty?", types::BoolExact, no_gc, leaf, elidable);
annotate!(rb_cNilClass, "nil?", types::TrueClass, no_gc, leaf, elidable);
annotate!(rb_mKernel, "nil?", types::FalseClass, no_gc, leaf, elidable);
Expand Down
Loading
Loading