Share packed box diagnostics across native execution

This commit is contained in:
gloamxun committed 2026-11-28 07:43:44 +08:00
1 parent 526ec9b3b0
commit ca3730338e
13 files changed
+126 -22

No files matched your search

@@ -795,7 +795,7 @@ fn empty_alignment_box(width: i64, horizontal: bool, span: Span) -> NativeBox {
} else {
BoxContent::Vertical(Vec::new())
},
diagnostic: Vec::new(),
diagnostic: Default::default(),
setting: GlueSetting::default(),
interword_runs: Vec::new(),
badness: 0,
@@ -1013,7 +1013,7 @@ fn set_alignment_row(
row.excess = 0;
if horizontal {
row.width = prototype.width;
row.diagnostic = super::super::diagnostics::text_nodes(&h);
row.diagnostic = super::super::diagnostics::text_nodes(&h).into();
row.content = BoxContent::Horizontal(h);
} else {
row.height = prototype.height;
@@ -521,7 +521,7 @@ impl Executor {
depth: 0,
shift: 0,
content: BoxContent::Horizontal(Vec::new()),
diagnostic: Vec::new(),
diagnostic: Default::default(),
setting: GlueSetting::default(),
interword_runs: Vec::new(),
badness: 0,
@@ -24,8 +24,8 @@ impl Executor {
return Ok(());
}
// Packing can move existing lists or replace an old register. Recount
// actual owners at an execution boundary before rejecting the job.
let usage = self.resource_usage(shipping, None);
// actual storage here, including a shared diagnostic allocation once.
let usage = self.collect_usage(shipping, None, Collector::for_capacity());
self.material_charge = usage
.active_material
.records()
@@ -40,7 +40,15 @@ impl Executor {
shipping: Option<&NativeBox>,
host: Option<HostResourceUsage>,
) -> ResourceUsage {
let mut c = Collector::default();
self.collect_usage(shipping, host, Collector::default())
}
fn collect_usage(
&self,
shipping: Option<&NativeBox>,
host: Option<HostResourceUsage>,
mut c: Collector,
) -> ResourceUsage {
self.state.collect_statistics(&mut c);
c.usage.steps = self.steps;
c.usage.source_files = self.sources.len();
@@ -132,7 +140,7 @@ impl Executor {
c.vertical(v, Retained);
}
for b in &p.diagnostic_lines {
c.diagnostics(&b.nodes, Retained);
c.shared_diagnostics(&b.nodes, Retained);
}
for paragraph in &p.lines {
for line in &paragraph.lines {