Advance replay checkpoints through completed entry lines
This commit is contained in:
1 parent
d249ec7eba
commit
51db480b34
5 files changed
+175
-14
No files matched your search
@@ -322,6 +322,7 @@ pub struct CheckpointSource<'a> {
|
||||
pub bytes: usize,
|
||||
pub frontier: usize,
|
||||
pub is_entry: bool,
|
||||
pub line_consumed: bool,
|
||||
pub output_returned: bool,
|
||||
}
|
||||
|
||||
@@ -355,6 +356,22 @@ impl EntryCheckpoint {
|
||||
self.executor.steps
|
||||
}
|
||||
|
||||
/// The later anchor may replace an ordinary checkpoint on the same
|
||||
/// already loaded physical line when it can accept the same source edits.
|
||||
pub fn can_advance_entry_anchor(&self, earlier: &Self) -> bool {
|
||||
self.active_source == self.entry
|
||||
&& earlier.active_source == earlier.entry
|
||||
&& self.frontier == earlier.frontier
|
||||
&& self.executor.steps > earlier.executor.steps
|
||||
&& self.executor.sources[self.entry].name == earlier.executor.sources[earlier.entry].name
|
||||
&& self.source_mouth(self.entry)
|
||||
.same_loaded_prefix_constraint(earlier.source_mouth(earlier.entry))
|
||||
&& (!self.executor.reads.observed_statistics()
|
||||
|| (earlier.executor.reads.observed_statistics()
|
||||
&& self.executor.sources[self.entry].data.len()
|
||||
== earlier.executor.sources[earlier.entry].data.len()))
|
||||
}
|
||||
|
||||
pub fn accepts_entry(&self, source: &SourceFile) -> bool {
|
||||
self.accepts_entry_bytes(&source.name, &source.data)
|
||||
}
|
||||
@@ -3945,6 +3962,7 @@ impl Executor {
|
||||
bytes: file.data.len(),
|
||||
frontier,
|
||||
is_entry: active_source == entry,
|
||||
line_consumed: mouth.line_consumed(),
|
||||
output_returned: engine.output_frame.is_none(),
|
||||
};
|
||||
let Some(slot) = select(position, engine.shipped_pages) else {
|
||||
|
||||
@@ -316,6 +316,17 @@ impl Mouth {
|
||||
(matches!(self.line_breaks, LineBreaks::Physical) && !self.end_after_line && self.offset > 0)
|
||||
.then_some(self.offset)
|
||||
}
|
||||
pub(super) fn line_consumed(&self) -> bool {
|
||||
self.cursor >= self.line.len()
|
||||
}
|
||||
|
||||
pub(super) fn same_loaded_prefix_constraint(&self, other: &Self) -> bool {
|
||||
self.offset == other.offset
|
||||
&& self.data[..self.offset] == other.data[..other.offset]
|
||||
&& self.xe.as_ref().map(|xe| (xe.terminated, &xe.autodetected))
|
||||
== other.xe.as_ref().map(|xe| (xe.terminated, &xe.autodetected))
|
||||
}
|
||||
|
||||
pub(super) fn matches_loaded_prefix(&self, data: &[u8]) -> bool {
|
||||
let Some(offset) = self.physical_frontier() else {
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user