MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / select_many

Method select_many

crates/tinywasm/src/interpreter/stack/value_stack.rs:157–180  ·  view source on GitHub ↗
(&mut self, count: usize, condition: bool)

Source from the content-addressed store, hash-verified

155
156 #[inline(always)]
157 pub(crate) fn select_many(&mut self, count: usize, condition: bool) {
158 if count == 0 {
159 return;
160 }
161
162 let len = self.data.len();
163 let needed = count.checked_mul(2).unwrap_or_else(|| {
164 cold_path();
165 unreachable!("Stack underflow, this is a bug");
166 });
167
168 if len < needed {
169 cold_path();
170 unreachable!("Stack underflow, this is a bug");
171 }
172
173 if !condition {
174 let dst = len - needed;
175 let src = len - count;
176 self.data.copy_within(src..len, dst);
177 }
178
179 self.data.truncate(len - count);
180 }
181}
182impl ValueStack {
183 pub(crate) fn new(config: &Config) -> Self {

Callers 1

select_multiMethod · 0.80

Calls 2

lenMethod · 0.45
copy_withinMethod · 0.45

Tested by

no test coverage detected