Move the advanced child executor into the live job

This commit is contained in:
gloamxun committed 2026-11-29 12:22:54 +08:00
1 parent d98d7b44c1
commit f6f447dd59
4 files changed
+27 -31

No files matched your search

+16 -14
View File
@@ -331,8 +331,8 @@ pub struct CheckpointSource<'a> {
/// validated and replayed the previous suffix into this revision's draft.
pub enum CheckpointDecision {
Continue,
/// Move to a validated later command boundary in the same input.
Advance(Arc<EntryCheckpoint>),
/// Move to a validated later command boundary and select captures there.
Advance(Box<EntryCheckpoint>),
Reuse(Box<Execution>),
ReplayFailed(String),
}
@@ -557,13 +557,16 @@ impl EntryCheckpoint {
}
impl Executor {
fn rebind_checkpoint_source(&mut self, id: usize, file: SourceFile) {
let mouth = self.inputs.iter_mut().rev().find_map(|frame| match frame {
fn source_mouth_mut(&mut self, id: usize) -> &mut Mouth {
self.inputs.iter_mut().rev().find_map(|frame| match frame {
InputFrame::Source { source, mouth, .. } if *source == id => Some(mouth),
_ => None,
}).expect("checkpoint retains the active scanner");
}).expect("checkpoint retains the source scanner")
}
fn rebind_checkpoint_source(&mut self, id: usize, file: SourceFile) {
if self.sources[id].as_ref() != &file {
mouth.rebind_loaded_prefix(file.data.clone());
self.source_mouth_mut(id).rebind_loaded_prefix(file.data.clone());
self.sources[id] = Arc::new(file);
}
}
@@ -3976,7 +3979,7 @@ impl Executor {
mut select: impl FnMut(CheckpointSource<'_>, usize) -> Option<S>,
mut capture: impl FnMut(S, EntryCheckpoint, &mut F) -> CheckpointDecision,
) -> impl FnMut(&mut Self, usize, bool, &mut F) -> CheckpointDecision {
move |engine, initial_depth, pages_processed, files| {
move |engine, initial_depth, pages_processed, files| loop {
if engine.job_ended {
return CheckpointDecision::Continue;
}
@@ -4031,14 +4034,13 @@ impl Executor {
};
match capture(slot, checkpoint, files) {
CheckpointDecision::Advance(checkpoint) => {
let cancellation = engine.cancellation.take();
let line_break_cache = engine.line_break_cache.take();
*engine = checkpoint.executor.clone();
engine.cancellation = cancellation;
engine.line_break_cache = line_break_cache;
CheckpointDecision::Continue
debug_assert!(checkpoint.completed_steps() > engine.steps);
let mut advanced = checkpoint.executor;
advanced.cancellation = engine.cancellation.take();
advanced.line_break_cache = engine.line_break_cache.take();
*engine = advanced;
}
decision => decision,
decision => return decision,
}
}
}
@@ -140,7 +140,8 @@ impl EntryCheckpoint {
return None;
}
let mut executor = later.executor.clone();
executor.rebind_checkpoint_source(child, (**source).clone());
executor.source_mouth_mut(child).share_loaded_source(self.source_mouth(child));
executor.sources[child] = Arc::clone(source);
executor.deferred_accounting = Some(Arc::new(DeferredAccounting {
current: Arc::clone(self),
basis,
@@ -350,6 +350,11 @@ impl Mouth {
debug_assert!(self.matches_loaded_prefix(&data));
self.data = Arc::new(data);
}
pub(super) fn share_loaded_source(&mut self, current: &Self) {
debug_assert!(self.matches_loaded_prefix(&current.data));
self.data = Arc::clone(&current.data);
}
pub(super) fn payload_bytes(&self) -> usize {
self.data.len()
}