Translate logical step counts when replaying native suffixes
This commit is contained in:
1 parent
9a6c162b46
commit
465a574124
8 files changed
+337
-86
No files matched your search
@@ -6,7 +6,7 @@ use std::fs;
|
||||
#[cfg(test)]
|
||||
use texrra_tex_core::source_map::SourceMap;
|
||||
use texrra_tex_core::{
|
||||
execution::{Error, HostResourceUsage, WriteDestination},
|
||||
execution::{Error, HostResourceUsage, StatisticsPhase, StatisticsReport, StepOffset, WriteDestination},
|
||||
resources::{LoadedResource, ResourceKind, ResourceVersion},
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ pub(super) enum Call {
|
||||
Checked(Arc<CheckedCall>),
|
||||
ReadSource(Arc<SourceRead>),
|
||||
FileSize(Arc<SizeRead>),
|
||||
EndStatistics(Arc<StatisticsReport>),
|
||||
}
|
||||
|
||||
pub(super) struct SourceRead {
|
||||
@@ -45,6 +46,7 @@ impl Call {
|
||||
pub(super) fn replay(&self, files: &mut Files, partial_source: Option<&ResourceVersion>) -> Result<(), String> {
|
||||
match self {
|
||||
Self::Checked(call) => call(files),
|
||||
Self::EndStatistics(report) => files.observe_statistics(report),
|
||||
Self::FileSize(read) => {
|
||||
let before = files.resource_trace().reads.len();
|
||||
let observed = files.file_size(&read.name, &read.from);
|
||||
@@ -150,16 +152,27 @@ impl<'a> RecordingHost<'a> {
|
||||
self.files
|
||||
}
|
||||
|
||||
pub(super) fn replay_suffix(&mut self, calls: &[Call], cancellation: &Cancellation) -> Result<(), String> {
|
||||
pub(super) fn replay_suffix(
|
||||
&mut self,
|
||||
calls: &[Call],
|
||||
offset: StepOffset,
|
||||
cancellation: &Cancellation,
|
||||
) -> Result<(), String> {
|
||||
let recorded = self.calls.as_mut().ok_or("host calls are unavailable")?;
|
||||
if recorded.len() + calls.len() >= MAX_REPLAY_CALLS {
|
||||
return Err("completed suffix exceeds the host recording budget".into());
|
||||
}
|
||||
for call in calls {
|
||||
check(cancellation).map_err(|error| error.to_string())?;
|
||||
let call = match call {
|
||||
Call::EndStatistics(report) if !offset.is_identity() => Call::EndStatistics(
|
||||
Arc::new(report.with_step_offset(offset).ok_or("invalid replayed statistics")?),
|
||||
),
|
||||
call => call.clone(),
|
||||
};
|
||||
call.replay(self.files, None)?;
|
||||
recorded.push(call);
|
||||
}
|
||||
recorded.extend_from_slice(calls);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -384,6 +397,17 @@ impl SourceProvider for RecordingHost<'_> {
|
||||
let text = text.to_owned();
|
||||
call!(self, observe_diagnostic(destination, &text))
|
||||
}
|
||||
fn observe_statistics(&mut self, report: &StatisticsReport) -> Result<(), String> {
|
||||
// Shipout reports do not write the step count in their transcript.
|
||||
if !matches!(&report.phase, StatisticsPhase::End { .. }) {
|
||||
return self.observe_diagnostic(report.destination, &report.text);
|
||||
}
|
||||
self.files.observe_statistics(report)?;
|
||||
if let Some(calls) = &mut self.calls && calls.len() < MAX_REPLAY_CALLS {
|
||||
calls.push(Call::EndStatistics(Arc::new(report.clone())));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn observe_inline_diagnostic(
|
||||
&mut self,
|
||||
destination: WriteDestination,
|
||||
|
||||
Reference in new issue
Block a user