* Implementation of reverse type reference lookup
Based on JanK's suggestion, I have implemented the basic logic
for reverse type reference lookup. I have demonstrated basic
functionality of this feature by adding two delegate tests involving
Action and Func<char, char>.
I also had to slightly refactor type signature emitter - my
initial implementation was heavily dependent on parsing an existing
metadata signature but in the resolution process we can hit synthetic
types that don't have such a metadata representation, most notably
for generics.
For this reason I believe we need custom recursive descent into the
type tree and this change includes the initial implementations. For
now I'm keeping the generic signature decoder as it's still used by
method signatures but my current thinking is that it will also become
unneeded at some point and we'll be better of with a custom
implementation matching our exact needs.
Thanks
Tomas
* Addressing part of PR feedback
I have refactored SignatureBuilder to use a big switch over the
TypeDesc.Category. This overall simplified things. I fixed several
signatures to stop emitting type signatures when only looking up
references as signature emission may be a relatively costly process.
I tried to add some provisions to increase robustness of the
reference resolution but for now I'm keeping the reference enumeration
as just hooking up resolveToken is not sufficient to provide a
sufficiently complete mapping from types to tokens.
Thanks
Tomas
* Incomplete changes for shared generic support
* Fix bug in X64 emitter
The MOV(register, register) instruction was implemented incorrectly.
The method GetRexPrefix assumes that the register specified as
parameter is the target, however we were using the other opcode
where the register is the source. I have fixed this inconsistency
and I added code comments to the individual REX values to improve
clarity.
Thanks
Tomas
* Improved support for interface dispatch and unboxing stubs
Based on debugging calls to Dispose on classes and valuetypes and
thanks to help from JanK I finally managed to make calls to dispose
work on both. The change mostly involves propagation of the
new unboxingStub flag, switching over to general MethodEntry
fixups that allow encoding the value of the flag and general
infrastructural plumbing in the R2RCG node factory.
Thanks
Tomas
* Some additional minor fixes for interface dispatch
I removed an apparently incorrect check I had put in CorInfoImpl
previously. I fixed a trivial typo in the DelayLoadHelperThunk.
With these changes I'm again passing all the previous tests
plus the new Dispose on class / struct tests demonstrating
initial vestiges of unboxing stub support. Generic enumeration
still doesn't work for some reason, I'll investigate that next.
Thanks
Tomas
* Removal of reverse lookup in favor of eager lookup
Based on Michal's suggestion I have replaced the reverse lookup
in ReadyToRunCodegenNodeFactory with eager lookup called from
CorInfoImpl.resolveToken. The current implementation seems to be
the minimum enough to compile the 22 trivial unit tests.
Thanks
Tomas
* Initial support for constrained type virtual method calls
Thanks to JanK's help I was finally able to put together
initial support for constrained method calls finally fixing
the call to List<string>.Enumerator.Dispose().
Thanks
Tomas
* Add unit tests for features unblocked by my previous commits
This mostly covers my recent contributions in the field of
unboxing stubs, constrained method calls and token lookup
improvements.
Thanks
Tomas
* Fix rebase conflict
* Addressing [most of] Michal's PR feedback
I have trivially applied the mechanical feedback (fixing the typo
lea -> mov in the X64Emitter comment, applying the good suggestion
to simplify register references by using the X64 namespace and
unifying the VALUETYPE / NULLABLE case in signature encoding.
For the remaining feedback, I'm trying to provide my rationale for
further discussion:
1) Why do we need the || READYTORUN part in CorInfoImpl around line
3100? To let us pass around call site names to interface dispatch
cells - as interface dispatch cells are per call site even though
they might reference the same interface method, we need some way
to distinguish their symbols as we validate symbol uniqueness to
maintain output consistency.
If you're fine with the concept and you're just suggesting there's
an easier way to encode this by means of preprocessor directives,
I don't see that, please enlighten me.
2) Stashing token information in CorInfoImpl - I think the big
problem is signature building where in general we need to dig
arbitrarily deep into composite signatures.
Based on how good your suggestion for using resolveToken seems
to be working, I'm starting to think that it might be easiest to
drop the token propagation from CorInfoImpl and just always
synthesize the tokens based on the pre-recorded information; it
might unify parts of the previously forked NodeFactory bits too.
Once we start mucking with multiple assemblies within a versioning
bubble, I think we have several possible ways to go. As I mentioned
in a comment to the previous Simon's PR, I believe that the
R2RCGNF class has already gotten too big and would merit splitting
into multipler parts.
One of these should be exactly this "token manager" and perhaps
separating it from the node factory into a class of its own might
address some of your concerns; I however still believe that in
general, CoreCLR signatures support reference module override
so that we should be able to use arbitrary token sources across
the entire versioning bubble for the purpose of referencing externals.
Thanks
Tomas
* Move token management logic into a separate class ModuleTokenResolver
In this mostly mechanical change I tried to address part of Michal's
PR feedback by moving the token resolution logic away from the
ReadyToRunCodegenNodeFactory into a separate class. While the change
is mostly mechanical, I believe it nicely demonstrates
the relationship between the two classes and possible future steps
regarding migration of the logic from one to the other. For now
the resolver naturally hangs off the factory, that can easily change
by it becoming a part of the CorInfoImpl.ReadyToRun class.
Thanks
Tomas
* Further propagation of ModuleTokenResolver
This change removes direct references to ReadyToRunCodegenNodeFactory
from those signatures that only needed it for token resolution.
Thanks
Tomas
* Remove unnecessary | READYTORUN in CorInfoImpl
Based on Michal's suggestion I'm removing the | READYTORUN clause
in the conditional directive producing call site name for
interface dispatch cells. I have double-checked that SUPPORT_JIT
is not defined in the project so that the condition is true.
Thanks
Tomas
* Support readytorun mode for CoreCLR tests
Currently 226 / 1829 tests pass (12.4%) from the KnownGood subset.
* CR Feedback
Break out the two large command lines into a variable so echo and command run use the exact same command line. This prevents the classical problem where we forget to keep the echo in sync with the actually run command line.
Make comparisons case insensitive.
The change to return an empty array instead of null broke a method handle test. Seems like generic arguments being null is a contract. Restoring the old logic and adding handling of null to the place that promted the change (https://github.com/dotnet/corert/pull/6182#discussion_r207886898).
[tfs-changeset: 1711212]
* Compile single input file specified in the compile option to single output file instead of multiple output files
* Parallelize multi-module with msbuild
* Fix missing binaries error
* Move BuildReadyToRunMultiModule to BuildIntegration folder
* Avoid using additional option moduleFilePaths
* Get multi-module to work without moduleFilePaths
* Fix error by not creating FullVTable
* Don't add EETypes to LibraryRootProvider for ReadyToRun
* Use ecmaTypes from compilationModule instead of eeTypeNode so AvailableTypes table has entries, get correct file extensions
* Disable ReadyToRunMultiModule test for JIT
* Compute AvailableTypes hash for types with namespaces
* Fix merge errors
* Use correct hashcode algorithm, add test for nested type
* Uncomment CheckCanGenerateMethod, remove IlcMultiModule property, remove todos
* Rename ReadyToRunMultiModule
Generating relocs to a shadow concrete method should work the same as a reloc to the canonical body it represents. This is why the ShadowConcreteMethod implements ISymbolNode (indirectly, through IMethodNode). It works that way in the CoreRT object emitter, but it got broken when the UTC emitter stopped looking at mangled names and started assigning IDs to symbols instead. We hit a similar problem in EETypeNode and "NodeForLinkage" was born at that time.
This change:
1. Rolls back CS 1710918 that is trying to sidestep the problem by introducing complexity at the place where we need a canonical node (we need to decide whether we need one for linkage purposes, or for dependency analysis purposes, with a subtle runtime failure mode if we pick the wrong one).
2. Makes NodeForLinkage a property of the symbol reference instead of property of the defining object node so that we can use this on nodes that don't have object data associated with them.
3. Implements NodeForLinkage on ShadowConcreteMethodNode
[tfs-changeset: 1711076]
* Make handle checks accurate on Windows
We can actually check the async state of a handle on Windows, so check directly when we have the API available.
Also allow all filetypes through when explicitly using extended syntax `\\?\` .
* Fix nits
* Don't throw in the handle constructor overloads
* Whoops
* Removing the close handle entirely. No adverse effects from closing a bad handle- or leaving it open for that matter.
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Corrects an issue with the conversion table for Gregorian to Japanese lunisolar dates.
See: #19450.
Issue: data discrepancy in year 1962.
Table entry for 1962 has incorrect days per month for months 6 and 7.
Notes
The DaysPerMonth flag uses the binary literal for ease of readability.
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
If for some reason (ie a test harness bug or user error) no assembly load events are fired, the harness will see the absence of jitted methods as a sign that all code ran R2R perfectly. Add a smell test that checks we at least saw one test module loaded.
Fix up tabs and some unused variables.
(Fixes a test in the Recoil category, which had a nullptr value for a ConstrainedMethodUse generic dictionary slot. The call to CanonicalEntrypoint was returning a ShadowConcreteMethod node, which was not really valid for that purpose. In fact, i'm not really sure why this test compiled successfully in the first place instead of hitting a linking error).
[tfs-changeset: 1710918]
* Build header tables using metadata manager
* Enable MetadataManager to track use of types / methods
* Introduce `AvailableType` which replaces the CoreRT EETypeNode.
Ready-to-run doesn't emit types directly into the image but records
their use and fills a table of available types used for type resolution
between ready-to-run modules by the runtime.
* Add dependency tracking in a few existing places where references to
types are being made. In library compilation mode, the non-private types
will be rooted so they always end up in the available types table.
* Use a single NodeCache for method entrypoints instead of a separate
dictionary for ready-to-run entrypoints. To smooth over the API
differences between the base `NodeFactory` and
`ReadyToRunCodegenNodeFactory`, allow a custom GetOrAdd method that
takes a creator callback.
* Switch over `RuntimeFunctionsTable`, `TypesTable`,
`MethodEntryPointTable` to use metadata manager for the list of types /
methods to emit entries for.
* Add System.Commandline package, fix concurrency error causing test to display as failed
* Add referenced assemblies to testModules, use System.CommandLine
Touches a lot of files, but most of this is just plumbing.
In the absence of invoke thunks, reflection will use the calling convention converter. Reflection invoke will get about 7x slower, but will still work. Saves about 1.5-2% in terms of size on disk. The default is still to use the thunks, since we tweak everything towards fast defaults.
Implemented for both Project N and Project X. On the X side, I decided to go with a "policy" class instead of bools. This will let us cleanly do further optimization in the future, such as selectively generating thunks only for specific methods.
[tfs-changeset: 1710656]
* Don't early terminate on null for 64bit NR HashCode
* Improved GetNonRandomizedHashCode
* Update message on GetNonRandomizedHashCode
* Consume null terminator rather than special case odd lengths
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* Create Microsoft.Internal.IO
Includes all of Path, Directory, *Info, etc. from System.IO with targets of NetFX 4.6.1 and NetCore 2.1.
* Tweaks / minor fixes
* Remove netstandard build.
* Add package
Update to build for 4.7.2 only
* Rename folder to prepare for project rename
* Change the name to Microsoft.IO.Redist
* Namespace tweaks
* Use open key, tweak references
* More tweaks on feedback
Also grab latest build tools for 4.7.x RIDs
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
This is a port of dotnet/coreclr#17732. Fixes bug 603305.
Per popular demand from people who would like to serialize ref returning properties or use them in data binding, adding support for this in MethodInfo.Invoke. The choice was to make these dereference the result and return it like that. For the corner case of returning a ref to a null, a `NullReferenceException` will be thrown (this behavior has a very unfortunate side effect of slowing down the general Invoke path because we can't throw this exception from a place where we would end up wrapping this in a TargetInvocationException).
I also made tweaks to byref parameters path to fix byref pointer parameters, but this is horribly broken on the CLR so I didn't bother to test it here. Should work.
Also includes a slight size on disk optimization that merges common tails of the static/instance paths of the invoker thunk.
Testing of the calling convention converter portion was done by disabling invoke thunks generation in NUTC and running UnitTests. I also ran it with GCStresss (RH_GCStressThrottleMode=1, RH_GCStress_Mode=1). Let me know if there's more testing needed. This has a huge test matrix for being such a corner case thing.
[tfs-changeset: 1709919]