use Assigned insread of Field and remove Field

This commit is contained in:
XFFXFF 2022-09-17 07:09:39 +08:00
parent 99cfca5799
commit 1ae6a7bbc5
6 changed files with 4 additions and 32 deletions

View file

@ -158,7 +158,7 @@ impl TrackedStruct {
let __ingredients = <#jar_ty as salsa::storage::HasIngredientsFor< #ident >>::ingredient(__jar);
let __id = __ingredients.#struct_index.new_struct(__runtime, (#(#id_field_names,)*));
#(
__ingredients.#value_field_indices.specify_field(__db, __id, #value_field_names);
__ingredients.#value_field_indices.specify_and_record(__db, __id, #value_field_names);
)*
__id
}

View file

@ -67,8 +67,7 @@ impl Stack {
match origin {
None
| Some(QueryOrigin::Assigned(_))
| Some(QueryOrigin::BaseInput)
| Some(QueryOrigin::Field) => {}
| Some(QueryOrigin::BaseInput) => {}
Some(QueryOrigin::Derived(edges)) | Some(QueryOrigin::DerivedUntracked(edges)) => {
for DependencyIndex {
ingredient_index,

View file

@ -174,14 +174,6 @@ where
// This value was `set` by the mutator thread -- ie, it's a base input and it cannot be out of date.
return true;
}
QueryOrigin::Field => {
// This value is the value of a field of some tracked struct S.
// The fact that we are here means that we are accessing fields from old revisions, which is not allowed.
panic!(
"accessing fields of tracked struct {:?} from older revisions",
std::any::type_name::<<C as Configuration>::SalsaStruct>()
)
}
QueryOrigin::DerivedUntracked(_) => {
// Untracked inputs? Have to assume that it changed.
return false;

View file

@ -55,8 +55,7 @@ impl<K: AsId, V> MemoMap<K, V> {
match memo.revisions.origin {
QueryOrigin::Assigned(_)
| QueryOrigin::DerivedUntracked(_)
| QueryOrigin::BaseInput
| QueryOrigin::Field => {
| QueryOrigin::BaseInput => {
// Careful: Cannot evict memos whose values were
// assigned as output of another query
// or those with untracked inputs

View file

@ -91,19 +91,6 @@ where
self.insert_memo(db, key, memo);
}
/// Specify the value for `key` but do not record it is an output.
/// This is used for the value fields declared on a tracked struct.
/// They are different from other calls to specify because we KNOW they will be given a value by construction,
/// so recording them as an explicit output (and checking them for validity, etc) is pure overhead.
pub fn specify_field<'db>(&self, db: &'db DynDb<'db, C>, key: C::Key, value: C::Value)
where
C::Key: TrackedStructInDb<DynDb<'db, C>>,
{
self.specify(db, key, value, |_| QueryOrigin::Field);
let database_key_index = self.database_key_index(key);
db.runtime().add_output(database_key_index.into());
}
/// Specify the value for `key` *and* record that we did so.
/// Used for explicit calls to `specify`, but not needed for pre-declared tracked struct fields.
pub fn specify_and_record<'db>(&self, db: &'db DynDb<'db, C>, key: C::Key, value: C::Value)
@ -140,7 +127,6 @@ where
// assigneed by `executor`.
match memo.revisions.origin {
QueryOrigin::Assigned(by_query) => assert_eq!(by_query, executor),
QueryOrigin::Field => {}
_ => panic!(
"expected a query assigned by `{:?}`, not `{:?}`",
executor.debug(db),

View file

@ -60,10 +60,6 @@ pub enum QueryOrigin {
/// The `DatabaseKeyIndex` is the identity of the assigning query.
Assigned(DatabaseKeyIndex),
/// This is the value field of a tracked struct.
/// These are different from `Assigned` because we know they will always be assigned a value and hence are never "out of date".
Field,
/// This value was set as a base input to the computation.
BaseInput,
@ -86,7 +82,7 @@ impl QueryOrigin {
QueryOrigin::Derived(edges) | QueryOrigin::DerivedUntracked(edges) => {
&edges.input_outputs[edges.separator as usize..]
}
QueryOrigin::Assigned(_) | QueryOrigin::BaseInput | QueryOrigin::Field => &[],
QueryOrigin::Assigned(_) | QueryOrigin::BaseInput => &[],
};
slice.iter().copied()