mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-08 21:35:47 +00:00
use Assigned
insread of Field
and remove Field
This commit is contained in:
parent
99cfca5799
commit
1ae6a7bbc5
6 changed files with 4 additions and 32 deletions
|
@ -158,7 +158,7 @@ impl TrackedStruct {
|
||||||
let __ingredients = <#jar_ty as salsa::storage::HasIngredientsFor< #ident >>::ingredient(__jar);
|
let __ingredients = <#jar_ty as salsa::storage::HasIngredientsFor< #ident >>::ingredient(__jar);
|
||||||
let __id = __ingredients.#struct_index.new_struct(__runtime, (#(#id_field_names,)*));
|
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
|
__id
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,7 @@ impl Stack {
|
||||||
match origin {
|
match origin {
|
||||||
None
|
None
|
||||||
| Some(QueryOrigin::Assigned(_))
|
| Some(QueryOrigin::Assigned(_))
|
||||||
| Some(QueryOrigin::BaseInput)
|
| Some(QueryOrigin::BaseInput) => {}
|
||||||
| Some(QueryOrigin::Field) => {}
|
|
||||||
Some(QueryOrigin::Derived(edges)) | Some(QueryOrigin::DerivedUntracked(edges)) => {
|
Some(QueryOrigin::Derived(edges)) | Some(QueryOrigin::DerivedUntracked(edges)) => {
|
||||||
for DependencyIndex {
|
for DependencyIndex {
|
||||||
ingredient_index,
|
ingredient_index,
|
||||||
|
|
|
@ -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.
|
// This value was `set` by the mutator thread -- ie, it's a base input and it cannot be out of date.
|
||||||
return true;
|
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(_) => {
|
QueryOrigin::DerivedUntracked(_) => {
|
||||||
// Untracked inputs? Have to assume that it changed.
|
// Untracked inputs? Have to assume that it changed.
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -55,8 +55,7 @@ impl<K: AsId, V> MemoMap<K, V> {
|
||||||
match memo.revisions.origin {
|
match memo.revisions.origin {
|
||||||
QueryOrigin::Assigned(_)
|
QueryOrigin::Assigned(_)
|
||||||
| QueryOrigin::DerivedUntracked(_)
|
| QueryOrigin::DerivedUntracked(_)
|
||||||
| QueryOrigin::BaseInput
|
| QueryOrigin::BaseInput => {
|
||||||
| QueryOrigin::Field => {
|
|
||||||
// Careful: Cannot evict memos whose values were
|
// Careful: Cannot evict memos whose values were
|
||||||
// assigned as output of another query
|
// assigned as output of another query
|
||||||
// or those with untracked inputs
|
// or those with untracked inputs
|
||||||
|
|
|
@ -91,19 +91,6 @@ where
|
||||||
self.insert_memo(db, key, memo);
|
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.
|
/// 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.
|
/// 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)
|
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`.
|
// assigneed by `executor`.
|
||||||
match memo.revisions.origin {
|
match memo.revisions.origin {
|
||||||
QueryOrigin::Assigned(by_query) => assert_eq!(by_query, executor),
|
QueryOrigin::Assigned(by_query) => assert_eq!(by_query, executor),
|
||||||
QueryOrigin::Field => {}
|
|
||||||
_ => panic!(
|
_ => panic!(
|
||||||
"expected a query assigned by `{:?}`, not `{:?}`",
|
"expected a query assigned by `{:?}`, not `{:?}`",
|
||||||
executor.debug(db),
|
executor.debug(db),
|
||||||
|
|
|
@ -60,10 +60,6 @@ pub enum QueryOrigin {
|
||||||
/// The `DatabaseKeyIndex` is the identity of the assigning query.
|
/// The `DatabaseKeyIndex` is the identity of the assigning query.
|
||||||
Assigned(DatabaseKeyIndex),
|
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.
|
/// This value was set as a base input to the computation.
|
||||||
BaseInput,
|
BaseInput,
|
||||||
|
|
||||||
|
@ -86,7 +82,7 @@ impl QueryOrigin {
|
||||||
QueryOrigin::Derived(edges) | QueryOrigin::DerivedUntracked(edges) => {
|
QueryOrigin::Derived(edges) | QueryOrigin::DerivedUntracked(edges) => {
|
||||||
&edges.input_outputs[edges.separator as usize..]
|
&edges.input_outputs[edges.separator as usize..]
|
||||||
}
|
}
|
||||||
QueryOrigin::Assigned(_) | QueryOrigin::BaseInput | QueryOrigin::Field => &[],
|
QueryOrigin::Assigned(_) | QueryOrigin::BaseInput => &[],
|
||||||
};
|
};
|
||||||
|
|
||||||
slice.iter().copied()
|
slice.iter().copied()
|
||||||
|
|
Loading…
Reference in a new issue