phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0
This commit is contained in:
34
examples/gc_counting_demo.hako
Normal file
34
examples/gc_counting_demo.hako
Normal file
@ -0,0 +1,34 @@
|
||||
// GC Counting demo (VM path) — verifies CountingGc counters and barrier sites
|
||||
// Run:
|
||||
// ./target/release/nyash --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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user