You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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).
Activity
benaadams commentedon Apr 13, 2019
Workaround is to lift the string load to a readonly static
AndyAyersMS commentedon Apr 13, 2019
I don't know the specifics here, so will defer to Jan.
benaadams commentedon Apr 13, 2019
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.
jkotas commentedon Apr 14, 2019
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.
benaadams commentedon Apr 14, 2019
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?
jkotas commentedon Apr 14, 2019
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).
benaadams commentedon Apr 14, 2019
Maybe hiding a
readonly staticstring behind a static property getter is the best approach then?As when it inlines it will just inline the pointer; whereas if it was a string const it would also inline the load?
benaadams commentedon Apr 14, 2019
e.g. with the readonly static + property I get
And the inlined string becomes a constant mov e.g.
becomes