-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add API that allows the emitter to indicate presence of localloc #27589
Conversation
@nguerrera @VSadov PTAL |
LGTM. This is technically new API needing review. @terrajobst can we fast track it? |
/// <exception cref="ArgumentOutOfRangeException"><paramref name="maxStack"/> is out of range [0, <see cref="ushort.MaxValue"/>].</exception> | ||
/// <exception cref="InvalidOperationException"> | ||
/// A label targeted by a branch in the instruction stream has not been marked, | ||
/// or the distance between a branch instruction and the target label is doesn't fit the size of the instruction operand. |
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.
Typo: "is doesn't"
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.
Fixed.
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.
.
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.
GTM
As discussed offline, the shape of API solves solves our issue.
API changes/additions here. What's the plan? |
@ahsonkhan when API is approved send shiproom brief note with reasoning for the churn. |
I don't see ref changes ... should they be there as well? |
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 means we'll have to track two bits instead of one in the compiler, but it also means this isn't a breaking change for S.R.M.
cc @t-camaia |
@karelz Created API proposal issue: https://github.com/dotnet/corefx/issues/27611 |
test Tizen armel Debug Build please |
@agocke - we can also always set hasDynamicStackAllocation and just twiddle the LocalsInit in the attributes. - the result is the same. Yes the API change is additive to not be breaking. |
Are they not auto-generated? I run |
Try running This is after building the repo at the root. |
@ahsonkhan Thanks. Added another commit with regenerated ref file. This process is very much broken. My previous PR also added new APIs but I didn't know the ref files need to be manually regenerated. Yet everything passed and it got merged! I wonder how many bugs are there currently in CoreFX due to this ref file generation. |
@@ -99,9 +99,7 @@ namespace System.Reflection.Metadata | |||
public System.Reflection.Metadata.StringHandle Name { get { throw null; } } | |||
public System.Reflection.Metadata.BlobHandle PublicKey { get { throw null; } } | |||
public System.Version Version { get { throw null; } } | |||
#if !NETSTANDARD11 |
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.
You need to sanitize the changes to only include the necessary changes you want (+ formatting cleanup/spacing/etc).
Keep the ifdefs.
@@ -2039,7 +2036,7 @@ public enum PrimitiveTypeCode : byte | |||
} | |||
public readonly partial struct PropertyAccessors | |||
{ | |||
private readonly int _dummy; | |||
private readonly object _dummy; |
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.
@weshaggard, is this change OK and expected (the _dummy fields going from int to object)?
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.
Some of those definitely look suspicious. object is the fallback if we cannot determine all the fields in the struct.
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.
Can you provide some rudimentary guidelines that we can follow to vet these changes ourselves?
@@ -3135,6 +3138,7 @@ public enum Machine : ushort | |||
AM33 = (ushort)467, | |||
Amd64 = (ushort)34404, | |||
Arm = (ushort)448, | |||
Arm64 = (ushort)43620, |
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.
@davidwrighton, this was added here - #26243
This is expected, correct?
The process isn't the greatest but it is the best we have. We cannot automatically generate these easily because we have a different surface area based on configuration in a lot of libraries there isn't one definitively implementation we can generate them from.
There may be a few but I don't expect there is a lot because most folks try to test or use their new APIs and they do it via the ref assembly and if the APIs aren't present then they cannot use them. |
If you add tests that exercise the newly added APIs, the build won't pass without the APIs being added to the ref. Only if you have test gaps would this be an issue. What does the code coverage look like for this assembly? |
Precisely. <!-- Some internal types are needed, so we reference the implementation assembly, rather than the reference assembly. --> |
The unit tests pass :(
Well, it passed. |
I wonder if we can use InternalsVisibleTo instead of referencing the implementation assembly. Would we then be able to reference the ref and circumvent this issue? |
This is not an acceptable answer. |
Seems the problem is not that one must manually update the ref, but that by some unknown means the unit tests passed without the ref update. @weshaggard ? |
@danmosemsft The means has been identified: the tests reference the implementation assembly as they require access to internals. |
@ahsonkhan We are using InternalsVisibleTo. Do you mean put the internals in the reference assembly? Do other assemblies do that? If this closes the test gap, then yes, we should at least do that. |
Filed an issue to fix the process: https://github.com/dotnet/corefx/issues/27639 |
Unit tests won't validate that the ref assembly is 100% correct. E.g. ref assembly contains private dummy fields. No unit test will validate those. |
I have somewhat fixed up the ref assembly. Please validate it's correct. |
The only thing would be to keep the |
What about two test libraries for the same implementation library, one with IVT and the other going only through public API would that help? |
@danmosemsft. That makes it more complicated, not less. I don't want any more complexity in this already over complicated system. This would help:
Perhaps these are not applicable on all projects in CoreFX that need some magic like System.Runtime but it will work at least for SCI and SRM (and maybe for others). |
Let's move the ref assembly discussion to https://github.com/dotnet/corefx/issues/27639 |
test OSX x64 Debug Build please |
test UWP CoreCLR x64 Debug Build please |
test OSX x64 Debug Build please |
test UWP CoreCLR x64 Debug Build please |
The OSX failure is a known issue - https://github.com/dotnet/core-eng/issues/2808 |
While working on https://github.com/dotnet/corefx/issues/27639 I regenerated the ref for System.Reflection.Metadata and also noticed the dummy fields being changed from int to object and I do think that is a correct update because those structs have ImmutableArray references which contain array references. As part of addressing https://github.com/dotnet/corefx/issues/27639 I will regenerate the ref to fix that. |
…net/corefx#27589) * Add API that allows the emitter to indicate presence of localloc * Regenerate ref assembly source Commit migrated from dotnet/corefx@3fc3900
When encoding method body header the encoder needs to decide whether to emit tiny or fat header. A small method that has no locals but contains
localloc
instruction and has InitLocals set to true should not be encoded with tiny header since tiny header implies InitLocals is false. The presence oflocalloc
instruction needs to be indicated by the caller of the method body encoder similarly to max stack and other info. Hence we need to add an overload that takes an extra bool parameter.Fixes https://github.com/dotnet/corefx/issues/26910
Implements https://github.com/dotnet/corefx/issues/27611