Add minor comments

This commit is contained in:
Maxime Chevalier-Boisvert 2025-02-14 14:26:37 -05:00 committed by Takashi Kokubun
parent ce9c9e0a6a
commit 9644b17279
Notes: git 2025-04-18 13:48:38 +00:00
2 changed files with 12 additions and 3 deletions

View File

@ -1,7 +1,11 @@
// We use the YARV bytecode constants which have a CRuby-style name
#![allow(non_upper_case_globals)]
use crate::{cruby::*, get_option, options::DumpSSA};
use crate::{
cruby::*,
get_option,
options::DumpSSA
};
use std::collections::{HashMap, HashSet};
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
@ -85,6 +89,7 @@ pub enum Insn {
NewArray { count: usize },
ArraySet { idx: usize, val: Opnd },
ArrayDup { val: Opnd },
// Check if the value is truthy and "return" a C boolean. In reality, we will likely fuse this
// with IfTrue/IfFalse in the backend to generate jcc.
Test { val: Opnd },
@ -108,7 +113,8 @@ pub enum Insn {
IfFalse { val: Opnd, target: BranchEdge },
// Call a C function
// TODO: should we store the C function name?
// NOTE: should we store the C function name for pretty-printing?
// or can we backtranslate the function pointer into a name string?
CCall { cfun: *const u8, args: Vec<Opnd> },
// Send with dynamic dispatch
@ -277,11 +283,12 @@ impl std::fmt::Display for FrameState {
}
}
/// Get instruction argument
/// Get YARV instruction argument
fn get_arg(pc: *const VALUE, arg_idx: isize) -> VALUE {
unsafe { *(pc.offset(arg_idx + 1)) }
}
/// Compute YARV instruction index at relative offset
fn insn_idx_at_offset(idx: u32, offset: i64) -> u32 {
((idx as isize) + (offset as isize)) as u32
}

View File

@ -95,6 +95,8 @@ pub extern "C" fn rb_zjit_iseq_gen_entry_point(iseq: IseqPtr, _ec: EcPtr) -> *co
let cb = ZJITState::get_code_block();
match gen_function(cb, &ssa) {
Some(start_ptr) => start_ptr.raw_ptr(cb),
// Compilation failed, continue executing in the interpreter only
None => std::ptr::null(),
}
}