AotPrep collections_hot matmul tuning and bench tweaks

This commit is contained in:
nyash-codex
2025-11-14 13:36:20 +09:00
parent 13f21334c9
commit f1fa182a4b
17 changed files with 760 additions and 219 deletions

View File

@ -0,0 +1,25 @@
//! Resolve context — capture per-thread prelude merge context for enriched diagnostics.
use std::cell::RefCell;
thread_local! {
static LAST_MERGED_PRELUDES: RefCell<Vec<String>> = RefCell::new(Vec::new());
}
/// Record the list of prelude file paths used for the last text merge in this thread.
pub fn set_last_merged_preludes(paths: Vec<String>) {
LAST_MERGED_PRELUDES.with(|c| {
*c.borrow_mut() = paths;
});
}
/// Get a clone of the last recorded prelude file paths (if any).
pub fn clone_last_merged_preludes() -> Vec<String> {
LAST_MERGED_PRELUDES.with(|c| c.borrow().clone())
}
/// Take and clear the last recorded prelude file paths.
#[allow(dead_code)]
pub fn take_last_merged_preludes() -> Vec<String> {
LAST_MERGED_PRELUDES.with(|c| std::mem::take(&mut *c.borrow_mut()))
}

View File

@ -25,6 +25,7 @@ pub mod using_resolution;
pub mod prelude_manager;
pub mod selfhost_pipeline;
pub mod path_util;
pub mod context;
// 📦 箱化モジュールの公開にゃ!
pub use using_resolution::{
@ -54,3 +55,9 @@ pub use strip::{
merge_prelude_asts_with_main,
merge_prelude_text,
};
// Expose context helpers for enhanced diagnostics
pub use context::{
set_last_merged_preludes,
clone_last_merged_preludes,
};

View File

@ -777,6 +777,8 @@ pub fn merge_prelude_text(
dfs_text(runner, p, &mut expanded, &mut seen)?;
}
let prelude_paths = &expanded;
// Record for enriched diagnostics (parse error context)
crate::runner::modes::common_util::resolve::set_last_merged_preludes(prelude_paths.clone());
if prelude_paths.is_empty() {
// No using statements, return original

View File

@ -66,6 +66,18 @@ impl NyashRunner {
Ok(ast) => ast,
Err(e) => {
eprintln!("❌ Parse error in {}: {}", filename, e);
// Enhanced context: list merged prelude files if any (from text-merge path)
let preludes = crate::runner::modes::common_util::resolve::clone_last_merged_preludes();
if !preludes.is_empty() {
eprintln!("[parse/context] merged prelude files ({}):", preludes.len());
let show = std::cmp::min(16, preludes.len());
for p in preludes.iter().take(show) {
eprintln!(" - {}", p);
}
if preludes.len() > show {
eprintln!(" ... ({} more)", preludes.len() - show);
}
}
process::exit(1);
}
};

View File

@ -183,6 +183,18 @@ impl NyashRunner {
Ok(ast) => ast,
Err(e) => {
eprintln!("❌ Parse error in {}: {}", filename, e);
// Enhanced context: list merged prelude files if any
let preludes = crate::runner::modes::common_util::resolve::clone_last_merged_preludes();
if !preludes.is_empty() {
eprintln!("[parse/context] merged prelude files ({}):", preludes.len());
let show = std::cmp::min(16, preludes.len());
for p in preludes.iter().take(show) {
eprintln!(" - {}", p);
}
if preludes.len() > show {
eprintln!(" ... ({} more)", preludes.len() - show);
}
}
process::exit(1);
}
};