-
Notifications
You must be signed in to change notification settings - Fork 128
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
Mark instance method bodies lazily #502
Mark instance method bodies lazily #502
Conversation
f5ed424
to
b5d68bd
Compare
Rebased and should be ready to go pending CI results 🤞 |
Did you forget to push the changes ;-) |
b5d68bd
to
084aaee
Compare
I didn't finish making all of the changes before I had to go. All changes are done and pushed now. |
I'm looking into the test failures with illink |
81ffabd
to
e33d11c
Compare
I refactored
I can't get the .net core tests running locally. Hopefully everything is fixed now, but I'll have to wait for CI to finish to know for certain. |
e33d11c
to
d8b743a
Compare
src/linker/Linker/BCL.cs
Outdated
@@ -71,6 +71,10 @@ public static TypeDefinition FindPredefinedType (string ns, string name, LinkCon | |||
if (cache.TryGetValue ("System.Private.CoreLib", out corlib)) | |||
return corlib.MainModule.GetType (ns, name); | |||
|
|||
// System.NotSupportedException lives here on .netcore |
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.
fyi, I had to add this so that System.NotSupportedException
could be found. This could become a tedious pattern to maintain
@sbomer I tried adding
To I can't get the .netcore tests working locally so that's making iterating on this challenging. |
d8b743a
to
05b3ace
Compare
@mrvoorhe I can take a look. Could you try running the tests locally on core using |
Also, it looks like |
Switching |
05b3ace
to
35dcf49
Compare
@sbomer How can I debug this? I tried what you said and I can reproduce the failure locally. However, Rider EAP and VS 2019 are not happy with |
I think I know what the issue is now. The test that is failing is an IL test. That said, I would still like some pro tips on how to debug individual tests on .netcore for future reference |
Instance method bodies do not need to be marked until an instance of the type could exist. * Add MethodConvertedToThrow callback * Update link xml preserve test expected behavior
35dcf49
to
727ccb7
Compare
#471 may help with IDE support for the .sln, but I'm not sure. I've had lots of issues with tooling support for projects that mix configurations/targetframeworks and projectreferences. Sorry it's causing you trouble. For debugging, I've been using VS code. Here's the best way I've found to do it so far:
|
@marek-safar Good to go! |
This has been shown to regress the mono harness when mono is bumped to this commit. |
@alexanderkyte Can you investigate a bit? If any types are created from native and do not get an instance .ctor marked it will cause problems. If this is the case it is not necessarily a problem with these changes. Instead the fix is to properly annotate w/e instance .ctor is needed by the type. It's certainly possible there is a bug with these changes, but I'd prefer to rule out the above before making any changes to disable this. |
@mrvoorhe I have a PR testing whether disabling the |
Instance method bodies do not need to be marked until an instance of the type could exist. Any instance methods that were marked on types that are never instantiated will be converted to a throw. * A number of existing tests needed to be updated to avoid lazy body marking * Add a new CodeOptimization to allow disabling this mechanism. Reasoning was, (1) it's simple to support an option. (2) It may be helpful if it causes problems. (3) I could see using this option to make writing certain tests easier. * Marking of some small bodies will not be deferred. The idea is that the size cost of some methods is less than converting them to a throw. So we might as well leave them alone. See `IsWorthConvertingToThrow` * Factored out `MarkAndCacheNotSupportedCtorString` since I need to call it from multiple places now. * Expose the `RewriteBody*` methods in CodeRewriterStep for overriding. A few motivations for this. (1) We have a runtime that doesn't support exceptions. When we target that runtime we will need to override `ConvertToThrow` with something else. (2) I will likely override all of the `RewriteBody*` methods so that I can record which bodies are changed and hook it up to logging mechanisms that we have. Note. This PR has a test that depends on dotnet/linker#501 . That PR will need to land first and I will need to rebase after that lands. There will be 1 failing test until that happens. Commit migrated from dotnet/linker@e9ed848
Instance method bodies do not need to be marked until an instance of the type could exist. Any instance methods that were marked on types that are never instantiated will be converted to a throw.
A number of existing tests needed to be updated to avoid lazy body marking
Add a new CodeOptimization to allow disabling this mechanism. Reasoning was, (1) it's simple to support an option. (2) It may be helpful if it causes problems. (3) I could see using this option to make writing certain tests easier.
Marking of some small bodies will not be deferred. The idea is that the size cost of some methods is less than converting them to a throw. So we might as well leave them alone. See
IsWorthConvertingToThrow
Factored out
MarkAndCacheNotSupportedCtorString
since I need to call it from multiple places now.Expose the
RewriteBody*
methods in CodeRewriterStep for overriding. A few motivations for this. (1) We have a runtime that doesn't support exceptions. When we target that runtime we will need to overrideConvertToThrow
with something else. (2) I will likely override all of theRewriteBody*
methods so that I can record which bodies are changed and hook it up to logging mechanisms that we have.Note. This PR has a test that depends on #501 . That PR will need to land first and I will need to rebase after that lands. There will be 1 failing test until that happens.