Files
hakorune/examples/gc_counting_demo.hako
nyash-codex d7805e5974 feat(joinir): Phase 213-2 Step 2-2 & 2-3 Data structure extensions
Extended PatternPipelineContext and CarrierUpdateInfo for Pattern 3 AST-based generalization.

Changes:
1. PatternPipelineContext:
   - Added loop_condition: Option<ASTNode>
   - Added loop_body: Option<Vec<ASTNode>>
   - Added loop_update_summary: Option<LoopUpdateSummary>
   - Updated build_pattern_context() for Pattern 3

2. CarrierUpdateInfo:
   - Added then_expr: Option<ASTNode>
   - Added else_expr: Option<ASTNode>
   - Updated analyze_loop_updates() with None defaults

Status: Phase 213-2 Steps 2-2 & 2-3 complete
Next: Create Pattern3IfAnalyzer to extract if statement and populate update summary
2025-12-10 00:01:53 +09:00

34 lines
922 B
Plaintext

// GC Counting demo (VM path) — verifies CountingGc counters and barrier sites
// Run:
// ./target/release/hakorune --backend vm examples/gc_counting_demo.hako
// Expect (with trace): [GC] counters: safepoints>0 read_barriers>=0 write_barriers>=0
static box Main {
main() {
// Turn on Counting GC + trace via Box-First path
local G
G = new GcConfigBox()
G = G.setFlag("counting", true)
G = G.setFlag("trace", true)
G.apply()
// Make sure we don't engage JIT path for this demo (VM baseline)
// If needed, you can set NYASH_JIT_EXEC=0 in the environment.
// Perform some mutating ops to hit write barriers on the VM path
local A, M
A = new ArrayBox()
A.push(1)
A.set(0, 2)
M = new MapBox()
M.set("k", "v")
// Simple read ops (should register read barriers on some implementations)
print(A.length())
print(M.size())
return "done"
}
}