Skip to content

Codex/generic closures#2835

Open
sydow wants to merge 42 commits into
mainfrom
codex/generic-closures
Open

Codex/generic closures#2835
sydow wants to merge 42 commits into
mainfrom
codex/generic-closures

Conversation

@sydow
Copy link
Copy Markdown
Collaborator

@sydow sydow commented Jun 1, 2026

Experimental branch which aims at reducing C file size by generating fewer closure classes. Instead we define a small number of structs in base/builtin/closures.c (and .h). The effect is that the total size of C code in acton/dist/base/out/types/ has decreased from 4.08 MB to 3.24 MB; from 72339 lines till 55021, thus in both measures a decrease of ca 25%. The closures.c/h files are together ca 300 lines. Uncommon and/or complicated closures (e.g. with many properties) are treated as before.

Not intended for merge now. Depends on new-unbox. Initial golden tests will fail.

sydow added 30 commits May 29, 2026 16:14
…ll standard library files; all generated C files compile without errors. Some tests in test suite do not work.
sydow and others added 12 commits May 29, 2026 18:03
UnitTest.run_test discarded the test function's return value, so unit
test snapshot output was always None and mismatches went undetected.
Bounded ints/floats now use raw scalar representations; bigints stay
boxed with Number witnesses. Regenerated boxing and codegen goldens.
dotCast passed a substituted general type to matchTypes, collapsing an
abstract return tyvar (e.g. Number.real : () -> Real) to its unboxable
instantiation and emitting a raw-double cast on a vtable slot that
returns a boxed $WORD. Pass the uninstantiated general type so abstract
positions stay boxed. Restores test_complex.act since it now works again.
The generated __deserialize__ for unboxed int/float fields copied the
field into the temporary instead of the reverse, so the deserialized
value was discarded and the field was never restored. It also used
sizeof($WORD), which would overflow sub-64-bit fields.

Write the value back with memcpy(&self->i, &tmp, sizeof(self->i)),
matching the RTS's hand-written $val_deserialize usage and preserving
float bit patterns. Fixes corrupt resumed actor state, which surfaced
as "Error unpacking client message, msg is NULL" in the DB resume tests.

Regenerated the affected codegen goldens.
The methodCast change (d21aa73) casts method-table function pointers
to the table slot's ABI shape but did not refresh the codegen goldens.
Mechanical regeneration of ints/deact/lines; no compiler change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant