Verify retained TeX accounting before reusing executed suffixes
This commit is contained in:
1 parent
0117449023
commit
57ce7116ad
8 files changed
+236
-15
No files matched your search
@@ -122,6 +122,11 @@ impl EntryCheckpoint {
|
||||
let mut sources = completed.sources.clone();
|
||||
sources[self.entry] = current.sources[self.entry].clone();
|
||||
let tail = completed.events.get(old.events.len()..)?;
|
||||
if completed.accounts_event_history && !current.equivalent_accounting_history(old) {
|
||||
return None;
|
||||
}
|
||||
// The joined events are published results. Resumption always starts
|
||||
// from a live checkpoint, whose original shared allocations stay intact.
|
||||
let mut events = current.events.clone().into_vec();
|
||||
events.extend_from_slice(tail);
|
||||
Some(Execution {
|
||||
@@ -145,6 +150,7 @@ impl EntryCheckpoint {
|
||||
outgoing_state: completed.outgoing_state,
|
||||
steps: completed.steps,
|
||||
reads_event_history: false,
|
||||
accounts_event_history: completed.accounts_event_history,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -219,6 +225,7 @@ fn same_kernel_continuation(current: &Executor, prior: &Executor) -> bool {
|
||||
writing,
|
||||
stack_peaks,
|
||||
alignment_balance,
|
||||
accounts_event_history,
|
||||
],
|
||||
[
|
||||
inputs,
|
||||
|
||||
@@ -25,7 +25,7 @@ impl Executor {
|
||||
}
|
||||
// Packing can move existing lists or replace an old register. Recount
|
||||
// actual storage here, counting each shared list allocation once.
|
||||
self.reads_event_history = true;
|
||||
self.accounts_event_history = true;
|
||||
let usage = self.collect_usage(shipping, None, Collector::for_capacity());
|
||||
self.material_charge = usage
|
||||
.active_material
|
||||
@@ -41,7 +41,7 @@ impl Executor {
|
||||
shipping: Option<&NativeBox>,
|
||||
host: Option<HostResourceUsage>,
|
||||
) -> ResourceUsage {
|
||||
self.reads_event_history = true;
|
||||
self.accounts_event_history = true;
|
||||
self.collect_usage(shipping, host, Collector::default())
|
||||
}
|
||||
|
||||
@@ -49,8 +49,19 @@ impl Executor {
|
||||
&self,
|
||||
shipping: Option<&NativeBox>,
|
||||
host: Option<HostResourceUsage>,
|
||||
mut c: Collector,
|
||||
c: Collector,
|
||||
) -> ResourceUsage {
|
||||
let mut c = self.collect_live_usage(shipping, host, c);
|
||||
Self::collect_event_usage(self.events.iter(), &mut c);
|
||||
c.usage
|
||||
}
|
||||
|
||||
fn collect_live_usage(
|
||||
&self,
|
||||
shipping: Option<&NativeBox>,
|
||||
host: Option<HostResourceUsage>,
|
||||
mut c: Collector,
|
||||
) -> Collector {
|
||||
self.state.collect_statistics(&mut c);
|
||||
c.usage.steps = self.steps;
|
||||
c.usage.source_files = self.sources.len();
|
||||
@@ -122,7 +133,11 @@ impl Executor {
|
||||
InputFrame::Boundary => {}
|
||||
}
|
||||
}
|
||||
for e in self.events.iter() {
|
||||
c
|
||||
}
|
||||
|
||||
fn collect_event_usage<'a>(events: impl Iterator<Item = &'a Event>, c: &mut Collector) {
|
||||
for e in events {
|
||||
if matches!(e, Event::Statistics(_)) {
|
||||
continue;
|
||||
}
|
||||
@@ -164,8 +179,30 @@ impl Executor {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
c.usage
|
||||
}
|
||||
|
||||
pub(super) fn equivalent_accounting_history(&self, old: &Self) -> bool {
|
||||
// These containers may reintroduce previously retained allocations
|
||||
// that are outside the accounting walk at this boundary.
|
||||
let fully_visited = |engine: &Self| {
|
||||
engine.state.pdf_forms.is_empty()
|
||||
&& engine.native_page.as_ref().is_none_or(|page| page.insertions.held.is_empty())
|
||||
};
|
||||
if !fully_visited(self) || !fully_visited(old) {
|
||||
return false;
|
||||
}
|
||||
|
||||
[Collector::for_capacity, Collector::default].into_iter().all(|collector| {
|
||||
let mut history = collector();
|
||||
let mut old_history = collector();
|
||||
Self::collect_event_usage(self.events.iter(), &mut history);
|
||||
Self::collect_event_usage(old.events.iter(), &mut old_history);
|
||||
let live = self.collect_live_usage(None, None, collector().tracking_aliases());
|
||||
let old_live = old.collect_live_usage(None, None, collector().tracking_aliases());
|
||||
live.has_equivalent_history(&old_live, &history, &old_history)
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn statistics_before_shipout(
|
||||
&mut self,
|
||||
b: &NativeBox,
|
||||
|
||||
Reference in new issue
Block a user