Skip to content
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

Allow skipping the processing of a reflection call if its MarkStep's ProcessReflectionDependency() returns true #1548

Conversation

brian-taylor-unity
Copy link
Contributor

Allow ReflectionMethodBodyScanner's HandleCall() to skip processing an instruction if its MarkStep's ProcessReflectionDependency() returns true.

@MattGal
Copy link
Member

MattGal commented Oct 7, 2020

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 1548 in repo mono/linker

@akoeplinger
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -487,14 +487,18 @@ static IntrinsicId GetIntrinsicIdForMethod (MethodDefinition calledMethod)

public override bool HandleCall (MethodBody callingMethodBody, MethodReference calledMethod, Instruction operation, ValueNodeList methodParams, out ValueNode methodReturnValue)
{
methodReturnValue = null;

var reflectionProcessed = _markStep.ProcessReflectionDependency (callingMethodBody, operation);
Copy link
Member

Choose a reason for hiding this comment

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

It seems the method will be called twice for each call. Once here and second time in the existing MarkStep.MarkReflectionLikeDependencies.

I don't know exactly what Unity wants here - maybe it would be easier to add an extension point which disables the data flow analysis completely (my understanding is that Unity has its own version of that anyway).
There's no virtual method to do that yet, but it would be pretty simple to add one like that.

Copy link
Contributor

Choose a reason for hiding this comment

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

See https://discordapp.com/channels/732297728826277939/751137004007456849/763083086782529556

Open to ideas. We were struggling to find a clean way to accomplish our goal.

As for being called twice, we should remove that. This entire loop is pointless https://github.com/mono/linker/blob/9a4a5a06d54ed13f2215a7e0d0e39663ee10b51d/src/linker/Linker.Steps/MarkStep.cs#L2965 . @brian-taylor-unity Can you update this PR to remove that entire loop over the instructions and calling ProcessReflectionDependency?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks - I read up on the Discord and it makes much more sense now. Once we remove the useless loop I'm fine with this change - if it works for you.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Do we need the local variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary, I added it mainly to encapsulate some of the meaning of why it would cause an early-return in the method, but I don't really have a strong opinion either way.

Copy link
Member

Choose a reason for hiding this comment

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

OK - I don't have strong feeling about it either

…n instruction if its MarkStep's ProcessReflectionDependency() returns true.
@brian-taylor-unity brian-taylor-unity force-pushed the process-reflection-dependency-check branch from fac6433 to 5006e58 Compare October 7, 2020 19:27
@@ -487,14 +487,18 @@ static IntrinsicId GetIntrinsicIdForMethod (MethodDefinition calledMethod)

public override bool HandleCall (MethodBody callingMethodBody, MethodReference calledMethod, Instruction operation, ValueNodeList methodParams, out ValueNode methodReturnValue)
{
methodReturnValue = null;

var reflectionProcessed = _markStep.ProcessReflectionDependency (callingMethodBody, operation);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Do we need the local variable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants