-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Move _ArrayEq, _ArrayPostblit and _ArrayDtor to druntime #8067
Conversation
See also #7765
I don't see why they can't be moved to object.d, and until I understand otherwise, I would prefer that be done instead of this PR.
I don't know, but it sure appears like it is. |
331bfd4
to
8938ea5
Compare
Thanks for your pull request, @wilzbach! 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 fetch digger
dub run digger -- build "master + dmd#8067" |
I wonder whether we can directly replace the calls, e.g. for diff --git a/src/dmd/dsymbolsem.d b/src/dmd/dsymbolsem.d
index 2db047e9c..aa2ad3a79 100644
--- a/src/dmd/dsymbolsem.d
+++ b/src/dmd/dsymbolsem.d
@@ -151,10 +151,11 @@ private extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope*
ex = new DotVarExp(loc, ex, sdv.postblit, false);
ex = new CallExp(loc, ex);
+ postblitCalls.push(new ExpStatement(loc, ex)); // combine in forward order
}
else
{
- // _ArrayPostblit((cast(S*)this.v.ptr)[0 .. n])
+ // (cast(S*)this.v.ptr)[0 .. n]
uinteger_t length = 1;
while (tv.ty == Tsarray)
@@ -179,9 +180,29 @@ private extern (C++) FuncDeclaration buildPostBlit(StructDeclaration sd, Scope*
// Prevent redundant bounds check
(cast(SliceExp)ex).upperIsInBounds = true;
(cast(SliceExp)ex).lowerIsLessThanUpper = true;
- ex = new CallExp(loc, new IdentifierExp(loc, Id._ArrayPostblit), ex);
+
+ /**
+ foreach (ref e; cast(S*)this.v.ptr)[0 .. n])
+ e.__xpostblit();
+ */
+ Parameters* params = new Parameters();
+ auto elIdent = Identifier.generateId("__e");
+ params.push(new Parameter(STC.ref_ | STC.const_, sdv.type, elIdent, null));
+
+ // foreach body
+ auto identPostblit = new IdentifierExp(loc, Id.__xpostblit);
+ Expression bodyEx = new IdentifierExp(loc, elIdent);
+ bodyEx = new DotExp(loc, bodyEx, identPostblit);
+ bodyEx = new CallExp(loc, bodyEx);
+ Statement body_ = new ExpStatement(loc, bodyEx);
+
+ Statement frs = new ForeachStatement(loc, TOK.foreach_, params, ex, body_, loc);
+ printf("ForeachStatement: %s\n", frs.toChars);
+ postblitCalls.push(frs);
+
}
- postblitCalls.push(new ExpStatement(loc, ex)); // combine in forward order
/* https://issues.dlang.org/show_bug.cgi?id=10972
* When the following field postblit calls fail, Though that segfaults for |
Update: scratch that, I got it to work. I must have done something wrong previously. How do we verify this before merging? Do we just merge druntime on faith first? |
In general, I would prefer if all rewrites/lowerings could be placed in the runtime when possible for the following reasons:
So, I would prefer trying to find ways to move feature implementations out of the compiler to the runtime rather than the other way around. |
Well, we could create a special branch at dmd and druntime, but while some CIs do checkout the respective branch for the repositories, I'm not sure whether all do (IIRC some still don't). |
This is congruent with item 4 in the Vision Statement:
|
So is everyone okay with moving this to druntime (see dlang/druntime#2147)? |
Ping! |
Needs rebasing. |
8938ea5
to
99069f8
Compare
Rebased. Though the druntime PR needs to be merged first. |
druntime PR has been merged. |
@@ -4823,7 +4823,7 @@ public: | |||
fd = (cast(VarExp)ecall).var.isFuncDeclaration(); | |||
assert(fd); | |||
|
|||
if (fd.ident == Id._ArrayPostblit || fd.ident == Id._ArrayDtor) |
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.
Do we actually need to special-case these?
This makes debugging DMD with simple source code easier as
-betterC
+ an emptyobject.d
actually don't add anything that hasn't been added by the user.Out of interest: what's the reason for these three declarations to be in the compiler?
Shouldn't it be part of
object.d
?Or is it just an historical artifact?