Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,6 @@ mod persistence {

QueryOrigin::assigned(key)
}
QueryOriginRef::FixpointInitial => unreachable!(
"`should_serialize` returns `false` for provisional queries"
),
};

let memo = memo.with_origin(flattened_origin);
Expand Down
8 changes: 0 additions & 8 deletions src/function/maybe_changed_after.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,6 @@ where
// in rev 1 but not in rev 2.
VerifyResult::changed()
}
// Return `Unchanged` similar to the initial value that we insert
// when we hit the cycle. Any dependencies accessed when creating the fixpoint initial
// are tracked by the outer query. Nothing should have changed assuming that the
// fixpoint initial function is deterministic.
QueryOriginRef::FixpointInitial => {
cycle_heads.insert_head(database_key_index);
VerifyResult::unchanged()
}
QueryOriginRef::DerivedUntracked(_) => {
// Untracked inputs? Have to assume that it changed.
VerifyResult::changed()
Expand Down
6 changes: 2 additions & 4 deletions src/function/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,15 @@ impl<C: Configuration> IngredientImpl<C> {
}

/// Evicts the existing memo for the given key, replacing it
/// with an equivalent memo that has no value. If the memo is untracked, FixpointInitial,
/// with an equivalent memo that has no value. If the memo is untracked
/// or has values assigned as output of another query, this has no effect.
pub(super) fn evict_value_from_memo_for(
table: MemoTableWithTypesMut<'_>,
memo_ingredient_index: MemoIngredientIndex,
) {
let map = |memo: &mut Memo<'static, C>| {
match memo.revisions.origin.as_ref() {
QueryOriginRef::Assigned(_)
| QueryOriginRef::DerivedUntracked(_)
| QueryOriginRef::FixpointInitial => {
QueryOriginRef::Assigned(_) | QueryOriginRef::DerivedUntracked(_) => {
// Careful: Cannot evict memos whose values were
// assigned as output of another query
// or those with untracked inputs
Expand Down
38 changes: 6 additions & 32 deletions src/zalsa_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ impl QueryRevisions {
Self {
changed_at: Revision::start(),
durability: Durability::MAX,
origin: QueryOrigin::fixpoint_initial(),
origin: QueryOrigin::derived(Box::default()),
#[cfg(feature = "accumulator")]
accumulated_inputs: Default::default(),
verified_final: AtomicBool::new(false),
Expand Down Expand Up @@ -813,9 +813,6 @@ pub enum QueryOriginRef<'a> {
/// The [`QueryEdges`] argument contains a listing of all the inputs we saw
/// (but we know there were more).
DerivedUntracked(&'a [QueryEdge]) = QueryOriginKind::DerivedUntracked as u8,

/// The value is an initial provisional value for a query that supports fixpoint iteration.
FixpointInitial = QueryOriginKind::FixpointInitial as u8,
}

impl<'a> QueryOriginRef<'a> {
Expand All @@ -825,7 +822,7 @@ impl<'a> QueryOriginRef<'a> {
pub(crate) fn inputs(self) -> impl DoubleEndedIterator<Item = DatabaseKeyIndex> + use<'a> {
let opt_edges = match self {
QueryOriginRef::Derived(edges) | QueryOriginRef::DerivedUntracked(edges) => Some(edges),
QueryOriginRef::Assigned(_) | QueryOriginRef::FixpointInitial => None,
QueryOriginRef::Assigned(_) => None,
};
opt_edges.into_iter().flat_map(input_edges)
}
Expand All @@ -834,7 +831,7 @@ impl<'a> QueryOriginRef<'a> {
pub(crate) fn outputs(self) -> impl DoubleEndedIterator<Item = DatabaseKeyIndex> + use<'a> {
let opt_edges = match self {
QueryOriginRef::Derived(edges) | QueryOriginRef::DerivedUntracked(edges) => Some(edges),
QueryOriginRef::Assigned(_) | QueryOriginRef::FixpointInitial => None,
QueryOriginRef::Assigned(_) => None,
};
opt_edges.into_iter().flat_map(output_edges)
}
Expand All @@ -843,7 +840,7 @@ impl<'a> QueryOriginRef<'a> {
pub(crate) fn edges(self) -> &'a [QueryEdge] {
let opt_edges = match self {
QueryOriginRef::Derived(edges) | QueryOriginRef::DerivedUntracked(edges) => Some(edges),
QueryOriginRef::Assigned(_) | QueryOriginRef::FixpointInitial => None,
QueryOriginRef::Assigned(_) => None,
};

opt_edges.unwrap_or_default()
Expand All @@ -856,11 +853,6 @@ impl<'a> QueryOriginRef<'a> {
#[derive(Clone, Copy)]
#[repr(u8)]
enum QueryOriginKind {
/// An initial provisional value.
///
/// This will occur occur in queries that support fixpoint iteration.
FixpointInitial = 0b00,

/// The value was assigned as the output of another query.
///
/// This can, for example, can occur when `specify` is used.
Expand Down Expand Up @@ -896,8 +888,6 @@ pub struct QueryOrigin {
///
/// For `QueryOriginKind::Assigned`, this is the `IngredientIndex` of assigning query.
/// Combined with the `Id` data, this forms a complete `DatabaseKeyIndex`.
///
/// For `QueryOriginKind::FixpointInitial`, this field is zero.
metadata: u32,
}

Expand All @@ -923,9 +913,6 @@ union QueryOriginData {

/// The identity of the assigning query for `QueryOriginKind::Assigned`.
index: Id,

/// `QueryOriginKind::FixpointInitial` holds no data.
empty: (),
}

/// SAFETY: The `input_outputs` pointer is owned and not accessed or shared concurrently.
Expand All @@ -934,15 +921,6 @@ unsafe impl Send for QueryOriginData {}
unsafe impl Sync for QueryOriginData {}

impl QueryOrigin {
/// Create a query origin of type `QueryOriginKind::FixpointInitial`.
pub fn fixpoint_initial() -> QueryOrigin {
QueryOrigin {
kind: QueryOriginKind::FixpointInitial,
metadata: 0,
data: QueryOriginData { empty: () },
}
}

pub fn is_derived_untracked(&self) -> bool {
matches!(self.kind, QueryOriginKind::DerivedUntracked)
}
Expand Down Expand Up @@ -1021,8 +999,6 @@ impl QueryOrigin {

QueryOriginRef::DerivedUntracked(input_outputs)
}

QueryOriginKind::FixpointInitial => QueryOriginRef::FixpointInitial,
}
}
}
Expand Down Expand Up @@ -1051,14 +1027,12 @@ impl<'de> serde::Deserialize<'de> for QueryOrigin {
Assigned(DatabaseKeyIndex) = QueryOriginKind::Assigned as u8,
Derived(Box<[QueryEdge]>) = QueryOriginKind::Derived as u8,
DerivedUntracked(Box<[QueryEdge]>) = QueryOriginKind::DerivedUntracked as u8,
FixpointInitial = QueryOriginKind::FixpointInitial as u8,
}

Ok(match QueryOriginOwned::deserialize(deserializer)? {
QueryOriginOwned::Assigned(key) => QueryOrigin::assigned(key),
QueryOriginOwned::Derived(edges) => QueryOrigin::derived(edges),
QueryOriginOwned::DerivedUntracked(edges) => QueryOrigin::derived_untracked(edges),
QueryOriginOwned::FixpointInitial => QueryOrigin::fixpoint_initial(),
})
}
}
Expand All @@ -1083,8 +1057,8 @@ impl Drop for QueryOrigin {
};
}

// The data stored for this variants is `Copy`.
QueryOriginKind::FixpointInitial | QueryOriginKind::Assigned => {}
// The data stored for this variant is `Copy`.
QueryOriginKind::Assigned => {}
}
}
}
Expand Down
Loading