pub(crate) fn resize_to(&mut self, new_sp: StackPtr) {
        debug_assert!(new_sp <= self.sp + VM_STACK_SIZE);
        if new_sp > self.sp {
            let mut p = self.sp;
            for _ in 0..(new_sp - self.sp) as usize {
                p[0] = Value::nil();
                p += 1;
            }
        }
        self.sp = new_sp;
    }
Resize the stack so that len is equal to new_len.
If new_len is greater than len, the stack is extended by the difference, with each additional slot filled with Nil.
If new_len is less than len, the stack is simply truncated.
ruruby/src/vm/executor/frame/ruby_stack.rs