{"action":"created","issue":{"url":"https://api.github.com/repos/scala-opt/scala/issues/14","labels_url":"https://api.github.com/repos/scala-opt/scala/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/scala-opt/scala/issues/14/comments","events_url":"https://api.github.com/repos/scala-opt/scala/issues/14/events","html_url":"https://github.com/scala-opt/scala/issues/14","id":58051891,"number":14,"title":"Closure inlining / elimination","user":{"login":"lrytz","id":119636,"avatar_url":"https://avatars.githubusercontent.com/u/119636?v=3","gravatar_id":"","url":"https://api.github.com/users/lrytz","html_url":"https://github.com/lrytz","followers_url":"https://api.github.com/users/lrytz/followers","following_url":"https://api.github.com/users/lrytz/following{/other_user}","gists_url":"https://api.github.com/users/lrytz/gists{/gist_id}","starred_url":"https://api.github.com/users/lrytz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrytz/subscriptions","organizations_url":"https://api.github.com/users/lrytz/orgs","repos_url":"https://api.github.com/users/lrytz/repos","events_url":"https://api.github.com/users/lrytz/events{/privacy}","received_events_url":"https://api.github.com/users/lrytz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/scala-opt/scala/labels/feature","name":"feature","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/scala-opt/scala/milestones/1","html_url":"https://github.com/scala-opt/scala/milestones/2.12.0-M2","labels_url":"https://api.github.com/repos/scala-opt/scala/milestones/1/labels","id":1135224,"number":1,"title":"2.12.0-M2","description":"","creator":{"login":"lrytz","id":119636,"avatar_url":"https://avatars.githubusercontent.com/u/119636?v=3","gravatar_id":"","url":"https://api.github.com/users/lrytz","html_url":"https://github.com/lrytz","followers_url":"https://api.github.com/users/lrytz/followers","following_url":"https://api.github.com/users/lrytz/following{/other_user}","gists_url":"https://api.github.com/users/lrytz/gists{/gist_id}","starred_url":"https://api.github.com/users/lrytz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrytz/subscriptions","organizations_url":"https://api.github.com/users/lrytz/orgs","repos_url":"https://api.github.com/users/lrytz/repos","events_url":"https://api.github.com/users/lrytz/events{/privacy}","received_events_url":"https://api.github.com/users/lrytz/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":0,"state":"open","created_at":"2015-05-27T05:57:44Z","updated_at":"2015-05-27T06:04:08Z","due_on":"2015-06-28T22:00:00Z","closed_at":null},"comments":2,"created_at":"2015-02-18T10:42:18Z","updated_at":"2015-05-29T09:12:03Z","closed_at":null,"body":"After inlining a higer-order function, inline the closure body. Enables further optimizations such as #11.\r\n\r\nInlining the closure apply should be straightforward when #13 is done.\r\n\r\nAfter that it would be nice to avoid emitting unnecessary closure classes. Note that with `InDy+LambdaMetaFactory`, we don't actually emit closure classes anymore, so it's simply a matter of removing the lambda body method if it's unused."},"comment":{"url":"https://api.github.com/repos/scala-opt/scala/issues/comments/106752517","html_url":"https://github.com/scala-opt/scala/issues/14#issuecomment-106752517","issue_url":"https://api.github.com/repos/scala-opt/scala/issues/14","id":106752517,"user":{"login":"lrytz","id":119636,"avatar_url":"https://avatars.githubusercontent.com/u/119636?v=3","gravatar_id":"","url":"https://api.github.com/users/lrytz","html_url":"https://github.com/lrytz","followers_url":"https://api.github.com/users/lrytz/followers","following_url":"https://api.github.com/users/lrytz/following{/other_user}","gists_url":"https://api.github.com/users/lrytz/gists{/gist_id}","starred_url":"https://api.github.com/users/lrytz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrytz/subscriptions","organizations_url":"https://api.github.com/users/lrytz/orgs","repos_url":"https://api.github.com/users/lrytz/repos","events_url":"https://api.github.com/users/lrytz/events{/privacy}","received_events_url":"https://api.github.com/users/lrytz/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T09:12:03Z","updated_at":"2015-05-29T09:12:03Z","body":"Indy Bytecode explained (as printed by asm\r\n\r\n```\r\n// load captured values onto the stack\r\nALOAD 1\r\n\r\n// name of the abstract method in the SAM (\"apply\")\r\n// signature of the actuall call: what is consumed from the stack, what is produced.\r\n// the consumed values correspond to the captured state, the result type is the SAM.\r\nINVOKEDYNAMIC apply(Ljava/lang/String;)Lscala/compat/java8/JFunction1; [\r\n\r\n// the kind of the method handle. altMetafactory is a static method. https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.8\r\n  // handle kind 0x6 : INVOKESTATIC\r\n\r\n// the method referenced in the method handle\r\n  java/lang/invoke/LambdaMetafactory.altMetafactory(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;\r\n\r\n// the arguments to altmetafactory, see https://docs.oracle.com/javase/8/docs/api/java/lang/invoke/LambdaMetafactory.html#altMetafactory-java.lang.invoke.MethodHandles.Lookup-java.lang.String-java.lang.invoke.MethodType-java.lang.Object...-\r\n  // arguments:\r\n  (Ljava/lang/Object;)Ljava/lang/Object;, \r\n  // handle kind 0x6 : INVOKESTATIC\r\n  C.C$$$anonfun$1(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;, \r\n  (Ljava/lang/Object;)Ljava/lang/String;, \r\n  3, \r\n  1, \r\n  Lscala/Serializable;.class, \r\n  0\r\n]\r\n\r\n// cast to Function1 - that's the type we expect for scala functions.\r\nCHECKCAST scala/Function1\r\n```"}}