Skip to content

Commit 4511ac6

Browse files
committed
Recalculate cached limits
When splitting bundles, we need the ability to recalculate the cached limit.
1 parent 17d2b22 commit 4511ac6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/ion/merge.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,28 @@ impl<'a, F: Function> Env<'a, F> {
392392
total
393393
}
394394

395+
pub fn compute_bundle_limit(&self, bundle: LiveBundleIndex) -> Option<usize> {
396+
let mut limit: Option<usize> = None;
397+
for entry in &self.bundles[bundle].ranges {
398+
for u in &self.ranges[entry.index].uses {
399+
use OperandConstraint::*;
400+
match u.operand.constraint() {
401+
Limit(current) => match limit {
402+
Some(prev) => limit = Some(prev.min(current)),
403+
None => limit = Some(current),
404+
},
405+
FixedReg(_) | Stack => {
406+
break;
407+
}
408+
Any | Reg | Reuse(_) => {
409+
continue;
410+
}
411+
}
412+
}
413+
}
414+
limit
415+
}
416+
395417
pub fn queue_bundles(&mut self) {
396418
for bundle in 0..self.bundles.len() {
397419
trace!("enqueueing bundle{}", bundle);

src/ion/process.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ impl<'a, F: Function> Env<'a, F> {
274274
let first_range_data = &self.ctx.ranges[first_range];
275275

276276
self.ctx.bundles[bundle].prio = self.compute_bundle_prio(bundle);
277+
self.ctx.bundles[bundle].limit = self.compute_bundle_limit(bundle);
277278

278279
if first_range_data.vreg.is_invalid() {
279280
trace!(" -> no vreg; minimal and fixed");

0 commit comments

Comments
 (0)