{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/63045869","id":63045869,"diff_hunk":"@@ -2042,4 +2054,353 @@ void SizePolicy::DetermineProfitability(CORINFO_METHOD_INFO* methodInfo)\n     return;\n }\n \n+bool  ReplayPolicy::s_WroteReplayBanner = false;\n+FILE* ReplayPolicy::s_ReplayFile = nullptr;\n+\n+//------------------------------------------------------------------------/\n+// ReplayPolicy: construct a new ReplayPolicy\n+//\n+// Arguments:\n+//    compiler -- compiler instance doing the inlining (root compiler)\n+//    inlineContext -- inline context for the inline\n+//    isPrejitRoot -- true if this compiler is prejitting the root method\n+\n+ReplayPolicy::ReplayPolicy(Compiler* compiler, InlineContext* inlineContext, bool isPrejitRoot)\n+    : DiscretionaryPolicy(compiler, isPrejitRoot)\n+    , m_InlineContext(inlineContext)\n+{\n+    // Is there a log file open already? If so, we can use it.\n+    if (s_ReplayFile == nullptr)\n+    {\n+        // Did we already try and open and fail?\n+        if (!s_WroteReplayBanner)\n+        {\n+            // Nope, open it up.\n+            const wchar_t* replayFileName = JitConfig.JitInlineReplayFile();\n+            s_ReplayFile = _wfopen(replayFileName, W(\"r\"));\n+            fprintf(stderr, \"*** %s inlines from %ws\",\n+                    s_ReplayFile == nullptr ? \"Unable to replay\" : \"Replaying\",\n+                    replayFileName);\n+            s_WroteReplayBanner = true;\n+        }\n+    }\n+}\n+\n+//------------------------------------------------------------------------\n+// FindMethod: find the root method in the inline Xml\n+//\n+// ReturnValue:\n+//    true if found. File position left pointing just after the\n+//    <Token> entry for the method.\n+\n+bool ReplayPolicy::FindMethod()\n+{\n+    const mdMethodDef methodToken =\n+        m_RootCompiler->info.compCompHnd->getMethodDefFromMethod(\n+            m_RootCompiler->info.compMethodHnd);\n+    const unsigned methodHash =\n+        m_RootCompiler->info.compMethodHash();\n+\n+    if (s_ReplayFile == nullptr)\n+    {\n+        return false;\n+    }\n+\n+    bool foundMethod = false;\n+    char buffer[256];\n+    fseek(s_ReplayFile, 0, SEEK_SET);\n+\n+    while (!foundMethod)\n+    {\n+        // Get next line\n+        if (!fgets(buffer, sizeof(buffer), s_ReplayFile))\n+        {\n+            break;\n+        }\n+\n+        // Look for next method entry\n+        if (!strstr(buffer, \"<Method>\"))","path":"src/jit/inlinepolicy.cpp","position":129,"original_position":129,"commit_id":"92dbbf5da611a730d5fc473d2c67719b76359b5c","original_commit_id":"92dbbf5da611a730d5fc473d2c67719b76359b5c","user":{"login":"kyulee1","id":10963908,"avatar_url":"https://avatars.githubusercontent.com/u/10963908?v=3","gravatar_id":"","url":"https://api.github.com/users/kyulee1","html_url":"https://github.com/kyulee1","followers_url":"https://api.github.com/users/kyulee1/followers","following_url":"https://api.github.com/users/kyulee1/following{/other_user}","gists_url":"https://api.github.com/users/kyulee1/gists{/gist_id}","starred_url":"https://api.github.com/users/kyulee1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyulee1/subscriptions","organizations_url":"https://api.github.com/users/kyulee1/orgs","repos_url":"https://api.github.com/users/kyulee1/repos","events_url":"https://api.github.com/users/kyulee1/events{/privacy}","received_events_url":"https://api.github.com/users/kyulee1/received_events","type":"User","site_admin":false},"body":"Should we check `== nullptr` per convention? Maybe the same thing in others like fgets.","created_at":"2016-05-12T15:54:01Z","updated_at":"2016-05-12T15:54:01Z","html_url":"https://github.com/dotnet/coreclr/pull/4921#discussion_r63045869","pull_request_url":"https://api.github.com/repos/dotnet/coreclr/pulls/4921","_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments/63045869"},"html":{"href":"https://github.com/dotnet/coreclr/pull/4921#discussion_r63045869"},"pull_request":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/4921"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/coreclr/pulls/4921","id":69755481,"html_url":"https://github.com/dotnet/coreclr/pull/4921","diff_url":"https://github.com/dotnet/coreclr/pull/4921.diff","patch_url":"https://github.com/dotnet/coreclr/pull/4921.patch","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/4921","number":4921,"state":"open","locked":false,"title":"Inliner: introduce ReplayPolicy","user":{"login":"AndyAyersMS","id":10121823,"avatar_url":"https://avatars.githubusercontent.com/u/10121823?v=3","gravatar_id":"","url":"https://api.github.com/users/AndyAyersMS","html_url":"https://github.com/AndyAyersMS","followers_url":"https://api.github.com/users/AndyAyersMS/followers","following_url":"https://api.github.com/users/AndyAyersMS/following{/other_user}","gists_url":"https://api.github.com/users/AndyAyersMS/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyAyersMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyAyersMS/subscriptions","organizations_url":"https://api.github.com/users/AndyAyersMS/orgs","repos_url":"https://api.github.com/users/AndyAyersMS/repos","events_url":"https://api.github.com/users/AndyAyersMS/events{/privacy}","received_events_url":"https://api.github.com/users/AndyAyersMS/received_events","type":"User","site_admin":false},"body":"The ReplayPolicy reads an external script to determine which inlines\r\nto perform. The script is the same Xml syntax that's produced by\r\nthe inliner when JitInlineDumpXml is enabled. This format can be edited\r\nby hand or tool to force particular inlining patterns to occur. Methods\r\nor calls sites not mentioned in the script are considered as noinline.\r\n\r\nThere's a bunch of work still left to make this fully robust, but in\r\ntesting it works well enough for my immediate use case that I'll hold\r\noff on further polish until it's needed. But, for future reference,\r\nhere's a laundry list:\r\n\r\n* Need better ways to identify methods. Token and hash are not enough.\r\n* Need better ways to identify call sites. Callee token is not enough.\r\n* Consider preparsing or mapping the script into memory.\r\n* Consider caching node positions in the InlineContexts.\r\n* Make it robust for multithreading.\r\n* Handle the prejit root case somehow.\r\n* Possibly allow overriding of inline attributes.","created_at":"2016-05-11T22:53:30Z","updated_at":"2016-05-12T15:54:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a318fb507cec71d6f70fd94822eb965ad7b1cef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/coreclr/pulls/4921/commits","review_comments_url":"https://api.github.com/repos/dotnet/coreclr/pulls/4921/comments","review_comment_url":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/4921/comments","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/92dbbf5da611a730d5fc473d2c67719b76359b5c","head":{"label":"AndyAyersMS:InlineReplay","ref":"InlineReplay","sha":"92dbbf5da611a730d5fc473d2c67719b76359b5c","user":{"login":"AndyAyersMS","id":10121823,"avatar_url":"https://avatars.githubusercontent.com/u/10121823?v=3","gravatar_id":"","url":"https://api.github.com/users/AndyAyersMS","html_url":"https://github.com/AndyAyersMS","followers_url":"https://api.github.com/users/AndyAyersMS/followers","following_url":"https://api.github.com/users/AndyAyersMS/following{/other_user}","gists_url":"https://api.github.com/users/AndyAyersMS/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyAyersMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyAyersMS/subscriptions","organizations_url":"https://api.github.com/users/AndyAyersMS/orgs","repos_url":"https://api.github.com/users/AndyAyersMS/repos","events_url":"https://api.github.com/users/AndyAyersMS/events{/privacy}","received_events_url":"https://api.github.com/users/AndyAyersMS/received_events","type":"User","site_admin":false},"repo":{"id":34692475,"name":"coreclr","full_name":"AndyAyersMS/coreclr","owner":{"login":"AndyAyersMS","id":10121823,"avatar_url":"https://avatars.githubusercontent.com/u/10121823?v=3","gravatar_id":"","url":"https://api.github.com/users/AndyAyersMS","html_url":"https://github.com/AndyAyersMS","followers_url":"https://api.github.com/users/AndyAyersMS/followers","following_url":"https://api.github.com/users/AndyAyersMS/following{/other_user}","gists_url":"https://api.github.com/users/AndyAyersMS/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyAyersMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyAyersMS/subscriptions","organizations_url":"https://api.github.com/users/AndyAyersMS/orgs","repos_url":"https://api.github.com/users/AndyAyersMS/repos","events_url":"https://api.github.com/users/AndyAyersMS/events{/privacy}","received_events_url":"https://api.github.com/users/AndyAyersMS/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AndyAyersMS/coreclr","description":"This repo contains the .NET Core runtime, called CoreCLR, and the base library, called mscorlib. It includes the garbage collector, JIT compiler, base .NET data types and many low-level classes.","fork":true,"url":"https://api.github.com/repos/AndyAyersMS/coreclr","forks_url":"https://api.github.com/repos/AndyAyersMS/coreclr/forks","keys_url":"https://api.github.com/repos/AndyAyersMS/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AndyAyersMS/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AndyAyersMS/coreclr/teams","hooks_url":"https://api.github.com/repos/AndyAyersMS/coreclr/hooks","issue_events_url":"https://api.github.com/repos/AndyAyersMS/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/AndyAyersMS/coreclr/events","assignees_url":"https://api.github.com/repos/AndyAyersMS/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/AndyAyersMS/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/AndyAyersMS/coreclr/tags","blobs_url":"https://api.github.com/repos/AndyAyersMS/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AndyAyersMS/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AndyAyersMS/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/AndyAyersMS/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AndyAyersMS/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/AndyAyersMS/coreclr/languages","stargazers_url":"https://api.github.com/repos/AndyAyersMS/coreclr/stargazers","contributors_url":"https://api.github.com/repos/AndyAyersMS/coreclr/contributors","subscribers_url":"https://api.github.com/repos/AndyAyersMS/coreclr/subscribers","subscription_url":"https://api.github.com/repos/AndyAyersMS/coreclr/subscription","commits_url":"https://api.github.com/repos/AndyAyersMS/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/AndyAyersMS/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/AndyAyersMS/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/AndyAyersMS/coreclr/issues/comments{/number}","contents_url":"https://api.github.com/repos/AndyAyersMS/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/AndyAyersMS/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AndyAyersMS/coreclr/merges","archive_url":"https://api.github.com/repos/AndyAyersMS/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AndyAyersMS/coreclr/downloads","issues_url":"https://api.github.com/repos/AndyAyersMS/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/AndyAyersMS/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/AndyAyersMS/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/AndyAyersMS/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AndyAyersMS/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/AndyAyersMS/coreclr/releases{/id}","deployments_url":"https://api.github.com/repos/AndyAyersMS/coreclr/deployments","created_at":"2015-04-27T21:34:06Z","updated_at":"2016-02-11T00:27:03Z","pushed_at":"2016-05-11T22:48:47Z","git_url":"git://github.com/AndyAyersMS/coreclr.git","ssh_url":"git@github.com:AndyAyersMS/coreclr.git","clone_url":"https://github.com/AndyAyersMS/coreclr.git","svn_url":"https://github.com/AndyAyersMS/coreclr","homepage":"","size":79312,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"c18fe80d0d43cccb1aa7214e9bc446711520d0c7","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","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":30092893,"name":"coreclr","full_name":"dotnet/coreclr","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","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/coreclr","description":"This repo contains the .NET Core runtime, called CoreCLR, and the base library, called mscorlib. It includes the garbage collector, JIT compiler, base .NET data types and many low-level classes.","fork":false,"url":"https://api.github.com/repos/dotnet/coreclr","forks_url":"https://api.github.com/repos/dotnet/coreclr/forks","keys_url":"https://api.github.com/repos/dotnet/coreclr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/coreclr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/coreclr/teams","hooks_url":"https://api.github.com/repos/dotnet/coreclr/hooks","issue_events_url":"https://api.github.com/repos/dotnet/coreclr/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/coreclr/events","assignees_url":"https://api.github.com/repos/dotnet/coreclr/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/coreclr/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/coreclr/tags","blobs_url":"https://api.github.com/repos/dotnet/coreclr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/coreclr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/coreclr/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/coreclr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/coreclr/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/coreclr/languages","stargazers_url":"https://api.github.com/repos/dotnet/coreclr/stargazers","contributors_url":"https://api.github.com/repos/dotnet/coreclr/contributors","subscribers_url":"https://api.github.com/repos/dotnet/coreclr/subscribers","subscription_url":"https://api.github.com/repos/dotnet/coreclr/subscription","commits_url":"https://api.github.com/repos/dotnet/coreclr/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/coreclr/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/coreclr/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/coreclr/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/coreclr/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/coreclr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/coreclr/merges","archive_url":"https://api.github.com/repos/dotnet/coreclr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/coreclr/downloads","issues_url":"https://api.github.com/repos/dotnet/coreclr/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/coreclr/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/coreclr/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/coreclr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/coreclr/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/coreclr/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/coreclr/deployments","created_at":"2015-01-30T22:10:02Z","updated_at":"2016-05-12T15:18:33Z","pushed_at":"2016-05-12T15:46:54Z","git_url":"git://github.com/dotnet/coreclr.git","ssh_url":"git@github.com:dotnet/coreclr.git","clone_url":"https://github.com/dotnet/coreclr.git","svn_url":"https://github.com/dotnet/coreclr","homepage":"http://dotnet.github.io/","size":86302,"stargazers_count":6335,"watchers_count":6335,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1437,"mirror_url":null,"open_issues_count":788,"forks":1437,"open_issues":788,"watchers":6335,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/4921"},"html":{"href":"https://github.com/dotnet/coreclr/pull/4921"},"issue":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/4921"},"comments":{"href":"https://api.github.com/repos/dotnet/coreclr/issues/4921/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/4921/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/coreclr/pulls/4921/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/coreclr/statuses/92dbbf5da611a730d5fc473d2c67719b76359b5c"}}}}