Add minor comments
This commit is contained in:
parent
ce9c9e0a6a
commit
9644b17279
Notes:
git
2025-04-18 13:48:38 +00:00
@ -1,7 +1,11 @@
|
|||||||
// We use the YARV bytecode constants which have a CRuby-style name
|
// We use the YARV bytecode constants which have a CRuby-style name
|
||||||
#![allow(non_upper_case_globals)]
|
#![allow(non_upper_case_globals)]
|
||||||
|
|
||||||
use crate::{cruby::*, get_option, options::DumpSSA};
|
use crate::{
|
||||||
|
cruby::*,
|
||||||
|
get_option,
|
||||||
|
options::DumpSSA
|
||||||
|
};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
|
||||||
@ -85,6 +89,7 @@ pub enum Insn {
|
|||||||
NewArray { count: usize },
|
NewArray { count: usize },
|
||||||
ArraySet { idx: usize, val: Opnd },
|
ArraySet { idx: usize, val: Opnd },
|
||||||
ArrayDup { val: Opnd },
|
ArrayDup { val: Opnd },
|
||||||
|
|
||||||
// Check if the value is truthy and "return" a C boolean. In reality, we will likely fuse this
|
// 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.
|
// with IfTrue/IfFalse in the backend to generate jcc.
|
||||||
Test { val: Opnd },
|
Test { val: Opnd },
|
||||||
@ -108,7 +113,8 @@ pub enum Insn {
|
|||||||
IfFalse { val: Opnd, target: BranchEdge },
|
IfFalse { val: Opnd, target: BranchEdge },
|
||||||
|
|
||||||
// Call a C function
|
// 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> },
|
CCall { cfun: *const u8, args: Vec<Opnd> },
|
||||||
|
|
||||||
// Send with dynamic dispatch
|
// 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 {
|
fn get_arg(pc: *const VALUE, arg_idx: isize) -> VALUE {
|
||||||
unsafe { *(pc.offset(arg_idx + 1)) }
|
unsafe { *(pc.offset(arg_idx + 1)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Compute YARV instruction index at relative offset
|
||||||
fn insn_idx_at_offset(idx: u32, offset: i64) -> u32 {
|
fn insn_idx_at_offset(idx: u32, offset: i64) -> u32 {
|
||||||
((idx as isize) + (offset as isize)) as u32
|
((idx as isize) + (offset as isize)) as u32
|
||||||
}
|
}
|
||||||
|
@ -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();
|
let cb = ZJITState::get_code_block();
|
||||||
match gen_function(cb, &ssa) {
|
match gen_function(cb, &ssa) {
|
||||||
Some(start_ptr) => start_ptr.raw_ptr(cb),
|
Some(start_ptr) => start_ptr.raw_ptr(cb),
|
||||||
|
|
||||||
|
// Compilation failed, continue executing in the interpreter only
|
||||||
None => std::ptr::null(),
|
None => std::ptr::null(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user