-
Notifications
You must be signed in to change notification settings - Fork 19
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
make function symbols store function parameters, needed for UFCS. #182
Conversation
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.
seems useful, but need to check again why you always set includeParameterSymbols
there. Do you actually always need it or is that a left-over from debugging? In the cases where we want it we can simply set the value to true
in the constructor, instead of forcing it to users. Alternatively if you can measure that there is no to little overhead in always including them (and posting your results on that) we can simply remove the boolean like I suggested in the first comment.
src/dsymbol/conversion/first.d
Outdated
@@ -152,6 +152,7 @@ final class FirstPass : ASTVisitor | |||
pushFunctionScope(dec.functionBody, semanticAllocator, | |||
dec.name.index + dec.name.text.length); | |||
scope (exit) popScope(); | |||
includeParameterSymbols = true; |
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 not be here (it effectively now makes the constructor parameter useless, as parameters would always be included)
If it's never a problem, consider instead removing the symbol completely, deprecating the ctor and stripping all the ifs
that checked on it
src/dsymbol/conversion/first.d
Outdated
@@ -981,6 +983,9 @@ private: | |||
addTypeToLookups(parameter.typeLookups, p.type); | |||
parameter.parent = currentSymbol; | |||
currentSymbol.acSymbol.argNames.insert(parameter.acSymbol.name); | |||
|
|||
currentSymbol.acSymbol.functionArguments ~= parameter.acSymbol; |
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.
mixed tabs and spaces
src/dsymbol/symbol.d
Outdated
UnrolledList!(istring) argNames; | ||
|
||
private uint _location; | ||
|
||
/** | ||
* Function argument symbols |
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.
mixed tabs and spaces
@WebFreak001 indeed looks like we probably can remove the includeParameterSymbols if it always should be true. I have looked into the changes and ran the default tests in DCD before and after the changes. before the change: one run:
10 runs:
after the change: one run:
10 runs:
Doesn't seem like it affects too much. |
src/dsymbol/symbol.d
Outdated
/** | ||
* Function argument symbols | ||
*/ | ||
DSymbol*[] functionArguments; |
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.
Does it need to be an array of pointers?
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 guess so since DSymbol isn't copyable unless we change that.
struct DSymbol
{
// Copying is disabled
@disable this();
@disable this(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.
usually all the DSymbol references are done by pointers, but it might be effective to use them inline in arrays (e.g. move them into the array)
We already know the count of items that get put into array before putting them there anyway, so we can already preallocate all the space and directly construct them in-place.
performance wise it looks ok. Did you also check memory impact opening a Phobos or DMD source file and checking process memory usage completing a single symbol? That would be particularly interesting I think. Otherwise LGTM to me now. |
src/dsymbol/conversion/first.d
Outdated
@@ -62,11 +62,10 @@ final class FirstPass : ASTVisitor | |||
* symbolFile = path to the file being converted | |||
* symbolAllocator = allocator used for the auto-complete symbols | |||
* semanticAllocator = allocator used for semantic symbols | |||
* includeParameterSymbols = include parameter symbols as children of | |||
* function decalarations and constructors |
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 line here (below the deleted one) was also part of the deleted comment, also delete this line.
@WebFreak001, Right good point. I made a test where I measure the memory after a completion: client test: test.d:
where cursor is on s I have measured the memory using pmap dcd-server memory usage: before change after change so an increase of 5mb Test opening dmd/compiler/src/dmd/cppmangle.d, then make it complete on the letter s before change after change: so an increase of 44mb The data increase is expected since we store more information now. On big files like cppmangle.d which today |
To not rely on callTips and properly support UFCS, we need functions to store their applicable argument symbols, this PR adds does this.