Reduce macro copying during native suffix convergence

This commit is contained in:
gloamxun committed 2026-12-01 22:50:53 +08:00
1 parent 57c05d9635
commit c008c52964
9 files changed
+228 -110

No files matched your search

@@ -1,4 +1,6 @@
use super::super::source_relocation::SourceRelocation;
use super::super::{
source_relocation::SourceRelocation, source_relocation_events::EventRelocation,
};
use super::*;
mod material;
mod relocate;
@@ -171,7 +173,10 @@ impl EntryCheckpoint {
None if self.frontier == prior.frontier => None,
None => return None,
};
if !same_kernel_continuation(current, old, relocation.as_ref()) {
// Comparison and publication visit some of the same original
// allocations. Keep the checked relocations for this donor only.
let mut moved = relocation.as_ref().map(EventRelocation::new);
if !same_kernel_continuation(current, old, moved.as_mut()) {
return None;
}
let offset = StepOffset::new(old.steps, current.steps);
@@ -214,8 +219,11 @@ impl EntryCheckpoint {
reads_event_history: false,
accounts_event_history: completed.accounts_event_history,
};
if let Some((map, sizes)) = relocation.as_ref().zip(entry_sizes) {
relocate::append_suffix(&mut execution, tail, offset, map, sizes, old.sources.len())?;
if let Some((moved, sizes)) = moved.as_mut().zip(entry_sizes) {
relocate::append_suffix(&mut execution, tail, offset, moved, sizes, old.sources.len())?;
if execution.state != completed.state {
execution.outgoing_state = execution.state.fingerprint();
}
} else if offset.is_identity() {
execution.events.extend_from_slice(tail);
} else {
@@ -378,7 +386,7 @@ fn is_idle_continuation(e: &Executor) -> bool {
fn same_kernel_continuation(
current: &Executor,
prior: &Executor,
relocation: Option<&SourceRelocation>,
relocation: Option<&mut EventRelocation<'_>>,
) -> bool {
// Every field belongs to one of these checks. Adding kernel state requires
// an explicit decision here before a later execution may be skipped.
@@ -489,9 +497,10 @@ fn same_kernel_continuation(
{
return false;
}
let map = relocation.as_ref().map(|context| context.map());
let relocated;
let prior = if let Some(map) = relocation {
relocated = match relocate::kernel_continuation(prior, map) {
let prior = if let Some(context) = relocation {
relocated = match relocate::kernel_continuation(prior, context) {
Some(executor) => executor,
None => return false,
};
@@ -522,5 +531,5 @@ fn same_kernel_continuation(
.inputs
.iter()
.zip(&prior.inputs)
.all(|(a, b)| a.same_at_shipout(b, relocation))
.all(|(a, b)| a.same_at_shipout(b, map))
}