Compiler-Inlining.js 68 KB

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