{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/csharplang/pulls/comments/201464730","pull_request_review_id":135973009,"id":201464730,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTQ2NDczMA==","diff_hunk":"@@ -0,0 +1,183 @@\n+# Compiler Intrinsics\n+\n+* [x] Proposed\n+* [ ] Prototype: Not Started\n+* [ ] Implementation: Not Started\n+* [ ] Specification: Below\n+\n+## Summary\n+\n+This proposal provides language constructs that expose low level IL opcodes that cannot currently\n+be accessed efficiently, or at all: `ldftn`, `ldvirtftn`, `ldtoken` and `calli`. These low level op \n+codes can be important in high performance code and developers need an efficient way to access \n+them.\n+\n+## Motivation\n+\n+The motivations and background for this feature are described in the following isssue (as is a \n+potential implementation of the feature): \n+\n+https://github.com/dotnet/csharplang/issues/191\n+\n+This alternate design proposal comes after reviewing a prototype implementation of the original\n+proposal by @msjabby as well as the use throughout a significant code base. This design was done \n+with significant input from @mjsabby, @tmat and @jkotas.\n+\n+## Detailed Design \n+\n+### Allow address of to target methods\n+\n+Method groups will now be allowed as arguments to an address-of expression. The type of such an \n+expression will be `void*`. \n+\n+``` csharp\n+class Util { \n+    public static void Log() { } \n+}\n+\n+// ldftn Util.Log\n+void* ptr = &Util.Log; \n+```\n+\n+Given there is no delegate conversion here the only mechanism for filtering members in the method\n+group is by static / instance access. If that cannot distinguish the members then a compile time\n+error will occur.\n+\n+``` csharp\n+class Util { \n+    public void Log() { } \n+    public void Log(string p1) { } \n+    public static void Log(int i) { };\n+}\n+\n+unsafe {\n+    // Error: Method group Log has more than one applicable candidate.\n+    void* ptr1 = &Log; \n+\n+    // Okay: only one static member to consider here.\n+    void* ptr2 = &Util.Log;\n+}\n+```\n+\n+The addressof expression in this context will be implemented in the following manner:\n+\n+- ldftn: when the method is static \n+- ldvirtftn: when the method is an instance method.\n+\n+Restrictions of this feature:\n+\n+- Instance methods can only be specified when using an invocation expression on a value\n+- Local functions cannot be used in `&`. The implementation details of these methods are\n+deliberately not specified by the language. This includes whether they are static vs. instance or\n+exactly what signature they are emitted with.\n+\n+### handleof\n+\n+The `handleof` contextual keyword will translate a field, member or type into their equivalent \n+`RuntimeHandle` using the `ldtoken` instruction.\n+\n+The arguments to `handleof` are identical to `nameof`. It must be a simple name, qualified name, \n+member access, base access with a specified member, or this access with a specified member. The \n+argument expression identifies a code definition, but it is never evaluated.\n+\n+The `handleof` expression is evaluated at runtime and has a return type of `RuntimeHandle`. This \n+can be executed in safe code as well as unsafe. \n+\n+``` \n+RuntimeHandle stringHandle = handleof(string);\n+```\n+\n+Restrictions of this feature:\n+\n+- Properties cannot be used in a `handleof` expression.\n+- The `handleof` expression cannot be used when there is an existing `handelof` name in scope. For \n+example a type, namespace, etc ...\n+\n+### calli\n+\n+The compiler will add support for a new type of `extern` function that efficients translates into\n+a `.calli` instruction. The exten attribute will be marked with an attribute of the following\n+shape:\n+\n+``` csharp\n+[AttributeUsage(AttributeTargets.Method)]\n+public sealed class CallIndirectAttribute : Attribute\n+{\n+    public CallingConvention CallingConvention { get; set; }\n+    public CallIndirectAttribute(CallingConvention callingConvention)\n+    {\n+        CallingConvention = callingConvention;\n+    }\n+}\n+```\n+\n+This allows developers to define methods in the following form:\n+\n+``` csharp\n+[CallIndirect(CallingConvention.Cdecl)]","path":"intrinsics.md","position":117,"original_position":117,"commit_id":"3b4697d79f077ce8c4d2edefea2508442537bbb5","original_commit_id":"3b4697d79f077ce8c4d2edefea2508442537bbb5","user":{"login":"luqunl","id":15055752,"node_id":"MDQ6VXNlcjE1MDU1NzUy","avatar_url":"https://avatars3.githubusercontent.com/u/15055752?v=4","gravatar_id":"","url":"https://api.github.com/users/luqunl","html_url":"https://github.com/luqunl","followers_url":"https://api.github.com/users/luqunl/followers","following_url":"https://api.github.com/users/luqunl/following{/other_user}","gists_url":"https://api.github.com/users/luqunl/gists{/gist_id}","starred_url":"https://api.github.com/users/luqunl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luqunl/subscriptions","organizations_url":"https://api.github.com/users/luqunl/orgs","repos_url":"https://api.github.com/users/luqunl/repos","events_url":"https://api.github.com/users/luqunl/events{/privacy}","received_events_url":"https://api.github.com/users/luqunl/received_events","type":"User","site_admin":false},"body":"> add a value to for the managed calling convention to CallingConvention enum\r\n\r\nAdd a new value in CallingConvention seems better than use two attributes. simpler and easy to understand.","created_at":"2018-07-10T19:23:59Z","updated_at":"2018-07-10T19:23:59Z","html_url":"https://github.com/dotnet/csharplang/pull/1685#discussion_r201464730","pull_request_url":"https://api.github.com/repos/dotnet/csharplang/pulls/1685","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dotnet/csharplang/pulls/comments/201464730"},"html":{"href":"https://github.com/dotnet/csharplang/pull/1685#discussion_r201464730"},"pull_request":{"href":"https://api.github.com/repos/dotnet/csharplang/pulls/1685"}},"in_reply_to_id":199390358},"pull_request":{"url":"https://api.github.com/repos/dotnet/csharplang/pulls/1685","id":198574785,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4NTc0Nzg1","html_url":"https://github.com/dotnet/csharplang/pull/1685","diff_url":"https://github.com/dotnet/csharplang/pull/1685.diff","patch_url":"https://github.com/dotnet/csharplang/pull/1685.patch","issue_url":"https://api.github.com/repos/dotnet/csharplang/issues/1685","number":1685,"state":"open","locked":false,"title":"Compiler intrinsics","user":{"login":"jaredpar","id":146967,"node_id":"MDQ6VXNlcjE0Njk2Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/146967?v=4","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false},"body":"This is an alternate proposal for the compiler intrinsicts feature:\r\n\r\nhttps://github.com/dotnet/csharplang/issues/191\r\nhttps://github.com/dotnet/roslyn/issues/11475\r\n\r\nThis alternate design proposal comes after reviewing a prototype implementation\r\nof the original proposal by @msjabby as well as the use throughout a significant\r\ncode base.\r\n\r\nThis design was done with significant input from @mjsabby, @tmat and @jkotas.","created_at":"2018-07-02T05:18:37Z","updated_at":"2018-07-10T19:23:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1e7afa01e3244c85353d28c2035f2bd891d3c1fe","assignee":{"login":"jaredpar","id":146967,"node_id":"MDQ6VXNlcjE0Njk2Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/146967?v=4","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false},"assignees":[{"login":"jaredpar","id":146967,"node_id":"MDQ6VXNlcjE0Njk2Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/146967?v=4","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/csharplang/pulls/1685/commits","review_comments_url":"https://api.github.com/repos/dotnet/csharplang/pulls/1685/comments","review_comment_url":"https://api.github.com/repos/dotnet/csharplang/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/csharplang/issues/1685/comments","statuses_url":"https://api.github.com/repos/dotnet/csharplang/statuses/3b4697d79f077ce8c4d2edefea2508442537bbb5","head":{"label":"jaredpar:fix-intrinsic","ref":"fix-intrinsic","sha":"3b4697d79f077ce8c4d2edefea2508442537bbb5","user":{"login":"jaredpar","id":146967,"node_id":"MDQ6VXNlcjE0Njk2Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/146967?v=4","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false},"repo":{"id":83361163,"node_id":"MDEwOlJlcG9zaXRvcnk4MzM2MTE2Mw==","name":"csharplang","full_name":"jaredpar/csharplang","owner":{"login":"jaredpar","id":146967,"node_id":"MDQ6VXNlcjE0Njk2Nw==","avatar_url":"https://avatars0.githubusercontent.com/u/146967?v=4","gravatar_id":"","url":"https://api.github.com/users/jaredpar","html_url":"https://github.com/jaredpar","followers_url":"https://api.github.com/users/jaredpar/followers","following_url":"https://api.github.com/users/jaredpar/following{/other_user}","gists_url":"https://api.github.com/users/jaredpar/gists{/gist_id}","starred_url":"https://api.github.com/users/jaredpar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaredpar/subscriptions","organizations_url":"https://api.github.com/users/jaredpar/orgs","repos_url":"https://api.github.com/users/jaredpar/repos","events_url":"https://api.github.com/users/jaredpar/events{/privacy}","received_events_url":"https://api.github.com/users/jaredpar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jaredpar/csharplang","description":"The official repo for the design of the C# programming language","fork":true,"url":"https://api.github.com/repos/jaredpar/csharplang","forks_url":"https://api.github.com/repos/jaredpar/csharplang/forks","keys_url":"https://api.github.com/repos/jaredpar/csharplang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jaredpar/csharplang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jaredpar/csharplang/teams","hooks_url":"https://api.github.com/repos/jaredpar/csharplang/hooks","issue_events_url":"https://api.github.com/repos/jaredpar/csharplang/issues/events{/number}","events_url":"https://api.github.com/repos/jaredpar/csharplang/events","assignees_url":"https://api.github.com/repos/jaredpar/csharplang/assignees{/user}","branches_url":"https://api.github.com/repos/jaredpar/csharplang/branches{/branch}","tags_url":"https://api.github.com/repos/jaredpar/csharplang/tags","blobs_url":"https://api.github.com/repos/jaredpar/csharplang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jaredpar/csharplang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jaredpar/csharplang/git/refs{/sha}","trees_url":"https://api.github.com/repos/jaredpar/csharplang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jaredpar/csharplang/statuses/{sha}","languages_url":"https://api.github.com/repos/jaredpar/csharplang/languages","stargazers_url":"https://api.github.com/repos/jaredpar/csharplang/stargazers","contributors_url":"https://api.github.com/repos/jaredpar/csharplang/contributors","subscribers_url":"https://api.github.com/repos/jaredpar/csharplang/subscribers","subscription_url":"https://api.github.com/repos/jaredpar/csharplang/subscription","commits_url":"https://api.github.com/repos/jaredpar/csharplang/commits{/sha}","git_commits_url":"https://api.github.com/repos/jaredpar/csharplang/git/commits{/sha}","comments_url":"https://api.github.com/repos/jaredpar/csharplang/comments{/number}","issue_comment_url":"https://api.github.com/repos/jaredpar/csharplang/issues/comments{/number}","contents_url":"https://api.github.com/repos/jaredpar/csharplang/contents/{+path}","compare_url":"https://api.github.com/repos/jaredpar/csharplang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jaredpar/csharplang/merges","archive_url":"https://api.github.com/repos/jaredpar/csharplang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jaredpar/csharplang/downloads","issues_url":"https://api.github.com/repos/jaredpar/csharplang/issues{/number}","pulls_url":"https://api.github.com/repos/jaredpar/csharplang/pulls{/number}","milestones_url":"https://api.github.com/repos/jaredpar/csharplang/milestones{/number}","notifications_url":"https://api.github.com/repos/jaredpar/csharplang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jaredpar/csharplang/labels{/name}","releases_url":"https://api.github.com/repos/jaredpar/csharplang/releases{/id}","deployments_url":"https://api.github.com/repos/jaredpar/csharplang/deployments","created_at":"2017-02-27T21:57:44Z","updated_at":"2018-05-01T15:08:13Z","pushed_at":"2018-07-09T14:10:47Z","git_url":"git://github.com/jaredpar/csharplang.git","ssh_url":"git@github.com:jaredpar/csharplang.git","clone_url":"https://github.com/jaredpar/csharplang.git","svn_url":"https://github.com/jaredpar/csharplang","homepage":"","size":1033,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"98043cdc889303d956d540d7ab3bc4f5044a9d3b","user":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":75990888,"node_id":"MDEwOlJlcG9zaXRvcnk3NTk5MDg4OA==","name":"csharplang","full_name":"dotnet/csharplang","owner":{"login":"dotnet","id":9141961,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkxNDE5NjE=","avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/csharplang","description":"The official repo for the design of the C# programming language","fork":false,"url":"https://api.github.com/repos/dotnet/csharplang","forks_url":"https://api.github.com/repos/dotnet/csharplang/forks","keys_url":"https://api.github.com/repos/dotnet/csharplang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/csharplang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/csharplang/teams","hooks_url":"https://api.github.com/repos/dotnet/csharplang/hooks","issue_events_url":"https://api.github.com/repos/dotnet/csharplang/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/csharplang/events","assignees_url":"https://api.github.com/repos/dotnet/csharplang/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/csharplang/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/csharplang/tags","blobs_url":"https://api.github.com/repos/dotnet/csharplang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/csharplang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/csharplang/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/csharplang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/csharplang/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/csharplang/languages","stargazers_url":"https://api.github.com/repos/dotnet/csharplang/stargazers","contributors_url":"https://api.github.com/repos/dotnet/csharplang/contributors","subscribers_url":"https://api.github.com/repos/dotnet/csharplang/subscribers","subscription_url":"https://api.github.com/repos/dotnet/csharplang/subscription","commits_url":"https://api.github.com/repos/dotnet/csharplang/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/csharplang/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/csharplang/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/csharplang/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/csharplang/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/csharplang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/csharplang/merges","archive_url":"https://api.github.com/repos/dotnet/csharplang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/csharplang/downloads","issues_url":"https://api.github.com/repos/dotnet/csharplang/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/csharplang/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/csharplang/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/csharplang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/csharplang/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/csharplang/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/csharplang/deployments","created_at":"2016-12-09T01:45:27Z","updated_at":"2018-07-10T16:41:32Z","pushed_at":"2018-07-10T00:10:07Z","git_url":"git://github.com/dotnet/csharplang.git","ssh_url":"git@github.com:dotnet/csharplang.git","clone_url":"https://github.com/dotnet/csharplang.git","svn_url":"https://github.com/dotnet/csharplang","homepage":"","size":1028,"stargazers_count":2913,"watchers_count":2913,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":290,"mirror_url":null,"archived":false,"open_issues_count":1092,"license":null,"forks":290,"open_issues":1092,"watchers":2913,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/csharplang/pulls/1685"},"html":{"href":"https://github.com/dotnet/csharplang/pull/1685"},"issue":{"href":"https://api.github.com/repos/dotnet/csharplang/issues/1685"},"comments":{"href":"https://api.github.com/repos/dotnet/csharplang/issues/1685/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/csharplang/pulls/1685/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/csharplang/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/csharplang/pulls/1685/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/csharplang/statuses/3b4697d79f077ce8c4d2edefea2508442537bbb5"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"luqunl"}}