Skip to content

reimplement std.traits.ParameterStorageClassTuple()#5626

Merged
dlang-bot merged 4 commits intodlang:masterfrom
rainers:retry_ParameterStorageClassTuple
Jul 19, 2017
Merged

reimplement std.traits.ParameterStorageClassTuple()#5626
dlang-bot merged 4 commits intodlang:masterfrom
rainers:retry_ParameterStorageClassTuple

Conversation

@rainers
Copy link
Member

@rainers rainers commented Jul 18, 2017

reboot #5427 by @WalterBright as it is required for the new mangling in dlang/dmd#6998

Maybe something else changes, but locally I cannot reproduce an error with toDelegate!(void function(FreeListRef!(shared(int), true), int delegate(int, int) pure nothrow @nogc @safe, int, int) nothrow @nogc @system) as in the previous attempts build logs.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @rainers!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@wilzbach
Copy link
Contributor

Maybe something else changes,

The project tester now tests the new v0.8.0 vibe.d release, we should test this with v0.7.31, but otherwise this is great :)

std/traits.d Outdated
ParameterStorageClass extractParameterStorageClassFlags(Attribs...)()
{
auto result = ParameterStorageClass.none;
foreach (attrib; Attribs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use [Attribs]!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it disables the loop-unrolling.
currently the switch will be duplicated Attribs.length times.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I need to reclarify - why is this a bad thing? Isn't this even faster due to the saved conditional jump and better pipelining?

Copy link
Member

@UplinkCoder UplinkCoder Jul 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is always executed at ctfe.
at ctfe it's strictly the less instructions you have, the better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brackets don't work, I get errors building the unittests:

std\traits.d(1092): Error: variable std.traits.extractParameterStorageClassFlags!().extractParameterStorageClassFlags.attrib variables cannot be of type void
std\traits.d(1092): Error: expression __r3585[__key3586] is void and has no value
std\traits.d(1058): Error: template instance std.traits.ParameterStorageClassTuple!(inout Inner(inout(Inner))).StorageClass!0LU error instantiating
std\traits.d(635):        instantiated from here: ParameterStorageClassTuple!(inout Inner(inout(Inner)))
std\traits.d(792):        instantiated from here: parametersTypeString!(inout Inner(inout(Inner)))
std\traits.d(472):        instantiated from here: fqnType!(inout Inner(inout(Inner)), false, false, false, false)
std\traits.d(860):        instantiated from here: fqn!(inout Inner(inout(Inner)))
std\traits.d(860):        while evaluating: static assert(fqn!(inout Inner(inout(Inner))) == format("inout(%s(inout(%s)))", "std.t
raits.QualifiedNameTests.Inner", "std.traits.QualifiedNameTests.Inner"))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put a static if (Attribs.length) if front of the foreach
then brackets should work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it works with static if (Attribs.length). Updated.

@wilzbach
Copy link
Contributor

we should test this with v0.7.31,

Tested. Builds fine.

std/traits.d Outdated
Params:
func = function symbol or type of function, delegate, or pointer to function
Returns:
a tuple of ParameterStorageClass bits
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Common style is to start with upper case here (it's not enforced yet).

@rainers
Copy link
Member Author

rainers commented Jul 18, 2017

Tested. Builds fine.

Thanks.

Nit: Common style is to start with upper case here (it's not enforced yet).

Updated. BTW: there is a "little demangler" at the top of the file that seems unused now. Should we ditch it?

@wilzbach
Copy link
Contributor

BTW: there is a "little demangler" at the top of the file that seems unused now. Should we ditch it?

I think so, but let's better do this in a different PR. I'm impatient as well and I want to see your great work merged rather sooner than later! It's been in the queue way too long.

@rainers
Copy link
Member Author

rainers commented Jul 18, 2017

but let's better do this in a different PR.

I was already removing it when having the same thought ;-)

Copy link
Member

@UplinkCoder UplinkCoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me like!

std/traits.d Outdated
* Returns:
* ParameterStorageClass bits
*/
ParameterStorageClass extractParameterStorageClassFlags(Attribs...)()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transform this into template extractParameterStorageClassFlags(Attribs...)

enum extractParameterStorageClassFlags = () {
// the old function body
} ();

this will force the template to resolve to literal rather then a symbol.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Interesting trick to avoid generating code into the object file for functions only executed at compile time. This should also avoid the coverage tests complaining.

@rainers
Copy link
Member Author

rainers commented Jul 19, 2017

@CyberShadow I suspect you are aware of this, but just in case: the documentation tester currently seems to complain about "Pull request SHA mismatch" on every phobos pull request I looked at. Anything we need to fix?

@CyberShadow
Copy link
Member

@rainers Yes, please see here and here. GitHub support has been notified and is looking into it.

@wilzbach
Copy link
Contributor

Merging this now as it has been approved before.

@wilzbach wilzbach closed this Jul 19, 2017
@wilzbach wilzbach reopened this Jul 19, 2017
@wilzbach
Copy link
Contributor

Merging this now as it has been approved before.

Due to our current CI problem here, I will create a new PR to be sure that there aren't any new failures popping up in Jenkins.

@wilzbach
Copy link
Contributor

wilzbach commented Jul 19, 2017

Okay sorry - seems that didn't help:

image

But at least restarting twice seems to work :/

edit: And FYI the first commit built fine

@wilzbach
Copy link
Contributor

wilzbach commented Jul 19, 2017

Jenkins failures are due to dlang/druntime#1879 (comment).

@dlang-bot dlang-bot merged commit e1de10a into dlang:master Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants