Compiler-Inlining.js 70 KB

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