{"action":"created","comment":{"url":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments/35028269","id":35028269,"diff_hunk":"@@ -45,11 +229,268 @@ static void insertWideCastTemps();\n static void derefWideStringActuals();\n static void derefWideRefsToWideClasses();\n static void widenGetPrivClass();\n+static void moveAddressSourcesToTemp();\n+static void fixAST();\n \n-AggregateType* wideStringType = NULL;\n+//\n+// Miscellaneous utility functions to help manage the AST\n+//\n \n-static void\n-buildWideClass(Type* type) {\n+static bool isFullyWide(BaseAST* bs) {\n+  return bs->typeInfo()->symbol->hasEitherFlag(FLAG_WIDE_CLASS, FLAG_WIDE_REF);\n+}\n+\n+static bool valIsWideClass(BaseAST* bs) {\n+  return bs->getValType()->symbol->hasFlag(FLAG_WIDE_CLASS);\n+}\n+\n+static Type* getNarrowType(BaseAST* bs) {\n+  //\n+  // TODO: This should really return a completely narrow ref, and not\n+  // a ref to a wide class.\n+  //\n+  if (isFullyWide(bs)) {\n+    return bs->typeInfo()->getField(\"addr\")->typeInfo();\n+  }\n+  else {\n+    return bs->typeInfo();\n+  }\n+}\n+\n+static bool hasSomeWideness(Symbol* sym) {\n+  return isFullyWide(sym) || valIsWideClass(sym);\n+}\n+\n+static bool isRef(BaseAST* bs) {\n+  return bs->typeInfo()->symbol->hasEitherFlag(FLAG_REF, FLAG_WIDE_REF);\n+}\n+\n+static bool isObj(BaseAST* bs) {\n+  return (isClass(bs->typeInfo()) && !isRef(bs)) || bs->typeInfo()->symbol->hasFlag(FLAG_WIDE_CLASS);\n+}\n+\n+static bool typeCanBeWide(Symbol *sym) {\n+  TypeSymbol* ts = sym->type->symbol;\n+  bool bad = sym->hasFlag(FLAG_EXTERN) ||\n+              ts->hasFlag(FLAG_NO_WIDE_CLASS) ||\n+              (!isFullyWide(sym) && isRecord(sym->type));\n+\n+  return !bad &&\n+         (isObj(sym) ||\n+          isRef(sym) ||\n+          ts->hasFlag(FLAG_DATA_CLASS) ||\n+          sym->type == dtString);","path":"compiler/passes/insertWideReferences.cpp","position":269,"original_position":269,"commit_id":"62d159b806c8a1af255ac7bf4ad99f9b7a72be28","original_commit_id":"62d159b806c8a1af255ac7bf4ad99f9b7a72be28","user":{"login":"hildeth","id":7853742,"avatar_url":"https://avatars.githubusercontent.com/u/7853742?v=3","gravatar_id":"","url":"https://api.github.com/users/hildeth","html_url":"https://github.com/hildeth","followers_url":"https://api.github.com/users/hildeth/followers","following_url":"https://api.github.com/users/hildeth/following{/other_user}","gists_url":"https://api.github.com/users/hildeth/gists{/gist_id}","starred_url":"https://api.github.com/users/hildeth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hildeth/subscriptions","organizations_url":"https://api.github.com/users/hildeth/orgs","repos_url":"https://api.github.com/users/hildeth/repos","events_url":"https://api.github.com/users/hildeth/events{/privacy}","received_events_url":"https://api.github.com/users/hildeth/received_events","type":"User","site_admin":false},"body":"Special treatment of dtString will also be removed.","created_at":"2015-07-20T18:38:43Z","updated_at":"2015-07-20T18:38:43Z","html_url":"https://github.com/chapel-lang/chapel/pull/2178#discussion_r35028269","pull_request_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/2178","_links":{"self":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments/35028269"},"html":{"href":"https://github.com/chapel-lang/chapel/pull/2178#discussion_r35028269"},"pull_request":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/2178"}}},"pull_request":{"url":"https://api.github.com/repos/chapel-lang/chapel/pulls/2178","id":40271330,"html_url":"https://github.com/chapel-lang/chapel/pull/2178","diff_url":"https://github.com/chapel-lang/chapel/pull/2178.diff","patch_url":"https://github.com/chapel-lang/chapel/pull/2178.patch","issue_url":"https://api.github.com/repos/chapel-lang/chapel/issues/2178","number":2178,"state":"open","locked":false,"title":"New implementation of insertWideReferences","user":{"login":"benharsh","id":1883119,"avatar_url":"https://avatars.githubusercontent.com/u/1883119?v=3","gravatar_id":"","url":"https://api.github.com/users/benharsh","html_url":"https://github.com/benharsh","followers_url":"https://api.github.com/users/benharsh/followers","following_url":"https://api.github.com/users/benharsh/following{/other_user}","gists_url":"https://api.github.com/users/benharsh/gists{/gist_id}","starred_url":"https://api.github.com/users/benharsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benharsh/subscriptions","organizations_url":"https://api.github.com/users/benharsh/orgs","repos_url":"https://api.github.com/users/benharsh/repos","events_url":"https://api.github.com/users/benharsh/events{/privacy}","received_events_url":"https://api.github.com/users/benharsh/received_events","type":"User","site_admin":false},"body":"This patch includes a new implementation that merges the two passes previously responsible for inserting wide pointers (insertWideReferences and narrowWideReferences).\r\n\r\nThis new implementation lives in only one pass: insertWideReferences.\r\n\r\nThe previous two passes behaved somewhat like this:\r\n1) Make everything is a wide pointer\r\n2) Based on how they're used, some things don't need to be a wide pointer.\r\n\r\nThe second pass (narrowWideReferences) essentially existed to try and undo the naive insertion done by the previous pass. The second pass also took the approach of using a directed graph to represent the dependencies that could cause a variable to be wide.\r\n\r\nI think that a better solution is to take an opposite stance with regard to default-wideness. Instead of widening everything from the start, my new pass only widens a relative handful of variables that absolutely need to be wide. From this set of wide variables, we will process the expressions in which they are used and potentially widen other variables. These newly-widened variables are then added to our set, and will also have their uses processed. When the set is empty, all necessarily-wide variables have been widened. This is a small step towards a more re-entrant style, which I think is ultimately desirable for this kind of pass.\r\n\r\nWith this strategy, narrow/local variables will be left untouched. All that's left to do is to insert some temporary variables here and there to make codegen happy.\r\n\r\nUltimately, I think this approach will make future development of this pass easier. It's much easier to never widen something than to try and make it narrow later.\r\n\r\nThis new pass doesn't fix all of our problems. In most cases, it will widen the same things as the old two-pass approach. That said, there are a couple of improvements that may or may not improve performance:\r\n  - ref fields in a coforall arg bundle have a better chance of being narrow\r\n  - module-scope locale-private variables aren't automatically widened if read in an on-statement\r\n\r\nI have also written a number of utility functions that should make life a bit easier for developers.\r\n\r\nThere's still a lot of work to be done to improve performance, but ultimately I think that rewriting this pass provides a better infrastructure for future optimizations.","created_at":"2015-07-17T21:04:20Z","updated_at":"2015-07-20T18:38:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2126d28f6fe201cd8c0600caeab59a23a664b1d7","assignee":{"login":"hildeth","id":7853742,"avatar_url":"https://avatars.githubusercontent.com/u/7853742?v=3","gravatar_id":"","url":"https://api.github.com/users/hildeth","html_url":"https://github.com/hildeth","followers_url":"https://api.github.com/users/hildeth/followers","following_url":"https://api.github.com/users/hildeth/following{/other_user}","gists_url":"https://api.github.com/users/hildeth/gists{/gist_id}","starred_url":"https://api.github.com/users/hildeth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hildeth/subscriptions","organizations_url":"https://api.github.com/users/hildeth/orgs","repos_url":"https://api.github.com/users/hildeth/repos","events_url":"https://api.github.com/users/hildeth/events{/privacy}","received_events_url":"https://api.github.com/users/hildeth/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/2178/commits","review_comments_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/2178/comments","review_comment_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chapel-lang/chapel/issues/2178/comments","statuses_url":"https://api.github.com/repos/chapel-lang/chapel/statuses/62d159b806c8a1af255ac7bf4ad99f9b7a72be28","head":{"label":"benharsh:merge-wide-passes","ref":"merge-wide-passes","sha":"62d159b806c8a1af255ac7bf4ad99f9b7a72be28","user":{"login":"benharsh","id":1883119,"avatar_url":"https://avatars.githubusercontent.com/u/1883119?v=3","gravatar_id":"","url":"https://api.github.com/users/benharsh","html_url":"https://github.com/benharsh","followers_url":"https://api.github.com/users/benharsh/followers","following_url":"https://api.github.com/users/benharsh/following{/other_user}","gists_url":"https://api.github.com/users/benharsh/gists{/gist_id}","starred_url":"https://api.github.com/users/benharsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benharsh/subscriptions","organizations_url":"https://api.github.com/users/benharsh/orgs","repos_url":"https://api.github.com/users/benharsh/repos","events_url":"https://api.github.com/users/benharsh/events{/privacy}","received_events_url":"https://api.github.com/users/benharsh/received_events","type":"User","site_admin":false},"repo":{"id":21908961,"name":"chapel","full_name":"benharsh/chapel","owner":{"login":"benharsh","id":1883119,"avatar_url":"https://avatars.githubusercontent.com/u/1883119?v=3","gravatar_id":"","url":"https://api.github.com/users/benharsh","html_url":"https://github.com/benharsh","followers_url":"https://api.github.com/users/benharsh/followers","following_url":"https://api.github.com/users/benharsh/following{/other_user}","gists_url":"https://api.github.com/users/benharsh/gists{/gist_id}","starred_url":"https://api.github.com/users/benharsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benharsh/subscriptions","organizations_url":"https://api.github.com/users/benharsh/orgs","repos_url":"https://api.github.com/users/benharsh/repos","events_url":"https://api.github.com/users/benharsh/events{/privacy}","received_events_url":"https://api.github.com/users/benharsh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/benharsh/chapel","description":"a Productive Parallel Programming Language","fork":true,"url":"https://api.github.com/repos/benharsh/chapel","forks_url":"https://api.github.com/repos/benharsh/chapel/forks","keys_url":"https://api.github.com/repos/benharsh/chapel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/benharsh/chapel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/benharsh/chapel/teams","hooks_url":"https://api.github.com/repos/benharsh/chapel/hooks","issue_events_url":"https://api.github.com/repos/benharsh/chapel/issues/events{/number}","events_url":"https://api.github.com/repos/benharsh/chapel/events","assignees_url":"https://api.github.com/repos/benharsh/chapel/assignees{/user}","branches_url":"https://api.github.com/repos/benharsh/chapel/branches{/branch}","tags_url":"https://api.github.com/repos/benharsh/chapel/tags","blobs_url":"https://api.github.com/repos/benharsh/chapel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/benharsh/chapel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/benharsh/chapel/git/refs{/sha}","trees_url":"https://api.github.com/repos/benharsh/chapel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/benharsh/chapel/statuses/{sha}","languages_url":"https://api.github.com/repos/benharsh/chapel/languages","stargazers_url":"https://api.github.com/repos/benharsh/chapel/stargazers","contributors_url":"https://api.github.com/repos/benharsh/chapel/contributors","subscribers_url":"https://api.github.com/repos/benharsh/chapel/subscribers","subscription_url":"https://api.github.com/repos/benharsh/chapel/subscription","commits_url":"https://api.github.com/repos/benharsh/chapel/commits{/sha}","git_commits_url":"https://api.github.com/repos/benharsh/chapel/git/commits{/sha}","comments_url":"https://api.github.com/repos/benharsh/chapel/comments{/number}","issue_comment_url":"https://api.github.com/repos/benharsh/chapel/issues/comments{/number}","contents_url":"https://api.github.com/repos/benharsh/chapel/contents/{+path}","compare_url":"https://api.github.com/repos/benharsh/chapel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/benharsh/chapel/merges","archive_url":"https://api.github.com/repos/benharsh/chapel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/benharsh/chapel/downloads","issues_url":"https://api.github.com/repos/benharsh/chapel/issues{/number}","pulls_url":"https://api.github.com/repos/benharsh/chapel/pulls{/number}","milestones_url":"https://api.github.com/repos/benharsh/chapel/milestones{/number}","notifications_url":"https://api.github.com/repos/benharsh/chapel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/benharsh/chapel/labels{/name}","releases_url":"https://api.github.com/repos/benharsh/chapel/releases{/id}","created_at":"2014-07-16T16:46:13Z","updated_at":"2015-03-02T21:09:24Z","pushed_at":"2015-07-17T23:19:20Z","git_url":"git://github.com/benharsh/chapel.git","ssh_url":"git@github.com:benharsh/chapel.git","clone_url":"https://github.com/benharsh/chapel.git","svn_url":"https://github.com/benharsh/chapel","homepage":"http://chapel.cray.com/","size":308537,"stargazers_count":1,"watchers_count":1,"language":"Chapel","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"chapel-lang:master","ref":"master","sha":"7c2aff45139a4cef37a3cfa0c3279a856bd004e6","user":{"login":"chapel-lang","id":7597261,"avatar_url":"https://avatars.githubusercontent.com/u/7597261?v=3","gravatar_id":"","url":"https://api.github.com/users/chapel-lang","html_url":"https://github.com/chapel-lang","followers_url":"https://api.github.com/users/chapel-lang/followers","following_url":"https://api.github.com/users/chapel-lang/following{/other_user}","gists_url":"https://api.github.com/users/chapel-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/chapel-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chapel-lang/subscriptions","organizations_url":"https://api.github.com/users/chapel-lang/orgs","repos_url":"https://api.github.com/users/chapel-lang/repos","events_url":"https://api.github.com/users/chapel-lang/events{/privacy}","received_events_url":"https://api.github.com/users/chapel-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":21663285,"name":"chapel","full_name":"chapel-lang/chapel","owner":{"login":"chapel-lang","id":7597261,"avatar_url":"https://avatars.githubusercontent.com/u/7597261?v=3","gravatar_id":"","url":"https://api.github.com/users/chapel-lang","html_url":"https://github.com/chapel-lang","followers_url":"https://api.github.com/users/chapel-lang/followers","following_url":"https://api.github.com/users/chapel-lang/following{/other_user}","gists_url":"https://api.github.com/users/chapel-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/chapel-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chapel-lang/subscriptions","organizations_url":"https://api.github.com/users/chapel-lang/orgs","repos_url":"https://api.github.com/users/chapel-lang/repos","events_url":"https://api.github.com/users/chapel-lang/events{/privacy}","received_events_url":"https://api.github.com/users/chapel-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chapel-lang/chapel","description":"a Productive Parallel Programming Language","fork":false,"url":"https://api.github.com/repos/chapel-lang/chapel","forks_url":"https://api.github.com/repos/chapel-lang/chapel/forks","keys_url":"https://api.github.com/repos/chapel-lang/chapel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chapel-lang/chapel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chapel-lang/chapel/teams","hooks_url":"https://api.github.com/repos/chapel-lang/chapel/hooks","issue_events_url":"https://api.github.com/repos/chapel-lang/chapel/issues/events{/number}","events_url":"https://api.github.com/repos/chapel-lang/chapel/events","assignees_url":"https://api.github.com/repos/chapel-lang/chapel/assignees{/user}","branches_url":"https://api.github.com/repos/chapel-lang/chapel/branches{/branch}","tags_url":"https://api.github.com/repos/chapel-lang/chapel/tags","blobs_url":"https://api.github.com/repos/chapel-lang/chapel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chapel-lang/chapel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chapel-lang/chapel/git/refs{/sha}","trees_url":"https://api.github.com/repos/chapel-lang/chapel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chapel-lang/chapel/statuses/{sha}","languages_url":"https://api.github.com/repos/chapel-lang/chapel/languages","stargazers_url":"https://api.github.com/repos/chapel-lang/chapel/stargazers","contributors_url":"https://api.github.com/repos/chapel-lang/chapel/contributors","subscribers_url":"https://api.github.com/repos/chapel-lang/chapel/subscribers","subscription_url":"https://api.github.com/repos/chapel-lang/chapel/subscription","commits_url":"https://api.github.com/repos/chapel-lang/chapel/commits{/sha}","git_commits_url":"https://api.github.com/repos/chapel-lang/chapel/git/commits{/sha}","comments_url":"https://api.github.com/repos/chapel-lang/chapel/comments{/number}","issue_comment_url":"https://api.github.com/repos/chapel-lang/chapel/issues/comments{/number}","contents_url":"https://api.github.com/repos/chapel-lang/chapel/contents/{+path}","compare_url":"https://api.github.com/repos/chapel-lang/chapel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chapel-lang/chapel/merges","archive_url":"https://api.github.com/repos/chapel-lang/chapel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chapel-lang/chapel/downloads","issues_url":"https://api.github.com/repos/chapel-lang/chapel/issues{/number}","pulls_url":"https://api.github.com/repos/chapel-lang/chapel/pulls{/number}","milestones_url":"https://api.github.com/repos/chapel-lang/chapel/milestones{/number}","notifications_url":"https://api.github.com/repos/chapel-lang/chapel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chapel-lang/chapel/labels{/name}","releases_url":"https://api.github.com/repos/chapel-lang/chapel/releases{/id}","created_at":"2014-07-09T18:15:54Z","updated_at":"2015-07-18T15:06:37Z","pushed_at":"2015-07-18T01:11:51Z","git_url":"git://github.com/chapel-lang/chapel.git","ssh_url":"git@github.com:chapel-lang/chapel.git","clone_url":"https://github.com/chapel-lang/chapel.git","svn_url":"https://github.com/chapel-lang/chapel","homepage":"http://chapel.cray.com/","size":437871,"stargazers_count":127,"watchers_count":127,"language":"Chapel","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":48,"mirror_url":null,"open_issues_count":7,"forks":48,"open_issues":7,"watchers":127,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/2178"},"html":{"href":"https://github.com/chapel-lang/chapel/pull/2178"},"issue":{"href":"https://api.github.com/repos/chapel-lang/chapel/issues/2178"},"comments":{"href":"https://api.github.com/repos/chapel-lang/chapel/issues/2178/comments"},"review_comments":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/2178/comments"},"review_comment":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/2178/commits"},"statuses":{"href":"https://api.github.com/repos/chapel-lang/chapel/statuses/62d159b806c8a1af255ac7bf4ad99f9b7a72be28"}}}}