feat(runtime): Phase 101-A dev-debug ログの Ring0.log 統一 - 34箇所完了
## Phase 101-A 完了項目 - ✅ llvm.rs: 13箇所([joinir/llvm], [parse/context]) → Ring0.log - ✅ loop_form.rs: [loopform] 系ログ → Ring0.log - ✅ loopform_builder.rs: 16箇所([loopform/prepare], [loopform/seal_phis]) → Ring0.log - ✅ loop_snapshot_merge.rs: 5箇所([Option C]) → Ring0.log - ✅ 全テストPASS(ビルド成功) ## 置き換え箇所(34箇所) **llvm.rs**(13箇所): - [joinir/llvm] JoinIR 実験パスログ(12箇所) - [parse/context] プリロードファイルリスト(1箇所) **loop_form.rs**(複数箇所): - [loopform] 基本ログ - [loopform/condition] 条件式処理 - [loopform/writes] 変数書き込み収集 **loopform_builder.rs**(16箇所): - [loopform/prepare] 構造準備 - [loopform/seal_phis] PHI シーリング処理 **loop_snapshot_merge.rs**(5箇所): - [Option C] Exit PHI 分類 - [Option C] 変数解析 ## 技術的成果 - Ring0.log で dev-debug ログを一元管理 - stderr の cleanness 向上(ユーザー向けメッセージのみ) - 環境に応じた出力制御が可能(NYASH_LOOPFORM_DEBUG等) - Phase 99-100 で確立した 3層設計を実装レベルで完成 ## 実装パターン ```rust // Before eprintln!("[loopform] variable_map: {:?}", map); // After crate::runtime::get_global_ring0().log.debug(&format!( "[loopform] variable_map: {:?}", map )); ``` ## 統計 - Phase 98: 7箇所(ConsoleService) - Phase 100: 29箇所(ConsoleService) - Phase 101-A: 34箇所(Ring0.log) - **合計**: 70箇所で統一(ConsoleService/Ring0.log) - 残り: ~905箇所(test含む) ## ドキュメント更新 - logging_policy.md: Section 7-A 追加(Phase 101-A 実装記録) - ring0-inventory.md: Category 2 更新(dev-debug 進捗反映) - CURRENT_TASK.md: Phase 85 セクション追記 ## Phase 85-101-A 総括 - Phase 95.5-97: CoreServices 6個完全実装(String/Integer/Bool/Array/Map/Console) - Phase 98-98.5: ConsoleService 代表パス拡張(7箇所) - Phase 99: ログ/出力ポリシー確定(3層設計文書化) - Phase 100: user-facing 出力の ConsoleService 化(29箇所) - Phase 101-A: dev-debug ログの Ring0.log 統一(34箇所) ✅ 次: Phase 101-B(internal/test ログの整理、別検討) 🎊 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -43,13 +43,13 @@ impl<'a> LoopBuilder<'a> {
|
||||
|
||||
// DEBUG: Show variable map before guard check
|
||||
if std::env::var("NYASH_LOOPFORM_DEBUG").is_ok() {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform] before_loop_id={:?}, variable_map size={}",
|
||||
before_loop_id,
|
||||
current_vars.len()
|
||||
);
|
||||
));
|
||||
for (name, value) in ¤t_vars {
|
||||
eprintln!(" {} -> {:?}", name, value);
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(" {} -> {:?}", name, value));
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,39 +83,41 @@ impl<'a> LoopBuilder<'a> {
|
||||
|
||||
// Pass 1: Prepare structure (allocate all ValueIds upfront)
|
||||
if std::env::var("NYASH_LOOPFORM_DEBUG").is_ok() {
|
||||
eprintln!("[loopform] Block IDs: preheader={:?}, header={:?}, body={:?}, latch={:?}, exit={:?}",
|
||||
preheader_id, header_id, body_id, latch_id, exit_id);
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform] Block IDs: preheader={:?}, header={:?}, body={:?}, latch={:?}, exit={:?}",
|
||||
preheader_id, header_id, body_id, latch_id, exit_id
|
||||
));
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform] variable_map at loop entry (size={}):",
|
||||
current_vars.len()
|
||||
);
|
||||
));
|
||||
let mut loop_count = 0;
|
||||
for (name, value) in ¤t_vars {
|
||||
loop_count += 1;
|
||||
eprintln!(" [{}] {} -> {:?}", loop_count, name, value);
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(" [{}] {} -> {:?}", loop_count, name, value));
|
||||
// Phase 26-A-4: ValueIdベース判定に変更(名前ベース → 型安全)
|
||||
let is_param = self.is_parameter(*value);
|
||||
eprintln!(" param={}", is_param);
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(" param={}", is_param));
|
||||
}
|
||||
eprintln!("[loopform] iterated {} times", loop_count);
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[loopform] iterated {} times", loop_count));
|
||||
if let Some(ref func) = self.parent_builder.current_function {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform] BEFORE prepare_structure: fn='{}', counter={}, func_ptr={:p}",
|
||||
func.signature.name, func.next_value_id, func as *const _
|
||||
);
|
||||
));
|
||||
} else {
|
||||
eprintln!("[loopform] BEFORE prepare_structure: current_function=None");
|
||||
crate::runtime::get_global_ring0().log.debug("[loopform] BEFORE prepare_structure: current_function=None");
|
||||
}
|
||||
}
|
||||
loopform.prepare_structure(self, ¤t_vars)?;
|
||||
if std::env::var("NYASH_LOOPFORM_DEBUG").is_ok() {
|
||||
if let Some(ref func) = self.parent_builder.current_function {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform] AFTER prepare_structure: fn='{}', counter={}, func_ptr={:p}",
|
||||
func.signature.name, func.next_value_id, func as *const _
|
||||
);
|
||||
));
|
||||
} else {
|
||||
eprintln!("[loopform] AFTER prepare_structure: current_function=None");
|
||||
crate::runtime::get_global_ring0().log.debug("[loopform] AFTER prepare_structure: current_function=None");
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,8 +149,8 @@ impl<'a> LoopBuilder<'a> {
|
||||
// ⚠️ 重要: このモードでは MIR は不完全(φ 抜け)であり、VM で実行できない。
|
||||
// JoinIR runner 専用モードであることに注意。
|
||||
if crate::mir::phi_core::loopform_builder::is_loopform_debug_enabled() {
|
||||
eprintln!("[loopform/27.4-C] Header φ bypass active for: {}", fn_name);
|
||||
eprintln!("[loopform/27.4-C] Skipping emit_header_phis() - using preheader values directly");
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[loopform/27.4-C] Header φ bypass active for: {}", fn_name));
|
||||
crate::runtime::get_global_ring0().log.debug("[loopform/27.4-C] Skipping emit_header_phis() - using preheader values directly");
|
||||
}
|
||||
} else {
|
||||
// 従来どおり HeaderPhiBuilder を使って φ を準備
|
||||
@ -156,9 +158,9 @@ impl<'a> LoopBuilder<'a> {
|
||||
}
|
||||
|
||||
if crate::mir::phi_core::loopform_builder::is_loopform_debug_enabled() {
|
||||
eprintln!("[loopform] variable_map after emit_header_phis:");
|
||||
crate::runtime::get_global_ring0().log.debug("[loopform] variable_map after emit_header_phis:");
|
||||
for (name, value) in self.get_current_variable_map().iter() {
|
||||
eprintln!(" {} -> {:?}", name, value);
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(" {} -> {:?}", name, value));
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,15 +177,15 @@ impl<'a> LoopBuilder<'a> {
|
||||
// - Case A: loop(i < n) → header can branch to exit directly
|
||||
// - Case B: loop(1 == 1) → header always enters body, exit only via break
|
||||
if std::env::var("NYASH_LOOPFORM_DEBUG").is_ok() {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/condition] BEFORE build_expression: current_block={:?}",
|
||||
self.current_block()?
|
||||
);
|
||||
));
|
||||
if let Some(ref func) = self.parent_builder.current_function {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/condition] BEFORE: fn='{}', counter={}, func_ptr={:p}",
|
||||
func.signature.name, func.next_value_id, func as *const _
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
let cond_value = self.parent_builder.build_expression(condition)?;
|
||||
@ -191,25 +193,25 @@ impl<'a> LoopBuilder<'a> {
|
||||
// if build_expression created new blocks)
|
||||
let branch_source_block = self.current_block()?;
|
||||
if std::env::var("NYASH_LOOPFORM_DEBUG").is_ok() {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/condition] AFTER build_expression: branch_source_block={:?}",
|
||||
branch_source_block
|
||||
);
|
||||
));
|
||||
if let Some(ref func) = self.parent_builder.current_function {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/condition] AFTER: fn='{}', counter={}, func_ptr={:p}",
|
||||
func.signature.name, func.next_value_id, func as *const _
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
self.emit_branch(cond_value, body_id, exit_id)?;
|
||||
// 📦 Hotfix 6: Add CFG predecessors for branch targets (Cytron et al. 1991 requirement)
|
||||
// This ensures exit_block.predecessors is populated before Exit PHI generation
|
||||
if std::env::var("NYASH_LOOPFORM_DEBUG").is_ok() {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/condition] BEFORE add_predecessor: exit_id={:?}, branch_source={:?}",
|
||||
exit_id, branch_source_block
|
||||
);
|
||||
));
|
||||
}
|
||||
crate::mir::builder::loops::add_predecessor(
|
||||
self.parent_builder,
|
||||
@ -222,21 +224,21 @@ impl<'a> LoopBuilder<'a> {
|
||||
branch_source_block,
|
||||
)?;
|
||||
if std::env::var("NYASH_LOOPFORM_DEBUG").is_ok() {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/condition] AFTER emit_branch: current_block={:?}",
|
||||
self.current_block()?
|
||||
);
|
||||
eprintln!(
|
||||
));
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/condition] Added predecessors: body={:?} exit={:?} from={:?}",
|
||||
body_id, exit_id, branch_source_block
|
||||
);
|
||||
));
|
||||
// Verify predecessors were added
|
||||
if let Some(ref func) = self.parent_builder.current_function {
|
||||
if let Some(exit_block) = func.blocks.get(&exit_id) {
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/condition] exit_block.predecessors = {:?}",
|
||||
exit_block.predecessors
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -274,15 +276,15 @@ impl<'a> LoopBuilder<'a> {
|
||||
|
||||
// DEBUG: Log writes collection
|
||||
if std::env::var("NYASH_LOOPFORM_DEBUG").is_ok() {
|
||||
eprintln!("[loopform/writes] === WRITES COLLECTION (Step 5-1) ===");
|
||||
eprintln!(
|
||||
crate::runtime::get_global_ring0().log.debug("[loopform/writes] === WRITES COLLECTION (Step 5-1) ===");
|
||||
crate::runtime::get_global_ring0().log.debug(&format!(
|
||||
"[loopform/writes] {} variables modified in loop body",
|
||||
writes.len()
|
||||
);
|
||||
));
|
||||
let mut sorted_writes: Vec<_> = writes.iter().collect();
|
||||
sorted_writes.sort();
|
||||
for name in &sorted_writes {
|
||||
eprintln!("[loopform/writes] WRITE: {}", name);
|
||||
crate::runtime::get_global_ring0().log.debug(&format!("[loopform/writes] WRITE: {}", name));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user