Refactoring: Make dmd.root.file.File stateless#9728
Refactoring: Make dmd.root.file.File stateless#9728thewilsonator merged 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request and interest in making D better, @kinke! 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 fetch digger
dub run digger -- build "master + dmd#9728" |
5957af8 to
67a890d
Compare
|
@kinke is this good to go? |
|
Nope, not ready; e.g., the autotester suffers from the 2.079 DMD host compiler with its |
|
I'm surprised about the review action taken here - don't get me wrong, I appreciate it, just definitely not used to that level of detail. ;) This started out as a small refactoring to aid me in analysing the ownership of these buffers and how on earth the dtor using I don't have the energy for a proper refactoring - I think there should be no |
|
I think this conversation shows a bit of the downside of combining a bug fix with refactoring. They really should be separate ones. It's a little hard to see the bug fix in this refactoring. As for refactoring, I really wish to raise the bar on what is a good refactoring. I've written a bit of a manifesto on it #9511. I'm not singling you out, consider #9729 where I put @benjones through the wringer. There's a lot of technical debt in dmd, and I don't want to have to refactor the refactors, so they have to be the best we can do. It had better be good if it says "cleanup" in the title :-) |
b4003d4 to
7e2d995
Compare
|
Just to give input here -- note that this ICE is blocking an i386 snap package release for LDC 1.15.0, and this could mean that something is broken also for i386 DMD 2.085.1. Is there any chance of the fix making it into a DMD 2.085.2 (which would allow a corresponding LDC 1.15.1)? |
|
DMD got |
|
The trouble with this PR is it combined refactoring with the bug fix. They need to be SEPARATE PRs. The refactoring is what is delaying approving this. The bug fix itself is not controversial. Please, everyone, do not mix refactoring with bug fixes. |
Completely agree that refactoring and fixes should not be combined. Sorry if my feedback came over as pressure or impatience -- it was related purely to the target branch for the fix, to ensure we got it everywhere that was needed. But @kinke's response allays those concerns. |
|
I split off the fixes to #9771, targeting the |
|
You can make a stable -> master PR with this script |
8f959d1 to
e10113e
Compare
This avoids buffer ownership complications, as the file contents buffers now need to be managed by the callers of `File.read()`. A tiny new helper struct, FileBuffer, makes sure the buffer is free'd via RAII. File writing is simplified to passing a filename and data slice. No need to set up a File instance and its buffer (incl. ownership) anymore.
|
Reduced to just a squashed refactoring. Semaphore failure seems unrelated. |
comments addressed.
|
|
||
| import core.stdc.string : strcmp; | ||
| const(char)* name = this.name.toChars(); | ||
| if (strcmp(name, "__main.d") == 0) |
There was a problem hiding this comment.
REGRESSION, you can no longer have a module named __main.d in any project.
This also breaks gdc, where __main.d implementation is not embedded inside the compiler.
There was a problem hiding this comment.
You're saying gdc itself uses a file named __main.d, without any path? My goal here was to move the special files to one place, instead of handling __stdin.d here and setting up __main.d in mars.d (the only place where the file buffer was set manually from outside and then File.read() being a no-op).
There was a problem hiding this comment.
$ echo "import std.stdio; int main() { writeln(\"Hello\"); return 42; }" > __main.d
$ ./generated/linux/release/64/dmd __main.d -ofmain
$ ./main
$ echo $?
0
How exactly is this desirable behaviour?
IMO, root/file.d should just be a generic wrapper around a file, it should not have any compiler-specific logic embedded within.
There was a problem hiding this comment.
This applies to __stdin.d as well then.
In 2.086, __main.d was 'read' in mars.d, and __stdin.d in struct File. In dlang#9728, I moved both to File, and neglected that __main.d is only a special filename if the `-main` switch is used. Move these special cases to mars.d and fix the __main.d oversight.
In 2.086, __main.d was 'read' in mars.d, and __stdin.d in struct File. In dlang#9728, I moved both to File, and neglected that __main.d is only a special filename if the `-main` switch is used. Move these special cases to mars.d and fix the __main.d oversight.
In 2.086, __main.d was 'read' in mars.d, and __stdin.d in struct File. In dlang#9728, I moved both to File, and neglected that __main.d is only a special filename if the `-main` switch is used. Move these special cases to mars.d and fix the __main.d oversight.
In 2.086, __main.d was 'read' in mars.d, and __stdin.d in struct File. In dlang#9728, I moved both to File, and neglected that __main.d is only a special filename if the `-main` switch is used. Move these special cases to mars.d and fix the __main.d oversight.
In 2.086, __main.d was 'read' in mars.d, and __stdin.d in struct File. In dlang#9728, I moved both to File, and neglected that __main.d is only a special filename if the `-main` switch is used. Move these special cases to mars.d and fix the __main.d oversight.
[I had to look into this, as we get an ICE with
-lowmemon Linux/i386, a segfault originating from aFiledtor.]