1
0

Compiler-Inlining.js 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702
  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,$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. return self._shouldInlineSend_(_st(_st(anIRAssignment)._instructions())._last());
  319. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  320. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  321. $ctx1.sendIdx["and:"]=1;
  322. return $1;
  323. }, function($ctx1) {$ctx1.fill(self,"shouldInlineAssignment:",{anIRAssignment:anIRAssignment},smalltalk.IRInliner)})},
  324. args: ["anIRAssignment"],
  325. source: "shouldInlineAssignment: anIRAssignment\x0a\x09^ anIRAssignment isInlined not and: [\x0a\x09\x09anIRAssignment instructions last isSend and: [\x0a\x09\x09\x09self shouldInlineSend: (anIRAssignment instructions last) ]]",
  326. messageSends: ["and:", "not", "isInlined", "isSend", "last", "instructions", "shouldInlineSend:"],
  327. referencedClasses: []
  328. }),
  329. smalltalk.IRInliner);
  330. smalltalk.addMethod(
  331. smalltalk.method({
  332. selector: "shouldInlineReturn:",
  333. category: 'testing',
  334. fn: function (anIRReturn){
  335. var self=this;
  336. return smalltalk.withContext(function($ctx1) {
  337. var $4,$3,$2,$1;
  338. $1=_st(_st(_st(anIRReturn)._isInlined())._not())._and_((function(){
  339. return smalltalk.withContext(function($ctx2) {
  340. $4=_st(anIRReturn)._instructions();
  341. $ctx2.sendIdx["instructions"]=1;
  342. $3=_st($4)._first();
  343. $ctx2.sendIdx["first"]=1;
  344. $2=_st($3)._isSend();
  345. return _st($2)._and_((function(){
  346. return smalltalk.withContext(function($ctx3) {
  347. return self._shouldInlineSend_(_st(_st(anIRReturn)._instructions())._first());
  348. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  349. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  350. $ctx1.sendIdx["and:"]=1;
  351. return $1;
  352. }, function($ctx1) {$ctx1.fill(self,"shouldInlineReturn:",{anIRReturn:anIRReturn},smalltalk.IRInliner)})},
  353. args: ["anIRReturn"],
  354. source: "shouldInlineReturn: anIRReturn\x0a\x09^ anIRReturn isInlined not and: [\x0a\x09\x09anIRReturn instructions first isSend and: [\x0a\x09\x09\x09self shouldInlineSend: (anIRReturn instructions first) ]]",
  355. messageSends: ["and:", "not", "isInlined", "isSend", "first", "instructions", "shouldInlineSend:"],
  356. referencedClasses: []
  357. }),
  358. smalltalk.IRInliner);
  359. smalltalk.addMethod(
  360. smalltalk.method({
  361. selector: "shouldInlineSend:",
  362. category: 'testing',
  363. fn: function (anIRSend){
  364. var self=this;
  365. function $IRSendInliner(){return smalltalk.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
  366. return smalltalk.withContext(function($ctx1) {
  367. var $1;
  368. $1=_st(_st(_st(anIRSend)._isInlined())._not())._and_((function(){
  369. return smalltalk.withContext(function($ctx2) {
  370. return _st($IRSendInliner())._shouldInline_(anIRSend);
  371. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  372. return $1;
  373. }, function($ctx1) {$ctx1.fill(self,"shouldInlineSend:",{anIRSend:anIRSend},smalltalk.IRInliner)})},
  374. args: ["anIRSend"],
  375. source: "shouldInlineSend: anIRSend\x0a\x09^ anIRSend isInlined not and: [\x0a\x09\x09IRSendInliner shouldInline: anIRSend ]",
  376. messageSends: ["and:", "not", "isInlined", "shouldInline:"],
  377. referencedClasses: ["IRSendInliner"]
  378. }),
  379. smalltalk.IRInliner);
  380. smalltalk.addMethod(
  381. smalltalk.method({
  382. selector: "transformNonLocalReturn:",
  383. category: 'visiting',
  384. fn: function (anIRNonLocalReturn){
  385. var self=this;
  386. var localReturn;
  387. function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
  388. return smalltalk.withContext(function($ctx1) {
  389. var $2,$1,$4,$3,$5,$6,$7,$8,$9;
  390. $2=_st(anIRNonLocalReturn)._scope();
  391. $ctx1.sendIdx["scope"]=1;
  392. $1=_st($2)._canInlineNonLocalReturns();
  393. if(smalltalk.assert($1)){
  394. $4=_st(anIRNonLocalReturn)._scope();
  395. $ctx1.sendIdx["scope"]=2;
  396. $3=_st($4)._methodScope();
  397. $5=_st(anIRNonLocalReturn)._scope();
  398. $ctx1.sendIdx["scope"]=3;
  399. _st($3)._removeNonLocalReturn_($5);
  400. $6=_st($IRReturn())._new();
  401. _st($6)._scope_(_st(anIRNonLocalReturn)._scope());
  402. $7=_st($6)._yourself();
  403. localReturn=$7;
  404. localReturn;
  405. _st(_st(anIRNonLocalReturn)._instructions())._do_((function(each){
  406. return smalltalk.withContext(function($ctx2) {
  407. return _st(localReturn)._add_(each);
  408. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  409. _st(anIRNonLocalReturn)._replaceWith_(localReturn);
  410. $8=localReturn;
  411. return $8;
  412. };
  413. $9=smalltalk.IRInliner.superclass.fn.prototype._visitIRNonLocalReturn_.apply(_st(self), [anIRNonLocalReturn]);
  414. return $9;
  415. }, function($ctx1) {$ctx1.fill(self,"transformNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn,localReturn:localReturn},smalltalk.IRInliner)})},
  416. args: ["anIRNonLocalReturn"],
  417. 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",
  418. messageSends: ["ifTrue:", "canInlineNonLocalReturns", "scope", "removeNonLocalReturn:", "methodScope", "scope:", "new", "yourself", "do:", "instructions", "add:", "replaceWith:", "visitIRNonLocalReturn:"],
  419. referencedClasses: ["IRReturn"]
  420. }),
  421. smalltalk.IRInliner);
  422. smalltalk.addMethod(
  423. smalltalk.method({
  424. selector: "visitIRAssignment:",
  425. category: 'visiting',
  426. fn: function (anIRAssignment){
  427. var self=this;
  428. return smalltalk.withContext(function($ctx1) {
  429. var $2,$1;
  430. $2=self._shouldInlineAssignment_(anIRAssignment);
  431. if(smalltalk.assert($2)){
  432. $1=_st(self._assignmentInliner())._inlineAssignment_(anIRAssignment);
  433. } else {
  434. $1=smalltalk.IRInliner.superclass.fn.prototype._visitIRAssignment_.apply(_st(self), [anIRAssignment]);
  435. };
  436. return $1;
  437. }, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment},smalltalk.IRInliner)})},
  438. args: ["anIRAssignment"],
  439. source: "visitIRAssignment: anIRAssignment\x0a\x09^ (self shouldInlineAssignment: anIRAssignment)\x0a\x09\x09ifTrue: [ self assignmentInliner inlineAssignment: anIRAssignment ]\x0a\x09\x09ifFalse: [ super visitIRAssignment: anIRAssignment ]",
  440. messageSends: ["ifTrue:ifFalse:", "shouldInlineAssignment:", "inlineAssignment:", "assignmentInliner", "visitIRAssignment:"],
  441. referencedClasses: []
  442. }),
  443. smalltalk.IRInliner);
  444. smalltalk.addMethod(
  445. smalltalk.method({
  446. selector: "visitIRNonLocalReturn:",
  447. category: 'visiting',
  448. fn: function (anIRNonLocalReturn){
  449. var self=this;
  450. return smalltalk.withContext(function($ctx1) {
  451. var $1;
  452. $1=self._transformNonLocalReturn_(anIRNonLocalReturn);
  453. return $1;
  454. }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn},smalltalk.IRInliner)})},
  455. args: ["anIRNonLocalReturn"],
  456. source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09^ self transformNonLocalReturn: anIRNonLocalReturn",
  457. messageSends: ["transformNonLocalReturn:"],
  458. referencedClasses: []
  459. }),
  460. smalltalk.IRInliner);
  461. smalltalk.addMethod(
  462. smalltalk.method({
  463. selector: "visitIRReturn:",
  464. category: 'visiting',
  465. fn: function (anIRReturn){
  466. var self=this;
  467. return smalltalk.withContext(function($ctx1) {
  468. var $2,$1;
  469. $2=self._shouldInlineReturn_(anIRReturn);
  470. if(smalltalk.assert($2)){
  471. $1=_st(self._returnInliner())._inlineReturn_(anIRReturn);
  472. } else {
  473. $1=smalltalk.IRInliner.superclass.fn.prototype._visitIRReturn_.apply(_st(self), [anIRReturn]);
  474. };
  475. return $1;
  476. }, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn},smalltalk.IRInliner)})},
  477. args: ["anIRReturn"],
  478. source: "visitIRReturn: anIRReturn\x0a\x09^ (self shouldInlineReturn: anIRReturn)\x0a\x09\x09ifTrue: [ self returnInliner inlineReturn: anIRReturn ]\x0a\x09\x09ifFalse: [ super visitIRReturn: anIRReturn ]",
  479. messageSends: ["ifTrue:ifFalse:", "shouldInlineReturn:", "inlineReturn:", "returnInliner", "visitIRReturn:"],
  480. referencedClasses: []
  481. }),
  482. smalltalk.IRInliner);
  483. smalltalk.addMethod(
  484. smalltalk.method({
  485. selector: "visitIRSend:",
  486. category: 'visiting',
  487. fn: function (anIRSend){
  488. var self=this;
  489. return smalltalk.withContext(function($ctx1) {
  490. var $2,$1;
  491. $2=self._shouldInlineSend_(anIRSend);
  492. if(smalltalk.assert($2)){
  493. $1=_st(self._sendInliner())._inlineSend_(anIRSend);
  494. } else {
  495. $1=smalltalk.IRInliner.superclass.fn.prototype._visitIRSend_.apply(_st(self), [anIRSend]);
  496. };
  497. return $1;
  498. }, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend},smalltalk.IRInliner)})},
  499. args: ["anIRSend"],
  500. source: "visitIRSend: anIRSend\x0a\x09^ (self shouldInlineSend: anIRSend)\x0a\x09\x09ifTrue: [ self sendInliner inlineSend: anIRSend ]\x0a\x09\x09ifFalse: [ super visitIRSend: anIRSend ]",
  501. messageSends: ["ifTrue:ifFalse:", "shouldInlineSend:", "inlineSend:", "sendInliner", "visitIRSend:"],
  502. referencedClasses: []
  503. }),
  504. smalltalk.IRInliner);
  505. smalltalk.addClass('IRInliningJSTranslator', smalltalk.IRJSTranslator, [], 'Compiler-Inlining');
  506. smalltalk.IRInliningJSTranslator.comment="I am a specialized JavaScript translator able to write inlined IR instructions to JavaScript stream (`JSStream` instance).";
  507. smalltalk.addMethod(
  508. smalltalk.method({
  509. selector: "visitIRInlinedAssignment:",
  510. category: 'visiting',
  511. fn: function (anIRInlinedAssignment){
  512. var self=this;
  513. return smalltalk.withContext(function($ctx1) {
  514. self._visit_(_st(_st(anIRInlinedAssignment)._instructions())._last());
  515. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedAssignment:",{anIRInlinedAssignment:anIRInlinedAssignment},smalltalk.IRInliningJSTranslator)})},
  516. args: ["anIRInlinedAssignment"],
  517. source: "visitIRInlinedAssignment: anIRInlinedAssignment\x0a\x09self visit: anIRInlinedAssignment instructions last",
  518. messageSends: ["visit:", "last", "instructions"],
  519. referencedClasses: []
  520. }),
  521. smalltalk.IRInliningJSTranslator);
  522. smalltalk.addMethod(
  523. smalltalk.method({
  524. selector: "visitIRInlinedClosure:",
  525. category: 'visiting',
  526. fn: function (anIRInlinedClosure){
  527. var self=this;
  528. return smalltalk.withContext(function($ctx1) {
  529. _st(self._stream())._nextPutVars_(_st(_st(anIRInlinedClosure)._tempDeclarations())._collect_((function(each){
  530. return smalltalk.withContext(function($ctx2) {
  531. return _st(_st(each)._name())._asVariableName();
  532. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})})));
  533. _st(_st(anIRInlinedClosure)._instructions())._do_((function(each){
  534. return smalltalk.withContext(function($ctx2) {
  535. return self._visit_(each);
  536. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  537. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure},smalltalk.IRInliningJSTranslator)})},
  538. args: ["anIRInlinedClosure"],
  539. 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 ]",
  540. messageSends: ["nextPutVars:", "stream", "collect:", "tempDeclarations", "asVariableName", "name", "do:", "instructions", "visit:"],
  541. referencedClasses: []
  542. }),
  543. smalltalk.IRInliningJSTranslator);
  544. smalltalk.addMethod(
  545. smalltalk.method({
  546. selector: "visitIRInlinedIfFalse:",
  547. category: 'visiting',
  548. fn: function (anIRInlinedIfFalse){
  549. var self=this;
  550. return smalltalk.withContext(function($ctx1) {
  551. var $1,$2,$4,$3;
  552. $1=self._stream();
  553. $ctx1.sendIdx["stream"]=1;
  554. _st($1)._nextPutIf_with_((function(){
  555. return smalltalk.withContext(function($ctx2) {
  556. $2=self._stream();
  557. $ctx2.sendIdx["stream"]=2;
  558. _st($2)._nextPutAll_("! smalltalk.assert(");
  559. $ctx2.sendIdx["nextPutAll:"]=1;
  560. $4=_st(anIRInlinedIfFalse)._instructions();
  561. $ctx2.sendIdx["instructions"]=1;
  562. $3=_st($4)._first();
  563. self._visit_($3);
  564. $ctx2.sendIdx["visit:"]=1;
  565. return _st(self._stream())._nextPutAll_(")");
  566. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  567. return smalltalk.withContext(function($ctx2) {
  568. return self._visit_(_st(_st(anIRInlinedIfFalse)._instructions())._last());
  569. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  570. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfFalse:",{anIRInlinedIfFalse:anIRInlinedIfFalse},smalltalk.IRInliningJSTranslator)})},
  571. args: ["anIRInlinedIfFalse"],
  572. 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 ]",
  573. messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"],
  574. referencedClasses: []
  575. }),
  576. smalltalk.IRInliningJSTranslator);
  577. smalltalk.addMethod(
  578. smalltalk.method({
  579. selector: "visitIRInlinedIfNil:",
  580. category: 'visiting',
  581. fn: function (anIRInlinedIfNil){
  582. var self=this;
  583. return smalltalk.withContext(function($ctx1) {
  584. var $1,$2,$4,$3;
  585. $1=self._stream();
  586. $ctx1.sendIdx["stream"]=1;
  587. _st($1)._nextPutIf_with_((function(){
  588. return smalltalk.withContext(function($ctx2) {
  589. $2=self._stream();
  590. $ctx2.sendIdx["stream"]=2;
  591. _st($2)._nextPutAll_("($receiver = ");
  592. $ctx2.sendIdx["nextPutAll:"]=1;
  593. $4=_st(anIRInlinedIfNil)._instructions();
  594. $ctx2.sendIdx["instructions"]=1;
  595. $3=_st($4)._first();
  596. self._visit_($3);
  597. $ctx2.sendIdx["visit:"]=1;
  598. return _st(self._stream())._nextPutAll_(") == nil || $receiver == null");
  599. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  600. return smalltalk.withContext(function($ctx2) {
  601. return self._visit_(_st(_st(anIRInlinedIfNil)._instructions())._last());
  602. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  603. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNil:",{anIRInlinedIfNil:anIRInlinedIfNil},smalltalk.IRInliningJSTranslator)})},
  604. args: ["anIRInlinedIfNil"],
  605. 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 ]",
  606. messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"],
  607. referencedClasses: []
  608. }),
  609. smalltalk.IRInliningJSTranslator);
  610. smalltalk.addMethod(
  611. smalltalk.method({
  612. selector: "visitIRInlinedIfNilIfNotNil:",
  613. category: 'visiting',
  614. fn: function (anIRInlinedIfNilIfNotNil){
  615. var self=this;
  616. return smalltalk.withContext(function($ctx1) {
  617. var $1,$2,$4,$3,$6,$5;
  618. $1=self._stream();
  619. $ctx1.sendIdx["stream"]=1;
  620. _st($1)._nextPutIfElse_with_with_((function(){
  621. return smalltalk.withContext(function($ctx2) {
  622. $2=self._stream();
  623. $ctx2.sendIdx["stream"]=2;
  624. _st($2)._nextPutAll_("($receiver = ");
  625. $ctx2.sendIdx["nextPutAll:"]=1;
  626. $4=_st(anIRInlinedIfNilIfNotNil)._instructions();
  627. $ctx2.sendIdx["instructions"]=1;
  628. $3=_st($4)._first();
  629. self._visit_($3);
  630. $ctx2.sendIdx["visit:"]=1;
  631. return _st(self._stream())._nextPutAll_(") == nil || $receiver == null");
  632. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  633. return smalltalk.withContext(function($ctx2) {
  634. $6=_st(anIRInlinedIfNilIfNotNil)._instructions();
  635. $ctx2.sendIdx["instructions"]=2;
  636. $5=_st($6)._second();
  637. return self._visit_($5);
  638. $ctx2.sendIdx["visit:"]=2;
  639. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),(function(){
  640. return smalltalk.withContext(function($ctx2) {
  641. return self._visit_(_st(_st(anIRInlinedIfNilIfNotNil)._instructions())._third());
  642. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  643. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNilIfNotNil:",{anIRInlinedIfNilIfNotNil:anIRInlinedIfNilIfNotNil},smalltalk.IRInliningJSTranslator)})},
  644. args: ["anIRInlinedIfNilIfNotNil"],
  645. 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 ]",
  646. messageSends: ["nextPutIfElse:with:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "second", "third"],
  647. referencedClasses: []
  648. }),
  649. smalltalk.IRInliningJSTranslator);
  650. smalltalk.addMethod(
  651. smalltalk.method({
  652. selector: "visitIRInlinedIfTrue:",
  653. category: 'visiting',
  654. fn: function (anIRInlinedIfTrue){
  655. var self=this;
  656. return smalltalk.withContext(function($ctx1) {
  657. var $1,$2,$4,$3;
  658. $1=self._stream();
  659. $ctx1.sendIdx["stream"]=1;
  660. _st($1)._nextPutIf_with_((function(){
  661. return smalltalk.withContext(function($ctx2) {
  662. $2=self._stream();
  663. $ctx2.sendIdx["stream"]=2;
  664. _st($2)._nextPutAll_("smalltalk.assert(");
  665. $ctx2.sendIdx["nextPutAll:"]=1;
  666. $4=_st(anIRInlinedIfTrue)._instructions();
  667. $ctx2.sendIdx["instructions"]=1;
  668. $3=_st($4)._first();
  669. self._visit_($3);
  670. $ctx2.sendIdx["visit:"]=1;
  671. return _st(self._stream())._nextPutAll_(")");
  672. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  673. return smalltalk.withContext(function($ctx2) {
  674. return self._visit_(_st(_st(anIRInlinedIfTrue)._instructions())._last());
  675. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  676. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrue:",{anIRInlinedIfTrue:anIRInlinedIfTrue},smalltalk.IRInliningJSTranslator)})},
  677. args: ["anIRInlinedIfTrue"],
  678. 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 ]",
  679. messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"],
  680. referencedClasses: []
  681. }),
  682. smalltalk.IRInliningJSTranslator);
  683. smalltalk.addMethod(
  684. smalltalk.method({
  685. selector: "visitIRInlinedIfTrueIfFalse:",
  686. category: 'visiting',
  687. fn: function (anIRInlinedIfTrueIfFalse){
  688. var self=this;
  689. return smalltalk.withContext(function($ctx1) {
  690. var $1,$2,$4,$3,$6,$5;
  691. $1=self._stream();
  692. $ctx1.sendIdx["stream"]=1;
  693. _st($1)._nextPutIfElse_with_with_((function(){
  694. return smalltalk.withContext(function($ctx2) {
  695. $2=self._stream();
  696. $ctx2.sendIdx["stream"]=2;
  697. _st($2)._nextPutAll_("smalltalk.assert(");
  698. $ctx2.sendIdx["nextPutAll:"]=1;
  699. $4=_st(anIRInlinedIfTrueIfFalse)._instructions();
  700. $ctx2.sendIdx["instructions"]=1;
  701. $3=_st($4)._first();
  702. self._visit_($3);
  703. $ctx2.sendIdx["visit:"]=1;
  704. return _st(self._stream())._nextPutAll_(")");
  705. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}),(function(){
  706. return smalltalk.withContext(function($ctx2) {
  707. $6=_st(anIRInlinedIfTrueIfFalse)._instructions();
  708. $ctx2.sendIdx["instructions"]=2;
  709. $5=_st($6)._second();
  710. return self._visit_($5);
  711. $ctx2.sendIdx["visit:"]=2;
  712. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}),(function(){
  713. return smalltalk.withContext(function($ctx2) {
  714. return self._visit_(_st(_st(anIRInlinedIfTrueIfFalse)._instructions())._third());
  715. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  716. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrueIfFalse:",{anIRInlinedIfTrueIfFalse:anIRInlinedIfTrueIfFalse},smalltalk.IRInliningJSTranslator)})},
  717. args: ["anIRInlinedIfTrueIfFalse"],
  718. 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 ]",
  719. messageSends: ["nextPutIfElse:with:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "second", "third"],
  720. referencedClasses: []
  721. }),
  722. smalltalk.IRInliningJSTranslator);
  723. smalltalk.addMethod(
  724. smalltalk.method({
  725. selector: "visitIRInlinedNonLocalReturn:",
  726. category: 'visiting',
  727. fn: function (anIRInlinedReturn){
  728. var self=this;
  729. return smalltalk.withContext(function($ctx1) {
  730. var $1;
  731. $1=self._stream();
  732. $ctx1.sendIdx["stream"]=1;
  733. _st($1)._nextPutStatementWith_((function(){
  734. return smalltalk.withContext(function($ctx2) {
  735. return self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
  736. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  737. _st(self._stream())._nextPutNonLocalReturnWith_((function(){
  738. return smalltalk.withContext(function($ctx2) {
  739. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)})}));
  740. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedNonLocalReturn:",{anIRInlinedReturn:anIRInlinedReturn},smalltalk.IRInliningJSTranslator)})},
  741. args: ["anIRInlinedReturn"],
  742. source: "visitIRInlinedNonLocalReturn: anIRInlinedReturn\x0a\x09self stream nextPutStatementWith: [\x0a\x09\x09self visit: anIRInlinedReturn instructions last ].\x0a\x09self stream nextPutNonLocalReturnWith: [ ]",
  743. messageSends: ["nextPutStatementWith:", "stream", "visit:", "last", "instructions", "nextPutNonLocalReturnWith:"],
  744. referencedClasses: []
  745. }),
  746. smalltalk.IRInliningJSTranslator);
  747. smalltalk.addMethod(
  748. smalltalk.method({
  749. selector: "visitIRInlinedReturn:",
  750. category: 'visiting',
  751. fn: function (anIRInlinedReturn){
  752. var self=this;
  753. return smalltalk.withContext(function($ctx1) {
  754. self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
  755. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedReturn:",{anIRInlinedReturn:anIRInlinedReturn},smalltalk.IRInliningJSTranslator)})},
  756. args: ["anIRInlinedReturn"],
  757. source: "visitIRInlinedReturn: anIRInlinedReturn\x0a\x09self visit: anIRInlinedReturn instructions last",
  758. messageSends: ["visit:", "last", "instructions"],
  759. referencedClasses: []
  760. }),
  761. smalltalk.IRInliningJSTranslator);
  762. smalltalk.addMethod(
  763. smalltalk.method({
  764. selector: "visitIRInlinedSequence:",
  765. category: 'visiting',
  766. fn: function (anIRInlinedSequence){
  767. var self=this;
  768. return smalltalk.withContext(function($ctx1) {
  769. _st(_st(anIRInlinedSequence)._instructions())._do_((function(each){
  770. return smalltalk.withContext(function($ctx2) {
  771. return _st(self._stream())._nextPutStatementWith_((function(){
  772. return smalltalk.withContext(function($ctx3) {
  773. return self._visit_(each);
  774. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)})}));
  775. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  776. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedSequence:",{anIRInlinedSequence:anIRInlinedSequence},smalltalk.IRInliningJSTranslator)})},
  777. args: ["anIRInlinedSequence"],
  778. source: "visitIRInlinedSequence: anIRInlinedSequence\x0a\x09anIRInlinedSequence instructions do: [ :each |\x0a\x09\x09self stream nextPutStatementWith: [ self visit: each ]]",
  779. messageSends: ["do:", "instructions", "nextPutStatementWith:", "stream", "visit:"],
  780. referencedClasses: []
  781. }),
  782. smalltalk.IRInliningJSTranslator);
  783. smalltalk.addClass('IRSendInliner', smalltalk.Object, ['send', 'translator'], 'Compiler-Inlining');
  784. smalltalk.IRSendInliner.comment="I inline some message sends and block closure arguments. I heavily rely on #perform: to dispatch inlining methods.";
  785. smalltalk.addMethod(
  786. smalltalk.method({
  787. selector: "ifFalse:",
  788. category: 'inlining',
  789. fn: function (anIRInstruction){
  790. var self=this;
  791. function $IRInlinedIfFalse(){return smalltalk.IRInlinedIfFalse||(typeof IRInlinedIfFalse=="undefined"?nil:IRInlinedIfFalse)}
  792. return smalltalk.withContext(function($ctx1) {
  793. var $1;
  794. $1=self._inlinedSend_with_(_st($IRInlinedIfFalse())._new(),anIRInstruction);
  795. return $1;
  796. }, function($ctx1) {$ctx1.fill(self,"ifFalse:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  797. args: ["anIRInstruction"],
  798. source: "ifFalse: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfFalse new with: anIRInstruction",
  799. messageSends: ["inlinedSend:with:", "new"],
  800. referencedClasses: ["IRInlinedIfFalse"]
  801. }),
  802. smalltalk.IRSendInliner);
  803. smalltalk.addMethod(
  804. smalltalk.method({
  805. selector: "ifFalse:ifTrue:",
  806. category: 'inlining',
  807. fn: function (anIRInstruction,anotherIRInstruction){
  808. var self=this;
  809. return smalltalk.withContext(function($ctx1) {
  810. var $1;
  811. $1=self._perform_withArguments_("ifTrue:ifFalse:",[anotherIRInstruction,anIRInstruction]);
  812. return $1;
  813. }, function($ctx1) {$ctx1.fill(self,"ifFalse:ifTrue:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  814. args: ["anIRInstruction", "anotherIRInstruction"],
  815. source: "ifFalse: anIRInstruction ifTrue: anotherIRInstruction\x0a\x09^ self perform: #ifTrue:ifFalse: withArguments: { anotherIRInstruction. anIRInstruction }",
  816. messageSends: ["perform:withArguments:"],
  817. referencedClasses: []
  818. }),
  819. smalltalk.IRSendInliner);
  820. smalltalk.addMethod(
  821. smalltalk.method({
  822. selector: "ifNil:",
  823. category: 'inlining',
  824. fn: function (anIRInstruction){
  825. var self=this;
  826. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  827. function $IRClosure(){return smalltalk.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
  828. function $IRBlockSequence(){return smalltalk.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
  829. return smalltalk.withContext(function($ctx1) {
  830. var $2,$4,$5,$7,$8,$6,$9,$3,$1;
  831. $2=_st($IRInlinedIfNilIfNotNil())._new();
  832. $ctx1.sendIdx["new"]=1;
  833. $4=_st($IRClosure())._new();
  834. $ctx1.sendIdx["new"]=2;
  835. _st($4)._scope_(_st(_st(anIRInstruction)._scope())._copy());
  836. $5=$4;
  837. $7=_st($IRBlockSequence())._new();
  838. _st($7)._add_(_st(_st(self._send())._instructions())._first());
  839. $8=_st($7)._yourself();
  840. $ctx1.sendIdx["yourself"]=1;
  841. $6=$8;
  842. _st($5)._add_($6);
  843. $ctx1.sendIdx["add:"]=1;
  844. $9=_st($4)._yourself();
  845. $3=$9;
  846. $1=self._inlinedSend_with_with_($2,anIRInstruction,$3);
  847. return $1;
  848. }, function($ctx1) {$ctx1.fill(self,"ifNil:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  849. args: ["anIRInstruction"],
  850. 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)",
  851. messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"],
  852. referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"]
  853. }),
  854. smalltalk.IRSendInliner);
  855. smalltalk.addMethod(
  856. smalltalk.method({
  857. selector: "ifNil:ifNotNil:",
  858. category: 'inlining',
  859. fn: function (anIRInstruction,anotherIRInstruction){
  860. var self=this;
  861. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  862. return smalltalk.withContext(function($ctx1) {
  863. var $1;
  864. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anIRInstruction,anotherIRInstruction);
  865. return $1;
  866. }, function($ctx1) {$ctx1.fill(self,"ifNil:ifNotNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  867. args: ["anIRInstruction", "anotherIRInstruction"],
  868. source: "ifNil: anIRInstruction ifNotNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new with: anIRInstruction with: anotherIRInstruction",
  869. messageSends: ["inlinedSend:with:with:", "new"],
  870. referencedClasses: ["IRInlinedIfNilIfNotNil"]
  871. }),
  872. smalltalk.IRSendInliner);
  873. smalltalk.addMethod(
  874. smalltalk.method({
  875. selector: "ifNotNil:",
  876. category: 'inlining',
  877. fn: function (anIRInstruction){
  878. var self=this;
  879. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  880. function $IRClosure(){return smalltalk.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
  881. function $IRBlockSequence(){return smalltalk.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
  882. return smalltalk.withContext(function($ctx1) {
  883. var $2,$4,$5,$7,$8,$6,$9,$3,$1;
  884. $2=_st($IRInlinedIfNilIfNotNil())._new();
  885. $ctx1.sendIdx["new"]=1;
  886. $4=_st($IRClosure())._new();
  887. $ctx1.sendIdx["new"]=2;
  888. _st($4)._scope_(_st(_st(anIRInstruction)._scope())._copy());
  889. $5=$4;
  890. $7=_st($IRBlockSequence())._new();
  891. _st($7)._add_(_st(_st(self._send())._instructions())._first());
  892. $8=_st($7)._yourself();
  893. $ctx1.sendIdx["yourself"]=1;
  894. $6=$8;
  895. _st($5)._add_($6);
  896. $ctx1.sendIdx["add:"]=1;
  897. $9=_st($4)._yourself();
  898. $3=$9;
  899. $1=self._inlinedSend_with_with_($2,$3,anIRInstruction);
  900. return $1;
  901. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  902. args: ["anIRInstruction"],
  903. 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",
  904. messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"],
  905. referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"]
  906. }),
  907. smalltalk.IRSendInliner);
  908. smalltalk.addMethod(
  909. smalltalk.method({
  910. selector: "ifNotNil:ifNil:",
  911. category: 'inlining',
  912. fn: function (anIRInstruction,anotherIRInstruction){
  913. var self=this;
  914. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  915. return smalltalk.withContext(function($ctx1) {
  916. var $1;
  917. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anotherIRInstruction,anIRInstruction);
  918. return $1;
  919. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:ifNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  920. args: ["anIRInstruction", "anotherIRInstruction"],
  921. source: "ifNotNil: anIRInstruction ifNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new with: anotherIRInstruction with: anIRInstruction",
  922. messageSends: ["inlinedSend:with:with:", "new"],
  923. referencedClasses: ["IRInlinedIfNilIfNotNil"]
  924. }),
  925. smalltalk.IRSendInliner);
  926. smalltalk.addMethod(
  927. smalltalk.method({
  928. selector: "ifTrue:",
  929. category: 'inlining',
  930. fn: function (anIRInstruction){
  931. var self=this;
  932. function $IRInlinedIfTrue(){return smalltalk.IRInlinedIfTrue||(typeof IRInlinedIfTrue=="undefined"?nil:IRInlinedIfTrue)}
  933. return smalltalk.withContext(function($ctx1) {
  934. var $1;
  935. $1=self._inlinedSend_with_(_st($IRInlinedIfTrue())._new(),anIRInstruction);
  936. return $1;
  937. }, function($ctx1) {$ctx1.fill(self,"ifTrue:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  938. args: ["anIRInstruction"],
  939. source: "ifTrue: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrue new with: anIRInstruction",
  940. messageSends: ["inlinedSend:with:", "new"],
  941. referencedClasses: ["IRInlinedIfTrue"]
  942. }),
  943. smalltalk.IRSendInliner);
  944. smalltalk.addMethod(
  945. smalltalk.method({
  946. selector: "ifTrue:ifFalse:",
  947. category: 'inlining',
  948. fn: function (anIRInstruction,anotherIRInstruction){
  949. var self=this;
  950. function $IRInlinedIfTrueIfFalse(){return smalltalk.IRInlinedIfTrueIfFalse||(typeof IRInlinedIfTrueIfFalse=="undefined"?nil:IRInlinedIfTrueIfFalse)}
  951. return smalltalk.withContext(function($ctx1) {
  952. var $1;
  953. $1=self._inlinedSend_with_with_(_st($IRInlinedIfTrueIfFalse())._new(),anIRInstruction,anotherIRInstruction);
  954. return $1;
  955. }, function($ctx1) {$ctx1.fill(self,"ifTrue:ifFalse:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  956. args: ["anIRInstruction", "anotherIRInstruction"],
  957. source: "ifTrue: anIRInstruction ifFalse: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrueIfFalse new with: anIRInstruction with: anotherIRInstruction",
  958. messageSends: ["inlinedSend:with:with:", "new"],
  959. referencedClasses: ["IRInlinedIfTrueIfFalse"]
  960. }),
  961. smalltalk.IRSendInliner);
  962. smalltalk.addMethod(
  963. smalltalk.method({
  964. selector: "inlineClosure:",
  965. category: 'inlining',
  966. fn: function (anIRClosure){
  967. var self=this;
  968. var inlinedClosure,sequence,statements;
  969. function $IRTempDeclaration(){return smalltalk.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
  970. function $IRAssignment(){return smalltalk.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
  971. function $IRVariable(){return smalltalk.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
  972. function $AliasVar(){return smalltalk.AliasVar||(typeof AliasVar=="undefined"?nil:AliasVar)}
  973. return smalltalk.withContext(function($ctx1) {
  974. var $1,$2,$3,$5,$6,$4,$7,$9,$10,$12,$14,$15,$16,$17,$13,$11,$18,$20,$22,$23,$21,$19,$24,$8,$26,$25,$29,$28,$30,$27,$31,$34,$33,$32,$35;
  975. inlinedClosure=self._inlinedClosure();
  976. $1=inlinedClosure;
  977. $2=_st(anIRClosure)._scope();
  978. $ctx1.sendIdx["scope"]=1;
  979. _st($1)._scope_($2);
  980. $ctx1.sendIdx["scope:"]=1;
  981. _st(_st(anIRClosure)._tempDeclarations())._do_((function(each){
  982. return smalltalk.withContext(function($ctx2) {
  983. return _st(inlinedClosure)._add_(each);
  984. $ctx2.sendIdx["add:"]=1;
  985. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  986. $ctx1.sendIdx["do:"]=1;
  987. sequence=self._inlinedSequence();
  988. _st(_st(anIRClosure)._arguments())._do_((function(each){
  989. return smalltalk.withContext(function($ctx2) {
  990. $3=inlinedClosure;
  991. $5=_st($IRTempDeclaration())._new();
  992. $ctx2.sendIdx["new"]=1;
  993. _st($5)._name_(each);
  994. $ctx2.sendIdx["name:"]=1;
  995. $6=_st($5)._yourself();
  996. $ctx2.sendIdx["yourself"]=1;
  997. $4=$6;
  998. _st($3)._add_($4);
  999. $ctx2.sendIdx["add:"]=2;
  1000. $7=sequence;
  1001. $9=_st($IRAssignment())._new();
  1002. $ctx2.sendIdx["new"]=2;
  1003. $10=$9;
  1004. $12=_st($IRVariable())._new();
  1005. $ctx2.sendIdx["new"]=3;
  1006. $14=_st($AliasVar())._new();
  1007. $ctx2.sendIdx["new"]=4;
  1008. $15=$14;
  1009. $16=_st(inlinedClosure)._scope();
  1010. $ctx2.sendIdx["scope"]=2;
  1011. _st($15)._scope_($16);
  1012. $ctx2.sendIdx["scope:"]=2;
  1013. _st($14)._name_(each);
  1014. $ctx2.sendIdx["name:"]=2;
  1015. $17=_st($14)._yourself();
  1016. $ctx2.sendIdx["yourself"]=2;
  1017. $13=$17;
  1018. $11=_st($12)._variable_($13);
  1019. $ctx2.sendIdx["variable:"]=1;
  1020. _st($10)._add_($11);
  1021. $ctx2.sendIdx["add:"]=4;
  1022. $18=$9;
  1023. $20=_st($IRVariable())._new();
  1024. $ctx2.sendIdx["new"]=5;
  1025. $22=_st($AliasVar())._new();
  1026. _st($22)._scope_(_st(inlinedClosure)._scope());
  1027. _st($22)._name_("$receiver");
  1028. $23=_st($22)._yourself();
  1029. $ctx2.sendIdx["yourself"]=3;
  1030. $21=$23;
  1031. $19=_st($20)._variable_($21);
  1032. _st($18)._add_($19);
  1033. $ctx2.sendIdx["add:"]=5;
  1034. $24=_st($9)._yourself();
  1035. $8=$24;
  1036. return _st($7)._add_($8);
  1037. $ctx2.sendIdx["add:"]=3;
  1038. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1039. $ctx1.sendIdx["do:"]=2;
  1040. _st(inlinedClosure)._add_(sequence);
  1041. $ctx1.sendIdx["add:"]=6;
  1042. $26=_st(anIRClosure)._instructions();
  1043. $ctx1.sendIdx["instructions"]=2;
  1044. $25=_st($26)._last();
  1045. $ctx1.sendIdx["last"]=1;
  1046. statements=_st($25)._instructions();
  1047. $ctx1.sendIdx["instructions"]=1;
  1048. _st(statements)._ifNotEmpty_((function(){
  1049. return smalltalk.withContext(function($ctx2) {
  1050. _st(_st(statements)._allButLast())._do_((function(each){
  1051. return smalltalk.withContext(function($ctx3) {
  1052. return _st(sequence)._add_(each);
  1053. $ctx3.sendIdx["add:"]=7;
  1054. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,4)})}));
  1055. $29=_st(statements)._last();
  1056. $ctx2.sendIdx["last"]=2;
  1057. $28=_st($29)._isReturn();
  1058. $27=_st($28)._and_((function(){
  1059. return smalltalk.withContext(function($ctx3) {
  1060. $30=_st(statements)._last();
  1061. $ctx3.sendIdx["last"]=3;
  1062. return _st($30)._isBlockReturn();
  1063. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)})}));
  1064. if(smalltalk.assert($27)){
  1065. $31=sequence;
  1066. $34=_st(statements)._last();
  1067. $ctx2.sendIdx["last"]=4;
  1068. $33=_st($34)._instructions();
  1069. $32=_st($33)._first();
  1070. return _st($31)._add_($32);
  1071. $ctx2.sendIdx["add:"]=8;
  1072. } else {
  1073. return _st(sequence)._add_(_st(statements)._last());
  1074. };
  1075. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)})}));
  1076. $35=inlinedClosure;
  1077. return $35;
  1078. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,sequence:sequence,statements:statements},smalltalk.IRSendInliner)})},
  1079. args: ["anIRClosure"],
  1080. 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",
  1081. messageSends: ["inlinedClosure", "scope:", "scope", "do:", "tempDeclarations", "add:", "inlinedSequence", "arguments", "name:", "new", "yourself", "variable:", "instructions", "last", "ifNotEmpty:", "allButLast", "ifTrue:ifFalse:", "and:", "isReturn", "isBlockReturn", "first"],
  1082. referencedClasses: ["IRTempDeclaration", "IRAssignment", "IRVariable", "AliasVar"]
  1083. }),
  1084. smalltalk.IRSendInliner);
  1085. smalltalk.addMethod(
  1086. smalltalk.method({
  1087. selector: "inlineSend:",
  1088. category: 'inlining',
  1089. fn: function (anIRSend){
  1090. var self=this;
  1091. return smalltalk.withContext(function($ctx1) {
  1092. var $3,$2,$1;
  1093. self._send_(anIRSend);
  1094. $3=self._send();
  1095. $ctx1.sendIdx["send"]=1;
  1096. $2=_st($3)._selector();
  1097. $1=self._perform_withArguments_($2,_st(_st(self._send())._instructions())._allButFirst());
  1098. return $1;
  1099. }, function($ctx1) {$ctx1.fill(self,"inlineSend:",{anIRSend:anIRSend},smalltalk.IRSendInliner)})},
  1100. args: ["anIRSend"],
  1101. source: "inlineSend: anIRSend\x0a\x09self send: anIRSend.\x0a\x09^ self\x0a\x09\x09perform: self send selector\x0a\x09\x09withArguments: self send instructions allButFirst",
  1102. messageSends: ["send:", "perform:withArguments:", "selector", "send", "allButFirst", "instructions"],
  1103. referencedClasses: []
  1104. }),
  1105. smalltalk.IRSendInliner);
  1106. smalltalk.addMethod(
  1107. smalltalk.method({
  1108. selector: "inlinedClosure",
  1109. category: 'factory',
  1110. fn: function (){
  1111. var self=this;
  1112. function $IRInlinedClosure(){return smalltalk.IRInlinedClosure||(typeof IRInlinedClosure=="undefined"?nil:IRInlinedClosure)}
  1113. return smalltalk.withContext(function($ctx1) {
  1114. var $1;
  1115. $1=_st($IRInlinedClosure())._new();
  1116. return $1;
  1117. }, function($ctx1) {$ctx1.fill(self,"inlinedClosure",{},smalltalk.IRSendInliner)})},
  1118. args: [],
  1119. source: "inlinedClosure\x0a\x09^ IRInlinedClosure new",
  1120. messageSends: ["new"],
  1121. referencedClasses: ["IRInlinedClosure"]
  1122. }),
  1123. smalltalk.IRSendInliner);
  1124. smalltalk.addMethod(
  1125. smalltalk.method({
  1126. selector: "inlinedSend:with:",
  1127. category: 'inlining',
  1128. fn: function (inlinedSend,anIRInstruction){
  1129. var self=this;
  1130. var inlinedClosure;
  1131. return smalltalk.withContext(function($ctx1) {
  1132. var $1,$2,$5,$4,$3,$6;
  1133. $1=_st(anIRInstruction)._isClosure();
  1134. if(! smalltalk.assert($1)){
  1135. self._inliningError_("Message argument should be a block");
  1136. $ctx1.sendIdx["inliningError:"]=1;
  1137. };
  1138. $2=_st(_st(_st(anIRInstruction)._arguments())._size()).__eq((0));
  1139. if(! smalltalk.assert($2)){
  1140. self._inliningError_("Inlined block should have zero argument");
  1141. };
  1142. inlinedClosure=_st(self._translator())._visit_(self._inlineClosure_(anIRInstruction));
  1143. $5=self._send();
  1144. $ctx1.sendIdx["send"]=1;
  1145. $4=_st($5)._instructions();
  1146. $3=_st($4)._first();
  1147. _st(inlinedSend)._add_($3);
  1148. $ctx1.sendIdx["add:"]=1;
  1149. $6=_st(inlinedSend)._add_(inlinedClosure);
  1150. _st(self._send())._replaceWith_(inlinedSend);
  1151. return inlinedSend;
  1152. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,inlinedClosure:inlinedClosure},smalltalk.IRSendInliner)})},
  1153. args: ["inlinedSend", "anIRInstruction"],
  1154. 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",
  1155. messageSends: ["ifFalse:", "isClosure", "inliningError:", "=", "size", "arguments", "visit:", "translator", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:"],
  1156. referencedClasses: []
  1157. }),
  1158. smalltalk.IRSendInliner);
  1159. smalltalk.addMethod(
  1160. smalltalk.method({
  1161. selector: "inlinedSend:with:with:",
  1162. category: 'inlining',
  1163. fn: function (inlinedSend,anIRInstruction,anotherIRInstruction){
  1164. var self=this;
  1165. var inlinedClosure1,inlinedClosure2;
  1166. return smalltalk.withContext(function($ctx1) {
  1167. var $1,$2,$3,$4,$7,$6,$5,$8;
  1168. $1=_st(anIRInstruction)._isClosure();
  1169. $ctx1.sendIdx["isClosure"]=1;
  1170. if(! smalltalk.assert($1)){
  1171. self._inliningError_("Message argument should be a block");
  1172. $ctx1.sendIdx["inliningError:"]=1;
  1173. };
  1174. $2=_st(anotherIRInstruction)._isClosure();
  1175. if(! smalltalk.assert($2)){
  1176. self._inliningError_("Message argument should be a block");
  1177. };
  1178. $3=self._translator();
  1179. $ctx1.sendIdx["translator"]=1;
  1180. $4=self._inlineClosure_(anIRInstruction);
  1181. $ctx1.sendIdx["inlineClosure:"]=1;
  1182. inlinedClosure1=_st($3)._visit_($4);
  1183. $ctx1.sendIdx["visit:"]=1;
  1184. inlinedClosure2=_st(self._translator())._visit_(self._inlineClosure_(anotherIRInstruction));
  1185. $7=self._send();
  1186. $ctx1.sendIdx["send"]=1;
  1187. $6=_st($7)._instructions();
  1188. $5=_st($6)._first();
  1189. _st(inlinedSend)._add_($5);
  1190. $ctx1.sendIdx["add:"]=1;
  1191. _st(inlinedSend)._add_(inlinedClosure1);
  1192. $ctx1.sendIdx["add:"]=2;
  1193. $8=_st(inlinedSend)._add_(inlinedClosure2);
  1194. _st(self._send())._replaceWith_(inlinedSend);
  1195. return inlinedSend;
  1196. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction,inlinedClosure1:inlinedClosure1,inlinedClosure2:inlinedClosure2},smalltalk.IRSendInliner)})},
  1197. args: ["inlinedSend", "anIRInstruction", "anotherIRInstruction"],
  1198. 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",
  1199. messageSends: ["ifFalse:", "isClosure", "inliningError:", "visit:", "translator", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:"],
  1200. referencedClasses: []
  1201. }),
  1202. smalltalk.IRSendInliner);
  1203. smalltalk.addMethod(
  1204. smalltalk.method({
  1205. selector: "inlinedSequence",
  1206. category: 'factory',
  1207. fn: function (){
  1208. var self=this;
  1209. function $IRInlinedSequence(){return smalltalk.IRInlinedSequence||(typeof IRInlinedSequence=="undefined"?nil:IRInlinedSequence)}
  1210. return smalltalk.withContext(function($ctx1) {
  1211. var $1;
  1212. $1=_st($IRInlinedSequence())._new();
  1213. return $1;
  1214. }, function($ctx1) {$ctx1.fill(self,"inlinedSequence",{},smalltalk.IRSendInliner)})},
  1215. args: [],
  1216. source: "inlinedSequence\x0a\x09^ IRInlinedSequence new",
  1217. messageSends: ["new"],
  1218. referencedClasses: ["IRInlinedSequence"]
  1219. }),
  1220. smalltalk.IRSendInliner);
  1221. smalltalk.addMethod(
  1222. smalltalk.method({
  1223. selector: "inliningError:",
  1224. category: 'error handling',
  1225. fn: function (aString){
  1226. var self=this;
  1227. function $InliningError(){return smalltalk.InliningError||(typeof InliningError=="undefined"?nil:InliningError)}
  1228. return smalltalk.withContext(function($ctx1) {
  1229. _st($InliningError())._signal_(aString);
  1230. return self}, function($ctx1) {$ctx1.fill(self,"inliningError:",{aString:aString},smalltalk.IRSendInliner)})},
  1231. args: ["aString"],
  1232. source: "inliningError: aString\x0a\x09InliningError signal: aString",
  1233. messageSends: ["signal:"],
  1234. referencedClasses: ["InliningError"]
  1235. }),
  1236. smalltalk.IRSendInliner);
  1237. smalltalk.addMethod(
  1238. smalltalk.method({
  1239. selector: "send",
  1240. category: 'accessing',
  1241. fn: function (){
  1242. var self=this;
  1243. return smalltalk.withContext(function($ctx1) {
  1244. var $1;
  1245. $1=self["@send"];
  1246. return $1;
  1247. }, function($ctx1) {$ctx1.fill(self,"send",{},smalltalk.IRSendInliner)})},
  1248. args: [],
  1249. source: "send\x0a\x09^ send",
  1250. messageSends: [],
  1251. referencedClasses: []
  1252. }),
  1253. smalltalk.IRSendInliner);
  1254. smalltalk.addMethod(
  1255. smalltalk.method({
  1256. selector: "send:",
  1257. category: 'accessing',
  1258. fn: function (anIRSend){
  1259. var self=this;
  1260. return smalltalk.withContext(function($ctx1) {
  1261. self["@send"]=anIRSend;
  1262. return self}, function($ctx1) {$ctx1.fill(self,"send:",{anIRSend:anIRSend},smalltalk.IRSendInliner)})},
  1263. args: ["anIRSend"],
  1264. source: "send: anIRSend\x0a\x09send := anIRSend",
  1265. messageSends: [],
  1266. referencedClasses: []
  1267. }),
  1268. smalltalk.IRSendInliner);
  1269. smalltalk.addMethod(
  1270. smalltalk.method({
  1271. selector: "translator",
  1272. category: 'accessing',
  1273. fn: function (){
  1274. var self=this;
  1275. return smalltalk.withContext(function($ctx1) {
  1276. var $1;
  1277. $1=self["@translator"];
  1278. return $1;
  1279. }, function($ctx1) {$ctx1.fill(self,"translator",{},smalltalk.IRSendInliner)})},
  1280. args: [],
  1281. source: "translator\x0a\x09^ translator",
  1282. messageSends: [],
  1283. referencedClasses: []
  1284. }),
  1285. smalltalk.IRSendInliner);
  1286. smalltalk.addMethod(
  1287. smalltalk.method({
  1288. selector: "translator:",
  1289. category: 'accessing',
  1290. fn: function (anASTTranslator){
  1291. var self=this;
  1292. return smalltalk.withContext(function($ctx1) {
  1293. self["@translator"]=anASTTranslator;
  1294. return self}, function($ctx1) {$ctx1.fill(self,"translator:",{anASTTranslator:anASTTranslator},smalltalk.IRSendInliner)})},
  1295. args: ["anASTTranslator"],
  1296. source: "translator: anASTTranslator\x0a\x09translator := anASTTranslator",
  1297. messageSends: [],
  1298. referencedClasses: []
  1299. }),
  1300. smalltalk.IRSendInliner);
  1301. smalltalk.addMethod(
  1302. smalltalk.method({
  1303. selector: "inlinedSelectors",
  1304. category: 'accessing',
  1305. fn: function (){
  1306. var self=this;
  1307. return smalltalk.withContext(function($ctx1) {
  1308. var $1;
  1309. $1=["ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:", "ifNil:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"];
  1310. return $1;
  1311. }, function($ctx1) {$ctx1.fill(self,"inlinedSelectors",{},smalltalk.IRSendInliner.klass)})},
  1312. args: [],
  1313. source: "inlinedSelectors\x0a\x09^ #('ifTrue:' 'ifFalse:' 'ifTrue:ifFalse:' 'ifFalse:ifTrue:' 'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:')",
  1314. messageSends: [],
  1315. referencedClasses: []
  1316. }),
  1317. smalltalk.IRSendInliner.klass);
  1318. smalltalk.addMethod(
  1319. smalltalk.method({
  1320. selector: "shouldInline:",
  1321. category: 'accessing',
  1322. fn: function (anIRInstruction){
  1323. var self=this;
  1324. return smalltalk.withContext(function($ctx1) {
  1325. var $1,$2;
  1326. var $early={};
  1327. try {
  1328. $1=_st(self._inlinedSelectors())._includes_(_st(anIRInstruction)._selector());
  1329. if(! smalltalk.assert($1)){
  1330. return false;
  1331. };
  1332. _st(_st(_st(anIRInstruction)._instructions())._allButFirst())._do_((function(each){
  1333. return smalltalk.withContext(function($ctx2) {
  1334. $2=_st(each)._isClosure();
  1335. if(! smalltalk.assert($2)){
  1336. throw $early=[false];
  1337. };
  1338. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)})}));
  1339. return true;
  1340. }
  1341. catch(e) {if(e===$early)return e[0]; throw e}
  1342. }, function($ctx1) {$ctx1.fill(self,"shouldInline:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner.klass)})},
  1343. args: ["anIRInstruction"],
  1344. 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",
  1345. messageSends: ["ifFalse:", "includes:", "inlinedSelectors", "selector", "do:", "allButFirst", "instructions", "isClosure"],
  1346. referencedClasses: []
  1347. }),
  1348. smalltalk.IRSendInliner.klass);
  1349. smalltalk.addClass('IRAssignmentInliner', smalltalk.IRSendInliner, ['assignment'], 'Compiler-Inlining');
  1350. 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};";
  1351. smalltalk.addMethod(
  1352. smalltalk.method({
  1353. selector: "assignment",
  1354. category: 'accessing',
  1355. fn: function (){
  1356. var self=this;
  1357. return smalltalk.withContext(function($ctx1) {
  1358. var $1;
  1359. $1=self["@assignment"];
  1360. return $1;
  1361. }, function($ctx1) {$ctx1.fill(self,"assignment",{},smalltalk.IRAssignmentInliner)})},
  1362. args: [],
  1363. source: "assignment\x0a\x09^ assignment",
  1364. messageSends: [],
  1365. referencedClasses: []
  1366. }),
  1367. smalltalk.IRAssignmentInliner);
  1368. smalltalk.addMethod(
  1369. smalltalk.method({
  1370. selector: "assignment:",
  1371. category: 'accessing',
  1372. fn: function (aNode){
  1373. var self=this;
  1374. return smalltalk.withContext(function($ctx1) {
  1375. self["@assignment"]=aNode;
  1376. return self}, function($ctx1) {$ctx1.fill(self,"assignment:",{aNode:aNode},smalltalk.IRAssignmentInliner)})},
  1377. args: ["aNode"],
  1378. source: "assignment: aNode\x0a\x09assignment := aNode",
  1379. messageSends: [],
  1380. referencedClasses: []
  1381. }),
  1382. smalltalk.IRAssignmentInliner);
  1383. smalltalk.addMethod(
  1384. smalltalk.method({
  1385. selector: "inlineAssignment:",
  1386. category: 'inlining',
  1387. fn: function (anIRAssignment){
  1388. var self=this;
  1389. var inlinedAssignment;
  1390. function $IRInlinedAssignment(){return smalltalk.IRInlinedAssignment||(typeof IRInlinedAssignment=="undefined"?nil:IRInlinedAssignment)}
  1391. return smalltalk.withContext(function($ctx1) {
  1392. var $1,$2;
  1393. self._assignment_(anIRAssignment);
  1394. inlinedAssignment=_st($IRInlinedAssignment())._new();
  1395. $1=_st(anIRAssignment)._instructions();
  1396. $ctx1.sendIdx["instructions"]=1;
  1397. _st($1)._do_((function(each){
  1398. return smalltalk.withContext(function($ctx2) {
  1399. return _st(inlinedAssignment)._add_(each);
  1400. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1401. _st(anIRAssignment)._replaceWith_(inlinedAssignment);
  1402. self._inlineSend_(_st(_st(inlinedAssignment)._instructions())._last());
  1403. $2=inlinedAssignment;
  1404. return $2;
  1405. }, function($ctx1) {$ctx1.fill(self,"inlineAssignment:",{anIRAssignment:anIRAssignment,inlinedAssignment:inlinedAssignment},smalltalk.IRAssignmentInliner)})},
  1406. args: ["anIRAssignment"],
  1407. 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",
  1408. messageSends: ["assignment:", "new", "do:", "instructions", "add:", "replaceWith:", "inlineSend:", "last"],
  1409. referencedClasses: ["IRInlinedAssignment"]
  1410. }),
  1411. smalltalk.IRAssignmentInliner);
  1412. smalltalk.addMethod(
  1413. smalltalk.method({
  1414. selector: "inlineClosure:",
  1415. category: 'inlining',
  1416. fn: function (anIRClosure){
  1417. var self=this;
  1418. var inlinedClosure,statements;
  1419. function $IRAssignment(){return smalltalk.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
  1420. return smalltalk.withContext(function($ctx1) {
  1421. var $2,$1,$4,$3,$5,$7,$8,$6,$9;
  1422. inlinedClosure=smalltalk.IRAssignmentInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]);
  1423. $2=_st(inlinedClosure)._instructions();
  1424. $ctx1.sendIdx["instructions"]=2;
  1425. $1=_st($2)._last();
  1426. $ctx1.sendIdx["last"]=1;
  1427. statements=_st($1)._instructions();
  1428. $ctx1.sendIdx["instructions"]=1;
  1429. _st(statements)._ifNotEmpty_((function(){
  1430. return smalltalk.withContext(function($ctx2) {
  1431. $4=_st(statements)._last();
  1432. $ctx2.sendIdx["last"]=2;
  1433. $3=_st($4)._canBeAssigned();
  1434. if(smalltalk.assert($3)){
  1435. $5=_st(statements)._last();
  1436. $ctx2.sendIdx["last"]=3;
  1437. $7=_st($IRAssignment())._new();
  1438. _st($7)._add_(_st(_st(self._assignment())._instructions())._first());
  1439. $ctx2.sendIdx["add:"]=1;
  1440. _st($7)._add_(_st(_st(statements)._last())._copy());
  1441. $8=_st($7)._yourself();
  1442. $6=$8;
  1443. return _st($5)._replaceWith_($6);
  1444. };
  1445. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1446. $9=inlinedClosure;
  1447. return $9;
  1448. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,statements:statements},smalltalk.IRAssignmentInliner)})},
  1449. args: ["anIRClosure"],
  1450. 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",
  1451. messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifTrue:", "canBeAssigned", "replaceWith:", "add:", "new", "first", "assignment", "copy", "yourself"],
  1452. referencedClasses: ["IRAssignment"]
  1453. }),
  1454. smalltalk.IRAssignmentInliner);
  1455. smalltalk.addClass('IRReturnInliner', smalltalk.IRSendInliner, [], 'Compiler-Inlining');
  1456. smalltalk.IRReturnInliner.comment="I inline message sends with inlined closure together with a return instruction.";
  1457. smalltalk.addMethod(
  1458. smalltalk.method({
  1459. selector: "inlineClosure:",
  1460. category: 'inlining',
  1461. fn: function (anIRClosure){
  1462. var self=this;
  1463. var closure,statements;
  1464. function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
  1465. return smalltalk.withContext(function($ctx1) {
  1466. var $1,$3,$2,$4,$5,$6,$7;
  1467. closure=smalltalk.IRReturnInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]);
  1468. $1=_st(_st(closure)._instructions())._last();
  1469. $ctx1.sendIdx["last"]=1;
  1470. statements=_st($1)._instructions();
  1471. $ctx1.sendIdx["instructions"]=1;
  1472. _st(statements)._ifNotEmpty_((function(){
  1473. return smalltalk.withContext(function($ctx2) {
  1474. $3=_st(statements)._last();
  1475. $ctx2.sendIdx["last"]=2;
  1476. $2=_st($3)._isReturn();
  1477. if(! smalltalk.assert($2)){
  1478. $4=_st(statements)._last();
  1479. $ctx2.sendIdx["last"]=3;
  1480. $5=_st($IRReturn())._new();
  1481. _st($5)._add_(_st(_st(statements)._last())._copy());
  1482. $6=_st($5)._yourself();
  1483. return _st($4)._replaceWith_($6);
  1484. };
  1485. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
  1486. $7=closure;
  1487. return $7;
  1488. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,closure:closure,statements:statements},smalltalk.IRReturnInliner)})},
  1489. args: ["anIRClosure"],
  1490. 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",
  1491. messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifFalse:", "isReturn", "replaceWith:", "add:", "new", "copy", "yourself"],
  1492. referencedClasses: ["IRReturn"]
  1493. }),
  1494. smalltalk.IRReturnInliner);
  1495. smalltalk.addMethod(
  1496. smalltalk.method({
  1497. selector: "inlineReturn:",
  1498. category: 'inlining',
  1499. fn: function (anIRReturn){
  1500. var self=this;
  1501. var return_;
  1502. return smalltalk.withContext(function($ctx1) {
  1503. var $1,$2;
  1504. return_=self._inlinedReturn();
  1505. $1=_st(anIRReturn)._instructions();
  1506. $ctx1.sendIdx["instructions"]=1;
  1507. _st($1)._do_((function(each){
  1508. return smalltalk.withContext(function($ctx2) {
  1509. return _st(return_)._add_(each);
  1510. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)})}));
  1511. _st(anIRReturn)._replaceWith_(return_);
  1512. self._inlineSend_(_st(_st(return_)._instructions())._last());
  1513. $2=return_;
  1514. return $2;
  1515. }, function($ctx1) {$ctx1.fill(self,"inlineReturn:",{anIRReturn:anIRReturn,return_:return_},smalltalk.IRReturnInliner)})},
  1516. args: ["anIRReturn"],
  1517. 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",
  1518. messageSends: ["inlinedReturn", "do:", "instructions", "add:", "replaceWith:", "inlineSend:", "last"],
  1519. referencedClasses: []
  1520. }),
  1521. smalltalk.IRReturnInliner);
  1522. smalltalk.addMethod(
  1523. smalltalk.method({
  1524. selector: "inlinedReturn",
  1525. category: 'factory',
  1526. fn: function (){
  1527. var self=this;
  1528. function $IRInlinedReturn(){return smalltalk.IRInlinedReturn||(typeof IRInlinedReturn=="undefined"?nil:IRInlinedReturn)}
  1529. return smalltalk.withContext(function($ctx1) {
  1530. var $1;
  1531. $1=_st($IRInlinedReturn())._new();
  1532. return $1;
  1533. }, function($ctx1) {$ctx1.fill(self,"inlinedReturn",{},smalltalk.IRReturnInliner)})},
  1534. args: [],
  1535. source: "inlinedReturn\x0a\x09^ IRInlinedReturn new",
  1536. messageSends: ["new"],
  1537. referencedClasses: ["IRInlinedReturn"]
  1538. }),
  1539. smalltalk.IRReturnInliner);
  1540. smalltalk.addClass('InliningCodeGenerator', smalltalk.CodeGenerator, [], 'Compiler-Inlining');
  1541. smalltalk.InliningCodeGenerator.comment="I am a specialized code generator that uses inlining to produce more optimized JavaScript output";
  1542. smalltalk.addMethod(
  1543. smalltalk.method({
  1544. selector: "compileNode:",
  1545. category: 'compiling',
  1546. fn: function (aNode){
  1547. var self=this;
  1548. var ir,stream;
  1549. return smalltalk.withContext(function($ctx1) {
  1550. var $2,$3,$1;
  1551. _st(self._semanticAnalyzer())._visit_(aNode);
  1552. $ctx1.sendIdx["visit:"]=1;
  1553. ir=_st(self._translator())._visit_(aNode);
  1554. $ctx1.sendIdx["visit:"]=2;
  1555. _st(self._inliner())._visit_(ir);
  1556. $ctx1.sendIdx["visit:"]=3;
  1557. $2=self._irTranslator();
  1558. _st($2)._currentClass_(self._currentClass());
  1559. _st($2)._visit_(ir);
  1560. $3=_st($2)._contents();
  1561. $1=$3;
  1562. return $1;
  1563. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},smalltalk.InliningCodeGenerator)})},
  1564. args: ["aNode"],
  1565. 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",
  1566. messageSends: ["visit:", "semanticAnalyzer", "translator", "inliner", "currentClass:", "irTranslator", "currentClass", "contents"],
  1567. referencedClasses: []
  1568. }),
  1569. smalltalk.InliningCodeGenerator);
  1570. smalltalk.addMethod(
  1571. smalltalk.method({
  1572. selector: "inliner",
  1573. category: 'compiling',
  1574. fn: function (){
  1575. var self=this;
  1576. function $IRInliner(){return smalltalk.IRInliner||(typeof IRInliner=="undefined"?nil:IRInliner)}
  1577. return smalltalk.withContext(function($ctx1) {
  1578. var $1;
  1579. $1=_st($IRInliner())._new();
  1580. return $1;
  1581. }, function($ctx1) {$ctx1.fill(self,"inliner",{},smalltalk.InliningCodeGenerator)})},
  1582. args: [],
  1583. source: "inliner\x0a\x09^ IRInliner new",
  1584. messageSends: ["new"],
  1585. referencedClasses: ["IRInliner"]
  1586. }),
  1587. smalltalk.InliningCodeGenerator);
  1588. smalltalk.addMethod(
  1589. smalltalk.method({
  1590. selector: "irTranslator",
  1591. category: 'compiling',
  1592. fn: function (){
  1593. var self=this;
  1594. function $IRInliningJSTranslator(){return smalltalk.IRInliningJSTranslator||(typeof IRInliningJSTranslator=="undefined"?nil:IRInliningJSTranslator)}
  1595. return smalltalk.withContext(function($ctx1) {
  1596. var $1;
  1597. $1=_st($IRInliningJSTranslator())._new();
  1598. return $1;
  1599. }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},smalltalk.InliningCodeGenerator)})},
  1600. args: [],
  1601. source: "irTranslator\x0a\x09^ IRInliningJSTranslator new",
  1602. messageSends: ["new"],
  1603. referencedClasses: ["IRInliningJSTranslator"]
  1604. }),
  1605. smalltalk.InliningCodeGenerator);
  1606. });