Skip to content

New unbox#2824

Merged
plajjan merged 43 commits into
mainfrom
new-unbox
Jun 4, 2026
Merged

New unbox#2824
plajjan merged 43 commits into
mainfrom
new-unbox

Conversation

@sydow
Copy link
Copy Markdown
Collaborator

@sydow sydow commented May 29, 2026

First version with total unbox of bounded ints and floats

Comment thread base/src/testing.act
Copy link
Copy Markdown
Contributor

@nordlander nordlander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! (The complexity of CodeGen had grown large long before this PR...)

@plajjan
Copy link
Copy Markdown
Contributor

plajjan commented Jun 3, 2026

FYI; I will take over this branch, rebase it etc - I noticed there are a few small mistakes, more technical in nature that I think come from rebasing issues or similar. I will clean up that as well as updating goldens etc to make sure the tests passes. Thanks for the fantastic work :) there will be downstream dependencies to be updated in all libraries that do C bindings basically - I will fix those too in time...

sydow added 27 commits June 3, 2026 22:17
…ll standard library files; all generated C files compile without errors. Some tests in test suite do not work.
sydow and others added 14 commits June 3, 2026 22:17
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.
genEnter/genDotCall now wrap the receiver in genReceiver, casting it to
its boxed type before ->$class. Fixes "member reference base type 'void'"
when the receiver is an untyped $WORD, e.g. a tuple component used as a
method receiver (pipes.client.write(...)).

Also refactors initClassBase's inherited-attribute casting to reuse
methodCast, and adds the indexedKWs helper.

Extracted from a combined commit; its unrelated build.zig std-option
change is dropped (that error was a build-state artifact, not needed).
Kristian Larsson added 2 commits June 4, 2026 10:11
The boxing pass can see zero-argument __bool__ calls on numeric values
whose receiver has already been lowered to an unboxed representation. The
generic method-call path leaves that as a Dot on a raw receiver, which
QuickType cannot schema and which caused http2.client to fail on an
UNBOXED u32 receiver.

Handle that case during boxing by lowering numeric truthiness directly to
a raw nonzero comparison. The comparison stays in the unboxed
representation, and only the resulting Acton bool is boxed for the
surrounding expression.
The std copy of math still used the older RealFuns witness wrapper while
base had moved to direct float functions. That left std.math out of step
with the unboxed math ABI used on this branch.

Copy the simplified math.act shape from base and keep only the std module
symbol prefix in math.ext.c. The exported C functions now use raw double
arguments and results like the base module.
@plajjan plajjan merged commit bdaff40 into main Jun 4, 2026
442 of 495 checks passed
@plajjan plajjan deleted the new-unbox branch June 4, 2026 13:16
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.

4 participants