Phase 10_6b scheduler complete; 10_4 GC hooks + counting/strict tracing; 10_c minimal JIT path (i64/bool consts, binop/compare/return, hostcall opt-in); docs & examples; add Phase 10.7 roadmap (JIT branch wiring + minimal ABI).

This commit is contained in:
Moe Charm
2025-08-27 17:06:46 +09:00
parent de03514085
commit ddae7fe1fc
67 changed files with 4618 additions and 268 deletions

View File

@ -0,0 +1,12 @@
// Param-array JIT HostCall PoC
box Utils {
getArrayLength(arr) {
return arr.length()
}
}
arr = new ArrayBox()
arr.push(1)
arr.push(2)
u = new Utils()
print(u.getArrayLength(arr))

View File

@ -0,0 +1,5 @@
// PoC: array push + len (JIT hostcall path gated)
arr = new ArrayBox()
arr.push(1)
arr.push(2)
print(arr.length())

19
examples/jit_demo.nyash Normal file
View File

@ -0,0 +1,19 @@
// JIT minimal path demo (Core-1)
// Enable with: NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 NYASH_JIT_STATS=1
// Optional hostcall: NYASH_JIT_HOSTCALL=1
// Straight-line integer math + compare + return
static box Main {
main() {
local a, b, c
a = 40
b = 2
c = a + b // 42
// Compare still compiles; branching falls back to VM when needed
if (c == 42) {
print("jit-ok")
}
return c
}
}

View File

@ -0,0 +1,12 @@
// Param-map JIT HostCall PoC
box Utils {
getMapSize(m) {
return m.size()
}
}
m = new MapBox()
m.set("a", 1)
m.set("b", 2)
u = new Utils()
print(u.getMapSize(m))

62
examples/ny_bench.nyash Normal file
View File

@ -0,0 +1,62 @@
// Nyash micro benchmarks using TimerBox (script-level)
// How to run:
// - Interpreter: ./target/release/nyash examples/ny_bench.nyash
// - VM: ./target/release/nyash --backend vm examples/ny_bench.nyash
// - VM+JIT (fast path!): NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 ./target/release/nyash --backend vm examples/ny_bench.nyash
local ITER
ITER = 100000 // change for heavier runs
local timer
timer = new TimerBox()
print("\n=== Nyash Micro Benchmarks (ITER=" + ITER + ") ===")
// 1) Simple arithmetic loop: sum 0..ITER-1
local i, sum, t0, t1, ms, ops
i = 0
sum = 0
t0 = timer.now()
loop(i < ITER) {
sum = sum + i
i = i + 1
}
t1 = timer.now()
ms = t1 - t0
ops = (ITER * 1000.0) / ms
print("[arith_loop] elapsed_ms=" + ms + ", ops/sec=" + ops)
// 2) Array push loop: push integers 0..ITER-1
local arr
arr = new ArrayBox()
i = 0
t0 = timer.now()
loop(i < ITER) {
arr.push(i)
i = i + 1
}
t1 = timer.now()
ms = t1 - t0
ops = (ITER * 1000.0) / ms
print("[array_push] elapsed_ms=" + ms + ", ops/sec=" + ops)
// 3) Mixed arithmetic: simple_add repeated
local a, b, z
a = 1
b = 2
i = 0
t0 = timer.now()
loop(i < ITER) {
z = a + b
a = a + 1
b = b + 1
i = i + 1
}
t1 = timer.now()
ms = t1 - t0
ops = (ITER * 1000.0) / ms
print("[simple_add_loop] elapsed_ms=" + ms + ", ops/sec=" + ops)
print("\nDone.")
return 0

View File

