Commit 4945891d
4945891d444fMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 7 months ago · 3 files · +1 added · ~2 modified
Description
feat: pidigits benchmark passes (bigint type inference + GC fix)
Bigint type inference:
- Expand loop multiplication detection: any x = ... * ... in while loop marks x as bigint candidate (not just x = x * y)
- This correctly detects nq = q * k, nr = (2*q+r) * b, nt = t * b
- Propagation then spreads bigint to q = nq, r = nr, t = nt
Bigint library:
- sp_gc_alloc made non-static when bigint is needed (extern visible)
- sp_bigint_alloc uses weak extern for GC integration
Build system:
- Makefile: build sp_bigint.o and link with test binaries
pidigits n=27: 0.002s, output matches Ruby exactly. 68 tests pass, bootstrap clean.
Co-Authored-By: Claude Opus 4.6 (1M context) [email protected]
Details
- Commit
- 4945891d444f
- Parent
- 1add49514304
MakefilemodifiedView file
@@ -79,13 +79,17 @@
7979
8080
# ---- Test ----8181
82-
test: spinel_parse spinel_codegen82+
build/sp_bigint.o: lib/sp_bigint.c lib/sp_bigint.h lib/mruby_shim.h83+
@mkdir -p build84+
$(CC) -c -O2 -Wno-all -Ilib lib/sp_bigint.c -o build/sp_bigint.o85+
86+
test: spinel_parse spinel_codegen build/sp_bigint.o8387
@pass=0; fail=0; err=0; \8488
for f in test/*.rb; do \8589
bn=$$(basename "$$f" .rb); \8690
./spinel_parse "$$f" /tmp/_sp_t.ast 2>/dev/null && \8791
./spinel_codegen /tmp/_sp_t.ast /tmp/_sp_t.c 2>/dev/null && \88-
$(CC) $(CFLAGS) /tmp/_sp_t.c -lm -o /tmp/_sp_t_bin 2>/dev/null; \92+
$(CC) $(CFLAGS) /tmp/_sp_t.c build/sp_bigint.o -lm -o /tmp/_sp_t_bin 2>/dev/null; \8993
if [ $$? -eq 0 ]; then \9094
expected=$$(timeout 10 ruby "$$f" 2>/dev/null); \9195
actual=$$(timeout 10 /tmp/_sp_t_bin 2>/dev/null); \spinel_codegen.rbmodifiedView file
Loading diff…
test/bm_pidigits.rbaddedView file
Loading diff…