Reduce repeated macro tracing and input position work
This commit is contained in:
1 parent
70822cbd94
commit
b681f9791a
5 files changed
+64
-29
No files matched your search
@@ -204,6 +204,7 @@ pub struct Executor {
|
||||
generated_inputs: std::collections::BTreeMap<usize, GeneratedInput>,
|
||||
reads: BTreeSet<Dependency>,
|
||||
meaning_reads: HashSet<CommandName>,
|
||||
reads_tracing_macros: bool,
|
||||
conditionals: Vec<Conditional>,
|
||||
in_csname: bool,
|
||||
command_trace_mode: Option<&'static str>,
|
||||
@@ -373,6 +374,7 @@ impl Executor {
|
||||
generated_inputs: Default::default(),
|
||||
reads: BTreeSet::new(),
|
||||
meaning_reads: HashSet::new(),
|
||||
reads_tracing_macros: false,
|
||||
conditionals: Vec::new(),
|
||||
in_csname: false,
|
||||
command_trace_mode: None,
|
||||
@@ -1791,7 +1793,17 @@ impl Executor {
|
||||
call: &Token,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<(), Error> {
|
||||
self.trace_macro_call(&definition, call, files)?;
|
||||
// A macro only scans raw tokens while matching its arguments, so
|
||||
// assignments cannot change the trace level during this call.
|
||||
if !self.reads_tracing_macros {
|
||||
self.reads
|
||||
.insert(Dependency::Parameter(Parameter::Tracingmacros));
|
||||
self.reads_tracing_macros = true;
|
||||
}
|
||||
let trace = self.state.parameter(Parameter::Tracingmacros).width() > 0;
|
||||
if trace {
|
||||
self.trace_macro_call(&definition, call, files)?;
|
||||
}
|
||||
for expected in &definition.prefix {
|
||||
if self.required_raw(files)?.token.kind != *expected {
|
||||
return self.fail("macro prefix does not match");
|
||||
@@ -1860,7 +1872,9 @@ impl Executor {
|
||||
}
|
||||
argument = Self::strip_outer_group(argument);
|
||||
}
|
||||
self.trace_macro_argument(&definition, index, &argument, files)?;
|
||||
if trace {
|
||||
self.trace_macro_argument(&definition, index, &argument, files)?;
|
||||
}
|
||||
arguments.push(argument);
|
||||
}
|
||||
self.discard_exhausted_tokens();
|
||||
|
||||
@@ -635,12 +635,9 @@ impl Executor {
|
||||
call: &Token,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<(), Error> {
|
||||
if self.read_parameter(Parameter::Tracingmacros).width() > 0 {
|
||||
let command = self.message_token(call);
|
||||
let body = self.macro_token_text(definition, call.span)?;
|
||||
self.emit_macro_trace(&format!("{command}{body}"), true, files)?;
|
||||
}
|
||||
Ok(())
|
||||
let command = self.message_token(call);
|
||||
let body = self.macro_token_text(definition, call.span)?;
|
||||
self.emit_macro_trace(&format!("{command}{body}"), true, files)
|
||||
}
|
||||
|
||||
pub(super) fn trace_macro_argument(
|
||||
@@ -650,28 +647,24 @@ impl Executor {
|
||||
argument: &[Token],
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<(), Error> {
|
||||
if self.read_parameter(Parameter::Tracingmacros).width() > 0 {
|
||||
let mut body = format!("{}{}<-", definition.parameter_chars[index], index + 1);
|
||||
let mut tally = 0;
|
||||
for token in argument {
|
||||
if tally >= 1000 {
|
||||
body.push_str(
|
||||
&self
|
||||
.string_token(&TokenKind::Command(CommandName::Control("ETC.".into()))),
|
||||
);
|
||||
break;
|
||||
}
|
||||
let piece = self.message_token(token);
|
||||
tally += piece.chars().count();
|
||||
if let TokenKind::Character(c, CatCode::Parameter) = token.kind {
|
||||
body.push(c);
|
||||
tally += 1;
|
||||
}
|
||||
body.push_str(&piece);
|
||||
let mut body = format!("{}{}<-", definition.parameter_chars[index], index + 1);
|
||||
let mut tally = 0;
|
||||
for token in argument {
|
||||
if tally >= 1000 {
|
||||
body.push_str(
|
||||
&self.string_token(&TokenKind::Command(CommandName::Control("ETC.".into()))),
|
||||
);
|
||||
break;
|
||||
}
|
||||
self.emit_macro_trace(&body, false, files)?;
|
||||
let piece = self.message_token(token);
|
||||
tally += piece.chars().count();
|
||||
if let TokenKind::Character(c, CatCode::Parameter) = token.kind {
|
||||
body.push(c);
|
||||
tally += 1;
|
||||
}
|
||||
body.push_str(&piece);
|
||||
}
|
||||
Ok(())
|
||||
self.emit_macro_trace(&body, false, files)
|
||||
}
|
||||
|
||||
fn emit_macro_trace(
|
||||
|
||||
@@ -148,9 +148,9 @@ impl Executor {
|
||||
self.inputs.pop();
|
||||
self.restore_input_position();
|
||||
}
|
||||
// Only a source frame changes the current physical line.
|
||||
Next::Token(None) => {
|
||||
self.inputs.pop();
|
||||
self.restore_input_position();
|
||||
}
|
||||
Next::Argument(tokens, call) => {
|
||||
if !tokens.is_empty() {
|
||||
|
||||
@@ -60,6 +60,11 @@ fn macro_trace_follows_real_calls_and_parameters_in_each_channel() {
|
||||
&mut Host,
|
||||
)
|
||||
.unwrap();
|
||||
assert!(
|
||||
result
|
||||
.reads
|
||||
.contains(&Dependency::Parameter(Parameter::Tracingmacros))
|
||||
);
|
||||
let mut native_log = String::new();
|
||||
let mut native_terminal = String::new();
|
||||
for event in result.events {
|
||||
|
||||
@@ -2175,6 +2175,29 @@ PDF,恢复实际 PFB 并反转斜切时复用 1277 步,只替换第二页。
|
||||
全量编译一致。incremental-receipt.json 的 SHA-256 为
|
||||
bbc0991b0316e6d76aa58649ec873525f5544ab530d93fe491fc6e16bd00a27d。
|
||||
|
||||
### 原样 XeLaTeX 启动的执行路径
|
||||
|
||||
读取同一发行版的 xelatex.ini、latex.ltx、expl3 及 Unicode 数据。
|
||||
原始调试作业的采样确认执行仍在推进。在 361466425 步时,已从
|
||||
UnicodeData.txt 消耗 1834151 / 2198209 字节,处于 expl3
|
||||
构造实际码位属性的循环。原始二进制、作业目录与每次采样保存在
|
||||
target/p3-native-xetex/xelatex-native 和 target/p3-xelatex-bootstrap/debugger。
|
||||
对应的 XeTeX 0.999998 参考格式由同一原样入口生成,日志登记
|
||||
40 个字体及 627714 个字体信息字。
|
||||
|
||||
宏调用只在任务首次读取时登记 tracingmacros 依赖。每次调用仍读取
|
||||
当前追踪等级,在扫描实参期间沿用该次的等级。token 列表弹出后沿用
|
||||
物理输入位置,实际文件或伪文件结束时恢复父输入位置。宏追踪、物理
|
||||
行号、伪文件及 everyjob 四组共 9 项定向对照通过。
|
||||
|
||||
固定时钟、绑定同一 CPU,两个调试构建运行同一未改的 xelatex.ini,
|
||||
在同一步数上限处保存失败证据。18000001 步时,两边状态指纹、执行
|
||||
证据、资源读取及诊断一致,日志和 texsys.aux 字节一致。单次配对
|
||||
的墙钟时间为 121.32 s 和 104.86 s,用户态 CPU 时间为 114.69 s
|
||||
和 99.73 s,峰值 RSS 为 92756 和 92736 KiB。计时包含启动和
|
||||
失败证据落盘。完整原样 XeLaTeX 启动、格式读取、类包和实时编辑的
|
||||
统一验收仍待完成。回执在 target/p3-xelatex-bootstrap/prefix-comparison.log。
|
||||
|
||||
### Unicode 入口的 OpenType 和 TrueType 文本
|
||||
|
||||
Unicode 入口可从版本化资源目录加载显式文件名的 OpenType 和
|
||||
|
||||
Reference in new issue
Block a user