Skip to content

Commit aeb03d0

Browse files
authored
Merge branch 'master' into zjit-bindgen-clang-16-update
2 parents 6bba6dd + 117e5b6 commit aeb03d0

File tree

11 files changed

+256
-27
lines changed

11 files changed

+256
-27
lines changed

insns.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,7 @@ opt_aref
15191519
* default_proc. This is a method call. So opt_aref is
15201520
* (surprisingly) not leaf. */
15211521
// attr bool leaf = false; /* has rb_funcall() */ /* calls #yield */
1522+
// attr bool zjit_profile = true;
15221523
{
15231524
val = vm_opt_aref(recv, obj);
15241525

zjit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ rb_zjit_print_exception(void)
235235
rb_warn("Ruby error: %"PRIsVALUE"", rb_funcall(exception, rb_intern("full_message"), 0));
236236
}
237237

238-
enum {
238+
enum zjit_exported_constants {
239239
RB_INVALID_SHAPE_ID = INVALID_SHAPE_ID,
240240
};
241241

zjit.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def stats_string
156156

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

160161
# Show fallback counters, ordered by the typical amount of fallbacks for the prefix at the time
161162
print_counters_with_prefix(prefix: 'unspecialized_def_type_', prompt: 'not optimized method types', buf:, stats:, limit: 20)

zjit/bindgen/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ fn main() {
290290
.allowlist_function("rb_zjit_insn_leaf")
291291
.allowlist_type("robject_offsets")
292292
.allowlist_type("rstring_offsets")
293-
.allowlist_var("RB_INVALID_SHAPE_ID")
293+
.allowlist_type("zjit_exported_constants")
294294
.allowlist_function("rb_assert_holding_vm_lock")
295295
.allowlist_function("rb_jit_shape_too_complex_p")
296296
.allowlist_function("rb_jit_multi_ractor_p")

zjit/src/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
409409
Insn::CCallWithFrame { cd, state, args, .. } if args.len() > C_ARG_OPNDS.len() =>
410410
gen_send_without_block(jit, asm, *cd, &function.frame_state(*state), SendFallbackReason::CCallWithFrameTooManyArgs),
411411
Insn::CCallWithFrame { cfunc, args, cme, state, .. } => gen_ccall_with_frame(jit, asm, *cfunc, opnds!(args), *cme, &function.frame_state(*state)),
412-
Insn::CCallVariadic { cfunc, recv, args, name: _, cme, state } => {
412+
Insn::CCallVariadic { cfunc, recv, args, name: _, cme, state, return_type: _, elidable: _ } => {
413413
gen_ccall_variadic(jit, asm, *cfunc, opnd!(recv), opnds!(args), *cme, &function.frame_state(*state))
414414
}
415415
Insn::GetIvar { self_val, id, state: _ } => gen_getivar(asm, opnd!(self_val), *id),

zjit/src/cruby_bindings.inc.rs

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zjit/src/cruby_methods.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ pub struct FnProperties {
3131
pub elidable: bool,
3232
}
3333

34+
/// A safe default for un-annotated Ruby methods: we can't optimize them or their returned values.
35+
impl Default for FnProperties {
36+
fn default() -> Self {
37+
Self {
38+
no_gc: false,
39+
leaf: false,
40+
return_type: types::BasicObject,
41+
elidable: false,
42+
}
43+
}
44+
}
45+
3446
impl Annotations {
3547
/// Query about properties of a C method
3648
pub fn get_cfunc_properties(&self, method: *const rb_callable_method_entry_t) -> Option<FnProperties> {
@@ -140,11 +152,12 @@ pub fn init() -> Annotations {
140152
let builtin_funcs = &mut HashMap::new();
141153

142154
macro_rules! annotate {
143-
($module:ident, $method_name:literal, $return_type:expr, $($properties:ident),+) => {
155+
($module:ident, $method_name:literal, $return_type:expr $(, $properties:ident)*) => {
156+
#[allow(unused_mut)]
144157
let mut props = FnProperties { no_gc: false, leaf: false, elidable: false, return_type: $return_type };
145158
$(
146159
props.$properties = true;
147-
)+
160+
)*
148161
annotate_c_method(cfuncs, unsafe { $module }, $method_name, props);
149162
}
150163
}
@@ -167,11 +180,14 @@ pub fn init() -> Annotations {
167180

168181
annotate!(rb_mKernel, "itself", types::BasicObject, no_gc, leaf, elidable);
169182
annotate!(rb_cString, "bytesize", types::Fixnum, no_gc, leaf);
183+
annotate!(rb_cString, "to_s", types::StringExact);
170184
annotate!(rb_cModule, "name", types::StringExact.union(types::NilClass), no_gc, leaf, elidable);
171185
annotate!(rb_cModule, "===", types::BoolExact, no_gc, leaf);
172186
annotate!(rb_cArray, "length", types::Fixnum, no_gc, leaf, elidable);
173187
annotate!(rb_cArray, "size", types::Fixnum, no_gc, leaf, elidable);
174188
annotate!(rb_cArray, "empty?", types::BoolExact, no_gc, leaf, elidable);
189+
annotate!(rb_cArray, "reverse", types::ArrayExact, leaf, elidable);
190+
annotate!(rb_cArray, "join", types::StringExact);
175191
annotate!(rb_cHash, "empty?", types::BoolExact, no_gc, leaf, elidable);
176192
annotate!(rb_cNilClass, "nil?", types::TrueClass, no_gc, leaf, elidable);
177193
annotate!(rb_mKernel, "nil?", types::FalseClass, no_gc, leaf, elidable);

0 commit comments

Comments
 (0)