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
2 changes: 1 addition & 1 deletion doc/language/packed_data.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -726,4 +726,4 @@ for one byte in the input or output string.

- <tt>'^'</tt> - Only for unpacking; the current position:

"foo\0\0\0".unpack("Z*C") # => ["foo", 6]
"foo\0\0\0".unpack("Z*^") # => ["foo", 4]
4 changes: 2 additions & 2 deletions zjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,10 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
Insn::ToRegexp { opt, values, state } => gen_toregexp(jit, asm, *opt, opnds!(values), &function.frame_state(*state)),
Insn::Param => unreachable!("block.insns should not have Insn::Param"),
Insn::Snapshot { .. } => return Ok(()), // we don't need to do anything for this instruction at the moment
&Insn::Send { cd, blockiseq, state, reason, .. } => gen_send(jit, asm, cd, blockiseq, &function.frame_state(state), reason),
&Insn::Send { cd, blockiseq: None, state, reason, .. } => gen_send_without_block(jit, asm, cd, &function.frame_state(state), reason),
&Insn::Send { cd, blockiseq: Some(blockiseq), state, reason, .. } => gen_send(jit, asm, cd, blockiseq, &function.frame_state(state), reason),
&Insn::SendForward { cd, blockiseq, state, reason, .. } => gen_send_forward(jit, asm, cd, blockiseq, &function.frame_state(state), reason),
Insn::SendDirect { cme, iseq, recv, args, kw_bits, blockiseq, state, .. } => gen_send_iseq_direct(cb, jit, asm, *cme, *iseq, opnd!(recv), opnds!(args), *kw_bits, &function.frame_state(*state), *blockiseq),
&Insn::SendWithoutBlock { cd, state, reason, .. } => gen_send_without_block(jit, asm, cd, &function.frame_state(state), reason),
&Insn::InvokeSuper { cd, blockiseq, state, reason, .. } => gen_invokesuper(jit, asm, cd, blockiseq, &function.frame_state(state), reason),
&Insn::InvokeSuperForward { cd, blockiseq, state, reason, .. } => gen_invokesuperforward(jit, asm, cd, blockiseq, &function.frame_state(state), reason),
&Insn::InvokeBlock { cd, state, reason, .. } => gen_invokeblock(jit, asm, cd, &function.frame_state(state), reason),
Expand Down
16 changes: 15 additions & 1 deletion zjit/src/cruby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,15 @@ pub mod test_utils {
})
}

/// Evaluate a given Ruby program with compile options
pub fn eval_with_options(program: &str, options_expr: &str) -> VALUE {
with_rubyvm(|| {
let options = eval(options_expr);
let wrapped_iseq = compile_to_wrapped_iseq_with_options(&unindent(program, false), options);
unsafe { rb_funcallv(wrapped_iseq, ID!(eval), 0, null()) }
})
}

/// Get the #inspect of a given Ruby program in Rust string
pub fn inspect(program: &str) -> String {
let inspect = format!("({program}).inspect");
Expand Down Expand Up @@ -1252,10 +1261,15 @@ pub mod test_utils {

/// Compile a program into a RubyVM::InstructionSequence object
fn compile_to_wrapped_iseq(program: &str) -> VALUE {
compile_to_wrapped_iseq_with_options(program, Qnil)
}

fn compile_to_wrapped_iseq_with_options(program: &str, options: VALUE) -> VALUE {
let bytes = program.as_bytes().as_ptr() as *const c_char;
unsafe {
let program_str = rb_utf8_str_new(bytes, program.len().try_into().unwrap());
rb_funcallv(rb_cISeq, ID!(compile), 1, &program_str)
let args = [program_str, Qnil, Qnil, VALUE(1_usize.wrapping_shl(1) | 1), options];
rb_funcallv(rb_cISeq, ID!(compile), args.len() as c_int, args.as_ptr())
}
}

Expand Down
2 changes: 1 addition & 1 deletion zjit/src/cruby_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ fn inline_thread_current(fun: &mut hir::Function, block: hir::BlockId, _recv: hi

fn inline_kernel_itself(_fun: &mut hir::Function, _block: hir::BlockId, recv: hir::InsnId, args: &[hir::InsnId], _state: hir::InsnId) -> Option<hir::InsnId> {
if args.is_empty() {
// No need to coerce the receiver; that is done by the SendWithoutBlock rewriting.
// No need to coerce the receiver; that is done by the Send rewriting.
return Some(recv);
}
None
Expand Down
Loading