Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we have the following sequence:
and
local n
is a reference to value, when walking the instructions inmono_method_to_ir, we generally try to avoid loading a whole value
type just to load one of the fields. I believe this is an
optimization.
The test here is not quite complete, though, as we have ref valuetypes
where the object stored at the location is actually an address, in
which case we still need to treat it as we would a normal reference.
This optimization isn't present in the ldloc.n coded forms and is
written in a slightly more robust way in ldloc.s, so no changes are
necessary there.
As an alternative to this commit, we might adopt a simplified version of the ldloc.s test for
ldloc as well, or merge in
mono@29428d9/mono/mini/method-to-ir.c
from master which encapsulates much the same intent.
Associated bug: https://fogbugz.unity3d.com/f/cases/1252663/