Skip to content

Commit 1a46155

Browse files
committed
comment edits
1 parent 57912d3 commit 1a46155

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

vm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2944,6 +2944,7 @@ zjit_materialize_frames(const rb_execution_context_t *ec, rb_control_frame_t *cf
29442944
stack -= ZJIT_STACK_MAP_SKIP_SIZE(entry);
29452945
}
29462946
else if (ZJIT_STACK_MAP_BASE_PTR_P(entry)) {
2947+
// This has to be the first code to align the write cursor for other entries
29472948
RUBY_ASSERT_ALWAYS(0 == i, "base_ptr stack map code only makes sense at 0");
29482949
VALUE *base_ptr = (VALUE *)((VALUE *)cfp->jit_return)[-(ssize_t)ZJIT_STACK_MAP_BASE_PTR_SLOT_INDEX(entry)];
29492950
stack = base_ptr + ZJIT_STACK_MAP_BASE_PTR_STACK_SIZE(entry);

zjit/src/jit_frame.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,20 @@ mod tests {
292292
"#), @r#""no bar""#);
293293
}
294294

295-
// A C function that calls back into Ruby (rb_const_missing here) pushes
296-
// recv + args onto *this* frame's VM stack via vm_call0_body(). A wrong
297-
// arity makes vm_callee_setup_arg() raise before vm_call_iseq_setup_normal()
298-
// restores cfp->sp, so cfp->sp is left 1 + argc slots high while this frame
299-
// is materialized for the rescue. The stack map has to be decoded from the
300-
// JIT's saved SP instead, or the live `1` operand lands above its slot and
301-
// the array comes back as [false, 2].
295+
// This test makes a JIT control frame move cfp->sp from as set by gen_prepare_non_leaf_call()
296+
// and then ask for materialization. A C function that calls back into Ruby (rb_const_missing
297+
// here) pushes recv+args using jit_entry's cfp->sp via vm_call0_body(). A wrong arity makes
298+
// vm_callee_setup_arg() raise before vm_call_iseq_setup_normal() restores cfp->sp, so cfp->sp
299+
// is left 1+argc slots high while this frame is materialized for the rescue. At the time of
300+
// materialization, the top most control frame is the JIT frame.
302301
#[test]
303302
fn test_stack_map_anchor_after_callee_arity_error() {
304303
assert_snapshot!(inspect(r#"
305304
class Holder
306305
def self.const_missing(a, b) = nil # wrong arity: called with 1 arg
307306
end
308307
def jit_entry
309-
[1, (begin # the 1 is live across the const_missing call
308+
[1, (begin # the 1 is live across the const_missing call
310309
Holder::NOPE
311310
rescue ArgumentError
312311
2

0 commit comments

Comments
 (0)