-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JIT: Throw statement triggers: "has ldstr VM restriction" #53726
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
From my understanding that is intentional: we don't inline methods with string literals inside from other modules, e.g.: ClassLibrary1: public class Class1
{
public string GetString() => "Hello";
} ConsoleApp1 (references ClassLibrary1 lib): string Test() => Class1.GetString(); // GetString won't be inlined -- has ldstr VM restriction because the way interning works, we only can inline it if ClassLibrary doesn't use that literal anywhere. However, I am not sure I fully understand this restriction (perhaps, AOT only?) |
Yes, I dont know really why it cannot be inlined. But in this case where there is no such construct and also it is essentially a |
CC @AndyAyersMS.
|
As @EgorBo says, this is a precaution migrating strings cross-module, in case string interning is active in the caller or callee's module. But seemingly we could relax this, when jitting, most of the time: runtime/src/coreclr/vm/jitinterface.cpp Lines 8082 to 8090 in 0177446
|
@AndyAyersMS ROFL, you got the scream. |
Pushing out to .NET 7 since it is not likely to be handled by Preview 7. |
The code that was dealing with this relaxation was deleted in dotnet#57693 last year (ceeload.cpp, line 4006). We still had code that was telling RyuJIT not to inline string literals across modules if `NoStringInterning` is active because it might be observable, but since fragile NGen got deleted, I don't believe it's actually observable anymore and we could have deleted this together with fragile NGen support. Closes dotnet#53726 - we no longer need to worry about loosening the restriction - we just drop it all.
* Delete code related to CompilationRelaxations.NoStringInterning The code that was dealing with this relaxation was deleted in #57693 last year (ceeload.cpp, line 4006). We still had code that was telling RyuJIT not to inline string literals across modules if `NoStringInterning` is active because it might be observable, but since fragile NGen got deleted, I don't believe it's actually observable anymore and we could have deleted this together with fragile NGen support. Closes #53726 - we no longer need to worry about loosening the restriction - we just drop it all.
Description
The JIT is not able to inline this method because of the
throw new FormatException("Bad variable size int");
statement with the following error:A cleanup version of the offending code:
Configuration
.Net 5.0
Analysis
It sounds to me that because the offending line is a throw statement and is to be marked as cold, that restriction should not apply.
The text was updated successfully, but these errors were encountered: