Skip to content

Commit

Permalink
Fix bit packing of bundle params (#192)
Browse files Browse the repository at this point in the history
Fix a fuzzbug introduced in #185 where we missed updating a mask after
also updating a constant indicating that the bit was no longer used.
This PR fixes the bug by using the appropriate constant when masking,
and also removing some additional functions that were missed in #185.

co-authored-by: Chris Fallin <[email protected]>
  • Loading branch information
elliottt and cfallin authored Sep 11, 2024
1 parent b778e88 commit d251c8e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
12 changes: 1 addition & 11 deletions src/ion/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,6 @@ impl LiveBundle {
self.spill_weight_and_props & (1 << 29) != 0
}

#[inline(always)]
pub fn cached_stack(&self) -> bool {
self.spill_weight_and_props & (1 << 28) != 0
}

#[inline(always)]
pub fn set_cached_fixed(&mut self) {
self.spill_weight_and_props |= 1 << 30;
Expand All @@ -254,14 +249,9 @@ impl LiveBundle {
self.spill_weight_and_props |= 1 << 29;
}

#[inline(always)]
pub fn set_cached_stack(&mut self) {
self.spill_weight_and_props |= 1 << 28;
}

#[inline(always)]
pub fn cached_spill_weight(&self) -> u32 {
self.spill_weight_and_props & ((1 << 28) - 1)
self.spill_weight_and_props & BUNDLE_MAX_SPILL_WEIGHT
}
}

Expand Down
12 changes: 1 addition & 11 deletions src/ion/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ impl<'a, F: Function> Env<'a, F> {
}

// Check for a requirements conflict.
if self.bundles[from].cached_stack()
|| self.bundles[from].cached_fixed()
|| self.bundles[to].cached_stack()
|| self.bundles[to].cached_fixed()
{
if self.bundles[from].cached_fixed() || self.bundles[to].cached_fixed() {
if self.merge_bundle_requirements(from, to).is_err() {
trace!(" -> conflicting requirements; aborting merge");
return false;
Expand Down Expand Up @@ -155,9 +151,6 @@ impl<'a, F: Function> Env<'a, F> {
}
self.bundles[to].ranges = list;

if self.bundles[from].cached_stack() {
self.bundles[to].set_cached_stack();
}
if self.bundles[from].cached_fixed() {
self.bundles[to].set_cached_fixed();
}
Expand Down Expand Up @@ -224,9 +217,6 @@ impl<'a, F: Function> Env<'a, F> {
*to_range = to_range.join(from_range);
}

if self.bundles[from].cached_stack() {
self.bundles[to].set_cached_stack();
}
if self.bundles[from].cached_fixed() {
self.bundles[to].set_cached_fixed();
}
Expand Down

0 comments on commit d251c8e

Please sign in to comment.