Compiler-Inlining.js 59 KB

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