Skip to content

Templatize _d_arraysetcapacity hook#21143

Merged
thewilsonator merged 22 commits into
dlang:masterfrom
Albert24GG:arraysetcapacity-hook-template
Apr 15, 2025
Merged

Templatize _d_arraysetcapacity hook#21143
thewilsonator merged 22 commits into
dlang:masterfrom
Albert24GG:arraysetcapacity-hook-template

Conversation

@Albert24GG
Copy link
Copy Markdown
Contributor

This replaces the _d_arraysetcapacity runtime hook from rt/lifetime.d with a templated version, now located in core/internal/array/capacity.d.

All the TypeInfo instances have been eliminated, except for the one pass as an argument to GC.malloc.

The only walkaround that I needed to do is to use a "fake" pure & nothrow wrapper over the templated hook, since the reserve and capacity functions both are pure & nothrow, but the __doPostblit function can sometimes invoke impure postblits, depending on the type T passed. If you have any suggestions regarding this issue, please let me know!

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @Albert24GG! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#21143"

Comment thread druntime/src/core/internal/array/capacity.d Outdated
Copy link
Copy Markdown
Member

@teodutu teodutu left a comment

Choose a reason for hiding this comment

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

Nice work overall! The failing tests seem unrelated to your work: a timeout and two file-related errors.

Comment thread druntime/src/core/internal/array/capacity.d Outdated
Comment thread druntime/src/core/internal/array/capacity.d Outdated
Comment thread druntime/src/core/internal/array/capacity.d Outdated
Comment thread druntime/src/core/internal/array/capacity.d Outdated
Comment thread druntime/src/core/internal/array/capacity.d Outdated
The previous implementation included a more convoluted way of achieving
the same goal. `is(typeof(arr[0].__xpostblit()))` was replaced by
`__traits(compiles, arr[0].__xpostblit)` and `is(immutable T == immutable
U, U)` with `alias Unqual_T = Unqual!T`
Copy link
Copy Markdown
Member

@teodutu teodutu left a comment

Choose a reason for hiding this comment

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

I only made some spacing suggestions. Otherwise this looks good. Thanks!

Comment thread druntime/src/core/internal/lifetime.d Outdated
Comment thread druntime/src/core/internal/array/capacity.d
@Albert24GG Albert24GG marked this pull request as ready for review April 5, 2025 11:55
Comment thread druntime/src/core/internal/array/capacity.d Outdated
@thewilsonator
Copy link
Copy Markdown
Contributor

@teodutu let me know when this is good to go

@teodutu
Copy link
Copy Markdown
Member

teodutu commented Apr 12, 2025

@teodutu let me know when this is good to go

It's OK now. The tests are failing because installing the host DMD returns 403, which is unrelated.

@Albert24GG Albert24GG marked this pull request as draft April 13, 2025 16:15
@Albert24GG Albert24GG requested a review from teodutu April 14, 2025 22:08
@Albert24GG Albert24GG marked this pull request as ready for review April 14, 2025 22:08
Copy link
Copy Markdown
Member

@teodutu teodutu left a comment

Choose a reason for hiding this comment

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

All good from me.

@thewilsonator thewilsonator merged commit 03c8f27 into dlang:master Apr 15, 2025
38 of 42 checks passed
@teodutu
Copy link
Copy Markdown
Member

teodutu commented May 1, 2025

@Albert24GG see this comment and create a PR with a changelog entry for this hook as well. Let's keep this in mind for the future.

[1] #21151 (comment)

@CyberShadow
Copy link
Copy Markdown
Member

This pull request introduced a regression:
#23102

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.

6 participants