Compiler-Inlining.js 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750
  1. define("amber_core/Compiler-Inlining", ["amber_vm/smalltalk", "amber_vm/nil", "amber_vm/_st", "amber_core/Compiler-IR", "amber_core/Kernel-Objects", "amber_core/Compiler-Core"], function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Compiler-Inlining');
  3. smalltalk.packages["Compiler-Inlining"].transport = {"type":"amd","amdNamespace":"amber_core"};
  4. smalltalk.addClass('IRInlinedAssignment', smalltalk.IRAssignment, [], 'Compiler-Inlining');
  5. smalltalk.IRInlinedAssignment.comment="I represent an inlined assignment instruction.";
  6. smalltalk.addMethod(
  7. smalltalk.method({
  8. selector: "accept:",
  9. category: 'visiting',
  10. fn: function (aVisitor){
  11. var self=this;
  12. return smalltalk.withContext(function($ctx1) {
  13. var $1;
  14. $1=_st(aVisitor)._visitIRInlinedAssignment_(self);
  15. return $1;
  16. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedAssignment)})},
  17. args: ["aVisitor"],
  18. source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInlinedAssignment: self",
  19. messageSends: ["visitIRInlinedAssignment:"],
  20. referencedClasses: []
  21. }),
  22. smalltalk.IRInlinedAssignment);
  23. smalltalk.addMethod(
  24. smalltalk.method({
  25. selector: "isInlined",
  26. category: 'testing',
  27. fn: function (){
  28. var self=this;
  29. return smalltalk.withContext(function($ctx1) {
  30. return true;
  31. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedAssignment)})},
  32. args: [],
  33. source: "isInlined\x0a\x09^ true",
  34. messageSends: [],
  35. referencedClasses: []
  36. }),
  37. smalltalk.IRInlinedAssignment);
  38. smalltalk.addClass('IRInlinedClosure', smalltalk.IRClosure, [], 'Compiler-Inlining');
  39. smalltalk.IRInlinedClosure.comment="I represent an inlined closure instruction.";
  40. smalltalk.addMethod(
  41. smalltalk.method({
  42. selector: "accept:",
  43. category: 'visiting',
  44. fn: function (aVisitor){
  45. var self=this;
  46. return smalltalk.withContext(function($ctx1) {
  47. _st(aVisitor)._visitIRInlinedClosure_(self);
  48. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedClosure)})},
  49. args: ["aVisitor"],
  50. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedClosure: self",
  51. messageSends: ["visitIRInlinedClosure:"],
  52. referencedClasses: []
  53. }),
  54. smalltalk.IRInlinedClosure);
  55. smalltalk.addMethod(
  56. smalltalk.method({
  57. selector: "isInlined",
  58. category: 'testing',
  59. fn: function (){
  60. var self=this;
  61. return smalltalk.withContext(function($ctx1) {
  62. return true;
  63. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedClosure)})},
  64. args: [],
  65. source: "isInlined\x0a\x09^ true",
  66. messageSends: [],
  67. referencedClasses: []
  68. }),
  69. smalltalk.IRInlinedClosure);
  70. smalltalk.addClass('IRInlinedReturn', smalltalk.IRReturn, [], 'Compiler-Inlining');
  71. smalltalk.IRInlinedReturn.comment="I represent an inlined local return instruction.";
  72. smalltalk.addMethod(
  73. smalltalk.method({
  74. selector: "accept:",
  75. category: 'visiting',
  76. fn: function (aVisitor){
  77. var self=this;
  78. return smalltalk.withContext(function($ctx1) {
  79. var $1;
  80. $1=_st(aVisitor)._visitIRInlinedReturn_(self);
  81. return $1;
  82. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedReturn)})},
  83. args: ["aVisitor"],
  84. source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInlinedReturn: self",
  85. messageSends: ["visitIRInlinedReturn:"],
  86. referencedClasses: []
  87. }),
  88. smalltalk.IRInlinedReturn);
  89. smalltalk.addMethod(
  90. smalltalk.method({
  91. selector: "isInlined",
  92. category: 'testing',
  93. fn: function (){
  94. var self=this;
  95. return smalltalk.withContext(function($ctx1) {
  96. return true;
  97. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedReturn)})},
  98. args: [],
  99. source: "isInlined\x0a\x09^ true",
  100. messageSends: [],
  101. referencedClasses: []
  102. }),
  103. smalltalk.IRInlinedReturn);
  104. smalltalk.addClass('IRInlinedSend', smalltalk.IRSend, [], 'Compiler-Inlining');
  105. smalltalk.IRInlinedSend.comment="I am the abstract super class of inlined message send instructions.";
  106. smalltalk.addMethod(
  107. smalltalk.method({
  108. selector: "accept:",
  109. category: 'visiting',
  110. fn: function (aVisitor){
  111. var self=this;
  112. return smalltalk.withContext(function($ctx1) {
  113. _st(aVisitor)._visitInlinedSend_(self);
  114. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedSend)})},
  115. args: ["aVisitor"],
  116. source: "accept: aVisitor\x0a\x09aVisitor visitInlinedSend: self",
  117. messageSends: ["visitInlinedSend:"],
  118. referencedClasses: []
  119. }),
  120. smalltalk.IRInlinedSend);
  121. smalltalk.addMethod(
  122. smalltalk.method({
  123. selector: "isInlined",
  124. category: 'testing',
  125. fn: function (){
  126. var self=this;
  127. return smalltalk.withContext(function($ctx1) {
  128. return true;
  129. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedSend)})},
  130. args: [],
  131. source: "isInlined\x0a\x09^ true",
  132. messageSends: [],
  133. referencedClasses: []
  134. }),
  135. smalltalk.IRInlinedSend);
  136. smalltalk.addClass('IRInlinedIfFalse', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  137. smalltalk.IRInlinedIfFalse.comment="I represent an inlined `#ifFalse:` message send instruction.";
  138. smalltalk.addMethod(
  139. smalltalk.method({
  140. selector: "accept:",
  141. category: 'visiting',
  142. fn: function (aVisitor){
  143. var self=this;
  144. return smalltalk.withContext(function($ctx1) {
  145. _st(aVisitor)._visitIRInlinedIfFalse_(self);
  146. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedIfFalse)})},
  147. args: ["aVisitor"],
  148. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfFalse: self",
  149. messageSends: ["visitIRInlinedIfFalse:"],
  150. referencedClasses: []
  151. }),
  152. smalltalk.IRInlinedIfFalse);
  153. smalltalk.addClass('IRInlinedIfNilIfNotNil', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  154. smalltalk.IRInlinedIfNilIfNotNil.comment="I represent an inlined `#ifNil:ifNotNil:` message send instruction.";
  155. smalltalk.addMethod(
  156. smalltalk.method({
  157. selector: "accept:",
  158. category: 'visiting',
  159. fn: function (aVisitor){
  160. var self=this;
  161. return smalltalk.withContext(function($ctx1) {
  162. _st(aVisitor)._visitIRInlinedIfNilIfNotNil_(self);
  163. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedIfNilIfNotNil)})},
  164. args: ["aVisitor"],
  165. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfNilIfNotNil: self",
  166. messageSends: ["visitIRInlinedIfNilIfNotNil:"],
  167. referencedClasses: []
  168. }),
  169. smalltalk.IRInlinedIfNilIfNotNil);
  170. smalltalk.addClass('IRInlinedIfTrue', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  171. smalltalk.IRInlinedIfTrue.comment="I represent an inlined `#ifTrue:` message send instruction.";
  172. smalltalk.addMethod(
  173. smalltalk.method({
  174. selector: "accept:",
  175. category: 'visiting',
  176. fn: function (aVisitor){
  177. var self=this;
  178. return smalltalk.withContext(function($ctx1) {
  179. _st(aVisitor)._visitIRInlinedIfTrue_(self);
  180. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedIfTrue)})},
  181. args: ["aVisitor"],
  182. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrue: self",
  183. messageSends: ["visitIRInlinedIfTrue:"],
  184. referencedClasses: []
  185. }),
  186. smalltalk.IRInlinedIfTrue);
  187. smalltalk.addClass('IRInlinedIfTrueIfFalse', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  188. smalltalk.IRInlinedIfTrueIfFalse.comment="I represent an inlined `#ifTrue:ifFalse:` message send instruction.";
  189. smalltalk.addMethod(
  190. smalltalk.method({
  191. selector: "accept:",
  192. category: 'visiting',
  193. fn: function (aVisitor){
  194. var self=this;
  195. return smalltalk.withContext(function($ctx1) {
  196. _st(aVisitor)._visitIRInlinedIfTrueIfFalse_(self);
  197. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedIfTrueIfFalse)})},
  198. args: ["aVisitor"],
  199. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrueIfFalse: self",
  200. messageSends: ["visitIRInlinedIfTrueIfFalse:"],
  201. referencedClasses: []
  202. }),
  203. smalltalk.IRInlinedIfTrueIfFalse);
  204. smalltalk.addClass('IRInlinedSequence', smalltalk.IRBlockSequence, [], 'Compiler-Inlining');
  205. smalltalk.IRInlinedSequence.comment="I represent a (block) sequence inside an inlined closure instruction (instance of `IRInlinedClosure`).";
  206. smalltalk.addMethod(
  207. smalltalk.method({
  208. selector: "accept:",
  209. category: 'visiting',
  210. fn: function (aVisitor){
  211. var self=this;
  212. return smalltalk.withContext(function($ctx1) {
  213. _st(aVisitor)._visitIRInlinedSequence_(self);
  214. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedSequence)})},
  215. args: ["aVisitor"],
  216. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedSequence: self",
  217. messageSends: ["visitIRInlinedSequence:"],
  218. referencedClasses: []
  219. }),
  220. smalltalk.IRInlinedSequence);
  221. smalltalk.addMethod(
  222. smalltalk.method({
  223. selector: "isInlined",
  224. category: 'testing',
  225. fn: function (){
  226. var self=this;
  227. return smalltalk.withContext(function($ctx1) {
  228. return true;
  229. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedSequence)})},
  230. args: [],
  231. source: "isInlined\x0a\x09^ true",
  232. messageSends: [],
  233. referencedClasses: []
  234. }),
  235. smalltalk.IRInlinedSequence);
  236. smalltalk.addClass('IRInliner', smalltalk.IRVisitor, [], 'Compiler-Inlining');
  237. smalltalk.IRInliner.comment="I visit an IR tree, inlining message sends and block closures.\x0a\x0aMessage selectors that can be inlined are answered by `IRSendInliner >> #inlinedSelectors`";
  238. smalltalk.addMethod(
  239. smalltalk.method({
  240. selector: "assignmentInliner",
  241. category: 'factory',
  242. fn: function (){
  243. var self=this;
  244. function $IRAssignmentInliner(){return smalltalk.IRAssignmentInliner||(typeof IRAssignmentInliner=="undefined"?nil:IRAssignmentInliner)}
  245. return smalltalk.withContext(function($ctx1) {
  246. var $2,$3,$1;
  247. $2=_st($IRAssignmentInliner())._new();
  248. _st($2)._translator_(self);
  249. $3=_st($2)._yourself();
  250. $1=$3;
  251. return $1;
  252. }, function($ctx1) {$ctx1.fill(self,"assignmentInliner",{},smalltalk.IRInliner)})},
  253. args: [],
  254. source: "assignmentInliner\x0a\x09^ IRAssignmentInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  255. messageSends: ["translator:", "new", "yourself"],
  256. referencedClasses: ["IRAssignmentInliner"]
  257. }),
  258. smalltalk.IRInliner);
  259. smalltalk.addMethod(
  260. smalltalk.method({
  261. selector: "returnInliner",
  262. category: 'factory',
  263. fn: function (){
  264. var self=this;
  265. function $IRReturnInliner(){return smalltalk.IRReturnInliner||(typeof IRReturnInliner=="undefined"?nil:IRReturnInliner)}
  266. return smalltalk.withContext(function($ctx1) {
  267. var $2,$3,$1;
  268. $2=_st($IRReturnInliner())._new();
  269. _st($2)._translator_(self);
  270. $3=_st($2)._yourself();
  271. $1=$3;
  272. return $1;
  273. }, function($ctx1) {$ctx1.fill(self,"returnInliner",{},smalltalk.IRInliner)})},
  274. args: [],
  275. source: "returnInliner\x0a\x09^ IRReturnInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  276. messageSends: ["translator:", "new", "yourself"],
  277. referencedClasses: ["IRReturnInliner"]
  278. }),
  279. smalltalk.IRInliner);
  280. smalltalk.addMethod(
  281. smalltalk.method({
  282. selector: "sendInliner",
  283. category: 'factory',
  284. fn: function (){
  285. var self=this;
  286. function $IRSendInliner(){return smalltalk.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
  287. return smalltalk.withContext(function($ctx1) {
  288. var $2,$3,$1;
  289. $2=_st($IRSendInliner())._new();
  290. _st($2)._translator_(self);
  291. $3=_st($2)._yourself();
  292. $1=$3;
  293. return $1;
  294. }, function($ctx1) {$ctx1.fill(self,"sendInliner",{},smalltalk.IRInliner)})},
  295. args: [],
  296. source: "sendInliner\x0a\x09^ IRSendInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  297. messageSends: ["translator:", "new", "yourself"],
  298. referencedClasses: ["IRSendInliner"]
  299. }),
  300. smalltalk.IRInliner);
  301. smalltalk.addMethod(
  302. smalltalk.method({
  303. selector: "shouldInlineAssignment:",
  304. category: 'testing',
  305. fn: function (anIRAssignment){
  306. var self=this;
  307. return smalltalk.withContext(function($ctx1) {
  308. var $4,$3,$2,$6,$5,$1;
  309. $1=_st(_st(_st(anIRAssignment)._isInlined())._not())._and_((function(){
  310. return smalltalk.withContext(function($ctx2) {
  311. $4=_st(anIRAssignment)._instructions();
  312. $ctx2.sendIdx["instructions"]=1;
  313. $3=_st($4)._last();
  314. $ctx2.sendIdx["last"]=1;
  315. $2=_st($3)._isSend();
  316. return _st($2)._and_((function(){
  317. return smalltalk.withContext(function($ctx3) {
  318. $6=_st(anIRAssignment)._instructions();
  319. $5=_st($6)._last();
  320. return self._shouldInlineSend_($5);
  321. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  322. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  323. $ctx1.sendIdx["and:"]=1;
  324. return $1;
  325. }, function($ctx1) {$ctx1.fill(self,"shouldInlineAssignment:",{anIRAssignment:anIRAssignment},smalltalk.IRInliner)})},
  326. args: ["anIRAssignment"],
  327. source: "shouldInlineAssignment: anIRAssignment\x0a\x09^ anIRAssignment isInlined not and: [\x0a\x09\x09anIRAssignment instructions last isSend and: [\x0a\x09\x09\x09self shouldInlineSend: (anIRAssignment instructions last) ]]",
  328. messageSends: ["and:", "not", "isInlined", "isSend", "last", "instructions", "shouldInlineSend:"],
  329. referencedClasses: []
  330. }),
  331. smalltalk.IRInliner);
  332. smalltalk.addMethod(
  333. smalltalk.method({
  334. selector: "shouldInlineReturn:",
  335. category: 'testing',
  336. fn: function (anIRReturn){
  337. var self=this;
  338. return smalltalk.withContext(function($ctx1) {
  339. var $4,$3,$2,$6,$5,$1;
  340. $1=_st(_st(_st(anIRReturn)._isInlined())._not())._and_((function(){
  341. return smalltalk.withContext(function($ctx2) {
  342. $4=_st(anIRReturn)._instructions();
  343. $ctx2.sendIdx["instructions"]=1;
  344. $3=_st($4)._first();
  345. $ctx2.sendIdx["first"]=1;
  346. $2=_st($3)._isSend();
  347. return _st($2)._and_((function(){
  348. return smalltalk.withContext(function($ctx3) {
  349. $6=_st(anIRReturn)._instructions();
  350. $5=_st($6)._first();
  351. return self._shouldInlineSend_($5);
  352. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  353. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  354. $ctx1.sendIdx["and:"]=1;
  355. return $1;
  356. }, function($ctx1) {$ctx1.fill(self,"shouldInlineReturn:",{anIRReturn:anIRReturn},smalltalk.IRInliner)})},
  357. args: ["anIRReturn"],
  358. source: "shouldInlineReturn: anIRReturn\x0a\x09^ anIRReturn isInlined not and: [\x0a\x09\x09anIRReturn instructions first isSend and: [\x0a\x09\x09\x09self shouldInlineSend: (anIRReturn instructions first) ]]",
  359. messageSends: ["and:", "not", "isInlined", "isSend", "first", "instructions", "shouldInlineSend:"],
  360. referencedClasses: []
  361. }),
  362. smalltalk.IRInliner);
  363. smalltalk.addMethod(
  364. smalltalk.method({
  365. selector: "shouldInlineSend:",
  366. category: 'testing',
  367. fn: function (anIRSend){
  368. var self=this;
  369. function $IRSendInliner(){return smalltalk.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
  370. return smalltalk.withContext(function($ctx1) {
  371. var $1;
  372. $1=_st(_st(_st(anIRSend)._isInlined())._not())._and_((function(){
  373. return smalltalk.withContext(function($ctx2) {
  374. return _st($IRSendInliner())._shouldInline_(anIRSend);
  375. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  376. return $1;
  377. }, function($ctx1) {$ctx1.fill(self,"shouldInlineSend:",{anIRSend:anIRSend},smalltalk.IRInliner)})},
  378. args: ["anIRSend"],
  379. source: "shouldInlineSend: anIRSend\x0a\x09^ anIRSend isInlined not and: [\x0a\x09\x09IRSendInliner shouldInline: anIRSend ]",
  380. messageSends: ["and:", "not", "isInlined", "shouldInline:"],
  381. referencedClasses: ["IRSendInliner"]
  382. }),
  383. smalltalk.IRInliner);
  384. smalltalk.addMethod(
  385. smalltalk.method({
  386. selector: "transformNonLocalReturn:",
  387. category: 'visiting',
  388. fn: function (anIRNonLocalReturn){
  389. var self=this;
  390. var localReturn;
  391. function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
  392. return smalltalk.withContext(function($ctx1) {
  393. var $2,$1,$4,$3,$5,$6,$7,$8,$9,$10,$11;
  394. $2=_st(anIRNonLocalReturn)._scope();
  395. $ctx1.sendIdx["scope"]=1;
  396. $1=_st($2)._canInlineNonLocalReturns();
  397. if(smalltalk.assert($1)){
  398. $4=_st(anIRNonLocalReturn)._scope();
  399. $ctx1.sendIdx["scope"]=2;
  400. $3=_st($4)._methodScope();
  401. $5=_st(anIRNonLocalReturn)._scope();
  402. $ctx1.sendIdx["scope"]=3;
  403. _st($3)._removeNonLocalReturn_($5);
  404. $6=_st($IRReturn())._new();
  405. $7=$6;
  406. $8=_st(anIRNonLocalReturn)._scope();
  407. _st($7)._scope_($8);
  408. $9=_st($6)._yourself();
  409. localReturn=$9;
  410. localReturn;
  411. _st(_st(anIRNonLocalReturn)._instructions())._do_((function(each){
  412. return smalltalk.withContext(function($ctx2) {
  413. return _st(localReturn)._add_(each);
  414. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  415. _st(anIRNonLocalReturn)._replaceWith_(localReturn);
  416. $10=localReturn;
  417. return $10;
  418. };
  419. $11=smalltalk.IRInliner.superclass.fn.prototype._visitIRNonLocalReturn_.apply(_st(self), [anIRNonLocalReturn]);
  420. return $11;
  421. }, function($ctx1) {$ctx1.fill(self,"transformNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn,localReturn:localReturn},smalltalk.IRInliner)})},
  422. args: ["anIRNonLocalReturn"],
  423. source: "transformNonLocalReturn: anIRNonLocalReturn\x0a\x09\x22Replace a non local return into a local return\x22\x0a\x0a\x09| localReturn |\x0a\x09anIRNonLocalReturn scope canInlineNonLocalReturns ifTrue: [\x0a\x09\x09anIRNonLocalReturn scope methodScope removeNonLocalReturn: anIRNonLocalReturn scope.\x0a\x09\x09localReturn := IRReturn new\x0a\x09\x09\x09scope: anIRNonLocalReturn scope;\x0a\x09\x09\x09yourself.\x0a\x09\x09anIRNonLocalReturn instructions do: [ :each |\x0a\x09\x09\x09localReturn add: each ].\x0a\x09\x09anIRNonLocalReturn replaceWith: localReturn.\x0a\x09\x09^ localReturn ].\x0a\x09^ super visitIRNonLocalReturn: anIRNonLocalReturn",
  424. messageSends: ["ifTrue:", "canInlineNonLocalReturns", "scope", "removeNonLocalReturn:", "methodScope", "scope:", "new", "yourself", "do:", "instructions", "add:", "replaceWith:", "visitIRNonLocalReturn:"],
  425. referencedClasses: ["IRReturn"]
  426. }),
  427. smalltalk.IRInliner);
  428. smalltalk.addMethod(
  429. smalltalk.method({
  430. selector: "visitIRAssignment:",
  431. category: 'visiting',
  432. fn: function (anIRAssignment){
  433. var self=this;
  434. return smalltalk.withContext(function($ctx1) {
  435. var $2,$1;
  436. $2=self._shouldInlineAssignment_(anIRAssignment);
  437. if(smalltalk.assert($2)){
  438. $1=_st(self._assignmentInliner())._inlineAssignment_(anIRAssignment);
  439. } else {
  440. $1=smalltalk.IRInliner.superclass.fn.prototype._visitIRAssignment_.apply(_st(self), [anIRAssignment]);
  441. };
  442. return $1;
  443. }, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment},smalltalk.IRInliner)})},
  444. args: ["anIRAssignment"],
  445. source: "visitIRAssignment: anIRAssignment\x0a\x09^ (self shouldInlineAssignment: anIRAssignment)\x0a\x09\x09ifTrue: [ self assignmentInliner inlineAssignment: anIRAssignment ]\x0a\x09\x09ifFalse: [ super visitIRAssignment: anIRAssignment ]",
  446. messageSends: ["ifTrue:ifFalse:", "shouldInlineAssignment:", "inlineAssignment:", "assignmentInliner", "visitIRAssignment:"],
  447. referencedClasses: []
  448. }),
  449. smalltalk.IRInliner);
  450. smalltalk.addMethod(
  451. smalltalk.method({
  452. selector: "visitIRNonLocalReturn:",
  453. category: 'visiting',
  454. fn: function (anIRNonLocalReturn){
  455. var self=this;
  456. return smalltalk.withContext(function($ctx1) {
  457. var $1;
  458. $1=self._transformNonLocalReturn_(anIRNonLocalReturn);
  459. return $1;
  460. }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn},smalltalk.IRInliner)})},
  461. args: ["anIRNonLocalReturn"],
  462. source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09^ self transformNonLocalReturn: anIRNonLocalReturn",
  463. messageSends: ["transformNonLocalReturn:"],
  464. referencedClasses: []
  465. }),
  466. smalltalk.IRInliner);
  467. smalltalk.addMethod(
  468. smalltalk.method({
  469. selector: "visitIRReturn:",
  470. category: 'visiting',
  471. fn: function (anIRReturn){
  472. var self=this;
  473. return smalltalk.withContext(function($ctx1) {
  474. var $2,$1;
  475. $2=self._shouldInlineReturn_(anIRReturn);
  476. if(smalltalk.assert($2)){
  477. $1=_st(self._returnInliner())._inlineReturn_(anIRReturn);
  478. } else {
  479. $1=smalltalk.IRInliner.superclass.fn.prototype._visitIRReturn_.apply(_st(self), [anIRReturn]);
  480. };
  481. return $1;
  482. }, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn},smalltalk.IRInliner)})},
  483. args: ["anIRReturn"],
  484. source: "visitIRReturn: anIRReturn\x0a\x09^ (self shouldInlineReturn: anIRReturn)\x0a\x09\x09ifTrue: [ self returnInliner inlineReturn: anIRReturn ]\x0a\x09\x09ifFalse: [ super visitIRReturn: anIRReturn ]",
  485. messageSends: ["ifTrue:ifFalse:", "shouldInlineReturn:", "inlineReturn:", "returnInliner", "visitIRReturn:"],
  486. referencedClasses: []
  487. }),
  488. smalltalk.IRInliner);
  489. smalltalk.addMethod(
  490. smalltalk.method({
  491. selector: "visitIRSend:",
  492. category: 'visiting',
  493. fn: function (anIRSend){
  494. var self=this;
  495. return smalltalk.withContext(function($ctx1) {
  496. var $2,$1;
  497. $2=self._shouldInlineSend_(anIRSend);
  498. if(smalltalk.assert($2)){
  499. $1=_st(self._sendInliner())._inlineSend_(anIRSend);
  500. } else {
  501. $1=smalltalk.IRInliner.superclass.fn.prototype._visitIRSend_.apply(_st(self), [anIRSend]);
  502. };
  503. return $1;
  504. }, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend},smalltalk.IRInliner)})},
  505. args: ["anIRSend"],
  506. source: "visitIRSend: anIRSend\x0a\x09^ (self shouldInlineSend: anIRSend)\x0a\x09\x09ifTrue: [ self sendInliner inlineSend: anIRSend ]\x0a\x09\x09ifFalse: [ super visitIRSend: anIRSend ]",
  507. messageSends: ["ifTrue:ifFalse:", "shouldInlineSend:", "inlineSend:", "sendInliner", "visitIRSend:"],
  508. referencedClasses: []
  509. }),
  510. smalltalk.IRInliner);
  511. smalltalk.addClass('IRInliningJSTranslator', smalltalk.IRJSTranslator, [], 'Compiler-Inlining');
  512. smalltalk.IRInliningJSTranslator.comment="I am a specialized JavaScript translator able to write inlined IR instructions to JavaScript stream (`JSStream` instance).";
  513. smalltalk.addMethod(
  514. smalltalk.method({
  515. selector: "visitIRInlinedAssignment:",
  516. category: 'visiting',
  517. fn: function (anIRInlinedAssignment){
  518. var self=this;
  519. return smalltalk.withContext(function($ctx1) {
  520. self._visit_(_st(_st(anIRInlinedAssignment)._instructions())._last());
  521. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedAssignment:",{anIRInlinedAssignment:anIRInlinedAssignment},smalltalk.IRInliningJSTranslator)})},
  522. args: ["anIRInlinedAssignment"],
  523. source: "visitIRInlinedAssignment: anIRInlinedAssignment\x0a\x09self visit: anIRInlinedAssignment instructions last",
  524. messageSends: ["visit:", "last", "instructions"],
  525. referencedClasses: []
  526. }),
  527. smalltalk.IRInliningJSTranslator);
  528. smalltalk.addMethod(
  529. smalltalk.method({
  530. selector: "visitIRInlinedClosure:",
  531. category: 'visiting',
  532. fn: function (anIRInlinedClosure){
  533. var self=this;
  534. return smalltalk.withContext(function($ctx1) {
  535. _st(self._stream())._nextPutVars_(_st(_st(anIRInlinedClosure)._tempDeclarations())._collect_((function(each){
  536. return smalltalk.withContext(function($ctx2) {
  537. return _st(_st(each)._name())._asVariableName();
  538. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})));
  539. _st(_st(anIRInlinedClosure)._instructions())._do_((function(each){
  540. return smalltalk.withContext(function($ctx2) {
  541. return self._visit_(each);
  542. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  543. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure},smalltalk.IRInliningJSTranslator)})},
  544. args: ["anIRInlinedClosure"],
  545. source: "visitIRInlinedClosure: anIRInlinedClosure\x0a\x09self stream nextPutVars: (anIRInlinedClosure tempDeclarations collect: [ :each |\x0a\x09\x09each name asVariableName ]).\x0a\x09anIRInlinedClosure instructions do: [ :each |\x0a\x09\x09self visit: each ]",
  546. messageSends: ["nextPutVars:", "stream", "collect:", "tempDeclarations", "asVariableName", "name", "do:", "instructions", "visit:"],
  547. referencedClasses: []
  548. }),
  549. smalltalk.IRInliningJSTranslator);
  550. smalltalk.addMethod(
  551. smalltalk.method({
  552. selector: "visitIRInlinedIfFalse:",
  553. category: 'visiting',
  554. fn: function (anIRInlinedIfFalse){
  555. var self=this;
  556. return smalltalk.withContext(function($ctx1) {
  557. var $1,$2,$4,$3,$5,$7,$6;
  558. $1=self._stream();
  559. $ctx1.sendIdx["stream"]=1;
  560. _st($1)._nextPutIf_with_((function(){
  561. return smalltalk.withContext(function($ctx2) {
  562. $2=self._stream();
  563. $ctx2.sendIdx["stream"]=2;
  564. _st($2)._nextPutAll_("! smalltalk.assert(");
  565. $ctx2.sendIdx["nextPutAll:"]=1;
  566. $4=_st(anIRInlinedIfFalse)._instructions();
  567. $ctx2.sendIdx["instructions"]=1;
  568. $3=_st($4)._first();
  569. self._visit_($3);
  570. $ctx2.sendIdx["visit:"]=1;
  571. $5=self._stream();
  572. return _st($5)._nextPutAll_(")");
  573. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  574. return smalltalk.withContext(function($ctx2) {
  575. $7=_st(anIRInlinedIfFalse)._instructions();
  576. $6=_st($7)._last();
  577. return self._visit_($6);
  578. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  579. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfFalse:",{anIRInlinedIfFalse:anIRInlinedIfFalse},smalltalk.IRInliningJSTranslator)})},
  580. args: ["anIRInlinedIfFalse"],
  581. source: "visitIRInlinedIfFalse: anIRInlinedIfFalse\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: '! smalltalk.assert('.\x0a\x09\x09self visit: anIRInlinedIfFalse instructions first.\x0a\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfFalse instructions last ]",
  582. messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"],
  583. referencedClasses: []
  584. }),
  585. smalltalk.IRInliningJSTranslator);
  586. smalltalk.addMethod(
  587. smalltalk.method({
  588. selector: "visitIRInlinedIfNil:",
  589. category: 'visiting',
  590. fn: function (anIRInlinedIfNil){
  591. var self=this;
  592. return smalltalk.withContext(function($ctx1) {
  593. var $1,$2,$4,$3,$5,$7,$6;
  594. $1=self._stream();
  595. $ctx1.sendIdx["stream"]=1;
  596. _st($1)._nextPutIf_with_((function(){
  597. return smalltalk.withContext(function($ctx2) {
  598. $2=self._stream();
  599. $ctx2.sendIdx["stream"]=2;
  600. _st($2)._nextPutAll_("($receiver = ");
  601. $ctx2.sendIdx["nextPutAll:"]=1;
  602. $4=_st(anIRInlinedIfNil)._instructions();
  603. $ctx2.sendIdx["instructions"]=1;
  604. $3=_st($4)._first();
  605. self._visit_($3);
  606. $ctx2.sendIdx["visit:"]=1;
  607. $5=self._stream();
  608. return _st($5)._nextPutAll_(") == nil || $receiver == null");
  609. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  610. return smalltalk.withContext(function($ctx2) {
  611. $7=_st(anIRInlinedIfNil)._instructions();
  612. $6=_st($7)._last();
  613. return self._visit_($6);
  614. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  615. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNil:",{anIRInlinedIfNil:anIRInlinedIfNil},smalltalk.IRInliningJSTranslator)})},
  616. args: ["anIRInlinedIfNil"],
  617. source: "visitIRInlinedIfNil: anIRInlinedIfNil\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: '($receiver = '.\x0a\x09\x09self visit: anIRInlinedIfNil instructions first.\x0a\x09\x09self stream nextPutAll: ') == nil || $receiver == null' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfNil instructions last ]",
  618. messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"],
  619. referencedClasses: []
  620. }),
  621. smalltalk.IRInliningJSTranslator);
  622. smalltalk.addMethod(
  623. smalltalk.method({
  624. selector: "visitIRInlinedIfNilIfNotNil:",
  625. category: 'visiting',
  626. fn: function (anIRInlinedIfNilIfNotNil){
  627. var self=this;
  628. return smalltalk.withContext(function($ctx1) {
  629. var $1,$2,$4,$3,$5,$7,$6,$9,$8;
  630. $1=self._stream();
  631. $ctx1.sendIdx["stream"]=1;
  632. _st($1)._nextPutIfElse_with_with_((function(){
  633. return smalltalk.withContext(function($ctx2) {
  634. $2=self._stream();
  635. $ctx2.sendIdx["stream"]=2;
  636. _st($2)._nextPutAll_("($receiver = ");
  637. $ctx2.sendIdx["nextPutAll:"]=1;
  638. $4=_st(anIRInlinedIfNilIfNotNil)._instructions();
  639. $ctx2.sendIdx["instructions"]=1;
  640. $3=_st($4)._first();
  641. self._visit_($3);
  642. $ctx2.sendIdx["visit:"]=1;
  643. $5=self._stream();
  644. return _st($5)._nextPutAll_(") == nil || $receiver == null");
  645. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  646. return smalltalk.withContext(function($ctx2) {
  647. $7=_st(anIRInlinedIfNilIfNotNil)._instructions();
  648. $ctx2.sendIdx["instructions"]=2;
  649. $6=_st($7)._second();
  650. return self._visit_($6);
  651. $ctx2.sendIdx["visit:"]=2;
  652. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),(function(){
  653. return smalltalk.withContext(function($ctx2) {
  654. $9=_st(anIRInlinedIfNilIfNotNil)._instructions();
  655. $8=_st($9)._third();
  656. return self._visit_($8);
  657. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  658. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNilIfNotNil:",{anIRInlinedIfNilIfNotNil:anIRInlinedIfNilIfNotNil},smalltalk.IRInliningJSTranslator)})},
  659. args: ["anIRInlinedIfNilIfNotNil"],
  660. source: "visitIRInlinedIfNilIfNotNil: anIRInlinedIfNilIfNotNil\x0a\x09self stream\x0a\x09\x09nextPutIfElse: [\x0a\x09\x09\x09self stream nextPutAll: '($receiver = '.\x0a\x09\x09\x09self visit: anIRInlinedIfNilIfNotNil instructions first.\x0a\x09\x09\x09self stream nextPutAll: ') == nil || $receiver == null' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfNilIfNotNil instructions second ]\x0a\x09\x09with: [ self visit: anIRInlinedIfNilIfNotNil instructions third ]",
  661. messageSends: ["nextPutIfElse:with:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "second", "third"],
  662. referencedClasses: []
  663. }),
  664. smalltalk.IRInliningJSTranslator);
  665. smalltalk.addMethod(
  666. smalltalk.method({
  667. selector: "visitIRInlinedIfTrue:",
  668. category: 'visiting',
  669. fn: function (anIRInlinedIfTrue){
  670. var self=this;
  671. return smalltalk.withContext(function($ctx1) {
  672. var $1,$2,$4,$3,$5,$7,$6;
  673. $1=self._stream();
  674. $ctx1.sendIdx["stream"]=1;
  675. _st($1)._nextPutIf_with_((function(){
  676. return smalltalk.withContext(function($ctx2) {
  677. $2=self._stream();
  678. $ctx2.sendIdx["stream"]=2;
  679. _st($2)._nextPutAll_("smalltalk.assert(");
  680. $ctx2.sendIdx["nextPutAll:"]=1;
  681. $4=_st(anIRInlinedIfTrue)._instructions();
  682. $ctx2.sendIdx["instructions"]=1;
  683. $3=_st($4)._first();
  684. self._visit_($3);
  685. $ctx2.sendIdx["visit:"]=1;
  686. $5=self._stream();
  687. return _st($5)._nextPutAll_(")");
  688. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  689. return smalltalk.withContext(function($ctx2) {
  690. $7=_st(anIRInlinedIfTrue)._instructions();
  691. $6=_st($7)._last();
  692. return self._visit_($6);
  693. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  694. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrue:",{anIRInlinedIfTrue:anIRInlinedIfTrue},smalltalk.IRInliningJSTranslator)})},
  695. args: ["anIRInlinedIfTrue"],
  696. source: "visitIRInlinedIfTrue: anIRInlinedIfTrue\x0a\x09self stream nextPutIf: [\x0a\x09\x09self stream nextPutAll: 'smalltalk.assert('.\x0a\x09\x09self visit: anIRInlinedIfTrue instructions first.\x0a\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfTrue instructions last ]",
  697. messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"],
  698. referencedClasses: []
  699. }),
  700. smalltalk.IRInliningJSTranslator);
  701. smalltalk.addMethod(
  702. smalltalk.method({
  703. selector: "visitIRInlinedIfTrueIfFalse:",
  704. category: 'visiting',
  705. fn: function (anIRInlinedIfTrueIfFalse){
  706. var self=this;
  707. return smalltalk.withContext(function($ctx1) {
  708. var $1,$2,$4,$3,$5,$7,$6,$9,$8;
  709. $1=self._stream();
  710. $ctx1.sendIdx["stream"]=1;
  711. _st($1)._nextPutIfElse_with_with_((function(){
  712. return smalltalk.withContext(function($ctx2) {
  713. $2=self._stream();
  714. $ctx2.sendIdx["stream"]=2;
  715. _st($2)._nextPutAll_("smalltalk.assert(");
  716. $ctx2.sendIdx["nextPutAll:"]=1;
  717. $4=_st(anIRInlinedIfTrueIfFalse)._instructions();
  718. $ctx2.sendIdx["instructions"]=1;
  719. $3=_st($4)._first();
  720. self._visit_($3);
  721. $ctx2.sendIdx["visit:"]=1;
  722. $5=self._stream();
  723. return _st($5)._nextPutAll_(")");
  724. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  725. return smalltalk.withContext(function($ctx2) {
  726. $7=_st(anIRInlinedIfTrueIfFalse)._instructions();
  727. $ctx2.sendIdx["instructions"]=2;
  728. $6=_st($7)._second();
  729. return self._visit_($6);
  730. $ctx2.sendIdx["visit:"]=2;
  731. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),(function(){
  732. return smalltalk.withContext(function($ctx2) {
  733. $9=_st(anIRInlinedIfTrueIfFalse)._instructions();
  734. $8=_st($9)._third();
  735. return self._visit_($8);
  736. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  737. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrueIfFalse:",{anIRInlinedIfTrueIfFalse:anIRInlinedIfTrueIfFalse},smalltalk.IRInliningJSTranslator)})},
  738. args: ["anIRInlinedIfTrueIfFalse"],
  739. source: "visitIRInlinedIfTrueIfFalse: anIRInlinedIfTrueIfFalse\x0a\x09self stream\x0a\x09\x09nextPutIfElse: [\x0a\x09\x09\x09self stream nextPutAll: 'smalltalk.assert('.\x0a\x09\x09\x09self visit: anIRInlinedIfTrueIfFalse instructions first.\x0a\x09\x09\x09self stream nextPutAll: ')' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfTrueIfFalse instructions second ]\x0a\x09\x09with: [ self visit: anIRInlinedIfTrueIfFalse instructions third ]",
  740. messageSends: ["nextPutIfElse:with:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "second", "third"],
  741. referencedClasses: []
  742. }),
  743. smalltalk.IRInliningJSTranslator);
  744. smalltalk.addMethod(
  745. smalltalk.method({
  746. selector: "visitIRInlinedNonLocalReturn:",
  747. category: 'visiting',
  748. fn: function (anIRInlinedReturn){
  749. var self=this;
  750. return smalltalk.withContext(function($ctx1) {
  751. var $1,$2;
  752. $1=self._stream();
  753. $ctx1.sendIdx["stream"]=1;
  754. _st($1)._nextPutStatementWith_((function(){
  755. return smalltalk.withContext(function($ctx2) {
  756. return self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
  757. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  758. $2=self._stream();
  759. _st($2)._nextPutNonLocalReturnWith_((function(){
  760. return smalltalk.withContext(function($ctx2) {
  761. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  762. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedNonLocalReturn:",{anIRInlinedReturn:anIRInlinedReturn},smalltalk.IRInliningJSTranslator)})},
  763. args: ["anIRInlinedReturn"],
  764. source: "visitIRInlinedNonLocalReturn: anIRInlinedReturn\x0a\x09self stream nextPutStatementWith: [\x0a\x09\x09self visit: anIRInlinedReturn instructions last ].\x0a\x09self stream nextPutNonLocalReturnWith: [ ]",
  765. messageSends: ["nextPutStatementWith:", "stream", "visit:", "last", "instructions", "nextPutNonLocalReturnWith:"],
  766. referencedClasses: []
  767. }),
  768. smalltalk.IRInliningJSTranslator);
  769. smalltalk.addMethod(
  770. smalltalk.method({
  771. selector: "visitIRInlinedReturn:",
  772. category: 'visiting',
  773. fn: function (anIRInlinedReturn){
  774. var self=this;
  775. return smalltalk.withContext(function($ctx1) {
  776. self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
  777. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedReturn:",{anIRInlinedReturn:anIRInlinedReturn},smalltalk.IRInliningJSTranslator)})},
  778. args: ["anIRInlinedReturn"],
  779. source: "visitIRInlinedReturn: anIRInlinedReturn\x0a\x09self visit: anIRInlinedReturn instructions last",
  780. messageSends: ["visit:", "last", "instructions"],
  781. referencedClasses: []
  782. }),
  783. smalltalk.IRInliningJSTranslator);
  784. smalltalk.addMethod(
  785. smalltalk.method({
  786. selector: "visitIRInlinedSequence:",
  787. category: 'visiting',
  788. fn: function (anIRInlinedSequence){
  789. var self=this;
  790. return smalltalk.withContext(function($ctx1) {
  791. _st(_st(anIRInlinedSequence)._instructions())._do_((function(each){
  792. return smalltalk.withContext(function($ctx2) {
  793. return _st(self._stream())._nextPutStatementWith_((function(){
  794. return smalltalk.withContext(function($ctx3) {
  795. return self._visit_(each);
  796. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  797. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  798. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedSequence:",{anIRInlinedSequence:anIRInlinedSequence},smalltalk.IRInliningJSTranslator)})},
  799. args: ["anIRInlinedSequence"],
  800. source: "visitIRInlinedSequence: anIRInlinedSequence\x0a\x09anIRInlinedSequence instructions do: [ :each |\x0a\x09\x09self stream nextPutStatementWith: [ self visit: each ]]",
  801. messageSends: ["do:", "instructions", "nextPutStatementWith:", "stream", "visit:"],
  802. referencedClasses: []
  803. }),
  804. smalltalk.IRInliningJSTranslator);
  805. smalltalk.addClass('IRSendInliner', smalltalk.Object, ['send', 'translator'], 'Compiler-Inlining');
  806. smalltalk.IRSendInliner.comment="I inline some message sends and block closure arguments. I heavily rely on #perform: to dispatch inlining methods.";
  807. smalltalk.addMethod(
  808. smalltalk.method({
  809. selector: "ifFalse:",
  810. category: 'inlining',
  811. fn: function (anIRInstruction){
  812. var self=this;
  813. function $IRInlinedIfFalse(){return smalltalk.IRInlinedIfFalse||(typeof IRInlinedIfFalse=="undefined"?nil:IRInlinedIfFalse)}
  814. return smalltalk.withContext(function($ctx1) {
  815. var $1;
  816. $1=self._inlinedSend_with_(_st($IRInlinedIfFalse())._new(),anIRInstruction);
  817. return $1;
  818. }, function($ctx1) {$ctx1.fill(self,"ifFalse:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  819. args: ["anIRInstruction"],
  820. source: "ifFalse: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfFalse new with: anIRInstruction",
  821. messageSends: ["inlinedSend:with:", "new"],
  822. referencedClasses: ["IRInlinedIfFalse"]
  823. }),
  824. smalltalk.IRSendInliner);
  825. smalltalk.addMethod(
  826. smalltalk.method({
  827. selector: "ifFalse:ifTrue:",
  828. category: 'inlining',
  829. fn: function (anIRInstruction,anotherIRInstruction){
  830. var self=this;
  831. return smalltalk.withContext(function($ctx1) {
  832. var $1;
  833. $1=self._perform_withArguments_("ifTrue:ifFalse:",[anotherIRInstruction,anIRInstruction]);
  834. return $1;
  835. }, function($ctx1) {$ctx1.fill(self,"ifFalse:ifTrue:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  836. args: ["anIRInstruction", "anotherIRInstruction"],
  837. source: "ifFalse: anIRInstruction ifTrue: anotherIRInstruction\x0a\x09^ self perform: #ifTrue:ifFalse: withArguments: { anotherIRInstruction. anIRInstruction }",
  838. messageSends: ["perform:withArguments:"],
  839. referencedClasses: []
  840. }),
  841. smalltalk.IRSendInliner);
  842. smalltalk.addMethod(
  843. smalltalk.method({
  844. selector: "ifNil:",
  845. category: 'inlining',
  846. fn: function (anIRInstruction){
  847. var self=this;
  848. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  849. function $IRClosure(){return smalltalk.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
  850. function $IRBlockSequence(){return smalltalk.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
  851. return smalltalk.withContext(function($ctx1) {
  852. var $2,$4,$5,$7,$8,$6,$9,$3,$1;
  853. $2=_st($IRInlinedIfNilIfNotNil())._new();
  854. $ctx1.sendIdx["new"]=1;
  855. $4=_st($IRClosure())._new();
  856. $ctx1.sendIdx["new"]=2;
  857. _st($4)._scope_(_st(_st(anIRInstruction)._scope())._copy());
  858. $5=$4;
  859. $7=_st($IRBlockSequence())._new();
  860. _st($7)._add_(_st(_st(self._send())._instructions())._first());
  861. $8=_st($7)._yourself();
  862. $ctx1.sendIdx["yourself"]=1;
  863. $6=$8;
  864. _st($5)._add_($6);
  865. $ctx1.sendIdx["add:"]=1;
  866. $9=_st($4)._yourself();
  867. $3=$9;
  868. $1=self._inlinedSend_with_with_($2,anIRInstruction,$3);
  869. return $1;
  870. }, function($ctx1) {$ctx1.fill(self,"ifNil:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  871. args: ["anIRInstruction"],
  872. source: "ifNil: anIRInstruction\x0a\x09^ self\x0a\x09\x09inlinedSend: IRInlinedIfNilIfNotNil new\x0a\x09\x09with: anIRInstruction\x0a\x09\x09with: (IRClosure new\x0a\x09\x09\x09scope: anIRInstruction scope copy;\x0a\x09\x09\x09add: (IRBlockSequence new\x0a\x09\x09\x09\x09add: self send instructions first;\x0a\x09\x09\x09\x09yourself);\x0a\x09\x09\x09yourself)",
  873. messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"],
  874. referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"]
  875. }),
  876. smalltalk.IRSendInliner);
  877. smalltalk.addMethod(
  878. smalltalk.method({
  879. selector: "ifNil:ifNotNil:",
  880. category: 'inlining',
  881. fn: function (anIRInstruction,anotherIRInstruction){
  882. var self=this;
  883. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  884. return smalltalk.withContext(function($ctx1) {
  885. var $1;
  886. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anIRInstruction,anotherIRInstruction);
  887. return $1;
  888. }, function($ctx1) {$ctx1.fill(self,"ifNil:ifNotNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  889. args: ["anIRInstruction", "anotherIRInstruction"],
  890. source: "ifNil: anIRInstruction ifNotNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new with: anIRInstruction with: anotherIRInstruction",
  891. messageSends: ["inlinedSend:with:with:", "new"],
  892. referencedClasses: ["IRInlinedIfNilIfNotNil"]
  893. }),
  894. smalltalk.IRSendInliner);
  895. smalltalk.addMethod(
  896. smalltalk.method({
  897. selector: "ifNotNil:",
  898. category: 'inlining',
  899. fn: function (anIRInstruction){
  900. var self=this;
  901. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  902. function $IRClosure(){return smalltalk.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
  903. function $IRBlockSequence(){return smalltalk.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
  904. return smalltalk.withContext(function($ctx1) {
  905. var $2,$4,$5,$7,$8,$6,$9,$3,$1;
  906. $2=_st($IRInlinedIfNilIfNotNil())._new();
  907. $ctx1.sendIdx["new"]=1;
  908. $4=_st($IRClosure())._new();
  909. $ctx1.sendIdx["new"]=2;
  910. _st($4)._scope_(_st(_st(anIRInstruction)._scope())._copy());
  911. $5=$4;
  912. $7=_st($IRBlockSequence())._new();
  913. _st($7)._add_(_st(_st(self._send())._instructions())._first());
  914. $8=_st($7)._yourself();
  915. $ctx1.sendIdx["yourself"]=1;
  916. $6=$8;
  917. _st($5)._add_($6);
  918. $ctx1.sendIdx["add:"]=1;
  919. $9=_st($4)._yourself();
  920. $3=$9;
  921. $1=self._inlinedSend_with_with_($2,$3,anIRInstruction);
  922. return $1;
  923. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  924. args: ["anIRInstruction"],
  925. source: "ifNotNil: anIRInstruction\x0a\x09^ self\x0a\x09\x09inlinedSend: IRInlinedIfNilIfNotNil new\x0a\x09\x09with: (IRClosure new\x0a\x09\x09\x09scope: anIRInstruction scope copy;\x0a\x09\x09\x09add: (IRBlockSequence new\x0a\x09\x09\x09\x09add: self send instructions first;\x0a\x09\x09\x09\x09yourself);\x0a\x09\x09\x09yourself)\x0a\x09\x09with: anIRInstruction",
  926. messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"],
  927. referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"]
  928. }),
  929. smalltalk.IRSendInliner);
  930. smalltalk.addMethod(
  931. smalltalk.method({
  932. selector: "ifNotNil:ifNil:",
  933. category: 'inlining',
  934. fn: function (anIRInstruction,anotherIRInstruction){
  935. var self=this;
  936. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  937. return smalltalk.withContext(function($ctx1) {
  938. var $1;
  939. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anotherIRInstruction,anIRInstruction);
  940. return $1;
  941. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:ifNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  942. args: ["anIRInstruction", "anotherIRInstruction"],
  943. source: "ifNotNil: anIRInstruction ifNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new with: anotherIRInstruction with: anIRInstruction",
  944. messageSends: ["inlinedSend:with:with:", "new"],
  945. referencedClasses: ["IRInlinedIfNilIfNotNil"]
  946. }),
  947. smalltalk.IRSendInliner);
  948. smalltalk.addMethod(
  949. smalltalk.method({
  950. selector: "ifTrue:",
  951. category: 'inlining',
  952. fn: function (anIRInstruction){
  953. var self=this;
  954. function $IRInlinedIfTrue(){return smalltalk.IRInlinedIfTrue||(typeof IRInlinedIfTrue=="undefined"?nil:IRInlinedIfTrue)}
  955. return smalltalk.withContext(function($ctx1) {
  956. var $1;
  957. $1=self._inlinedSend_with_(_st($IRInlinedIfTrue())._new(),anIRInstruction);
  958. return $1;
  959. }, function($ctx1) {$ctx1.fill(self,"ifTrue:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  960. args: ["anIRInstruction"],
  961. source: "ifTrue: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrue new with: anIRInstruction",
  962. messageSends: ["inlinedSend:with:", "new"],
  963. referencedClasses: ["IRInlinedIfTrue"]
  964. }),
  965. smalltalk.IRSendInliner);
  966. smalltalk.addMethod(
  967. smalltalk.method({
  968. selector: "ifTrue:ifFalse:",
  969. category: 'inlining',
  970. fn: function (anIRInstruction,anotherIRInstruction){
  971. var self=this;
  972. function $IRInlinedIfTrueIfFalse(){return smalltalk.IRInlinedIfTrueIfFalse||(typeof IRInlinedIfTrueIfFalse=="undefined"?nil:IRInlinedIfTrueIfFalse)}
  973. return smalltalk.withContext(function($ctx1) {
  974. var $1;
  975. $1=self._inlinedSend_with_with_(_st($IRInlinedIfTrueIfFalse())._new(),anIRInstruction,anotherIRInstruction);
  976. return $1;
  977. }, function($ctx1) {$ctx1.fill(self,"ifTrue:ifFalse:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  978. args: ["anIRInstruction", "anotherIRInstruction"],
  979. source: "ifTrue: anIRInstruction ifFalse: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrueIfFalse new with: anIRInstruction with: anotherIRInstruction",
  980. messageSends: ["inlinedSend:with:with:", "new"],
  981. referencedClasses: ["IRInlinedIfTrueIfFalse"]
  982. }),
  983. smalltalk.IRSendInliner);
  984. smalltalk.addMethod(
  985. smalltalk.method({
  986. selector: "inlineClosure:",
  987. category: 'inlining',
  988. fn: function (anIRClosure){
  989. var self=this;
  990. var inlinedClosure,sequence,statements;
  991. function $IRTempDeclaration(){return smalltalk.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
  992. function $IRAssignment(){return smalltalk.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
  993. function $IRVariable(){return smalltalk.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
  994. function $AliasVar(){return smalltalk.AliasVar||(typeof AliasVar=="undefined"?nil:AliasVar)}
  995. return smalltalk.withContext(function($ctx1) {
  996. var $1,$2,$3,$5,$6,$4,$7,$9,$10,$12,$14,$15,$16,$17,$13,$11,$18,$20,$22,$23,$24,$25,$21,$19,$26,$8,$28,$27,$31,$30,$32,$29,$33,$36,$35,$34,$37,$38,$39;
  997. inlinedClosure=self._inlinedClosure();
  998. $1=inlinedClosure;
  999. $2=_st(anIRClosure)._scope();
  1000. $ctx1.sendIdx["scope"]=1;
  1001. _st($1)._scope_($2);
  1002. $ctx1.sendIdx["scope:"]=1;
  1003. _st(_st(anIRClosure)._tempDeclarations())._do_((function(each){
  1004. return smalltalk.withContext(function($ctx2) {
  1005. return _st(inlinedClosure)._add_(each);
  1006. $ctx2.sendIdx["add:"]=1;
  1007. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1008. $ctx1.sendIdx["do:"]=1;
  1009. sequence=self._inlinedSequence();
  1010. _st(_st(anIRClosure)._arguments())._do_((function(each){
  1011. return smalltalk.withContext(function($ctx2) {
  1012. $3=inlinedClosure;
  1013. $5=_st($IRTempDeclaration())._new();
  1014. $ctx2.sendIdx["new"]=1;
  1015. _st($5)._name_(each);
  1016. $ctx2.sendIdx["name:"]=1;
  1017. $6=_st($5)._yourself();
  1018. $ctx2.sendIdx["yourself"]=1;
  1019. $4=$6;
  1020. _st($3)._add_($4);
  1021. $ctx2.sendIdx["add:"]=2;
  1022. $7=sequence;
  1023. $9=_st($IRAssignment())._new();
  1024. $ctx2.sendIdx["new"]=2;
  1025. $10=$9;
  1026. $12=_st($IRVariable())._new();
  1027. $ctx2.sendIdx["new"]=3;
  1028. $14=_st($AliasVar())._new();
  1029. $ctx2.sendIdx["new"]=4;
  1030. $15=$14;
  1031. $16=_st(inlinedClosure)._scope();
  1032. $ctx2.sendIdx["scope"]=2;
  1033. _st($15)._scope_($16);
  1034. $ctx2.sendIdx["scope:"]=2;
  1035. _st($14)._name_(each);
  1036. $ctx2.sendIdx["name:"]=2;
  1037. $17=_st($14)._yourself();
  1038. $ctx2.sendIdx["yourself"]=2;
  1039. $13=$17;
  1040. $11=_st($12)._variable_($13);
  1041. $ctx2.sendIdx["variable:"]=1;
  1042. _st($10)._add_($11);
  1043. $ctx2.sendIdx["add:"]=4;
  1044. $18=$9;
  1045. $20=_st($IRVariable())._new();
  1046. $ctx2.sendIdx["new"]=5;
  1047. $22=_st($AliasVar())._new();
  1048. $23=$22;
  1049. $24=_st(inlinedClosure)._scope();
  1050. _st($23)._scope_($24);
  1051. _st($22)._name_("$receiver");
  1052. $25=_st($22)._yourself();
  1053. $ctx2.sendIdx["yourself"]=3;
  1054. $21=$25;
  1055. $19=_st($20)._variable_($21);
  1056. _st($18)._add_($19);
  1057. $ctx2.sendIdx["add:"]=5;
  1058. $26=_st($9)._yourself();
  1059. $8=$26;
  1060. return _st($7)._add_($8);
  1061. $ctx2.sendIdx["add:"]=3;
  1062. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1063. $ctx1.sendIdx["do:"]=2;
  1064. _st(inlinedClosure)._add_(sequence);
  1065. $ctx1.sendIdx["add:"]=6;
  1066. $28=_st(anIRClosure)._instructions();
  1067. $ctx1.sendIdx["instructions"]=2;
  1068. $27=_st($28)._last();
  1069. $ctx1.sendIdx["last"]=1;
  1070. statements=_st($27)._instructions();
  1071. $ctx1.sendIdx["instructions"]=1;
  1072. _st(statements)._ifNotEmpty_((function(){
  1073. return smalltalk.withContext(function($ctx2) {
  1074. _st(_st(statements)._allButLast())._do_((function(each){
  1075. return smalltalk.withContext(function($ctx3) {
  1076. return _st(sequence)._add_(each);
  1077. $ctx3.sendIdx["add:"]=7;
  1078. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,4)})}));
  1079. $31=_st(statements)._last();
  1080. $ctx2.sendIdx["last"]=2;
  1081. $30=_st($31)._isReturn();
  1082. $29=_st($30)._and_((function(){
  1083. return smalltalk.withContext(function($ctx3) {
  1084. $32=_st(statements)._last();
  1085. $ctx3.sendIdx["last"]=3;
  1086. return _st($32)._isBlockReturn();
  1087. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)})}));
  1088. if(smalltalk.assert($29)){
  1089. $33=sequence;
  1090. $36=_st(statements)._last();
  1091. $ctx2.sendIdx["last"]=4;
  1092. $35=_st($36)._instructions();
  1093. $34=_st($35)._first();
  1094. return _st($33)._add_($34);
  1095. $ctx2.sendIdx["add:"]=8;
  1096. } else {
  1097. $37=sequence;
  1098. $38=_st(statements)._last();
  1099. return _st($37)._add_($38);
  1100. };
  1101. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  1102. $39=inlinedClosure;
  1103. return $39;
  1104. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,sequence:sequence,statements:statements},smalltalk.IRSendInliner)})},
  1105. args: ["anIRClosure"],
  1106. source: "inlineClosure: anIRClosure\x0a\x09| inlinedClosure sequence statements |\x0a\x0a\x09inlinedClosure := self inlinedClosure.\x0a\x09inlinedClosure scope: anIRClosure scope.\x0a\x0a\x09\x22Add the possible temp declarations\x22\x0a\x09anIRClosure tempDeclarations do: [ :each |\x0a\x09\x09\x09inlinedClosure add: each ].\x0a\x0a\x09\x22Add a block sequence\x22\x0a\x09sequence := self inlinedSequence.\x0a\x0a\x09\x22Map the closure arguments to the receiver of the message send\x22\x0a\x09anIRClosure arguments do: [ :each |\x0a\x09\x09inlinedClosure add: (IRTempDeclaration new name: each; yourself).\x0a\x09\x09sequence add: (IRAssignment new\x0a\x09\x09\x09add: (IRVariable new variable: (AliasVar new scope: inlinedClosure scope; name: each; yourself));\x0a\x09\x09\x09add: (IRVariable new variable: (AliasVar new scope: inlinedClosure scope; name: '$receiver'; yourself));\x0a\x09\x09\x09yourself) ].\x0a\x09\x09\x09\x0a\x09\x22To ensure the correct order of the closure instructions: first the temps then the sequence\x22\x0a\x09inlinedClosure add: sequence.\x0a\x0a\x09\x22Get all the statements\x22\x0a\x09statements := anIRClosure instructions last instructions.\x0a\x09\x0a\x09statements ifNotEmpty: [\x0a\x09\x09statements allButLast do: [ :each | sequence add: each ].\x0a\x0a\x09\x09\x22Inlined closures don't have implicit local returns\x22\x0a\x09\x09(statements last isReturn and: [ statements last isBlockReturn ])\x0a\x09\x09\x09ifTrue: [ sequence add: statements last instructions first ]\x0a\x09\x09\x09ifFalse: [ sequence add: statements last ] ].\x0a\x0a\x09^ inlinedClosure",
  1107. messageSends: ["inlinedClosure", "scope:", "scope", "do:", "tempDeclarations", "add:", "inlinedSequence", "arguments", "name:", "new", "yourself", "variable:", "instructions", "last", "ifNotEmpty:", "allButLast", "ifTrue:ifFalse:", "and:", "isReturn", "isBlockReturn", "first"],
  1108. referencedClasses: ["IRTempDeclaration", "IRAssignment", "IRVariable", "AliasVar"]
  1109. }),
  1110. smalltalk.IRSendInliner);
  1111. smalltalk.addMethod(
  1112. smalltalk.method({
  1113. selector: "inlineSend:",
  1114. category: 'inlining',
  1115. fn: function (anIRSend){
  1116. var self=this;
  1117. return smalltalk.withContext(function($ctx1) {
  1118. var $3,$2,$6,$5,$4,$1;
  1119. self._send_(anIRSend);
  1120. $3=self._send();
  1121. $ctx1.sendIdx["send"]=1;
  1122. $2=_st($3)._selector();
  1123. $6=self._send();
  1124. $5=_st($6)._instructions();
  1125. $4=_st($5)._allButFirst();
  1126. $1=self._perform_withArguments_($2,$4);
  1127. return $1;
  1128. }, function($ctx1) {$ctx1.fill(self,"inlineSend:",{anIRSend:anIRSend},smalltalk.IRSendInliner)})},
  1129. args: ["anIRSend"],
  1130. source: "inlineSend: anIRSend\x0a\x09self send: anIRSend.\x0a\x09^ self\x0a\x09\x09perform: self send selector\x0a\x09\x09withArguments: self send instructions allButFirst",
  1131. messageSends: ["send:", "perform:withArguments:", "selector", "send", "allButFirst", "instructions"],
  1132. referencedClasses: []
  1133. }),
  1134. smalltalk.IRSendInliner);
  1135. smalltalk.addMethod(
  1136. smalltalk.method({
  1137. selector: "inlinedClosure",
  1138. category: 'factory',
  1139. fn: function (){
  1140. var self=this;
  1141. function $IRInlinedClosure(){return smalltalk.IRInlinedClosure||(typeof IRInlinedClosure=="undefined"?nil:IRInlinedClosure)}
  1142. return smalltalk.withContext(function($ctx1) {
  1143. var $1;
  1144. $1=_st($IRInlinedClosure())._new();
  1145. return $1;
  1146. }, function($ctx1) {$ctx1.fill(self,"inlinedClosure",{},smalltalk.IRSendInliner)})},
  1147. args: [],
  1148. source: "inlinedClosure\x0a\x09^ IRInlinedClosure new",
  1149. messageSends: ["new"],
  1150. referencedClasses: ["IRInlinedClosure"]
  1151. }),
  1152. smalltalk.IRSendInliner);
  1153. smalltalk.addMethod(
  1154. smalltalk.method({
  1155. selector: "inlinedSend:with:",
  1156. category: 'inlining',
  1157. fn: function (inlinedSend,anIRInstruction){
  1158. var self=this;
  1159. var inlinedClosure;
  1160. return smalltalk.withContext(function($ctx1) {
  1161. var $1,$2,$5,$4,$3,$6,$7;
  1162. $1=_st(anIRInstruction)._isClosure();
  1163. if(! smalltalk.assert($1)){
  1164. self._inliningError_("Message argument should be a block");
  1165. $ctx1.sendIdx["inliningError:"]=1;
  1166. };
  1167. $2=_st(_st(_st(anIRInstruction)._arguments())._size()).__eq((0));
  1168. if(! smalltalk.assert($2)){
  1169. self._inliningError_("Inlined block should have zero argument");
  1170. };
  1171. inlinedClosure=_st(self._translator())._visit_(self._inlineClosure_(anIRInstruction));
  1172. $5=self._send();
  1173. $ctx1.sendIdx["send"]=1;
  1174. $4=_st($5)._instructions();
  1175. $3=_st($4)._first();
  1176. _st(inlinedSend)._add_($3);
  1177. $ctx1.sendIdx["add:"]=1;
  1178. $6=_st(inlinedSend)._add_(inlinedClosure);
  1179. $7=self._send();
  1180. _st($7)._replaceWith_(inlinedSend);
  1181. return inlinedSend;
  1182. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,inlinedClosure:inlinedClosure},smalltalk.IRSendInliner)})},
  1183. args: ["inlinedSend", "anIRInstruction"],
  1184. source: "inlinedSend: inlinedSend with: anIRInstruction\x0a\x09| inlinedClosure |\x0a\x0a\x09anIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x09anIRInstruction arguments size = 0 ifFalse: [ self inliningError: 'Inlined block should have zero argument' ].\x0a\x0a\x09inlinedClosure := self translator visit: (self inlineClosure: anIRInstruction).\x0a\x0a\x09inlinedSend\x0a\x09\x09add: self send instructions first;\x0a\x09\x09add: inlinedClosure.\x0a\x0a\x09self send replaceWith: inlinedSend.\x0a\x0a\x09^ inlinedSend",
  1185. messageSends: ["ifFalse:", "isClosure", "inliningError:", "=", "size", "arguments", "visit:", "translator", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:"],
  1186. referencedClasses: []
  1187. }),
  1188. smalltalk.IRSendInliner);
  1189. smalltalk.addMethod(
  1190. smalltalk.method({
  1191. selector: "inlinedSend:with:with:",
  1192. category: 'inlining',
  1193. fn: function (inlinedSend,anIRInstruction,anotherIRInstruction){
  1194. var self=this;
  1195. var inlinedClosure1,inlinedClosure2;
  1196. return smalltalk.withContext(function($ctx1) {
  1197. var $1,$2,$3,$4,$5,$6,$9,$8,$7,$10,$11;
  1198. $1=_st(anIRInstruction)._isClosure();
  1199. $ctx1.sendIdx["isClosure"]=1;
  1200. if(! smalltalk.assert($1)){
  1201. self._inliningError_("Message argument should be a block");
  1202. $ctx1.sendIdx["inliningError:"]=1;
  1203. };
  1204. $2=_st(anotherIRInstruction)._isClosure();
  1205. if(! smalltalk.assert($2)){
  1206. self._inliningError_("Message argument should be a block");
  1207. };
  1208. $3=self._translator();
  1209. $ctx1.sendIdx["translator"]=1;
  1210. $4=self._inlineClosure_(anIRInstruction);
  1211. $ctx1.sendIdx["inlineClosure:"]=1;
  1212. inlinedClosure1=_st($3)._visit_($4);
  1213. $ctx1.sendIdx["visit:"]=1;
  1214. $5=self._translator();
  1215. $6=self._inlineClosure_(anotherIRInstruction);
  1216. inlinedClosure2=_st($5)._visit_($6);
  1217. $9=self._send();
  1218. $ctx1.sendIdx["send"]=1;
  1219. $8=_st($9)._instructions();
  1220. $7=_st($8)._first();
  1221. _st(inlinedSend)._add_($7);
  1222. $ctx1.sendIdx["add:"]=1;
  1223. _st(inlinedSend)._add_(inlinedClosure1);
  1224. $ctx1.sendIdx["add:"]=2;
  1225. $10=_st(inlinedSend)._add_(inlinedClosure2);
  1226. $11=self._send();
  1227. _st($11)._replaceWith_(inlinedSend);
  1228. return inlinedSend;
  1229. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction,inlinedClosure1:inlinedClosure1,inlinedClosure2:inlinedClosure2},smalltalk.IRSendInliner)})},
  1230. args: ["inlinedSend", "anIRInstruction", "anotherIRInstruction"],
  1231. source: "inlinedSend: inlinedSend with: anIRInstruction with: anotherIRInstruction\x0a\x09| inlinedClosure1 inlinedClosure2 |\x0a\x0a\x09anIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x09anotherIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x0a\x09inlinedClosure1 := self translator visit: (self inlineClosure: anIRInstruction).\x0a\x09inlinedClosure2 := self translator visit: (self inlineClosure: anotherIRInstruction).\x0a\x0a\x09inlinedSend\x0a\x09\x09add: self send instructions first;\x0a\x09\x09add: inlinedClosure1;\x0a\x09\x09add: inlinedClosure2.\x0a\x0a\x09self send replaceWith: inlinedSend.\x0a\x09^ inlinedSend",
  1232. messageSends: ["ifFalse:", "isClosure", "inliningError:", "visit:", "translator", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:"],
  1233. referencedClasses: []
  1234. }),
  1235. smalltalk.IRSendInliner);
  1236. smalltalk.addMethod(
  1237. smalltalk.method({
  1238. selector: "inlinedSequence",
  1239. category: 'factory',
  1240. fn: function (){
  1241. var self=this;
  1242. function $IRInlinedSequence(){return smalltalk.IRInlinedSequence||(typeof IRInlinedSequence=="undefined"?nil:IRInlinedSequence)}
  1243. return smalltalk.withContext(function($ctx1) {
  1244. var $1;
  1245. $1=_st($IRInlinedSequence())._new();
  1246. return $1;
  1247. }, function($ctx1) {$ctx1.fill(self,"inlinedSequence",{},smalltalk.IRSendInliner)})},
  1248. args: [],
  1249. source: "inlinedSequence\x0a\x09^ IRInlinedSequence new",
  1250. messageSends: ["new"],
  1251. referencedClasses: ["IRInlinedSequence"]
  1252. }),
  1253. smalltalk.IRSendInliner);
  1254. smalltalk.addMethod(
  1255. smalltalk.method({
  1256. selector: "inliningError:",
  1257. category: 'error handling',
  1258. fn: function (aString){
  1259. var self=this;
  1260. function $InliningError(){return smalltalk.InliningError||(typeof InliningError=="undefined"?nil:InliningError)}
  1261. return smalltalk.withContext(function($ctx1) {
  1262. _st($InliningError())._signal_(aString);
  1263. return self}, function($ctx1) {$ctx1.fill(self,"inliningError:",{aString:aString},smalltalk.IRSendInliner)})},
  1264. args: ["aString"],
  1265. source: "inliningError: aString\x0a\x09InliningError signal: aString",
  1266. messageSends: ["signal:"],
  1267. referencedClasses: ["InliningError"]
  1268. }),
  1269. smalltalk.IRSendInliner);
  1270. smalltalk.addMethod(
  1271. smalltalk.method({
  1272. selector: "send",
  1273. category: 'accessing',
  1274. fn: function (){
  1275. var self=this;
  1276. return smalltalk.withContext(function($ctx1) {
  1277. var $1;
  1278. $1=self["@send"];
  1279. return $1;
  1280. }, function($ctx1) {$ctx1.fill(self,"send",{},smalltalk.IRSendInliner)})},
  1281. args: [],
  1282. source: "send\x0a\x09^ send",
  1283. messageSends: [],
  1284. referencedClasses: []
  1285. }),
  1286. smalltalk.IRSendInliner);
  1287. smalltalk.addMethod(
  1288. smalltalk.method({
  1289. selector: "send:",
  1290. category: 'accessing',
  1291. fn: function (anIRSend){
  1292. var self=this;
  1293. return smalltalk.withContext(function($ctx1) {
  1294. self["@send"]=anIRSend;
  1295. return self}, function($ctx1) {$ctx1.fill(self,"send:",{anIRSend:anIRSend},smalltalk.IRSendInliner)})},
  1296. args: ["anIRSend"],
  1297. source: "send: anIRSend\x0a\x09send := anIRSend",
  1298. messageSends: [],
  1299. referencedClasses: []
  1300. }),
  1301. smalltalk.IRSendInliner);
  1302. smalltalk.addMethod(
  1303. smalltalk.method({
  1304. selector: "translator",
  1305. category: 'accessing',
  1306. fn: function (){
  1307. var self=this;
  1308. return smalltalk.withContext(function($ctx1) {
  1309. var $1;
  1310. $1=self["@translator"];
  1311. return $1;
  1312. }, function($ctx1) {$ctx1.fill(self,"translator",{},smalltalk.IRSendInliner)})},
  1313. args: [],
  1314. source: "translator\x0a\x09^ translator",
  1315. messageSends: [],
  1316. referencedClasses: []
  1317. }),
  1318. smalltalk.IRSendInliner);
  1319. smalltalk.addMethod(
  1320. smalltalk.method({
  1321. selector: "translator:",
  1322. category: 'accessing',
  1323. fn: function (anASTTranslator){
  1324. var self=this;
  1325. return smalltalk.withContext(function($ctx1) {
  1326. self["@translator"]=anASTTranslator;
  1327. return self}, function($ctx1) {$ctx1.fill(self,"translator:",{anASTTranslator:anASTTranslator},smalltalk.IRSendInliner)})},
  1328. args: ["anASTTranslator"],
  1329. source: "translator: anASTTranslator\x0a\x09translator := anASTTranslator",
  1330. messageSends: [],
  1331. referencedClasses: []
  1332. }),
  1333. smalltalk.IRSendInliner);
  1334. smalltalk.addMethod(
  1335. smalltalk.method({
  1336. selector: "inlinedSelectors",
  1337. category: 'accessing',
  1338. fn: function (){
  1339. var self=this;
  1340. return smalltalk.withContext(function($ctx1) {
  1341. var $1;
  1342. $1=["ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:", "ifNil:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"];
  1343. return $1;
  1344. }, function($ctx1) {$ctx1.fill(self,"inlinedSelectors",{},smalltalk.IRSendInliner.klass)})},
  1345. args: [],
  1346. source: "inlinedSelectors\x0a\x09^ #('ifTrue:' 'ifFalse:' 'ifTrue:ifFalse:' 'ifFalse:ifTrue:' 'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:')",
  1347. messageSends: [],
  1348. referencedClasses: []
  1349. }),
  1350. smalltalk.IRSendInliner.klass);
  1351. smalltalk.addMethod(
  1352. smalltalk.method({
  1353. selector: "shouldInline:",
  1354. category: 'accessing',
  1355. fn: function (anIRInstruction){
  1356. var self=this;
  1357. return smalltalk.withContext(function($ctx1) {
  1358. var $1,$2;
  1359. var $early={};
  1360. try {
  1361. $1=_st(self._inlinedSelectors())._includes_(_st(anIRInstruction)._selector());
  1362. if(! smalltalk.assert($1)){
  1363. return false;
  1364. };
  1365. _st(_st(_st(anIRInstruction)._instructions())._allButFirst())._do_((function(each){
  1366. return smalltalk.withContext(function($ctx2) {
  1367. $2=_st(each)._isClosure();
  1368. if(! smalltalk.assert($2)){
  1369. throw $early=[false];
  1370. };
  1371. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1372. return true;
  1373. }
  1374. catch(e) {if(e===$early)return e[0]; throw e}
  1375. }, function($ctx1) {$ctx1.fill(self,"shouldInline:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner.klass)})},
  1376. args: ["anIRInstruction"],
  1377. source: "shouldInline: anIRInstruction\x0a\x09(self inlinedSelectors includes: anIRInstruction selector) ifFalse: [ ^ false ].\x0a\x09anIRInstruction instructions allButFirst do: [ :each |\x0a\x09\x09each isClosure ifFalse: [ ^ false ]].\x0a\x09^ true",
  1378. messageSends: ["ifFalse:", "includes:", "inlinedSelectors", "selector", "do:", "allButFirst", "instructions", "isClosure"],
  1379. referencedClasses: []
  1380. }),
  1381. smalltalk.IRSendInliner.klass);
  1382. smalltalk.addClass('IRAssignmentInliner', smalltalk.IRSendInliner, ['assignment'], 'Compiler-Inlining');
  1383. smalltalk.IRAssignmentInliner.comment="I inline message sends together with assignments by moving them around into the inline closure instructions.\x0a\x0a##Example\x0a\x0a\x09foo\x0a\x09\x09| a |\x0a\x09\x09a := true ifTrue: [ 1 ]\x0a\x0aWill produce:\x0a\x0a\x09if(smalltalk.assert(true) {\x0a\x09\x09a = 1;\x0a\x09};";
  1384. smalltalk.addMethod(
  1385. smalltalk.method({
  1386. selector: "assignment",
  1387. category: 'accessing',
  1388. fn: function (){
  1389. var self=this;
  1390. return smalltalk.withContext(function($ctx1) {
  1391. var $1;
  1392. $1=self["@assignment"];
  1393. return $1;
  1394. }, function($ctx1) {$ctx1.fill(self,"assignment",{},smalltalk.IRAssignmentInliner)})},
  1395. args: [],
  1396. source: "assignment\x0a\x09^ assignment",
  1397. messageSends: [],
  1398. referencedClasses: []
  1399. }),
  1400. smalltalk.IRAssignmentInliner);
  1401. smalltalk.addMethod(
  1402. smalltalk.method({
  1403. selector: "assignment:",
  1404. category: 'accessing',
  1405. fn: function (aNode){
  1406. var self=this;
  1407. return smalltalk.withContext(function($ctx1) {
  1408. self["@assignment"]=aNode;
  1409. return self}, function($ctx1) {$ctx1.fill(self,"assignment:",{aNode:aNode},smalltalk.IRAssignmentInliner)})},
  1410. args: ["aNode"],
  1411. source: "assignment: aNode\x0a\x09assignment := aNode",
  1412. messageSends: [],
  1413. referencedClasses: []
  1414. }),
  1415. smalltalk.IRAssignmentInliner);
  1416. smalltalk.addMethod(
  1417. smalltalk.method({
  1418. selector: "inlineAssignment:",
  1419. category: 'inlining',
  1420. fn: function (anIRAssignment){
  1421. var self=this;
  1422. var inlinedAssignment;
  1423. function $IRInlinedAssignment(){return smalltalk.IRInlinedAssignment||(typeof IRInlinedAssignment=="undefined"?nil:IRInlinedAssignment)}
  1424. return smalltalk.withContext(function($ctx1) {
  1425. var $1,$3,$2,$4;
  1426. self._assignment_(anIRAssignment);
  1427. inlinedAssignment=_st($IRInlinedAssignment())._new();
  1428. $1=_st(anIRAssignment)._instructions();
  1429. $ctx1.sendIdx["instructions"]=1;
  1430. _st($1)._do_((function(each){
  1431. return smalltalk.withContext(function($ctx2) {
  1432. return _st(inlinedAssignment)._add_(each);
  1433. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1434. _st(anIRAssignment)._replaceWith_(inlinedAssignment);
  1435. $3=_st(inlinedAssignment)._instructions();
  1436. $2=_st($3)._last();
  1437. self._inlineSend_($2);
  1438. $4=inlinedAssignment;
  1439. return $4;
  1440. }, function($ctx1) {$ctx1.fill(self,"inlineAssignment:",{anIRAssignment:anIRAssignment,inlinedAssignment:inlinedAssignment},smalltalk.IRAssignmentInliner)})},
  1441. args: ["anIRAssignment"],
  1442. source: "inlineAssignment: anIRAssignment\x0a\x09| inlinedAssignment |\x0a\x09self assignment: anIRAssignment.\x0a\x09inlinedAssignment := IRInlinedAssignment new.\x0a\x09anIRAssignment instructions do: [ :each |\x0a\x09\x09inlinedAssignment add: each ].\x0a\x09anIRAssignment replaceWith: inlinedAssignment.\x0a\x09self inlineSend: inlinedAssignment instructions last.\x0a\x09^ inlinedAssignment",
  1443. messageSends: ["assignment:", "new", "do:", "instructions", "add:", "replaceWith:", "inlineSend:", "last"],
  1444. referencedClasses: ["IRInlinedAssignment"]
  1445. }),
  1446. smalltalk.IRAssignmentInliner);
  1447. smalltalk.addMethod(
  1448. smalltalk.method({
  1449. selector: "inlineClosure:",
  1450. category: 'inlining',
  1451. fn: function (anIRClosure){
  1452. var self=this;
  1453. var inlinedClosure,statements;
  1454. function $IRAssignment(){return smalltalk.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
  1455. return smalltalk.withContext(function($ctx1) {
  1456. var $2,$1,$4,$3,$5,$7,$8,$10,$9,$11,$13,$12,$14,$6,$15;
  1457. inlinedClosure=smalltalk.IRAssignmentInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]);
  1458. $2=_st(inlinedClosure)._instructions();
  1459. $ctx1.sendIdx["instructions"]=2;
  1460. $1=_st($2)._last();
  1461. $ctx1.sendIdx["last"]=1;
  1462. statements=_st($1)._instructions();
  1463. $ctx1.sendIdx["instructions"]=1;
  1464. _st(statements)._ifNotEmpty_((function(){
  1465. return smalltalk.withContext(function($ctx2) {
  1466. $4=_st(statements)._last();
  1467. $ctx2.sendIdx["last"]=2;
  1468. $3=_st($4)._canBeAssigned();
  1469. if(smalltalk.assert($3)){
  1470. $5=_st(statements)._last();
  1471. $ctx2.sendIdx["last"]=3;
  1472. $7=_st($IRAssignment())._new();
  1473. $8=$7;
  1474. $10=_st(self._assignment())._instructions();
  1475. $9=_st($10)._first();
  1476. _st($8)._add_($9);
  1477. $ctx2.sendIdx["add:"]=1;
  1478. $11=$7;
  1479. $13=_st(statements)._last();
  1480. $12=_st($13)._copy();
  1481. _st($11)._add_($12);
  1482. $14=_st($7)._yourself();
  1483. $6=$14;
  1484. return _st($5)._replaceWith_($6);
  1485. };
  1486. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1487. $15=inlinedClosure;
  1488. return $15;
  1489. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,statements:statements},smalltalk.IRAssignmentInliner)})},
  1490. args: ["anIRClosure"],
  1491. source: "inlineClosure: anIRClosure\x0a\x09| inlinedClosure statements |\x0a\x0a\x09inlinedClosure := super inlineClosure: anIRClosure.\x0a\x09statements := inlinedClosure instructions last instructions.\x0a\x09\x0a\x09statements ifNotEmpty: [\x0a\x09\x09statements last canBeAssigned ifTrue: [\x0a\x09\x09\x09statements last replaceWith: (IRAssignment new\x0a\x09\x09\x09\x09add: self assignment instructions first;\x0a\x09\x09\x09\x09add: statements last copy;\x0a\x09\x09\x09\x09yourself) ] ].\x0a\x0a\x09^ inlinedClosure",
  1492. messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifTrue:", "canBeAssigned", "replaceWith:", "add:", "new", "first", "assignment", "copy", "yourself"],
  1493. referencedClasses: ["IRAssignment"]
  1494. }),
  1495. smalltalk.IRAssignmentInliner);
  1496. smalltalk.addClass('IRReturnInliner', smalltalk.IRSendInliner, [], 'Compiler-Inlining');
  1497. smalltalk.IRReturnInliner.comment="I inline message sends with inlined closure together with a return instruction.";
  1498. smalltalk.addMethod(
  1499. smalltalk.method({
  1500. selector: "inlineClosure:",
  1501. category: 'inlining',
  1502. fn: function (anIRClosure){
  1503. var self=this;
  1504. var closure,statements;
  1505. function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
  1506. return smalltalk.withContext(function($ctx1) {
  1507. var $2,$1,$4,$3,$5,$7,$8,$10,$9,$11,$6,$12;
  1508. closure=smalltalk.IRReturnInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]);
  1509. $2=_st(closure)._instructions();
  1510. $1=_st($2)._last();
  1511. $ctx1.sendIdx["last"]=1;
  1512. statements=_st($1)._instructions();
  1513. $ctx1.sendIdx["instructions"]=1;
  1514. _st(statements)._ifNotEmpty_((function(){
  1515. return smalltalk.withContext(function($ctx2) {
  1516. $4=_st(statements)._last();
  1517. $ctx2.sendIdx["last"]=2;
  1518. $3=_st($4)._isReturn();
  1519. if(! smalltalk.assert($3)){
  1520. $5=_st(statements)._last();
  1521. $ctx2.sendIdx["last"]=3;
  1522. $7=_st($IRReturn())._new();
  1523. $8=$7;
  1524. $10=_st(statements)._last();
  1525. $9=_st($10)._copy();
  1526. _st($8)._add_($9);
  1527. $11=_st($7)._yourself();
  1528. $6=$11;
  1529. return _st($5)._replaceWith_($6);
  1530. };
  1531. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1532. $12=closure;
  1533. return $12;
  1534. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,closure:closure,statements:statements},smalltalk.IRReturnInliner)})},
  1535. args: ["anIRClosure"],
  1536. source: "inlineClosure: anIRClosure\x0a\x09| closure statements |\x0a\x0a\x09closure := super inlineClosure: anIRClosure.\x0a\x09statements := closure instructions last instructions.\x0a\x09\x0a\x09statements ifNotEmpty: [\x0a\x09\x09statements last isReturn\x0a\x09\x09\x09ifFalse: [ statements last replaceWith: (IRReturn new\x0a\x09\x09\x09\x09add: statements last copy;\x0a\x09\x09\x09\x09yourself)] ].\x0a\x0a\x09^ closure",
  1537. messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifFalse:", "isReturn", "replaceWith:", "add:", "new", "copy", "yourself"],
  1538. referencedClasses: ["IRReturn"]
  1539. }),
  1540. smalltalk.IRReturnInliner);
  1541. smalltalk.addMethod(
  1542. smalltalk.method({
  1543. selector: "inlineReturn:",
  1544. category: 'inlining',
  1545. fn: function (anIRReturn){
  1546. var self=this;
  1547. var return_;
  1548. return smalltalk.withContext(function($ctx1) {
  1549. var $1,$3,$2,$4;
  1550. return_=self._inlinedReturn();
  1551. $1=_st(anIRReturn)._instructions();
  1552. $ctx1.sendIdx["instructions"]=1;
  1553. _st($1)._do_((function(each){
  1554. return smalltalk.withContext(function($ctx2) {
  1555. return _st(return_)._add_(each);
  1556. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1557. _st(anIRReturn)._replaceWith_(return_);
  1558. $3=_st(return_)._instructions();
  1559. $2=_st($3)._last();
  1560. self._inlineSend_($2);
  1561. $4=return_;
  1562. return $4;
  1563. }, function($ctx1) {$ctx1.fill(self,"inlineReturn:",{anIRReturn:anIRReturn,return_:return_},smalltalk.IRReturnInliner)})},
  1564. args: ["anIRReturn"],
  1565. source: "inlineReturn: anIRReturn\x0a\x09| return |\x0a\x09return := self inlinedReturn.\x0a\x09anIRReturn instructions do: [ :each |\x0a\x09\x09return add: each ].\x0a\x09anIRReturn replaceWith: return.\x0a\x09self inlineSend: return instructions last.\x0a\x09^ return",
  1566. messageSends: ["inlinedReturn", "do:", "instructions", "add:", "replaceWith:", "inlineSend:", "last"],
  1567. referencedClasses: []
  1568. }),
  1569. smalltalk.IRReturnInliner);
  1570. smalltalk.addMethod(
  1571. smalltalk.method({
  1572. selector: "inlinedReturn",
  1573. category: 'factory',
  1574. fn: function (){
  1575. var self=this;
  1576. function $IRInlinedReturn(){return smalltalk.IRInlinedReturn||(typeof IRInlinedReturn=="undefined"?nil:IRInlinedReturn)}
  1577. return smalltalk.withContext(function($ctx1) {
  1578. var $1;
  1579. $1=_st($IRInlinedReturn())._new();
  1580. return $1;
  1581. }, function($ctx1) {$ctx1.fill(self,"inlinedReturn",{},smalltalk.IRReturnInliner)})},
  1582. args: [],
  1583. source: "inlinedReturn\x0a\x09^ IRInlinedReturn new",
  1584. messageSends: ["new"],
  1585. referencedClasses: ["IRInlinedReturn"]
  1586. }),
  1587. smalltalk.IRReturnInliner);
  1588. smalltalk.addClass('InliningCodeGenerator', smalltalk.CodeGenerator, [], 'Compiler-Inlining');
  1589. smalltalk.InliningCodeGenerator.comment="I am a specialized code generator that uses inlining to produce more optimized JavaScript output";
  1590. smalltalk.addMethod(
  1591. smalltalk.method({
  1592. selector: "compileNode:",
  1593. category: 'compiling',
  1594. fn: function (aNode){
  1595. var self=this;
  1596. var ir,stream;
  1597. return smalltalk.withContext(function($ctx1) {
  1598. var $2,$3,$1;
  1599. _st(self._semanticAnalyzer())._visit_(aNode);
  1600. $ctx1.sendIdx["visit:"]=1;
  1601. ir=_st(self._translator())._visit_(aNode);
  1602. $ctx1.sendIdx["visit:"]=2;
  1603. _st(self._inliner())._visit_(ir);
  1604. $ctx1.sendIdx["visit:"]=3;
  1605. $2=self._irTranslator();
  1606. _st($2)._currentClass_(self._currentClass());
  1607. _st($2)._visit_(ir);
  1608. $3=_st($2)._contents();
  1609. $1=$3;
  1610. return $1;
  1611. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},smalltalk.InliningCodeGenerator)})},
  1612. args: ["aNode"],
  1613. source: "compileNode: aNode\x0a\x09| ir stream |\x0a\x0a\x09self semanticAnalyzer visit: aNode.\x0a\x09ir := self translator visit: aNode.\x0a\x09self inliner visit: ir.\x0a\x0a\x09^ self irTranslator\x0a\x09\x09currentClass: self currentClass;\x0a\x09\x09visit: ir;\x0a\x09\x09contents",
  1614. messageSends: ["visit:", "semanticAnalyzer", "translator", "inliner", "currentClass:", "irTranslator", "currentClass", "contents"],
  1615. referencedClasses: []
  1616. }),
  1617. smalltalk.InliningCodeGenerator);
  1618. smalltalk.addMethod(
  1619. smalltalk.method({
  1620. selector: "inliner",
  1621. category: 'compiling',
  1622. fn: function (){
  1623. var self=this;
  1624. function $IRInliner(){return smalltalk.IRInliner||(typeof IRInliner=="undefined"?nil:IRInliner)}
  1625. return smalltalk.withContext(function($ctx1) {
  1626. var $1;
  1627. $1=_st($IRInliner())._new();
  1628. return $1;
  1629. }, function($ctx1) {$ctx1.fill(self,"inliner",{},smalltalk.InliningCodeGenerator)})},
  1630. args: [],
  1631. source: "inliner\x0a\x09^ IRInliner new",
  1632. messageSends: ["new"],
  1633. referencedClasses: ["IRInliner"]
  1634. }),
  1635. smalltalk.InliningCodeGenerator);
  1636. smalltalk.addMethod(
  1637. smalltalk.method({
  1638. selector: "irTranslator",
  1639. category: 'compiling',
  1640. fn: function (){
  1641. var self=this;
  1642. function $IRInliningJSTranslator(){return smalltalk.IRInliningJSTranslator||(typeof IRInliningJSTranslator=="undefined"?nil:IRInliningJSTranslator)}
  1643. return smalltalk.withContext(function($ctx1) {
  1644. var $1;
  1645. $1=_st($IRInliningJSTranslator())._new();
  1646. return $1;
  1647. }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},smalltalk.InliningCodeGenerator)})},
  1648. args: [],
  1649. source: "irTranslator\x0a\x09^ IRInliningJSTranslator new",
  1650. messageSends: ["new"],
  1651. referencedClasses: ["IRInliningJSTranslator"]
  1652. }),
  1653. smalltalk.InliningCodeGenerator);
  1654. });