{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/corert/issues/2080","repository_url":"https://api.github.com/repos/dotnet/corert","labels_url":"https://api.github.com/repos/dotnet/corert/issues/2080/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corert/issues/2080/comments","events_url":"https://api.github.com/repos/dotnet/corert/issues/2080/events","html_url":"https://github.com/dotnet/corert/issues/2080","id":185303958,"number":2080,"title":"Hoisted static base incorrectly reused across GC/non-GC static regions","user":{"login":"MichalStrehovsky","id":13110571,"avatar_url":"https://avatars.githubusercontent.com/u/13110571?v=3","gravatar_id":"","url":"https://api.github.com/users/MichalStrehovsky","html_url":"https://github.com/MichalStrehovsky","followers_url":"https://api.github.com/users/MichalStrehovsky/followers","following_url":"https://api.github.com/users/MichalStrehovsky/following{/other_user}","gists_url":"https://api.github.com/users/MichalStrehovsky/gists{/gist_id}","starred_url":"https://api.github.com/users/MichalStrehovsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MichalStrehovsky/subscriptions","organizations_url":"https://api.github.com/users/MichalStrehovsky/orgs","repos_url":"https://api.github.com/users/MichalStrehovsky/repos","events_url":"https://api.github.com/users/MichalStrehovsky/events{/privacy}","received_events_url":"https://api.github.com/users/MichalStrehovsky/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corert/labels/CodeGen","name":"CodeGen","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"sandreenko","id":22642771,"avatar_url":"https://avatars.githubusercontent.com/u/22642771?v=3","gravatar_id":"","url":"https://api.github.com/users/sandreenko","html_url":"https://github.com/sandreenko","followers_url":"https://api.github.com/users/sandreenko/followers","following_url":"https://api.github.com/users/sandreenko/following{/other_user}","gists_url":"https://api.github.com/users/sandreenko/gists{/gist_id}","starred_url":"https://api.github.com/users/sandreenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandreenko/subscriptions","organizations_url":"https://api.github.com/users/sandreenko/orgs","repos_url":"https://api.github.com/users/sandreenko/repos","events_url":"https://api.github.com/users/sandreenko/events{/privacy}","received_events_url":"https://api.github.com/users/sandreenko/received_events","type":"User","site_admin":false},"assignees":[{"login":"sandreenko","id":22642771,"avatar_url":"https://avatars.githubusercontent.com/u/22642771?v=3","gravatar_id":"","url":"https://api.github.com/users/sandreenko","html_url":"https://github.com/sandreenko","followers_url":"https://api.github.com/users/sandreenko/followers","following_url":"https://api.github.com/users/sandreenko/following{/other_user}","gists_url":"https://api.github.com/users/sandreenko/gists{/gist_id}","starred_url":"https://api.github.com/users/sandreenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandreenko/subscriptions","organizations_url":"https://api.github.com/users/sandreenko/orgs","repos_url":"https://api.github.com/users/sandreenko/repos","events_url":"https://api.github.com/users/sandreenko/events{/privacy}","received_events_url":"https://api.github.com/users/sandreenko/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2016-10-26T05:57:29Z","updated_at":"2016-10-26T05:57:29Z","closed_at":null,"body":"```csharp\r\nusing System;\r\n\r\nclass WithCctor<T>\r\n{\r\n    public static int IntField = 123;\r\n    public static string StringField = \"Hello\";\r\n\r\n    public static string Touch()\r\n    {\r\n        return (IntField == 123 ? \"123\" : \"0\") + StringField;\r\n    }\r\n}\r\n\r\ninternal class Program\r\n{\r\n    private static void Main(string[] args)\r\n    {\r\n        Console.WriteLine(WithCctor<string>.Touch());\r\n    }\r\n}\r\n```\r\n\r\nCompile with `--usesharedgenerics`.\r\n\r\nThis results in:\r\n\r\n```nasm\r\n00007FF66EE2C28C  call        __GenericLookupFromDict_repro_WithCctor_1__System___Canon_NonGCStaticBase_repro_WithCctor_1__T_System___Canon (07FF66EEDF3A0h)  \r\n00007FF66EE2C291  cmp         dword ptr [rax],7Bh  \r\n00007FF66EE2C294  je          repro_WithCctor_1__System___Canon__repro_WithCctor_1__Touch+17h (07FF66EE2C29Fh)  \r\n00007FF66EE2C296  lea         rcx,[repro__Str__0 (07FF66F42DE28h)]  \r\n00007FF66EE2C29D  jmp         repro_WithCctor_1__System___Canon__repro_WithCctor_1__Touch+1Eh (07FF66EE2C2A6h)  \r\n00007FF66EE2C29F  lea         rcx,[repro__Str__123 (07FF66F42DE40h)]  \r\n00007FF66EE2C2A6  mov         rdx,qword ptr [rax+8]  \r\n00007FF66EE2C2AA  call        System_Private_CoreLib_System_String__Concat_5 (07FF66EE2B704h)  \r\n\r\n```\r\n\r\nNotice there's only one generic lookup (for the non-GC static base) and it's getting reused to load `StringField` too, even though that one lives in the GC static base.\r\n\r\nI think we want to keep it hoistable, but the hoisting should check the entrypoint. Or maybe we just need separate helpers beside `CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE` so that RyuJIT can tell them apart."}}
{"actor":{"display_login":"MichalStrehovsky"}}