Skip to content

Commit 9644b17

Browse files
Maxime Chevalier-Boisvertk0kubun
authored andcommitted
Add minor comments
1 parent ce9c9e0 commit 9644b17

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

zjit/src/hir.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// We use the YARV bytecode constants which have a CRuby-style name
22
#![allow(non_upper_case_globals)]
33

4-
use crate::{cruby::*, get_option, options::DumpSSA};
4+
use crate::{
5+
cruby::*,
6+
get_option,
7+
options::DumpSSA
8+
};
59
use std::collections::{HashMap, HashSet};
610

711
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
@@ -85,6 +89,7 @@ pub enum Insn {
8589
NewArray { count: usize },
8690
ArraySet { idx: usize, val: Opnd },
8791
ArrayDup { val: Opnd },
92+
8893
// Check if the value is truthy and "return" a C boolean. In reality, we will likely fuse this
8994
// with IfTrue/IfFalse in the backend to generate jcc.
9095
Test { val: Opnd },
@@ -108,7 +113,8 @@ pub enum Insn {
108113
IfFalse { val: Opnd, target: BranchEdge },
109114

110115
// Call a C function
111-
// TODO: should we store the C function name?
116+
// NOTE: should we store the C function name for pretty-printing?
117+
// or can we backtranslate the function pointer into a name string?
112118
CCall { cfun: *const u8, args: Vec<Opnd> },
113119

114120
// Send with dynamic dispatch
@@ -277,11 +283,12 @@ impl std::fmt::Display for FrameState {
277283
}
278284
}
279285

280-
/// Get instruction argument
286+
/// Get YARV instruction argument
281287
fn get_arg(pc: *const VALUE, arg_idx: isize) -> VALUE {
282288
unsafe { *(pc.offset(arg_idx + 1)) }
283289
}
284290

291+
/// Compute YARV instruction index at relative offset
285292
fn insn_idx_at_offset(idx: u32, offset: i64) -> u32 {
286293
((idx as isize) + (offset as isize)) as u32
287294
}

zjit/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ pub extern "C" fn rb_zjit_iseq_gen_entry_point(iseq: IseqPtr, _ec: EcPtr) -> *co
9595
let cb = ZJITState::get_code_block();
9696
match gen_function(cb, &ssa) {
9797
Some(start_ptr) => start_ptr.raw_ptr(cb),
98+
99+
// Compilation failed, continue executing in the interpreter only
98100
None => std::ptr::null(),
99101
}
100102
}

0 commit comments

Comments
 (0)