-
-
Notifications
You must be signed in to change notification settings - Fork 597
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
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
@@ -3576,6 +3577,8 @@ extern (C++) final class NewExp : Expression | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are previous lowerings going to be retroactively transplanted into a lowering field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the plan.
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 |
@@ -539,6 +539,8 @@ class NewExp final : public Expression | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't have this been a pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Fixed by #14872.
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 |
This PR makes the following changes:
_d_newclassT
todruntime.src.core.lifetime.d
new C()
to_d_newclassT!C()
lowering
member toNewExp
. This field stores the above lowering to be used by e2ir.d_d_newclass
hook because it's used byTypeInfo_Class.create()
_d_newclassT
hook to tests that redefine theobject
modulenew 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=gc
tests