Compiler-Inlining.js 70 KB

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