MCPcopy Index your code
hub / github.com/explodingcamera/tinywasm / enter_locals

Method enter_locals

crates/tinywasm/src/interpreter/stack/value_stack.rs:112–134  ·  view source on GitHub ↗
(&mut self, param_count: usize, local_count: usize)

Source from the content-addressed store, hash-verified

110
111 #[inline(always)]
112 pub(crate) fn enter_locals(&mut self, param_count: usize, local_count: usize) -> Result<u32, Trap> {
113 debug_assert!(param_count <= local_count);
114 debug_assert!(param_count <= self.data.len());
115
116 let len = self.data.len();
117 let start = len - param_count;
118 let end = start + local_count;
119
120 if end > self.data.capacity() {
121 cold_path();
122 if end > self.max_size || !self.dynamic {
123 return Err(Trap::ValueStackOverflow);
124 }
125 let cap = self.data.capacity();
126 let target = end.max(cap.max(1).saturating_mul(2)).min(self.max_size);
127 if self.data.try_reserve_exact(target - len).is_err() {
128 return Err(Trap::ValueStackOverflow);
129 }
130 }
131
132 self.data.resize(end, T::default());
133 Ok(start as u32)
134 }
135
136 fn ensure_capacity_for(&mut self, required_len: usize) -> bool {
137 let cap = self.data.capacity();

Callers 7

call_innerMethod · 0.80
call_resumable_innerMethod · 0.80
call_untypedMethod · 0.80
exec_callMethod · 0.80
exec_return_callMethod · 0.80
exec_call_selfMethod · 0.80
exec_return_call_selfMethod · 0.80

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected