Skip to content

Add Collectable trait and make_collectable shim - #47

Merged
bors[bot] merged 2 commits into
softdevteam:masterfrom
jacob-hughes:make_collectable_intrinsic_shim
Feb 24, 2022
Merged

bors[bot] merged 2 commits into
softdevteam:masterfrom
jacob-hughes:make_collectable_intrinsic_shim

Conversation

@jacob-hughes

Copy link
Copy Markdown
Collaborator

This adds the necessary boilerplate trait and intrinsics for the GC to be able to remove finalizers on types marked NoFinalize. There are no tests for this as make_collectable is currently stubbed as todo!.

Values of types which implement the collectable trait can dynamically
change their heap allocation from non-GC'd to GC'd.
@ltratt

ltratt commented Feb 24, 2022

Copy link
Copy Markdown
Member

bors r+

@bors

bors Bot commented Feb 24, 2022

Copy link
Copy Markdown

Build failed:

@jacob-hughes

Copy link
Copy Markdown
Collaborator Author

bors try

@bors

bors Bot commented Feb 24, 2022

Copy link
Copy Markdown

try

Build failed:

@jacob-hughes

Copy link
Copy Markdown
Collaborator Author

bors try

@jacob-hughes

Copy link
Copy Markdown
Collaborator Author

bors try-

@jacob-hughes

Copy link
Copy Markdown
Collaborator Author

bors try

@bors

bors Bot commented Feb 24, 2022

Copy link
Copy Markdown

try

Build succeeded:

@jacob-hughes

Copy link
Copy Markdown
Collaborator Author

This can be squashed now.

@ltratt

ltratt commented Feb 24, 2022

Copy link
Copy Markdown
Member

Please squash.

If `T` is `NoFinalize`, `Gc<T>::new(value: T)` needs to be able to
switch any heap allocations which make up `value` to collectable.

It should do this by recursing through the component types of `T`
looking for fields/variants/indices etc which implement `Collectable`.
When it finds types which do, it should call
`Collectable::set_collectable()` on them. Recursing over types in this way
is not possible in standard Rust code, so it needs to be done as part of
a new intrinsic in rustc.

This introduces the boilerplate needed to setup that intrinsic, named
`make_collectable`.
@jacob-hughes
jacob-hughes force-pushed the make_collectable_intrinsic_shim branch from 6a92585 to 5483246 Compare February 24, 2022 16:38
@jacob-hughes

Copy link
Copy Markdown
Collaborator Author

Squashed

@ltratt

ltratt commented Feb 24, 2022

Copy link
Copy Markdown
Member

bors r+

@bors

bors Bot commented Feb 24, 2022

Copy link
Copy Markdown

Build failed:

@ltratt

ltratt commented Feb 24, 2022

Copy link
Copy Markdown
Member

bors r+

@bors

bors Bot commented Feb 24, 2022

Copy link
Copy Markdown

Build succeeded:

@bors
bors Bot merged commit 5ca4bd9 into softdevteam:master Feb 24, 2022
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.

2 participants