-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Avoid stack overflow due to deep recursion on long chain of calls. #67913
Changes from 5 commits
1f97f7f
09a18da
3829157
b131a4f
8fecdcf
aeb9d49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,5 +135,49 @@ protected BoundTreeWalkerWithStackGuardWithoutRecursionOnTheLeftOfBinaryOperator | |
rightOperands.Free(); | ||
return null; | ||
} | ||
|
||
public sealed override BoundNode? VisitCall(BoundCall node) | ||
{ | ||
if (node.ReceiverOpt is BoundCall receiver1) | ||
{ | ||
var calls = ArrayBuilder<BoundCall>.GetInstance(); | ||
|
||
calls.Push(node); | ||
|
||
node = receiver1; | ||
while (node.ReceiverOpt is BoundCall receiver2) | ||
{ | ||
calls.Push(node); | ||
node = receiver2; | ||
} | ||
|
||
VisitReceiver(node); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why isn't this inside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The intermediate |
||
|
||
do | ||
{ | ||
VisitArguments(node); | ||
} | ||
while (calls.TryPop(out node!)); | ||
|
||
calls.Free(); | ||
} | ||
else | ||
{ | ||
VisitReceiver(node); | ||
VisitArguments(node); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
protected virtual void VisitReceiver(BoundCall node) | ||
AlekseyTs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
this.Visit(node.ReceiverOpt); | ||
} | ||
|
||
protected virtual void VisitArguments(BoundCall node) | ||
{ | ||
this.VisitList(node.Arguments); | ||
} | ||
} | ||
} |
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 like this is roughly the same code on several derivations of
CSharpSyntaxWalker
? Did you consider putting a helper directly there that we could access? Probably cost us aDelegate
allocation but maybe that's not too much. #ResolvedThere 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 only two of them and they are slightly different. I do not think it is worth adding an abstraction across them