MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / respect_priority

Function respect_priority

cranelift/isle/isle/src/serialize.rs:160–170  ·  view source on GitHub ↗

Given a set of rules that's been partitioned into two groups, move rules from the first partition to the second if there are higher-priority rules in the second group. In the final generated code, we'll check the rules in the first ("selected") group before any in the second ("deferred") group. But we need the result to be _as if_ we checked the rules in strict descending priority order. When eva

(rules: &RuleSet, order: &mut [usize], partition_point: usize)

Source from the content-addressed store, hash-verified

158/// set, the returned partition-point is always less than or equal to the
159/// initial partition-point.
160fn respect_priority(rules: &RuleSet, order: &mut [usize], partition_point: usize) -> usize {
161 let (selected, deferred) = order.split_at_mut(partition_point);
162
163 if let Some(max_deferred_prio) = deferred.iter().map(|&idx| rules.rules[idx].prio).max() {
164 partition_in_place(selected, |&idx| rules.rules[idx].prio >= max_deferred_prio)
165 } else {
166 // If the deferred set is empty, all selected rules are fine where
167 // they are.
168 partition_point
169 }
170}
171
172/// A query which can be tested against a [Rule] to see if that rule requires
173/// the given kind of control flow around the given binding sites. These

Callers 2

partitionMethod · 0.85
best_control_flowMethod · 0.85

Calls 4

partition_in_placeFunction · 0.85
maxMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected