-
-
Couldn't load subscription status.
- Fork 655
convert vec.c to dvec.d #8257
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
convert vec.c to dvec.d #8257
Conversation
|
Thanks for your pull request, @WalterBright! 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#8257" |
| * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/dvec.d, backend/dvec.d) | ||
| */ | ||
|
|
||
|
|
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.
Should there be a module declaration?
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.
The module name defaults to the file name.
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 know that but all other D files in DMD has a module declaration.
src/dmd/backend/dvec.d
Outdated
|
|
||
| static assert(vec_base_t.sizeof==2 && VECSHIFT==4 || | ||
| vec_base_t.sizeof==4 && VECSHIFT==5 || | ||
| vec_base_t.sizeof==8 && VECSHIFT==6); |
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.
Would be nice with a space around the operators.
src/dmd/backend/dvec.d
Outdated
| void vec_set(vec_t v) | ||
| { | ||
| if (v) | ||
| { memset(v, ~0, v[0].sizeof * vec_dim(v)); |
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.
Braces on their own lines.
|
The Visual Studio project file is not updated. |
c0f5172 to
bba39f1
Compare
|
Regarding the Jenkins failure - the Ocean failure is unrelated. |
| * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/backend/dvec.d, backend/dvec.d) | ||
| */ | ||
|
|
||
| module dvec; |
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.
Should be module dmd.backend.dvec, otherwise separate compilation fails.
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.
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 haven't yet heard a convincing reason why dmc and dmd should not share a common directory structure, e.g. use module name tk.dvec and put it into the respective folder. Not using package names is unlikely to be a good idea for shared modules.
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.
The reason is:
- It's a lot of nuisance work for me to crowbar dmc into a totally different directory structure - messing up the git history, changing all the imports, etc.
- I'm the one doing the work, and this is the way I want to do the work, because mashing it into multiple directories is unproductive for me.
- All the blocking items for making this work are inconsequential and do not negatively impact anything else.
- All the blocking items are things we need to do anyway (like support the -mv command). I can hardly be the only one who wants to share the same modules among multiple projects.
- assert() support in 2.068 is so heavy it is disabled in dmd, with various negative consequences that show up now and then. The back end relies heavily on asserts being ON. 2.079 has much better support for lightweight assert().
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 cannot make this work for both dmc and dmd, because they use separate directory structures.
As I mentioned before, this isn't necessarily an issue. If you really can't be bothered [1] to choose a standard directory structure, just keeping them in the top-level package like this is fine (as long as it is actually used as import dvec;).
All the blocking items for making this work are inconsequential and do not negatively impact anything else.
If one were to e.g. regard -betterC as a badly designed command line switch, then supporting it does negatively impact e.g. GDC, as it adds complexity that can't easily be gotten rid of again.
All the blocking items are things we need to do anyway (like support the -mv command). I can hardly be the only one who wants to share the same modules among multiple projects.
People usually prefer to use non-surprising directory structures for this.
assert() support in 2.068 is so heavy it is disabled in dmd, with various negative consequences that show up now and then. The back end relies heavily on asserts being ON. 2.079 has much better support for lightweight assert().
Just replace assert() by a custom template then. Trivial to do during the translation.
[1] Note that moving src/{ddmd -> dmd} came with many more issues (src/dmd being used by the executable, files also used from GDC/LDC), yet you were happy to agree to that.
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 could have had the back end converted a year ago. Instead I spend time on this back and forth over a trivial blocker.
You keep repeating this claim, yet all these "blockers" are trivially worked around. If you were really interested in converting the backend, you could have done just that a year ago. Your earlier statement applies verbatim: "It's also TRIVIAL. I simply cannot understand the resistance to it."
As I've pointed out elsewhere, I believe the only such workaround that would require code changes is that to support "release asserts". Any time you might need to spend writing a sed script/… to convert those assert calls to a custom function is entirely dwarfed by the time it takes to do the conversion itself, or indeed the required changes to all the various build systems that go with it.
So, can we please stop pretending that "I need it to convert the backend to D" is a valid argument in favour of bumping the bootstrap compiler version requirement? If you'd like to change the version requirements to make your life easier, I'm not sure why you would need to make up bogus reasons to ask for that. Your word still carries weight here.
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.
sed scripts
Adding more technical debt is to be avoided, not embraced. Never mind that sed isn't a standard tool on Windows, so I'd have to write a program to do that, and check it into the repositories. I know what I think when I see such things in other projects.
trivial
Yes, I could write a script to copy directory structures around before each compile. Is that something you'd want to do for your project? I prefer to avoid rube goldberg build setups. (Heaven knows the build system is fragile enough as it is.)
pretending
I'm used to doing ugly things to get things to work when I have no choice. I've even resorted to writing programs to patch object files. But there's no reason to do that here. The advantage to owning the tool chain is the fix can be put in the right spot.
Your word still carries weight here.
Then please pull the blocking PRs.
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.
sed scripts
Adding more technical debt is to be avoided, not embraced. Never mind that sed isn't a standard tool on Windows
Replacing assert with my_assert is a one-time thing, to be done along with many other mechanical changes during the C -> D conversion.
trivial
Yes, I could write a script to copy directory structures around before each compile.
No need for that, as explained before. Just keep the backend modules in the root package (as in this PR) if you don't want to deal with directories. That's possibly not the prettiest thing to do, but then you are the one who is arguing for a flat structure.
I'm used to doing ugly things to get things to work when I have no choice.
Imho both -betterC and -mv are such ugly things, but that's somewhat besides the point here. What even are the ugly things that you would need to accept in order to use an old D version?
Naming a non-standard assert something different isn't really one, at least in my opinion. A different name can be gainfully employed to highlight (and explain via a DDoc comment) the special requirements for backend use (small code/always enabled/…).
Then please pull the blocking PRs.
One is failing, and @kinke seems to have a valid suggestion for the other one.
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 had my own non-standard assert for years in the back end. I finally removed it along with a lot of other garbage I used to think was a good idea.
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.
One is failing,
Because it's blocked by the other.
and @kinke seems to have a valid suggestion for the other one.
Regardless of the merit of his suggestion, it requires delaying for multiple release cycles.
| @@ -1,446 +1,443 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
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.
This is probably converting CRLF to LF. This should not happen for the VC project files.
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.
Changed it back to CRLF.
|
Is there a reason for changing the name from |
| else | ||
| { | ||
| v = cast(vec_t) calloc(dim + 2, vec_base_t.sizeof); | ||
| assert(v); |
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.
This should better be reporting "out of memory", the backend uses err_nomem() for this.
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.
It uses the assert because the file is supposed to be independent of any other project modules. The C++ version it was translated from did this, too.
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.
The C++ version uses mem_calloc/mem_exception from mem.c.
assert(v) has the problem that it is likely to go away in a release build, so if you want no dependencies I'd recommend if (!v) assert(false, "out of memory").
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.
See my other comment about why assert not being disabled is required in the back end.
| else | ||
| { | ||
| vc = cast(vec_t) calloc(nbytes, 1); | ||
| assert(vc); |
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.
Same here.
Otherwise, translation looks good.
| /** | ||
| * Compiler implementation of the | ||
| * $(LINK2 http://www.dlang.org, D programming language). | ||
| * |
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 suggest adding a description of the module. I have no idea what the code in this file does. Also, a more descriptive file name wouldn't hurt
0d6decd to
f313eee
Compare
|
@CyberShadow can you please upgrade the boot compiler on CyberShadow/DAutoTest to 2.079 so this passes? |
|
Done, should take effect on the next rebuild. |
|
@CyberShadow thanks! It's working now, ready to pull! |
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.
There are a lot of valid concerns voiced in the review of this PR, but Walter has addressed most of it and made his decision. I think it's time to move on; some things can even be addressed after the conversion to D.
|
This PR broke my local dmd build, which bootstraps with 2.069: Checking out the revision before this PR was merged fixes the problem. |
|
You'll need to upgrade your boot compiler. |
No description provided.