Commit 55c3f365
55c3f365d345Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 5 files · ~5 modified
Description
compiler: convert the ffi_func registry from parallel arrays to an FfiFunc struct
The ffi_func declaration registry was a struct-of-arrays: five parallel arrays
(mods/names/ret/args/nargs) grown in lockstep with five reallocs, indexed as
ffi_func_names[i] at ~22 sites. Adding a field meant touching the struct, the
grow block, and every access. Fold them into a single FfiFunc struct array:
the grow is one realloc, accesses read ffi_funcs[i].name, and a new field is one
struct member.
First of the six FFI registries (const/buf/reader/lib/cflag to follow). Pure internal refactor -- generated C is byte-for-byte identical across optcarrot, all benchmark/test inputs, and the FFI test programs.
Gates: 950 tests pass, optcarrot checksum 59662.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 55c3f365d345
- Parent
- e711be5c57f0
src/analyze_infer.cmodifiedView file
rcmod = nt_str(nt, recv, "name"); if (rcmod) { int fi = ffi_find_func(c, rcmod, name); if (fi >= 0) return ffi_spec_to_ty(c->ffi_func_ret[fi]); if (fi >= 0) return ffi_spec_to_ty(c->ffi_funcs[fi].ret); /* ffi_buffer: Module.buf_name returns the static char* (ptr type -> TY_POLY) */ if (ffi_find_buf(c, rcmod, name) >= 0) return TY_POLY; /* ffi_read_*: Module.reader_name(buf) returns int or ptr */src/analyze_scope.cmodifiedView file
Loading diff…
src/codegen.cmodifiedView file
Loading diff…
src/codegen_call.cmodifiedView file
Loading diff…
src/compiler.hmodifiedView file
Loading diff…