Commit 70bd3a1d

70bd3a1d6e9dMerged

Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 2 files · ~2 modified

Description

feat: life benchmark codegen (range blocks, _N params, N.times.map)

Fixes Conway's Game of Life benchmark end-to-end. Changes:

  • Add compile_array_count_block helper via emit_iter_open so count { ... } works on range, int_array, sym_array, str_array.
  • Route sum { ... } and count { ... } through the method return path in compile_body_return so their values aren't discarded when they appear as a method's last expression.
  • Handle NumberedParametersNode (_1, _2) in scan_locals so block param locals are declared at function scope.
  • Handle N.times.map { ... } in both compile_map_expr and compile_map_block — emits a straight for loop with index assignment, building an IntArray/StrArray/FloatArray per block type.

Life: 22 ms Spinel vs 1,525 ms Ruby (69.3x). Bench: 53/54 pass (fizzbuzz remains the pre-existing failure).

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
70bd3a1d6e9d
Parent
15e17858ba56

README.mdmodifiedView file

@@ -78,7 +78,7 @@
7878
7979 ## Benchmarks
8080
81-75 tests pass. 52/54 benchmarks pass (2 pre-existing failures).
81+75 tests pass. 53/54 benchmarks pass (1 pre-existing failure).
8282 Geometric mean: **~49x faster** than CRuby across 50 benchmarks.
8383
8484 ### Computation
@@ -86,6 +86,7 @@
8686 | Benchmark | Spinel | CRuby | Speedup |
8787 |---|---|---|---|
8888 | ackermann | 5 ms | 394 ms | 78.8x |
89+| life (Conway's GoL) | 22 ms | 1,525 ms | 69.3x |
8990 | fib (recursive) | 11 ms | 560 ms | 50.9x |
9091 | mandelbrot | 24 ms | 1,187 ms | 49.5x |
9192 | matmul | 9 ms | 329 ms | 36.6x |