Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

R2R ilstubs#24823

Merged
davidwrighton merged 20 commits intodotnet:masterfrom
davidwrighton:r2r_ilstubs
Jun 11, 2019
Merged

R2R ilstubs#24823
davidwrighton merged 20 commits intodotnet:masterfrom
davidwrighton:r2r_ilstubs

Conversation

@davidwrighton
Copy link
Copy Markdown
Member

IL stub generation for interop takes measurable time at startup, and it is possible to generate some of them in an ahead of time

This change introduces ahead of time R2R compilation of IL stubs

  • Relatively complete coverage for System.Private.CoreLib
  • Limited IL stubs for other assemblies
    • Only stubs which do not use any api surface in their marshalers.

As of this writing IL stubs do not participate in tiering. Need for this will be investigated before checkin

- Restrict generation of IL stubs into R2R binaries where the IL stub may have runtime specific dependencies
- Enable various marshallers
- Allow/disallow a few different instructions
- Also tweak logic around corelib ilstub r2r usage so that it actually uses the ilstubs in only the right circumstances
- The cross bitness logic is not correct for IL Stub generation
@davidwrighton davidwrighton changed the title [WIP] R2R ilstubs R2R ilstubs Jun 10, 2019
@davidwrighton davidwrighton marked this pull request as ready for review June 10, 2019 17:45
Comment thread src/inc/corcompile.h
Comment thread src/vm/compile.cpp
Comment thread src/vm/compile.cpp Outdated
Comment thread src/vm/compile.cpp
Comment thread src/vm/prestub.cpp Outdated
Comment thread src/vm/zapsig.cpp
@@ -1324,19 +1324,44 @@ BOOL ZapSig::EncodeMethod(
{
Module * pReferencingModule = pMethod->IsNDirect() ?
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please document why pReferencingModule is valid to be NULL. Based on existing code this is a core assumption that is no longer value. If there is a way I would strong suggest to remove using NULL as an invariant since this function was written where that was never an issue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In particular see previous logic at line 1342.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The problem is that there isn't a referencing module. Dynamic methods don't really have associated modules in the same way that normal methods do. (In particular, the tokens are not relative to the module, which is what all of the code here is assuming.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But a comment is certainly worth it.

Comment thread src/vm/zapsig.cpp
}
else
{
// Dynamic scope case. IL Stubs only
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any way we can assert this instead of commenting on it? (i.e. "IL Stubs only" <- can that be asserted?)

Comment thread src/vm/zapsig.cpp
ThrowHR(E_FAIL);
}

if (pInfoModule == pMethod->GetModule())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this checking where the method's metadata is located? This check warrants a comment I think.

Comment thread src/zap/zapinfo.cpp Outdated
@davidwrighton davidwrighton merged commit 93675fb into dotnet:master Jun 11, 2019
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Basic support for precompiled pinvoke stubs

* Generate R2R file with multiple references to same IL stub (one per method which the IL stub is associated with)
* Not all il stubs are p/invokes. Don't fail when they aren't.
* Consistently use IsDynamicScope and GetModule to avoid unsafe memory access in IL stub compilation paths
* Enable full p/invoke il stubs when compiling System.Private.Corelib
* Disable IL Stub generation in crossgen for ARM32.
- The cross bitness logic is not correct for IL Stub generation


Commit migrated from dotnet/coreclr@93675fb
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants