Skip to content

Commit 4eb1a09

Browse files
committed
Revert "ZJIT: Fix cases where we need to super to C functions with >6 params (ruby#17186)"
This reverts commit e90a7ce.
1 parent 4dfaa2c commit 4eb1a09

3 files changed

Lines changed: 4 additions & 59 deletions

File tree

zjit/src/codegen.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,9 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
711711
Insn::PatchPoint { invariant, state } => no_output!(gen_patch_point(jit, asm, invariant, &function.frame_state(*state))),
712712
Insn::CCall { cfunc, recv, args, name, owner: _, return_type: _, elidable: _ } => gen_ccall(asm, *cfunc, *name, opnd!(recv), opnds!(args)),
713713
// Give up CCallWithFrame for 7+ args since asm.ccall() supports at most 6 args (recv + args).
714-
// We're currently emitting a CCallWithFrame for `super` in to a cfunction.
715-
// We can't lower to `gen_send_without_block` because the
716-
// source opcode isn't necessarily `opt_send_without_block`
717-
// and so the interpreter stack layout may be incompatible.
718-
Insn::CCallWithFrame { cd, state, args, block, .. } if args.len() + 1 > C_ARG_OPNDS.len() => return Err(*state),
714+
// There's no test case for this because no core cfuncs have this many parameters. But C extensions could have such methods.
715+
Insn::CCallWithFrame { cd, state, args, .. } if args.len() + 1 > C_ARG_OPNDS.len() =>
716+
gen_send_without_block(jit, asm, *cd, &function.frame_state(*state), SendFallbackReason::CCallWithFrameTooManyArgs),
719717
Insn::CCallWithFrame { cfunc, recv, name, args, cme, state, block, .. } =>
720718
gen_ccall_with_frame(jit, asm, *cfunc, *name, opnd!(recv), opnds!(args), *cme, *block, &function.frame_state(*state)),
721719
Insn::CCallVariadic { cfunc, recv, name, args, cme, state, block, return_type: _, elidable: _ } => {

zjit/src/codegen_tests.rs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,52 +1237,6 @@ fn test_invokesuper_to_cfunc_varargs() {
12371237
"#), @r#"["MyString", true]"#);
12381238
}
12391239

1240-
#[test]
1241-
fn test_invokesuper_to_cfunc_with_too_many_args_exits() {
1242-
unsafe extern "C" fn test_six_args(
1243-
_self: VALUE,
1244-
a: VALUE,
1245-
b: VALUE,
1246-
c: VALUE,
1247-
d: VALUE,
1248-
e: VALUE,
1249-
f: VALUE,
1250-
) -> VALUE {
1251-
unsafe { rb_ary_new_from_args(6, a, b, c, d, e, f) }
1252-
}
1253-
1254-
with_rubyvm(|| {
1255-
let superclass = define_class("ZJITSixArgs", unsafe { rb_cObject });
1256-
unsafe {
1257-
rb_define_method(
1258-
superclass,
1259-
c"six".as_ptr(),
1260-
Some(std::mem::transmute::<
1261-
unsafe extern "C" fn(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE) -> VALUE,
1262-
unsafe extern "C" fn(VALUE) -> VALUE,
1263-
>(test_six_args)),
1264-
6,
1265-
);
1266-
}
1267-
});
1268-
1269-
assert_snapshot!(assert_compiles_allowing_exits(r#"
1270-
class ZJITSixArgsSubclass < ZJITSixArgs
1271-
def six(a, b, c, d, e, f)
1272-
super
1273-
end
1274-
end
1275-
1276-
def test
1277-
ZJITSixArgsSubclass.new.six(1, 2, 3, 4, 5, 6)
1278-
end
1279-
1280-
test
1281-
test
1282-
test
1283-
"#), @"[1, 2, 3, 4, 5, 6]");
1284-
}
1285-
12861240
#[test]
12871241
fn test_string_new_preserves_string_arg() {
12881242
assert_snapshot!(inspect(r#"

zjit/src/cruby.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
use std::convert::From;
9292
use std::ffi::{c_void, CString, CStr};
9393
use std::fmt::{Debug, Display, Formatter};
94-
use std::os::raw::{c_char, c_int, c_long, c_uint};
94+
use std::os::raw::{c_char, c_int, c_uint};
9595
use std::panic::{catch_unwind, UnwindSafe};
9696

9797
use crate::cast::IntoUsize as _;
@@ -132,7 +132,6 @@ unsafe extern "C" {
132132
pub fn rb_float_new(d: f64) -> VALUE;
133133

134134
pub fn rb_hash_empty_p(hash: VALUE) -> VALUE;
135-
pub fn rb_ary_new_from_args(n: c_long, ...) -> VALUE;
136135
pub fn rb_str_setbyte(str: VALUE, index: VALUE, value: VALUE) -> VALUE;
137136
pub fn rb_str_getbyte(str: VALUE, index: VALUE) -> VALUE;
138137
pub fn rb_vm_splat_array(flag: VALUE, ary: VALUE) -> VALUE;
@@ -166,12 +165,6 @@ unsafe extern "C" {
166165
pub fn rb_vm_stack_canary() -> VALUE;
167166
pub fn rb_vm_push_cfunc_frame(cme: *const rb_callable_method_entry_t, recv_idx: c_int);
168167
pub fn rb_obj_class(klass: VALUE) -> VALUE;
169-
pub fn rb_define_method(
170-
klass: VALUE,
171-
mid: *const c_char,
172-
func: Option<unsafe extern "C" fn(args: VALUE) -> VALUE>,
173-
arity: c_int,
174-
);
175168
pub fn rb_vm_objtostring(reg_cfp: CfpPtr, recv: VALUE, cd: *const rb_call_data) -> VALUE;
176169
}
177170

0 commit comments

Comments
 (0)