Translate _d_newclass to a template#14837
Conversation
|
Thanks for your pull request, @teodutu! 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#14837" |
4a44315 to
b56560c
Compare
|
|
b56560c to
60fbea0
Compare
| bool onstack; // allocate on stack | ||
| bool thrownew; // this NewExp is the expression of a ThrowStatement | ||
|
|
||
| Expression lowering; // lowered druntime hook: `_d_newclass` |
There was a problem hiding this comment.
Is this necessary? If yes keep it but keep an eye on adding unnecessary fields as dmd's classes are absolutely enormous
There was a problem hiding this comment.
I think it's necessary. I need an expression where to store the lowering, so I can then pass it to the backend in e2ir.d. This expression can either be a field in NewExp or the result set by visit(NewExp) (instead of the original expression) in expressionsemantic.d. The latter option is difficult because it requires me to initialise the context pointer in the semantic phase. I tried doing this in the past and it's ugly. I'd rather use the existing machinery that handles context pointers in e2ir.d instead. Furthermore, I received feedback from @ibuclaw in the past that eliding the original expressions might hinder some optimisations in GDC and LDC.
RazvanN7
left a comment
There was a problem hiding this comment.
Why aren't we deleting the old hook?
60fbea0 to
91cd038
Compare
Because it's used by |
|
Can't we just call the template? |
Maybe, but for this, we would need the actual type to be available at compile time. We can obtain it from |
08a5136 to
de58969
Compare
| const rtl = RTLSYM.NEWCLASS; | ||
| ex = el_bin(OPcall,TYnptr,el_var(getRtlsym(rtl)),el_ptr(csym)); | ||
| toTraceGC(irs, ex, ne.loc); | ||
| ex = toElem(ne.lowering, irs); |
There was a problem hiding this comment.
Are previous lowerings going to be retroactively transplanted into a lowering field?
e1f1ebc to
0af6853
Compare
|
@thewilsonator why have you removed the |
|
It has been addressed. |
|
@ibuclaw is this ready to go? |
|
@thewilsonator @ibuclaw re-adding the |
This makes the following changes: - Add template `_d_newclassT` to `druntime.src.core.lifetime.d` - Replace lowering of `new C()` to `_d_newclassT!C()` - Add `lowering` member to `NewExp`. This field stores the above lowering to be used by e2ir.d - Keep the old `_d_newclass` hook because it's used by `TypeInfo_Class.create()` - Add dummy `_d_newclassT` hook to tests that redefine the `object` module - Remove `new MinHeap!(TestType)()` from `fail308.d`. Otherwise the errror was changed and printed the local path to druntime - Move `err` to global scope in rt.sections.d to avoid the frontend lowering - Account for the `GC.malloc()` called by the template hook in the `-profile=gc` tests Signed-off-by: Teodor Dutu <teodor.dutu@gmail.com>
0af6853 to
48eacda
Compare
|
This changes how COM classes are managed - the memory will now be allocated by the GC whereas currently |
Good catch. The linkage reported for a class is derived from its member
IMO GC memory is the right choice, but adding/removing roots should be done in AddRef/Release. See https://issues.dlang.org/show_bug.cgi?id=4092 |
Scratch that, it returns D on my machine for both 32 and 64 bit builds. |
|
How are we supposed to test if a class is a COM class? See if it implements IUnknown? Is there an easier way? |
|
Can't you use |
|
This PR introduced a regression https://issues.dlang.org/show_bug.cgi?id=23688 |
| bool onstack; // allocate on stack | ||
| bool thrownew; // this NewExp is the expression of a ThrowStatement | ||
|
|
||
| Expression lowering; // lowered druntime hook: `_d_newclass` |
There was a problem hiding this comment.
Shouldn't have this been a pointer?
|
This PR caused a regression. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110113 I'm going to have to revert this PR if a proper fix doesn't come in a reasonable time-frame given the severity of it. |
|
Does it only trigger with dip1021?
…On Wed, 7 Jun 2023, 18:01 Iain Buclaw, ***@***.***> wrote:
This PR caused a regression.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110113
I'm going to have to revert this PR if a proper fix doesn't come in a
reasonable time-frame given the severity of it.
—
Reply to this email directly, view it on GitHub
<#14837 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABLI75BIM27AEIKVTJWJIF3XKCXWLANCNFSM6AAAAAAT7M52QY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
All that dip1021 is doing is making the compiler do a few more GC allocations/freeing by executing this code. https://github.com/dlang/dmd/blob/master/compiler/src/dmd/ob.d I think more likely, the trigger is Upstream bug report. https://issues.dlang.org/show_bug.cgi?id=23978 |
Pr dlang#14837 added templated lowering for _d_newclass and lowering field to NewExp. Pr dlang#13494 added templated lowering for _d_newThroable. This Pr merges those two. In expressionsem.d, instead of giving up the expression node and keeping just the id.expressionSemantic of it, the result is the whole node with all its previous fields and a new one, lowering, that is set to the previously returned value. In e2ir.d, for a newExpression, the expression is already created in the semantic phase with all the arguments needed, so the visitor will not recreate it, therefore the assert at line 1153 is no longer necessary. Signed-off-by: Andrei Rusanescu <andreirusanescu154@gmail.com>
Pr dlang#14837 added templated lowering for _d_newclass and lowering field to NewExp. Pr dlang#13494 added templated lowering for _d_newThroable. This Pr merges those two. In expressionsem.d, instead of giving up the expression node and keeping just the id.expressionSemantic of it, the result is the whole node with all its previous fields and a new one, lowering, that is set to the previously returned value. In e2ir.d, for a newExpression, the expression is already created in the semantic phase with all the arguments needed, so the visitor will not recreate it, therefore the assert at line 1153 is no longer necessary. Signed-off-by: Andrei Rusanescu <andreirusanescu154@gmail.com>
* Remove RTLSYM for Translation PR #15819: Removed NEWARRAYMITX, NEWARRAYMITX, TRACENEWARRAYMTX and TRACENEWARRAYMITX * Remove RTLSYM for Translation PR #15299: Removed NEWARRAYT, NEWARRAYIT, TRACENEWARRAYT and TRACENEWARRAYIT * Remove RTLSYM for Translation PR #14837: Removed NEWCLASS, TRACENEWCLASS * Remove RTLSYM for Translation PR #14664: Removed NEWITEMT, NEWITEMIT, TRACENEWITEMT and TRACENEWITEMIT * Remove RTLSYM for Translation PR #14550: Removed ARRAYCATNTX, ARRAYCATT, TRACEARRAYCATNTX and TRACEARRAYCATT * Remove RTLSYM for Translation PR #14382: Removed ARRAYSETASSIGN * Remove RTLSYM for Translation PR #14310: Removed ARRAYASSIGN * Remove RTLSYM for Translation PR #13495: Removed ARRAYAPPENDT, ARRAYAPPENDCTX, TRACEARRAYAPPENDT and TRACEARRAYAPPENDCTX
This PR makes the following changes:
_d_newclassTtodruntime.src.core.lifetime.dnew C()to_d_newclassT!C()loweringmember toNewExp. This field stores the above lowering to be used by e2ir.d_d_newclasshook because it's used byTypeInfo_Class.create()_d_newclassThook to tests that redefine theobjectmodulenew MinHeap!(TestType)()fromfail308.d. Otherwise the errror was changed and printed the local path to druntimeGC.malloc()called by the template hook in the-profile=gctests