Add adjustable stack size and call depth (bp #12728) (#12769)

* Add adjustable stack size and call depth (#12728)

(cherry picked from commit c3907be623)

# Conflicts:
#	programs/bpf/Cargo.lock
#	programs/bpf/Cargo.toml
#	programs/bpf/build.rs
#	programs/bpf_loader/Cargo.toml
#	programs/bpf_loader/src/lib.rs
#	runtime/src/feature_set.rs
#	runtime/src/process_instruction.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-10-09 23:27:59 +00:00
committed by GitHub
parent 079ea91d6f
commit ad31768dd9
12 changed files with 140 additions and 12 deletions

View File

@@ -0,0 +1,27 @@
//! @brief Example Rust-based BPF program that tests call depth and stack usage
use solana_sdk::{entrypoint::SUCCESS, info};
#[inline(never)]
pub fn recurse(data: &mut [u8]) {
if data.len() <= 1 {
return;
}
recurse(&mut data[1..]);
info!(line!(), 0, 0, 0, data[0]);
}
/// # Safety
#[inline(never)]
#[no_mangle]
pub unsafe extern "C" fn entrypoint(input: *mut u8) -> u64 {
info!("Call depth");
let depth = *(input.add(16) as *mut u8);
info!(line!(), 0, 0, 0, depth);
let mut data = Vec::with_capacity(depth as usize);
for i in 0_u8..depth {
data.push(i);
}
recurse(&mut data);
SUCCESS
}