Commit 86828e88

86828e88be37Merged

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

Description

compiler: convert the remaining five FFI registries to struct arrays

Follow-up to the ffi_func conversion: fold the const/buffer/reader/lib/cflag registries from parallel arrays into FfiConst/FfiBuf/FfiReader/FfiLib/FfiCflag struct arrays. Each grow site drops from N lockstep reallocs to one, and a new field on any registry is now a single struct member instead of a parallel array threaded through the struct, the grow block, and every access.

All six FFI registries are now arrays-of-structs. 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
86828e88be37
Parent
55c3f365d345

src/analyze_infer.cmodifiedView file

@@ -617,7 +617,7 @@
617617 /* ffi_read_*: Module.reader_name(buf) returns int or ptr */
618618 int ri = ffi_find_reader(c, rcmod, name);
619619 if (ri >= 0) {
620- const char *kind = c->ffi_reader_kinds[ri];
620+ const char *kind = c->ffi_readers[ri].kind;
621621 if (kind && !strcmp(kind, "ptr")) return TY_POLY;
622622 return TY_INT;
623623 }
@@ -2471,8 +2471,8 @@
24712471 /* FFI const: Module::NAME -> int */
24722472 if (par_nm && nm) {
24732473 for (int fci = 0; fci < c->n_ffi_consts; fci++) {
2474- if (!strcmp(c->ffi_const_mods[fci], par_nm) &&
2475- !strcmp(c->ffi_const_names[fci], nm))
2474+ if (!strcmp(c->ffi_consts[fci].mod, par_nm) &&
2475+ !strcmp(c->ffi_consts[fci].name, nm))
24762476 return TY_INT;
24772477 }
24782478 }