Refactored arraysetlengthT and arraysetlengthiT into a Single arraysetlengthT Template #21151
Conversation
|
Thanks for your pull request and interest in making D better, @shivangshukla7020! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
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 referencesYour 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 locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#21151" |
teodutu
left a comment
There was a problem hiding this comment.
Overall this is looking good. I made some small suggestions.
e8265b8 to
d1bc7e6
Compare
09df08b to
0e0cd9c
Compare
30a3d1b to
2ab5424
Compare
f329524 to
136317e
Compare
teodutu
left a comment
There was a problem hiding this comment.
The compiler code looks OK, but the runtime checks for __traits(compiles might be superfluous.
30d42ab to
94d9c90
Compare
teodutu
left a comment
There was a problem hiding this comment.
It's looking good now. Since you have 73 commits here, it would be easier for eventual regressions to squash them into a single one before merging.
|
Plese rebase and resolve the merge conflicts |
8102985 to
00cd468
Compare
00cd468 to
6b0463c
Compare
Done |
|
runtime hook change should probably require a change log entry |
Oh yeah you're right, I forgot to mention this. @shivangshukla7020 please raise another PR where you add a file to this folder (check those already existing for formatting): https://github.com/dlang/dmd/tree/master/changelog |
|
Okay, I'll update and add the changelog accordingly |
|
This pull request introduced a regression: #21832 |
|
This PR caused a build regression |
| ubyte overflow = 0; | ||
|
|
||
| size_t newsize = void; | ||
|
|
||
| version (D_InlineAsm_X86) | ||
| { | ||
| asm pure nothrow @nogc | ||
| { | ||
| mov EAX, sizeelem; | ||
| mul newlength; // EDX:EAX = EAX * newlength | ||
| mov newsize, EAX; | ||
| setc overflow; | ||
| } | ||
| } | ||
| else version (D_InlineAsm_X86_64) | ||
| { | ||
| asm pure nothrow @nogc | ||
| { | ||
| auto ti = typeid(Tarr); | ||
| mov RAX, sizeelem; | ||
| mul newlength; // RDX:RAX = RAX * newlength | ||
| mov newsize, RAX; | ||
| setc overflow; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| newsize = mulu(sizeelem, newlength, overflow); | ||
| } |
There was a problem hiding this comment.
... here, overflow has wrong type.
Changes Introduced
This PR merges
arraysetlengthTandarraysetlengthiTinto a single template, improving compile-time specialization and reducing redundancy. The key updates include:arraysetlengthTandarraysetlengthiTinto a single template, distinguishing them based on initialization behavior.arraysetlengthT) and non-zero-initialized (arraysetlengthiT) cases.emplacefor non-trivial types instead ofmemcpyto ensure correct postblit behavior.gc_expandArrayUsedfor in-place array expansion where applicable.D_ProfileGCsupport via_d_HookTraceImpl.This refactoring improves performance by removing
TypeInfolookups and enabling better compile-time specialization.