Compiler-Inlining.js 68 KB

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