{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla/j2me.js/issues/1312","labels_url":"https://api.github.com/repos/mozilla/j2me.js/issues/1312/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/j2me.js/issues/1312/comments","events_url":"https://api.github.com/repos/mozilla/j2me.js/issues/1312/events","html_url":"https://github.com/mozilla/j2me.js/pull/1312","id":64326963,"number":1312,"title":"WIP: Use Soot to optimize classes.jar bytecode","user":{"login":"marco-c","id":1616846,"avatar_url":"https://avatars.githubusercontent.com/u/1616846?v=3","gravatar_id":"","url":"https://api.github.com/users/marco-c","html_url":"https://github.com/marco-c","followers_url":"https://api.github.com/users/marco-c/followers","following_url":"https://api.github.com/users/marco-c/following{/other_user}","gists_url":"https://api.github.com/users/marco-c/gists{/gist_id}","starred_url":"https://api.github.com/users/marco-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco-c/subscriptions","organizations_url":"https://api.github.com/users/marco-c/orgs","repos_url":"https://api.github.com/users/marco-c/repos","events_url":"https://api.github.com/users/marco-c/events{/privacy}","received_events_url":"https://api.github.com/users/marco-c/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-25T17:30:47Z","updated_at":"2015-03-26T02:14:18Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mozilla/j2me.js/pulls/1312","html_url":"https://github.com/mozilla/j2me.js/pull/1312","diff_url":"https://github.com/mozilla/j2me.js/pull/1312.diff","patch_url":"https://github.com/mozilla/j2me.js/pull/1312.patch"},"body":"From https://github.com/Sable/soot/wiki/Using-Soot-as-a-Program-Optimizer:\r\n*Soot is able to optimize individual classfiles. Some of the transformations which can be carried out on individual classfiles include: common subexpression elimination, partial redundancy elimination, copy propagation, constant propagation and folding, conditional branch folding, dead assignment elimination, unreachable code elimination, unconditional branch folding, and unused local elimination.*\r\n\r\nUsing Soot does remove 20 kB of code, but it doesn't seem to improve startup time significantly (on Desktop)."},"comment":{"url":"https://api.github.com/repos/mozilla/j2me.js/issues/comments/86294585","html_url":"https://github.com/mozilla/j2me.js/pull/1312#issuecomment-86294585","issue_url":"https://api.github.com/repos/mozilla/j2me.js/issues/1312","id":86294585,"user":{"login":"marco-c","id":1616846,"avatar_url":"https://avatars.githubusercontent.com/u/1616846?v=3","gravatar_id":"","url":"https://api.github.com/users/marco-c","html_url":"https://github.com/marco-c","followers_url":"https://api.github.com/users/marco-c/followers","following_url":"https://api.github.com/users/marco-c/following{/other_user}","gists_url":"https://api.github.com/users/marco-c/gists{/gist_id}","starred_url":"https://api.github.com/users/marco-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco-c/subscriptions","organizations_url":"https://api.github.com/users/marco-c/orgs","repos_url":"https://api.github.com/users/marco-c/repos","events_url":"https://api.github.com/users/marco-c/events{/privacy}","received_events_url":"https://api.github.com/users/marco-c/received_events","type":"User","site_admin":false},"created_at":"2015-03-26T02:14:18Z","updated_at":"2015-03-26T02:14:18Z","body":"Looks like when we exit the com/sun/cldc/util/j2me/TimeZoneImpl.getInstance.(Ljava/lang/String;)Ljava/util/TimeZone; method, the lock on the object is undefined.\r\n\r\nThis is the code generated by the baseline compiler:\r\n```JavaScript\r\nvar th=$.ctx.thread;\r\nvar re,lk,k0=$G_INu3hj;\r\nvar a,b;\r\na=this;\r\nvar A,B;\r\nvar pc=0;\r\nif(O){\r\n  var _=O.local;\r\n  a=_[0],b=_[1];\r\n  pc=O.pc;\r\n  O=null;\r\n}else{\r\n  lk=a._lock;\r\n  if(lk&&lk.level===0){lk.thread=th;lk.level=1;}else{ME(a);\r\n    if(U){$.B(0,0,[a,b],[],a);return;}\r\n  }\r\n}\r\ntry{\r\n  var label=0;\r\n  // Entry Dispatch Block\r\n  if (pc===0) {\r\n  label = 1;\r\n  } else if (!(pc===35)) {\r\n  J2ME.Debug.assert(false, 'Invalid OSR PC: ' + pc)\r\n  }\r\n  if (label == 1) {\r\n  if (!(b!==null)) {\r\n  if (!(($.$G_INu3hj.s0)!==null)) {\r\n  if ($.initialized[\"java/lang/System\"] === undefined) { $.$GBEt6NdQ.classObject.initialize(); }\r\n  A=k0.c(4);\r\n  U&&B1(12,12);\r\n  re=$GBEt6NdQ.m(4)(A);\r\n  U&&B0(12);\r\n  $.$G_INu3hj.s0=re;\r\n  if (!(($.$G_INu3hj.s0)!==null)) {\r\n  $.$G_INu3hj.s0=k0.c(136);\r\n  }\r\n  }\r\n  b=$.$G_INu3hj.s0;\r\n  }\r\n  a=0;\r\n  }\r\n  while(1) {\r\n  if (a>=(($.$G_INu3hj.s30).length)) {\r\n  label = 11;\r\n  break;\r\n  }\r\n  if ((a >>> 0) >= ($.$G_INu3hj.s30.length >>> 0)) TI(a);\r\n  CCK($.$G_INu3hj.s30[a],k0);\r\n  re=(($.$G_INu3hj.s30[a]).f0).v2(b);\r\n  if (U && re !== undefined) { J2ME.Debug.assert(false, 'Unexpected return value during unwind.'); }\r\n  if(U){J2ME.Debug.assert(false,'Unexpected unwind.');}\r\n  if (!(re===0)) {\r\n  label = 9;\r\n  break;\r\n  }\r\n  a+=1;\r\n  }\r\n  if (label == 9) {\r\n  if ((a >>> 0) >= ($.$G_INu3hj.s30.length >>> 0)) TI(a);\r\n  if(a._lock.level===1&&a._lock.ready.length===0)a._lock.level=0;else MX(a);\r\n  return ($.$G_INu3hj.s30[a]);\r\n  }\r\n  else if (label == 11) {\r\n  re=k0.m(10)(b);\r\n  U&&B0(74);\r\n  if(a._lock.level===1&&a._lock.ready.length===0)a._lock.level=0;else MX(a);\r\n  return re;\r\n  }\r\n  J2ME.Debug.assert(false, 'Invalid PC: ' + pc)\r\n}catch(ex){\r\n  if(U){$.T(ex,[a,b],[A,B],a);return;}\r\n  A=TE(ex);\r\n  if(a._lock.level===1&&a._lock.ready.length===0)a._lock.level=0;else MX(a);\r\n  throw A;\r\n}\r\n```"}}