@@ -2,21 +2,21 @@ pub(crate) use maybe_changed_after::{VerifyCycleHeads, VerifyResult};
22pub ( crate ) use sync:: { ClaimGuard , ClaimResult , Reentrancy , SyncGuard , SyncOwner , SyncTable } ;
33
44use std:: any:: Any ;
5- use std:: fmt ;
5+ use std:: marker :: PhantomData ;
66use std:: ptr:: NonNull ;
77use std:: sync:: atomic:: Ordering ;
88use std:: sync:: OnceLock ;
9+ use std:: { fmt, mem} ;
910
1011use crate :: cycle:: { CycleRecoveryAction , CycleRecoveryStrategy , IterationCount , ProvisionalStatus } ;
1112use crate :: database:: RawDatabase ;
12- use crate :: function:: delete:: DeletedEntries ;
1313use crate :: hash:: { FxHashSet , FxIndexSet } ;
1414use crate :: ingredient:: { Ingredient , WaitForResult } ;
1515use crate :: key:: DatabaseKeyIndex ;
1616use crate :: plumbing:: { self , MemoIngredientMap } ;
1717use crate :: salsa_struct:: SalsaStructInDb ;
1818use crate :: sync:: Arc ;
19- use crate :: table:: memo:: MemoTableTypes ;
19+ use crate :: table:: memo:: { DeletedEntries , MemoTableTypes } ;
2020use crate :: table:: Table ;
2121use crate :: views:: DatabaseDownCaster ;
2222use crate :: zalsa:: { IngredientIndex , JarKind , MemoIngredientIndex , Zalsa } ;
@@ -26,7 +26,6 @@ use crate::{Id, Revision};
2626#[ cfg( feature = "accumulator" ) ]
2727mod accumulated;
2828mod backdate;
29- mod delete;
3029mod diff_outputs;
3130mod execute;
3231mod fetch;
@@ -183,7 +182,8 @@ pub struct IngredientImpl<C: Configuration> {
183182 /// current revision: you would be right, but we are being defensive, because
184183 /// we don't know that we can trust the database to give us the same runtime
185184 /// everytime and so forth.
186- deleted_entries : DeletedEntries < C > ,
185+ delete : DeletedEntries ,
186+ config : PhantomData < fn ( C ) -> C > ,
187187}
188188
189189impl < C > IngredientImpl < C >
@@ -198,10 +198,11 @@ where
198198 Self {
199199 index,
200200 memo_ingredient_indices,
201- lru : lru:: Lru :: new ( lru) ,
202- deleted_entries : Default :: default ( ) ,
203201 view_caster : OnceLock :: new ( ) ,
202+ lru : lru:: Lru :: new ( lru) ,
203+ delete : DeletedEntries :: default ( ) ,
204204 sync_table : SyncTable :: new ( index) ,
205+ config : PhantomData ,
205206 }
206207 }
207208
@@ -258,16 +259,7 @@ where
258259 // FIXME: Use `Box::into_non_null` once stable
259260 let memo = NonNull :: from ( Box :: leak ( Box :: new ( memo) ) ) ;
260261
261- if let Some ( old_value) =
262- self . insert_memo_into_table_for ( zalsa, id, memo, memo_ingredient_index)
263- {
264- // In case there is a reference to the old memo out there, we have to store it
265- // in the deleted entries. This will get cleared when a new revision starts.
266- //
267- // SAFETY: Once the revision starts, there will be no outstanding borrows to the
268- // memo contents, and so it will be safe to free.
269- unsafe { self . deleted_entries . push ( old_value) } ;
270- }
262+ self . insert_memo_into_table_for ( zalsa, id, memo, memo_ingredient_index) ;
271263 // SAFETY: memo has been inserted into the table
272264 unsafe { self . extend_memo_lifetime ( memo. as_ref ( ) ) }
273265 }
@@ -464,16 +456,19 @@ where
464456 true
465457 }
466458
467- fn reset_for_new_revision ( & mut self , table : & mut Table ) {
459+ fn reset_for_new_revision (
460+ & mut self ,
461+ table : & mut Table ,
462+ new_buffer : DeletedEntries ,
463+ ) -> DeletedEntries {
468464 self . lru . for_each_evicted ( |evict| {
469465 let ingredient_index = table. ingredient_index ( evict) ;
470466 Self :: evict_value_from_memo_for (
471467 table. memos_mut ( evict) ,
472468 self . memo_ingredient_indices . get ( ingredient_index) ,
473469 )
474470 } ) ;
475-
476- self . deleted_entries . clear ( ) ;
471+ mem:: replace ( & mut self . delete , new_buffer)
477472 }
478473
479474 fn debug_name ( & self ) -> & ' static str {
0 commit comments