@ -0,0 +1,58 @@
// Nyash micro benchmarks using TimeBox (script-level)
// How to run:
// - Interpreter: ./target/release/nyash examples/ny_bench_fixed.nyash
// - VM: ./target/release/nyash --backend vm examples/ny_bench_fixed.nyash
// - VM+JIT (fast path!): NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 ./target/release/nyash --backend vm examples/ny_bench_fixed.nyash
local ITER
ITER = 100000 // change for heavier runs
local timer
timer = new TimeBox()
print("\n=== Nyash Micro Benchmarks (ITER=" + ITER + ") ===")
// 1) Simple arithmetic loop: sum 0..ITER-1
local i, sum, ms, ops
i = 0
sum = 0
timer.reset()
loop(i < ITER) {
sum = sum + i
i = i + 1
}
ms = timer.elapsed()
ops = (ITER * 1000.0) / ms
print("[arith_loop] elapsed_ms=" + ms + ", ops/sec=" + ops)
// 2) Array push loop: push integers 0..ITER-1
local arr
arr = new ArrayBox()
i = 0
timer.reset()
loop(i < ITER) {
arr.push(i)
i = i + 1
}
ms = timer.elapsed()
ops = (ITER * 1000.0) / ms
print("[array_push] elapsed_ms=" + ms + ", ops/sec=" + ops)
// 3) Mixed arithmetic: simple_add repeated
local a, b, z
a = 1
b = 2
i = 0
timer.reset()
loop(i < ITER) {
z = a + b
a = a + 1
b = b + 1
i = i + 1
}
ms = timer.elapsed()
ops = (ITER * 1000.0) / ms
print("[simple_add_loop] elapsed_ms=" + ms + ", ops/sec=" + ops)
print("\nDone.")
return 0

View File

@ -0,0 +1,46 @@
// Nyash simple benchmarks - just measure iterations without timer
// How to run:
// - Interpreter: ./target/release/nyash examples/ny_bench_simple.nyash
// - VM: ./target/release/nyash --backend vm examples/ny_bench_simple.nyash
// - VM+JIT (fast path!): NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 ./target/release/nyash --backend vm examples/ny_bench_simple.nyash
local ITER
ITER = 100000 // change for heavier runs
print("\n=== Nyash Simple Benchmarks (ITER=" + ITER + ") ===")
// 1) Simple arithmetic loop: sum 0..ITER-1
local i, sum
i = 0
sum = 0
loop(i < ITER) {
sum = sum + i
i = i + 1
}
print("[arith_loop] sum = " + sum)
// 2) Array push loop: push integers 0..ITER-1
local arr
arr = new ArrayBox()
i = 0
loop(i < ITER) {
arr.push(i)
i = i + 1
}
print("[array_push] length = " + arr.length())
// 3) Mixed arithmetic: simple_add repeated
local a, b, z
a = 1
b = 2
i = 0
loop(i < ITER) {
z = a + b
a = a + 1
b = b + 1
i = i + 1
}
print("[simple_add_loop] final z = " + z)
print("\nDone.")
return 0

View File

@ -0,0 +1,46 @@
// Nyash small benchmarks - reduced iterations for quick testing
// How to run:
// - Interpreter: ./target/release/nyash examples/ny_bench_small.nyash
// - VM: ./target/release/nyash --backend vm examples/ny_bench_small.nyash
// - VM+JIT (fast path!): NYASH_JIT_EXEC=1 NYASH_JIT_THRESHOLD=1 ./target/release/nyash --backend vm examples/ny_bench_small.nyash
local ITER
ITER = 1000 // reduced for interpreter testing
print("\n=== Nyash Small Benchmarks (ITER=" + ITER + ") ===")
// 1) Simple arithmetic loop: sum 0..ITER-1
local i, sum
i = 0
sum = 0
loop(i < ITER) {
sum = sum + i
i = i + 1
}
print("[arith_loop] sum = " + sum)
// 2) Array push loop: push integers 0..ITER-1
local arr
arr = new ArrayBox()
i = 0
loop(i < ITER) {
arr.push(i)
i = i + 1
}
print("[array_push] length = " + arr.length())
// 3) Mixed arithmetic: simple_add repeated
local a, b, z
a = 1
b = 2
i = 0
loop(i < ITER) {
z = a + b
a = a + 1
b = b + 1
i = i + 1
}
print("[simple_add_loop] final z = " + z)
print("\nDone.")
return 0

View File

@ -0,0 +1,12 @@
// Scheduler demo: produces multiple safepoints via loop
// Run with: NYASH_SCHED_DEMO=1 NYASH_SCHED_POLL_BUDGET=2 ./target/release/nyash --backend vm examples/scheduler_demo.nyash
local i
i = 0
loop(i < 5) {
print("tick " + i)
i = i + 1
}
print("done")