3 // check that we don't have linear stack usage with multiple calls to `push`
11 if test::black_box(false) {
15 None, None, None, None, None, None, None, None,
16 None, None, None, None, None, None, None, None,
17 None, None, None, None, None, None, None, None,
18 None, None, None, None, None, None, None, None,
19 None, None, None, None, None, None, None, None,
20 None, None, None, None, None, None, None, None,
25 drop_me: [Option<Box<u8>>; 48],
29 fn push(out: &mut Vec<Big>) {
34 pub fn supersize_me(out: &mut Vec<Big>) {
50 push(out); // 16 calls to `push`
52 verify_stack_usage(out);
69 push(out); // 16 calls to `push`
73 fn verify_stack_usage(before_ptr: *mut Vec<Big>) {
74 // To check stack usage, create locals before and after
75 // and check the difference in addresses between them.
76 let mut stack_var: Vec<Big> = vec![];
77 test::black_box(&mut stack_var);
78 let stack_usage = isize::abs(
79 (&mut stack_var as *mut _ as isize) -
80 (before_ptr as isize)) as usize;
81 // Give space for 2 copies of `Big` + 272 "misc" bytes
82 // (value observed on x86_64-pc-windows-gnu).
83 if stack_usage > mem::size_of::<Big>() * 2 + 272 {
84 panic!("used {} bytes of stack, but `struct Big` is only {} bytes",
85 stack_usage, mem::size_of::<Big>());
92 test::black_box(&mut v);