fix(joinir): Use BTreeMap for MirModule.functions deterministic iteration

HashMap iteration order is non-deterministic due to HashDoS protection.
This caused merge_joinir_mir_blocks to sometimes process functions in
wrong order, leading to incorrect block remapping.

Changed:
- MirModule.functions: HashMap → BTreeMap
- MirInterpreter.functions: HashMap → BTreeMap
- IfLoweringDryRunner.scan_module: HashMap → BTreeMap parameter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-05 17:22:14 +09:00
parent 1c89befdac
commit c4c0814fd6
3 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@
* Print/Debug (best-effort), Barrier/Safepoint (no-op).
*/
use std::collections::HashMap;
use std::collections::{BTreeMap, HashMap};
use crate::box_trait::NyashBox;
@ -31,7 +31,7 @@ pub struct MirInterpreter {
pub(super) mem: HashMap<ValueId, VMValue>,
// Object field storage keyed by stable object identity (Arc ptr addr fallback)
pub(super) obj_fields: HashMap<u64, HashMap<String, VMValue>>,
pub(super) functions: HashMap<String, MirFunction>,
pub(super) functions: BTreeMap<String, MirFunction>,
pub(super) cur_fn: Option<String>,
// Trace context (dev-only; enabled with NYASH_VM_TRACE=1)
pub(super) last_block: Option<BasicBlockId>,
@ -54,7 +54,7 @@ impl MirInterpreter {
regs: HashMap::new(),
mem: HashMap::new(),
obj_fields: HashMap::new(),
functions: HashMap::new(),
functions: BTreeMap::new(),
cur_fn: None,
last_block: None,
last_inst: None,