Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rwstauner committed Nov 12, 2024
1 parent d605068 commit 7090d86
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5802,20 +5802,44 @@ fn jit_rb_str_aref_m(
_known_recv_class: Option<VALUE>,
) -> bool {
if argc == 2 {
// eprintln!("STRING SLICE {:?} {:?}", asm.ctx.get_stack_size(), (asm.ctx.get_opnd_type(StackOpnd(0)), asm.ctx.get_opnd_type(StackOpnd(1))));
match (asm.ctx.get_opnd_type(StackOpnd(0)), asm.ctx.get_opnd_type(StackOpnd(1))) {
// rb_str_substr should be leaf if indexes are fixnums
(Type::Fixnum, Type::Fixnum) => {},
// There is a two-argument form of (RegExp, Fixnum) which needs a different c func.
// Other types will raise.
_ => return false,
_ => {
return false
},
}
} else if argc == 1 {

match asm.ctx.get_opnd_type(StackOpnd(0)) {
// rb_str_substr should be leaf if indexes are fixnums
Type::Fixnum => {},
Type::Fixnum => {
// eprintln!("STRING SLICE {:?} {:?}", asm.ctx.get_stack_size(), asm.ctx.get_opnd_type(StackOpnd(0)));
},
// This could be a Range or a RegExp which are handled by separate c funcs.
// Other types will raise.
_ => return false,
_ => {
let comptime_arg = jit.peek_at_stack(&asm.ctx, 0);
let arg0 = asm.stack_opnd(0);
if comptime_arg.fixnum_p() {
asm.test(arg0, Opnd::UImm(RUBY_FIXNUM_FLAG as u64));

// eprintln!("STRING SLICE yay");
jit_chain_guard(
JCC_JZ,
jit,
asm,
SEND_MAX_DEPTH,
Counter::guard_send_not_fixnums,
);
} else {
// eprintln!("STRING SLICE comptime arg {:?}", Type::from(comptime_arg));
return false
}
},
}
} else {
return false
Expand Down

0 comments on commit 7090d86

Please sign in to comment.