Reuse cached layouts for relocated native shipouts

This commit is contained in:
gloamxun committed 2026-12-01 22:30:37 +08:00
1 parent 41a459b4ca
commit 57c05d9635
8 files changed
+394 -26

No files matched your search

@@ -87,10 +87,43 @@ impl InputFrame {
}
}
/// Source coordinates for the shipouts copied from a moved execution suffix.
pub struct RelocatedShipoutSuffix {
first_page: usize,
map: SourceRelocation,
}
impl RelocatedShipoutSuffix {
/// Relocate a raw local layout from the exact donor execution at the
/// given zero-based shipout index. The host must match that execution
/// before supplying a cached list.
pub fn relocate_layout(
&self,
index: usize,
layout: &crate::render::DisplayList,
) -> Option<crate::render::DisplayList> {
if index < self.first_page {
return None;
}
layout.relocate_sources(|span| self.map.relocate_span(span))
}
}
impl EntryCheckpoint {
/// Construct an execution with the current prefix and a previously
/// completed suffix. The host must still validate and replay that suffix.
pub fn splice_settled_suffix(&self, prior: &Self, completed: &Execution) -> Option<Execution> {
self.splice_settled_suffix_with_layout(prior, completed)
.map(|(execution, _)| execution)
}
/// Also return the coordinate mapping for copied shipouts whose cached
/// local layouts belong to the supplied completed execution.
pub fn splice_settled_suffix_with_layout(
&self,
prior: &Self,
completed: &Execution,
) -> Option<(Execution, Option<RelocatedShipoutSuffix>)> {
if self.entry != self.active_source
|| prior.entry != prior.active_source
|| self.entry != prior.entry
@@ -190,7 +223,13 @@ impl EntryCheckpoint {
execution.events.push(offset_event_steps(event, offset)?);
}
}
Some(execution)
let layout = relocation.map(|map| RelocatedShipoutSuffix {
// The executor records one top-level shipout event whenever
// this count advances. Form canvases do not enter this sequence.
first_page: old.shipped_pages,
map,
});
Some((execution, layout))
}
/// Carry later checkpoints from the suffix accepted by
/// splice_settled_suffix into this revision. The host must still replay