-
Notifications
You must be signed in to change notification settings - Fork 5k
Inlining FAILED: has ldstr VM restriction #12492
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
Comments
Workaround is to lift the string load to a readonly static public static class HeaderNames
{
private readonly static string s_date = "Date";
public static string Date => s_date;
} |
I don't know the specifics here, so will defer to Jan. |
Note, the behaviour I'm trying to capture is reference equality which direct string consts cross-assembly don't have (as they embed in the call site assembly); so using properties to achieve this. |
This check is there to ensure that the inlining won't change the string instance returned for constant string. It looks like a fragile NGen optimization. I think this restriction can be relaxed without giving up much since we are not optimizing for fragile NGen anymore. |
My aim is to maintain reference equality so not propagate the const cross assembly at AoT (as string consts are not deduped cross assembly at assembly load). This is to achieve a fast path for string IgnoreCase comparisons for known strings (e.g. Header names dotnet/aspnetcore#9341) With that goal in mind would it make sense to still block for crossgen/R2R; but allow at Jit/Tier1? i.e. would a cross-assembly ldstr maintain reference equality at Jit time? |
C# sets CompilationRelaxations.NoStringInterning by default that gives runtime freedom in whether to de-dup cross-assembly. I think it should be possible to adjust the system to de-dup more often or with less restrictions; but I am not sure whether we would want to start guaranteeing that everything is de-duped perfectly (ie ignore NoStringInterning). |
Maybe hiding a As when it inlines it will just inline the pointer; whereas if it was a string const it would also inline the load? |
e.g. with the readonly static + property I get
And the inlined string becomes a constant mov e.g. if (ReferenceEquals(HeaderNames.Host, key)) becomes G_M13073_IG06:
mov rdx, 0x15B8E12EBA8 ; HeaderNames:get_Host():ref
cmp gword ptr [rdx], rdi ; ReferenceEquals
jne SHORT G_M13073_IG07 |
If one assembly has a static property as follows:
Using it in another assembly
Fails to inline the property at Jit time with
Is this by design? /cc @AndyAyersMS @jkotas
The text was updated successfully, but these errors were encountered: