-
Notifications
You must be signed in to change notification settings - Fork 8
feat!: Improved array lowering #2109
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
Draft
mark-koch
wants to merge
7
commits into
release-rs-v0.16.0
Choose a base branch
from
feat/arrays
base: release-rs-v0.16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* The old `array` type is now called `value_array` and lives in a separate extension * The default `array` is now a linear type. Additional `clone` and `discard` operations follow in a separate PR * To avoid code duplication, array operations and values are now defined generically over a new `ArrayKind` trait that is instantiated with `Array` (the linear one) and `VArray` (the copyable one) to generate the `array` and `value_array` extensions Closes #2066 BREAKING CHANGE: `std.collections.array` is now a linear type, even if the contained elements are copyable. Use the new `std.collections.value_array` for an array with the previous copyable semantics.
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-rs-v0.16.0 #2109 +/- ##
======================================================
- Coverage 83.49% 83.38% -0.11%
======================================================
Files 219 225 +6
Lines 42188 42335 +147
Branches 38290 38388 +98
======================================================
+ Hits 35225 35303 +78
- Misses 5150 5215 +65
- Partials 1813 1817 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Since the array type is now linear following #2097, we need to change the signature of the `array.get` op to give the passed array back to the user. BREAKING CHANGE: `std.collections.array.get` now also returns the passed array as an extra output
Closes #2067 An `array<n, T>` is now lowered to a struct `{ptr, usize}` where `ptr` is a heap allocated pointer of size at least `n * sizeof(T)` and the `usize` is an offset pointing to the first element (i.e. the first element is at `ptr + offset * sizeof(T)`). The rational behind the additional offset is the `pop_left` operation which bumps the offset instead of mutating the pointer. This way, we can still free the original pointer when the array is discarded after a pop. BREAKING CHANGE: Removed old lowering for value arrays
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature branch for improved array lowering.
array
type is now calledvalue_array
and lives in a separate extensionarray
is now a linear type with additionalclone
anddiscard
operationsArrayKind
trait that is instantiated withArray
(the linear one) andVArray
(the copyable one) to generate thearray
andvalue_array
extensionsarray<n, T>
is now lowered to a fat pointer{ptr, usize}
whereptr
is a heap allocated pointer of size at leastn * sizeof(T)
and theusize
is an offset pointing to the first element (i.e. the first element is atptr + offset * sizeof(T)
). The rational behind the additional offset is thepop_left
operation which bumps the offset instead of mutating the pointer. This way, we can still free the original pointer when the array is discarded after a pop.Tracked PRs:
array.get
give back the passed array #2110BREAKING CHANGE:
std.collections.array
is now a linear type, even if the contained elements are copyable. Use the newstd.collections.value_array
for an array with the previous copyable semantics.BREAKING CHANGE:
std.collections.array.get
now also returns the passed array as an extra output