MCPcopy Index your code
hub / github.com/RustPython/RustPython / push_slow

Method push_slow

crates/vm/src/datastack.rs:101–123  ·  view source on GitHub ↗
(&mut self, aligned_size: usize)

Source from the content-addressed store, hash-verified

99 #[cold]
100 #[inline(never)]
101 fn push_slow(&mut self, aligned_size: usize) -> *mut u8 {
102 let mut chunk_size = MIN_CHUNK_SIZE;
103 let needed = aligned_size
104 .checked_add(MINIMUM_OVERHEAD)
105 .and_then(|v| v.checked_add(core::mem::size_of::<DataStackChunk>()))
106 .and_then(|v| v.checked_add(ALIGN))
107 .expect("DataStack chunk size overflow");
108 while chunk_size < needed {
109 chunk_size = chunk_size
110 .checked_mul(2)
111 .expect("DataStack chunk size overflow");
112 }
113 // Save current position in old chunk.
114 unsafe {
115 (*self.chunk).saved_top = self.top as usize - self.chunk as usize;
116 }
117 let new_chunk = Self::alloc_chunk(chunk_size, self.chunk);
118 self.chunk = new_chunk;
119 let start = unsafe { (*new_chunk).data_start() };
120 self.limit = unsafe { (*new_chunk).data_limit() };
121 self.top = unsafe { start.add(aligned_size) };
122 start
123 }
124
125 /// Pop a previous allocation. `base` must be the pointer returned by
126 /// `push()`. Calls must be in LIFO order.

Callers 1

pushMethod · 0.80

Calls 3

data_startMethod · 0.80
data_limitMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected