Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to support garbage collected arrays/vectors #29

Merged
merged 10 commits into from
Jul 6, 2021

Conversation

Techcable
Copy link
Member

This crashes even the most basic tests :(
Everything is broken.

I feel like I need to clean up the allocator interface even more.

NOTE: This supersedes #20

This crashes even the most basic tests :(
Everything is broken.

I feel like I need to cleanup.
@Techcable Techcable added the impl-simple The simple mark/sweep collector (our first one :D) label Jul 4, 2021
@Techcable Techcable added this to the 0.2.0 milestone Jul 4, 2021
@Techcable Techcable self-assigned this Jul 4, 2021
@Techcable Techcable linked an issue Jul 4, 2021 that may be closed by this pull request
@andersk
Copy link

andersk commented Jul 4, 2021

Although this is marked as superseding #20, it won’t fix #15 (support garbage collected trait objects).

Using the small-object-arenas allocator still causes
a SEGFAULT unfortunately.
However, I've made significant progress ;)
As of now, the 'array' tests pass.

Add cfg!(zerogc_simple_debug_alloc) which adds internal padding bytes.
This was very helpful in finding this bug ;)
They should suppress the generation of implicit where bounds
They are unsafe, because GcVec has an explicit reference
to the owning context, which cant be meaningfully erased.

Add GcVec::extend_from_slice
Mostly a copy of the "arrays" test.
It's even in the same file.
Dangling pointers don't have a valid `GcVecHeader`,
so its not possible to fetch the length/capacity.

The allocated vector is a singleton (assuming proper alignment),
so we still wont waste much memory.
Also remove the Drop impl from GcRawVec.
Dropping is the responsibility of the underlying RawVecRepr.
We were including the header in the 'value_layout',
which should only be the array value....
If we want to keep using it, we need the garbage
collector to preserve it....

Fix GcVec::extend_from_slice to correctly do set_len
@Techcable Techcable marked this pull request as ready for review July 6, 2021 05:45
@Techcable
Copy link
Member Author

You are right @andersk . I'll put that next on my TODO list :)

@Techcable Techcable merged commit 3ec6bd8 into master Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impl-simple The simple mark/sweep collector (our first one :D)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support arrays of GC-allocated objects
2 participants