Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini

This commit is contained in:
nyash-codex
2025-12-11 20:54:33 +09:00
parent 59a985b7fa
commit af6f95cd4b
170 changed files with 4423 additions and 1897 deletions

View File

@ -30,7 +30,11 @@
use std::collections::HashMap;
#[cfg(feature = "normalized_dev")]
use crate::config::env::normalized_dev_enabled;
use crate::mir::join_ir::{ConstValue, JoinFuncId, JoinInst, JoinModule, MirLikeInst, VarId};
#[cfg(feature = "normalized_dev")]
use crate::mir::join_ir::normalized::{normalized_dev_roundtrip_structured, shape_guard};
// Phase 27.8: ops box からの再エクスポート
pub use crate::mir::join_ir_ops::{JoinIrOpError, JoinValue};
@ -44,9 +48,49 @@ pub fn run_joinir_function(
entry: JoinFuncId,
args: &[JoinValue],
) -> Result<JoinValue, JoinRuntimeError> {
#[cfg(feature = "normalized_dev")]
if normalized_dev_enabled() {
return run_joinir_function_normalized_dev(vm, module, entry, args);
}
execute_function(vm, module, entry, args.to_vec())
}
#[cfg(feature = "normalized_dev")]
fn run_joinir_function_normalized_dev(
vm: &mut crate::backend::mir_interpreter::MirInterpreter,
module: &JoinModule,
entry: JoinFuncId,
args: &[JoinValue],
) -> Result<JoinValue, JoinRuntimeError> {
// Keep dev path opt-in and fail-fast: only Structured P1/P2 minis are supported.
let verbose = crate::config::env::joinir_dev_enabled();
let args_vec = args.to_vec();
let shapes = shape_guard::supported_shapes(module);
if shapes.is_empty() {
if verbose {
eprintln!(
"[joinir/runner/normalized-dev] shape unsupported; staying on Structured path"
);
}
return execute_function(vm, module, entry, args_vec);
}
let structured_roundtrip = normalized_dev_roundtrip_structured(module)
.map_err(|msg| JoinRuntimeError::new(format!("[joinir/runner/normalized-dev] {}", msg)))?;
if verbose {
eprintln!(
"[joinir/runner/normalized-dev] normalized roundtrip succeeded (shapes={:?}, functions={})",
shapes,
structured_roundtrip.functions.len()
);
}
execute_function(vm, &structured_roundtrip, entry, args_vec)
}
fn execute_function(
vm: &mut crate::backend::mir_interpreter::MirInterpreter,
module: &JoinModule,