Compiler-Inlining.deploy.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. smalltalk.addPackage('Compiler-Inlining', {});
  2. smalltalk.addClass('IRInlinedAssignment', smalltalk.IRAssignment, [], 'Compiler-Inlining');
  3. smalltalk.addMethod(
  4. "_accept_",
  5. smalltalk.method({
  6. selector: "accept:",
  7. fn: function (aVisitor){
  8. var self=this;
  9. return smalltalk.send(aVisitor,"_visitIRInlinedAssignment_",[self]);
  10. }
  11. }),
  12. smalltalk.IRInlinedAssignment);
  13. smalltalk.addMethod(
  14. "_isInlined",
  15. smalltalk.method({
  16. selector: "isInlined",
  17. fn: function (){
  18. var self=this;
  19. return true;
  20. }
  21. }),
  22. smalltalk.IRInlinedAssignment);
  23. smalltalk.addClass('IRInlinedClosure', smalltalk.IRClosure, [], 'Compiler-Inlining');
  24. smalltalk.addMethod(
  25. "_accept_",
  26. smalltalk.method({
  27. selector: "accept:",
  28. fn: function (aVisitor){
  29. var self=this;
  30. smalltalk.send(aVisitor,"_visitIRInlinedClosure_",[self]);
  31. return self}
  32. }),
  33. smalltalk.IRInlinedClosure);
  34. smalltalk.addMethod(
  35. "_isInlined",
  36. smalltalk.method({
  37. selector: "isInlined",
  38. fn: function (){
  39. var self=this;
  40. return true;
  41. }
  42. }),
  43. smalltalk.IRInlinedClosure);
  44. smalltalk.addClass('IRInlinedReturn', smalltalk.IRReturn, [], 'Compiler-Inlining');
  45. smalltalk.addMethod(
  46. "_accept_",
  47. smalltalk.method({
  48. selector: "accept:",
  49. fn: function (aVisitor){
  50. var self=this;
  51. return smalltalk.send(aVisitor,"_visitIRInlinedReturn_",[self]);
  52. }
  53. }),
  54. smalltalk.IRInlinedReturn);
  55. smalltalk.addMethod(
  56. "_isInlined",
  57. smalltalk.method({
  58. selector: "isInlined",
  59. fn: function (){
  60. var self=this;
  61. return true;
  62. }
  63. }),
  64. smalltalk.IRInlinedReturn);
  65. smalltalk.addClass('IRInlinedNonLocalReturn', smalltalk.IRInlinedReturn, [], 'Compiler-Inlining');
  66. smalltalk.addMethod(
  67. "_accept_",
  68. smalltalk.method({
  69. selector: "accept:",
  70. fn: function (aVisitor){
  71. var self=this;
  72. return smalltalk.send(aVisitor,"_visitIRInlinedNonLocalReturn_",[self]);
  73. }
  74. }),
  75. smalltalk.IRInlinedNonLocalReturn);
  76. smalltalk.addMethod(
  77. "_isInlined",
  78. smalltalk.method({
  79. selector: "isInlined",
  80. fn: function (){
  81. var self=this;
  82. return true;
  83. }
  84. }),
  85. smalltalk.IRInlinedNonLocalReturn);
  86. smalltalk.addClass('IRInlinedSend', smalltalk.IRSend, [], 'Compiler-Inlining');
  87. smalltalk.addMethod(
  88. "_accept_",
  89. smalltalk.method({
  90. selector: "accept:",
  91. fn: function (aVisitor){
  92. var self=this;
  93. smalltalk.send(aVisitor,"_visitInlinedSend_",[self]);
  94. return self}
  95. }),
  96. smalltalk.IRInlinedSend);
  97. smalltalk.addMethod(
  98. "_isInlined",
  99. smalltalk.method({
  100. selector: "isInlined",
  101. fn: function (){
  102. var self=this;
  103. return true;
  104. }
  105. }),
  106. smalltalk.IRInlinedSend);
  107. smalltalk.addClass('IRInlinedIfFalse', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  108. smalltalk.addMethod(
  109. "_accept_",
  110. smalltalk.method({
  111. selector: "accept:",
  112. fn: function (aVisitor){
  113. var self=this;
  114. smalltalk.send(aVisitor,"_visitIRInlinedIfFalse_",[self]);
  115. return self}
  116. }),
  117. smalltalk.IRInlinedIfFalse);
  118. smalltalk.addClass('IRInlinedIfTrue', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  119. smalltalk.addMethod(
  120. "_accept_",
  121. smalltalk.method({
  122. selector: "accept:",
  123. fn: function (aVisitor){
  124. var self=this;
  125. smalltalk.send(aVisitor,"_visitIRInlinedIfTrue_",[self]);
  126. return self}
  127. }),
  128. smalltalk.IRInlinedIfTrue);
  129. smalltalk.addClass('IRInlinedSequence', smalltalk.IRBlockSequence, [], 'Compiler-Inlining');
  130. smalltalk.addMethod(
  131. "_accept_",
  132. smalltalk.method({
  133. selector: "accept:",
  134. fn: function (aVisitor){
  135. var self=this;
  136. smalltalk.send(aVisitor,"_visitIRInlinedSequence_",[self]);
  137. return self}
  138. }),
  139. smalltalk.IRInlinedSequence);
  140. smalltalk.addMethod(
  141. "_isInlined",
  142. smalltalk.method({
  143. selector: "isInlined",
  144. fn: function (){
  145. var self=this;
  146. return true;
  147. }
  148. }),
  149. smalltalk.IRInlinedSequence);
  150. smalltalk.addClass('IRAssigningInlinedSequence', smalltalk.IRInlinedSequence, ['assignTo'], 'Compiler-Inlining');
  151. smalltalk.addMethod(
  152. "_accept_",
  153. smalltalk.method({
  154. selector: "accept:",
  155. fn: function (aVisitor){
  156. var self=this;
  157. return smalltalk.send(aVisitor,"_visitIRAssigningInlinedSequence_",[self]);
  158. }
  159. }),
  160. smalltalk.IRAssigningInlinedSequence);
  161. smalltalk.addMethod(
  162. "_assignTo",
  163. smalltalk.method({
  164. selector: "assignTo",
  165. fn: function (){
  166. var self=this;
  167. return self["@assignTo"];
  168. }
  169. }),
  170. smalltalk.IRAssigningInlinedSequence);
  171. smalltalk.addMethod(
  172. "_assignTo_",
  173. smalltalk.method({
  174. selector: "assignTo:",
  175. fn: function (anIRInstruction){
  176. var self=this;
  177. self["@assignTo"]=anIRInstruction;
  178. return self}
  179. }),
  180. smalltalk.IRAssigningInlinedSequence);
  181. smalltalk.addClass('IRReturningInlinedSequence', smalltalk.IRInlinedSequence, [], 'Compiler-Inlining');
  182. smalltalk.addMethod(
  183. "_accept_",
  184. smalltalk.method({
  185. selector: "accept:",
  186. fn: function (aVisitor){
  187. var self=this;
  188. return smalltalk.send(aVisitor,"_visitIRReturningInlinedSequence_",[self]);
  189. }
  190. }),
  191. smalltalk.IRReturningInlinedSequence);
  192. smalltalk.addClass('IRNonLocalReturningInlinedSequence', smalltalk.IRReturningInlinedSequence, [], 'Compiler-Inlining');
  193. smalltalk.addMethod(
  194. "_accept_",
  195. smalltalk.method({
  196. selector: "accept:",
  197. fn: function (aVisitor){
  198. var self=this;
  199. return smalltalk.send(aVisitor,"_visitIRNonLocalReturningInlinedSequence_",[self]);
  200. }
  201. }),
  202. smalltalk.IRNonLocalReturningInlinedSequence);
  203. smalltalk.addClass('IRInliner', smalltalk.IRVisitor, [], 'Compiler-Inlining');
  204. smalltalk.addMethod(
  205. "_assignmentInliner",
  206. smalltalk.method({
  207. selector: "assignmentInliner",
  208. fn: function (){
  209. var self=this;
  210. var $1,$2;
  211. $1=smalltalk.send((smalltalk.IRAssignmentInliner || IRAssignmentInliner),"_new",[]);
  212. smalltalk.send($1,"_translator_",[self]);
  213. $2=smalltalk.send($1,"_yourself",[]);
  214. return $2;
  215. }
  216. }),
  217. smalltalk.IRInliner);
  218. smalltalk.addMethod(
  219. "_nonLocalReturnInliner",
  220. smalltalk.method({
  221. selector: "nonLocalReturnInliner",
  222. fn: function (){
  223. var self=this;
  224. var $1,$2;
  225. $1=smalltalk.send((smalltalk.IRNonLocalReturnInliner || IRNonLocalReturnInliner),"_new",[]);
  226. smalltalk.send($1,"_translator_",[self]);
  227. $2=smalltalk.send($1,"_yourself",[]);
  228. return $2;
  229. }
  230. }),
  231. smalltalk.IRInliner);
  232. smalltalk.addMethod(
  233. "_returnInliner",
  234. smalltalk.method({
  235. selector: "returnInliner",
  236. fn: function (){
  237. var self=this;
  238. var $1,$2;
  239. $1=smalltalk.send((smalltalk.IRReturnInliner || IRReturnInliner),"_new",[]);
  240. smalltalk.send($1,"_translator_",[self]);
  241. $2=smalltalk.send($1,"_yourself",[]);
  242. return $2;
  243. }
  244. }),
  245. smalltalk.IRInliner);
  246. smalltalk.addMethod(
  247. "_sendInliner",
  248. smalltalk.method({
  249. selector: "sendInliner",
  250. fn: function (){
  251. var self=this;
  252. var $1,$2;
  253. $1=smalltalk.send((smalltalk.IRSendInliner || IRSendInliner),"_new",[]);
  254. smalltalk.send($1,"_translator_",[self]);
  255. $2=smalltalk.send($1,"_yourself",[]);
  256. return $2;
  257. }
  258. }),
  259. smalltalk.IRInliner);
  260. smalltalk.addMethod(
  261. "_shouldInlineAssignment_",
  262. smalltalk.method({
  263. selector: "shouldInlineAssignment:",
  264. fn: function (anIRAssignment){
  265. var self=this;
  266. return smalltalk.send(smalltalk.send(smalltalk.send(anIRAssignment,"_isInlined",[]),"_not",[]),"_and_",[(function(){
  267. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRAssignment,"_instructions",[]),"_last",[]),"_isSend",[]),"_and_",[(function(){
  268. return smalltalk.send(self,"_shouldInlineSend_",[smalltalk.send(smalltalk.send(anIRAssignment,"_instructions",[]),"_last",[])]);
  269. })]);
  270. })]);
  271. }
  272. }),
  273. smalltalk.IRInliner);
  274. smalltalk.addMethod(
  275. "_shouldInlineReturn_",
  276. smalltalk.method({
  277. selector: "shouldInlineReturn:",
  278. fn: function (anIRReturn){
  279. var self=this;
  280. return smalltalk.send(smalltalk.send(smalltalk.send(anIRReturn,"_isInlined",[]),"_not",[]),"_and_",[(function(){
  281. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRReturn,"_instructions",[]),"_first",[]),"_isSend",[]),"_and_",[(function(){
  282. return smalltalk.send(self,"_shouldInlineSend_",[smalltalk.send(smalltalk.send(anIRReturn,"_instructions",[]),"_first",[])]);
  283. })]);
  284. })]);
  285. }
  286. }),
  287. smalltalk.IRInliner);
  288. smalltalk.addMethod(
  289. "_shouldInlineSend_",
  290. smalltalk.method({
  291. selector: "shouldInlineSend:",
  292. fn: function (anIRSend){
  293. var self=this;
  294. return smalltalk.send(smalltalk.send(smalltalk.send(anIRSend,"_isInlined",[]),"_not",[]),"_and_",[(function(){
  295. return smalltalk.send((smalltalk.IRSendInliner || IRSendInliner),"_shouldInline_",[anIRSend]);
  296. })]);
  297. }
  298. }),
  299. smalltalk.IRInliner);
  300. smalltalk.addMethod(
  301. "_transformNonLocalReturn_",
  302. smalltalk.method({
  303. selector: "transformNonLocalReturn:",
  304. fn: function (anIRNonLocalReturn){
  305. var self=this;
  306. var $1,$2;
  307. var localReturn;
  308. if(smalltalk.assert(smalltalk.send(smalltalk.send(anIRNonLocalReturn,"_scope",[]),"_canInlineNonLocalReturns",[]))){
  309. smalltalk.send(smalltalk.send(smalltalk.send(anIRNonLocalReturn,"_scope",[]),"_methodScope",[]),"_removeNonLocalReturn_",[smalltalk.send(anIRNonLocalReturn,"_scope",[])]);
  310. $1=smalltalk.send((smalltalk.IRReturn || IRReturn),"_new",[]);
  311. smalltalk.send($1,"_scope_",[smalltalk.send(anIRNonLocalReturn,"_scope",[])]);
  312. $2=smalltalk.send($1,"_yourself",[]);
  313. localReturn=$2;
  314. localReturn;
  315. smalltalk.send(smalltalk.send(anIRNonLocalReturn,"_instructions",[]),"_do_",[(function(each){
  316. return smalltalk.send(localReturn,"_add_",[each]);
  317. })]);
  318. smalltalk.send(anIRNonLocalReturn,"_replaceWith_",[localReturn]);
  319. return localReturn;
  320. };
  321. return smalltalk.send(self,"_visitIRNonLocalReturn_",[anIRNonLocalReturn],smalltalk.IRVisitor);
  322. }
  323. }),
  324. smalltalk.IRInliner);
  325. smalltalk.addMethod(
  326. "_visitIRAssignment_",
  327. smalltalk.method({
  328. selector: "visitIRAssignment:",
  329. fn: function (anIRAssignment){
  330. var self=this;
  331. return smalltalk.send(smalltalk.send(self,"_shouldInlineAssignment_",[anIRAssignment]),"_ifTrue_ifFalse_",[(function(){
  332. return smalltalk.send(smalltalk.send(self,"_assignmentInliner",[]),"_inlineAssignment_",[anIRAssignment]);
  333. }),(function(){
  334. return smalltalk.send(self,"_visitIRAssignment_",[anIRAssignment],smalltalk.IRVisitor);
  335. })]);
  336. }
  337. }),
  338. smalltalk.IRInliner);
  339. smalltalk.addMethod(
  340. "_visitIRNonLocalReturn_",
  341. smalltalk.method({
  342. selector: "visitIRNonLocalReturn:",
  343. fn: function (anIRNonLocalReturn){
  344. var self=this;
  345. return smalltalk.send(smalltalk.send(self,"_shouldInlineReturn_",[anIRNonLocalReturn]),"_ifTrue_ifFalse_",[(function(){
  346. return smalltalk.send(smalltalk.send(self,"_nonLocalReturnInliner",[]),"_inlineReturn_",[anIRNonLocalReturn]);
  347. }),(function(){
  348. return smalltalk.send(self,"_transformNonLocalReturn_",[anIRNonLocalReturn]);
  349. })]);
  350. }
  351. }),
  352. smalltalk.IRInliner);
  353. smalltalk.addMethod(
  354. "_visitIRReturn_",
  355. smalltalk.method({
  356. selector: "visitIRReturn:",
  357. fn: function (anIRReturn){
  358. var self=this;
  359. return smalltalk.send(smalltalk.send(self,"_shouldInlineReturn_",[anIRReturn]),"_ifTrue_ifFalse_",[(function(){
  360. return smalltalk.send(smalltalk.send(self,"_returnInliner",[]),"_inlineReturn_",[anIRReturn]);
  361. }),(function(){
  362. return smalltalk.send(self,"_visitIRReturn_",[anIRReturn],smalltalk.IRVisitor);
  363. })]);
  364. }
  365. }),
  366. smalltalk.IRInliner);
  367. smalltalk.addMethod(
  368. "_visitIRSend_",
  369. smalltalk.method({
  370. selector: "visitIRSend:",
  371. fn: function (anIRSend){
  372. var self=this;
  373. return smalltalk.send(smalltalk.send(self,"_shouldInlineSend_",[anIRSend]),"_ifTrue_ifFalse_",[(function(){
  374. return smalltalk.send(smalltalk.send(self,"_sendInliner",[]),"_inlineSend_",[anIRSend]);
  375. }),(function(){
  376. return smalltalk.send(self,"_visitIRSend_",[anIRSend],smalltalk.IRVisitor);
  377. })]);
  378. }
  379. }),
  380. smalltalk.IRInliner);
  381. smalltalk.addClass('IRInliningJSTranslator', smalltalk.IRJSTranslator, [], 'Compiler-Inlining');
  382. smalltalk.addMethod(
  383. "_visitIRAssigningInlinedSequence_",
  384. smalltalk.method({
  385. selector: "visitIRAssigningInlinedSequence:",
  386. fn: function (anIRInlinedSequence){
  387. var self=this;
  388. var $1,$2;
  389. smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_allButLast",[]),"_do_",[(function(each){
  390. return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
  391. return smalltalk.send(self,"_visit_",[each]);
  392. })]);
  393. })]);
  394. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
  395. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[]),"_canBeAssigned",[]),"_ifTrue_ifFalse_",[(function(){
  396. $1=smalltalk.send(self,"_stream",[]);
  397. smalltalk.send($1,"_nextPutAll_",[smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_assignTo",[]),"_variable",[]),"_alias",[])]);
  398. $2=smalltalk.send($1,"_nextPutAssignment",[]);
  399. $2;
  400. return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
  401. }),(function(){
  402. return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
  403. })]);
  404. })]);
  405. return self}
  406. }),
  407. smalltalk.IRInliningJSTranslator);
  408. smalltalk.addMethod(
  409. "_visitIRInlinedAssignment_",
  410. smalltalk.method({
  411. selector: "visitIRInlinedAssignment:",
  412. fn: function (anIRInlinedAssignment){
  413. var self=this;
  414. smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedAssignment,"_instructions",[]),"_last",[])]);
  415. return self}
  416. }),
  417. smalltalk.IRInliningJSTranslator);
  418. smalltalk.addMethod(
  419. "_visitIRInlinedClosure_",
  420. smalltalk.method({
  421. selector: "visitIRInlinedClosure:",
  422. fn: function (anIRInlinedClosure){
  423. var self=this;
  424. smalltalk.send(smalltalk.send(anIRInlinedClosure,"_instructions",[]),"_do_",[(function(each){
  425. return smalltalk.send(self,"_visit_",[each]);
  426. })]);
  427. return self}
  428. }),
  429. smalltalk.IRInliningJSTranslator);
  430. smalltalk.addMethod(
  431. "_visitIRInlinedIfFalse_",
  432. smalltalk.method({
  433. selector: "visitIRInlinedIfFalse:",
  434. fn: function (anIRInlinedIfFalse){
  435. var self=this;
  436. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutIf_with_",[(function(){
  437. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",["! smalltalk.assert("]);
  438. smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfFalse,"_instructions",[]),"_first",[])]);
  439. return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",[")"]);
  440. }),(function(){
  441. return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfFalse,"_instructions",[]),"_last",[])]);
  442. })]);
  443. return self}
  444. }),
  445. smalltalk.IRInliningJSTranslator);
  446. smalltalk.addMethod(
  447. "_visitIRInlinedIfTrue_",
  448. smalltalk.method({
  449. selector: "visitIRInlinedIfTrue:",
  450. fn: function (anIRInlinedIfTrue){
  451. var self=this;
  452. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutIf_with_",[(function(){
  453. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",["smalltalk.assert("]);
  454. smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfTrue,"_instructions",[]),"_first",[])]);
  455. return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",[")"]);
  456. }),(function(){
  457. return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfTrue,"_instructions",[]),"_last",[])]);
  458. })]);
  459. return self}
  460. }),
  461. smalltalk.IRInliningJSTranslator);
  462. smalltalk.addMethod(
  463. "_visitIRInlinedNonLocalReturn_",
  464. smalltalk.method({
  465. selector: "visitIRInlinedNonLocalReturn:",
  466. fn: function (anIRInlinedReturn){
  467. var self=this;
  468. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
  469. return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedReturn,"_instructions",[]),"_last",[])]);
  470. })]);
  471. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutNonLocalReturnWith_",[(function(){
  472. })]);
  473. return self}
  474. }),
  475. smalltalk.IRInliningJSTranslator);
  476. smalltalk.addMethod(
  477. "_visitIRInlinedReturn_",
  478. smalltalk.method({
  479. selector: "visitIRInlinedReturn:",
  480. fn: function (anIRInlinedReturn){
  481. var self=this;
  482. smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedReturn,"_instructions",[]),"_last",[])]);
  483. return self}
  484. }),
  485. smalltalk.IRInliningJSTranslator);
  486. smalltalk.addMethod(
  487. "_visitIRInlinedSequence_",
  488. smalltalk.method({
  489. selector: "visitIRInlinedSequence:",
  490. fn: function (anIRInlinedSequence){
  491. var self=this;
  492. smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_do_",[(function(each){
  493. return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
  494. return smalltalk.send(self,"_visit_",[each]);
  495. })]);
  496. })]);
  497. return self}
  498. }),
  499. smalltalk.IRInliningJSTranslator);
  500. smalltalk.addMethod(
  501. "_visitIRNonLocalReturningInlinedSequence_",
  502. smalltalk.method({
  503. selector: "visitIRNonLocalReturningInlinedSequence:",
  504. fn: function (anIRInlinedSequence){
  505. var self=this;
  506. smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_allButLast",[]),"_do_",[(function(each){
  507. return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
  508. return smalltalk.send(self,"_visit_",[each]);
  509. })]);
  510. })]);
  511. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
  512. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[]),"_canBeAssigned",[]),"_ifTrue_ifFalse_",[(function(){
  513. return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutNonLocalReturnWith_",[(function(){
  514. return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
  515. })]);
  516. }),(function(){
  517. return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
  518. })]);
  519. })]);
  520. return self}
  521. }),
  522. smalltalk.IRInliningJSTranslator);
  523. smalltalk.addMethod(
  524. "_visitIRReturningInlinedSequence_",
  525. smalltalk.method({
  526. selector: "visitIRReturningInlinedSequence:",
  527. fn: function (anIRInlinedSequence){
  528. var self=this;
  529. smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_allButLast",[]),"_do_",[(function(each){
  530. return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
  531. return smalltalk.send(self,"_visit_",[each]);
  532. })]);
  533. })]);
  534. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
  535. return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[]),"_canBeAssigned",[]),"_ifTrue_ifFalse_",[(function(){
  536. smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutReturn",[]);
  537. return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
  538. }),(function(){
  539. return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
  540. })]);
  541. })]);
  542. return self}
  543. }),
  544. smalltalk.IRInliningJSTranslator);
  545. smalltalk.addClass('IRSendInliner', smalltalk.Object, ['send', 'translator'], 'Compiler-Inlining');
  546. smalltalk.addMethod(
  547. "_ifFalse_",
  548. smalltalk.method({
  549. selector: "ifFalse:",
  550. fn: function (anIRInstruction){
  551. var self=this;
  552. var $1;
  553. var inlinedSend;
  554. var inlinedClosure;
  555. if(! smalltalk.assert(smalltalk.send(anIRInstruction,"_isClosure",[]))){
  556. smalltalk.send(self,"_inliningError_",["Message argument should be a block"]);
  557. };
  558. if(! smalltalk.assert(smalltalk.send(smalltalk.send(smalltalk.send(anIRInstruction,"_arguments",[]),"_size",[]),"__eq",[(0)]))){
  559. smalltalk.send(self,"_inliningError_",["Inlined block should have zero argument"]);
  560. };
  561. inlinedClosure=smalltalk.send(self,"_inlineClosure_",[anIRInstruction]);
  562. inlinedSend=smalltalk.send((smalltalk.IRInlinedIfFalse || IRInlinedIfFalse),"_new",[]);
  563. smalltalk.send(inlinedSend,"_add_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_send",[]),"_instructions",[]),"_first",[])]);
  564. $1=smalltalk.send(inlinedSend,"_add_",[inlinedClosure]);
  565. smalltalk.send(smalltalk.send(self,"_send",[]),"_replaceWith_",[inlinedSend]);
  566. return inlinedSend;
  567. }
  568. }),
  569. smalltalk.IRSendInliner);
  570. smalltalk.addMethod(
  571. "_ifTrue_",
  572. smalltalk.method({
  573. selector: "ifTrue:",
  574. fn: function (anIRInstruction){
  575. var self=this;
  576. var $1;
  577. var inlinedSend;
  578. var inlinedClosure;
  579. if(! smalltalk.assert(smalltalk.send(anIRInstruction,"_isClosure",[]))){
  580. smalltalk.send(self,"_inliningError_",["Message argument should be a block"]);
  581. };
  582. if(! smalltalk.assert(smalltalk.send(smalltalk.send(smalltalk.send(anIRInstruction,"_arguments",[]),"_size",[]),"__eq",[(0)]))){
  583. smalltalk.send(self,"_inliningError_",["Inlined block should have zero argument"]);
  584. };
  585. inlinedClosure=smalltalk.send(self,"_inlineClosure_",[anIRInstruction]);
  586. inlinedSend=smalltalk.send((smalltalk.IRInlinedIfTrue || IRInlinedIfTrue),"_new",[]);
  587. smalltalk.send(inlinedSend,"_add_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_send",[]),"_instructions",[]),"_first",[])]);
  588. $1=smalltalk.send(inlinedSend,"_add_",[inlinedClosure]);
  589. smalltalk.send(smalltalk.send(self,"_send",[]),"_replaceWith_",[inlinedSend]);
  590. return inlinedSend;
  591. }
  592. }),
  593. smalltalk.IRSendInliner);
  594. smalltalk.addMethod(
  595. "_inlineClosure_",
  596. smalltalk.method({
  597. selector: "inlineClosure:",
  598. fn: function (anIRClosure){
  599. var self=this;
  600. var inlinedClosure;
  601. var sequence;
  602. var statements;
  603. inlinedClosure=smalltalk.send(self,"_inlinedClosure",[]);
  604. smalltalk.send(inlinedClosure,"_scope_",[smalltalk.send(anIRClosure,"_scope",[])]);
  605. smalltalk.send(smalltalk.send(anIRClosure,"_instructions",[]),"_do_",[(function(each){
  606. if(! smalltalk.assert(smalltalk.send(each,"_isSequence",[]))){
  607. return smalltalk.send(inlinedClosure,"_add_",[each]);
  608. };
  609. })]);
  610. sequence=smalltalk.send(self,"_inlinedSequence",[]);
  611. smalltalk.send(inlinedClosure,"_add_",[sequence]);
  612. statements=smalltalk.send(smalltalk.send(smalltalk.send(anIRClosure,"_instructions",[]),"_last",[]),"_instructions",[]);
  613. smalltalk.send(statements,"_ifNotEmpty_",[(function(){
  614. smalltalk.send(smalltalk.send(statements,"_allButLast",[]),"_do_",[(function(each){
  615. return smalltalk.send(sequence,"_add_",[smalltalk.send(smalltalk.send(self,"_translator",[]),"_visit_",[each])]);
  616. })]);
  617. return smalltalk.send(smalltalk.send(smalltalk.send(statements,"_last",[]),"_isLocalReturn",[]),"_ifTrue_ifFalse_",[(function(){
  618. return smalltalk.send(sequence,"_add_",[smalltalk.send(smalltalk.send(self,"_translator",[]),"_visit_",[smalltalk.send(smalltalk.send(smalltalk.send(statements,"_last",[]),"_instructions",[]),"_first",[])])]);
  619. }),(function(){
  620. return smalltalk.send(sequence,"_add_",[smalltalk.send(smalltalk.send(self,"_translator",[]),"_visit_",[smalltalk.send(statements,"_last",[])])]);
  621. })]);
  622. })]);
  623. return inlinedClosure;
  624. }
  625. }),
  626. smalltalk.IRSendInliner);
  627. smalltalk.addMethod(
  628. "_inlineSend_",
  629. smalltalk.method({
  630. selector: "inlineSend:",
  631. fn: function (anIRSend){
  632. var self=this;
  633. smalltalk.send(self,"_send_",[anIRSend]);
  634. return smalltalk.send(self,"_perform_withArguments_",[smalltalk.send(smalltalk.send(self,"_send",[]),"_selector",[]),smalltalk.send(smalltalk.send(smalltalk.send(self,"_send",[]),"_instructions",[]),"_allButFirst",[])]);
  635. }
  636. }),
  637. smalltalk.IRSendInliner);
  638. smalltalk.addMethod(
  639. "_inlinedClosure",
  640. smalltalk.method({
  641. selector: "inlinedClosure",
  642. fn: function (){
  643. var self=this;
  644. return smalltalk.send((smalltalk.IRInlinedClosure || IRInlinedClosure),"_new",[]);
  645. }
  646. }),
  647. smalltalk.IRSendInliner);
  648. smalltalk.addMethod(
  649. "_inlinedSequence",
  650. smalltalk.method({
  651. selector: "inlinedSequence",
  652. fn: function (){
  653. var self=this;
  654. return smalltalk.send((smalltalk.IRInlinedSequence || IRInlinedSequence),"_new",[]);
  655. }
  656. }),
  657. smalltalk.IRSendInliner);
  658. smalltalk.addMethod(
  659. "_inliningError_",
  660. smalltalk.method({
  661. selector: "inliningError:",
  662. fn: function (aString){
  663. var self=this;
  664. smalltalk.send((smalltalk.InliningError || InliningError),"_signal_",[aString]);
  665. return self}
  666. }),
  667. smalltalk.IRSendInliner);
  668. smalltalk.addMethod(
  669. "_send",
  670. smalltalk.method({
  671. selector: "send",
  672. fn: function (){
  673. var self=this;
  674. return self["@send"];
  675. }
  676. }),
  677. smalltalk.IRSendInliner);
  678. smalltalk.addMethod(
  679. "_send_",
  680. smalltalk.method({
  681. selector: "send:",
  682. fn: function (anIRSend){
  683. var self=this;
  684. self["@send"]=anIRSend;
  685. return self}
  686. }),
  687. smalltalk.IRSendInliner);
  688. smalltalk.addMethod(
  689. "_translator",
  690. smalltalk.method({
  691. selector: "translator",
  692. fn: function (){
  693. var self=this;
  694. return self["@translator"];
  695. }
  696. }),
  697. smalltalk.IRSendInliner);
  698. smalltalk.addMethod(
  699. "_translator_",
  700. smalltalk.method({
  701. selector: "translator:",
  702. fn: function (anASTTranslator){
  703. var self=this;
  704. self["@translator"]=anASTTranslator;
  705. return self}
  706. }),
  707. smalltalk.IRSendInliner);
  708. smalltalk.addMethod(
  709. "_inlinedSelectors",
  710. smalltalk.method({
  711. selector: "inlinedSelectors",
  712. fn: function (){
  713. var self=this;
  714. return ["ifTrue:", "ifFalse:"];
  715. }
  716. }),
  717. smalltalk.IRSendInliner.klass);
  718. smalltalk.addMethod(
  719. "_shouldInline_",
  720. smalltalk.method({
  721. selector: "shouldInline:",
  722. fn: function (anIRInstruction){
  723. var self=this;
  724. var $early={};
  725. try {
  726. if(! smalltalk.assert(smalltalk.send(smalltalk.send(self,"_inlinedSelectors",[]),"_includes_",[smalltalk.send(anIRInstruction,"_selector",[])]))){
  727. return false;
  728. };
  729. smalltalk.send(smalltalk.send(smalltalk.send(anIRInstruction,"_instructions",[]),"_allButFirst",[]),"_do_",[(function(each){
  730. if(! smalltalk.assert(smalltalk.send(each,"_isClosure",[]))){
  731. throw $early=[false];
  732. };
  733. })]);
  734. return true;
  735. }
  736. catch(e) {if(e===$early)return e[0]; throw e}
  737. }
  738. }),
  739. smalltalk.IRSendInliner.klass);
  740. smalltalk.addClass('IRAssignmentInliner', smalltalk.IRSendInliner, ['assignment'], 'Compiler-Inlining');
  741. smalltalk.addMethod(
  742. "_assignment",
  743. smalltalk.method({
  744. selector: "assignment",
  745. fn: function (){
  746. var self=this;
  747. return self["@assignment"];
  748. }
  749. }),
  750. smalltalk.IRAssignmentInliner);
  751. smalltalk.addMethod(
  752. "_assignment_",
  753. smalltalk.method({
  754. selector: "assignment:",
  755. fn: function (aNode){
  756. var self=this;
  757. self["@assignment"]=aNode;
  758. return self}
  759. }),
  760. smalltalk.IRAssignmentInliner);
  761. smalltalk.addMethod(
  762. "_inlineAssignment_",
  763. smalltalk.method({
  764. selector: "inlineAssignment:",
  765. fn: function (anIRAssignment){
  766. var self=this;
  767. var inlinedAssignment;
  768. smalltalk.send(self,"_assignment_",[anIRAssignment]);
  769. inlinedAssignment=smalltalk.send((smalltalk.IRInlinedAssignment || IRInlinedAssignment),"_new",[]);
  770. smalltalk.send(smalltalk.send(anIRAssignment,"_instructions",[]),"_do_",[(function(each){
  771. return smalltalk.send(inlinedAssignment,"_add_",[each]);
  772. })]);
  773. smalltalk.send(anIRAssignment,"_replaceWith_",[inlinedAssignment]);
  774. smalltalk.send(self,"_inlineSend_",[smalltalk.send(smalltalk.send(inlinedAssignment,"_instructions",[]),"_last",[])]);
  775. return inlinedAssignment;
  776. }
  777. }),
  778. smalltalk.IRAssignmentInliner);
  779. smalltalk.addMethod(
  780. "_inlinedSequence",
  781. smalltalk.method({
  782. selector: "inlinedSequence",
  783. fn: function (){
  784. var self=this;
  785. var $1,$2;
  786. $1=smalltalk.send((smalltalk.IRAssigningInlinedSequence || IRAssigningInlinedSequence),"_new",[]);
  787. smalltalk.send($1,"_assignTo_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_assignment",[]),"_instructions",[]),"_first",[])]);
  788. $2=smalltalk.send($1,"_yourself",[]);
  789. return $2;
  790. }
  791. }),
  792. smalltalk.IRAssignmentInliner);
  793. smalltalk.addClass('IRReturnInliner', smalltalk.IRSendInliner, [], 'Compiler-Inlining');
  794. smalltalk.addMethod(
  795. "_inlineReturn_",
  796. smalltalk.method({
  797. selector: "inlineReturn:",
  798. fn: function (anIRReturn){
  799. var self=this;
  800. var return_;
  801. return_=smalltalk.send(self,"_inlinedReturn",[]);
  802. smalltalk.send(smalltalk.send(anIRReturn,"_instructions",[]),"_do_",[(function(each){
  803. return smalltalk.send(return_,"_add_",[each]);
  804. })]);
  805. smalltalk.send(anIRReturn,"_replaceWith_",[return_]);
  806. smalltalk.send(self,"_inlineSend_",[smalltalk.send(smalltalk.send(return_,"_instructions",[]),"_last",[])]);
  807. return return_;
  808. }
  809. }),
  810. smalltalk.IRReturnInliner);
  811. smalltalk.addMethod(
  812. "_inlinedReturn",
  813. smalltalk.method({
  814. selector: "inlinedReturn",
  815. fn: function (){
  816. var self=this;
  817. return smalltalk.send((smalltalk.IRInlinedReturn || IRInlinedReturn),"_new",[]);
  818. }
  819. }),
  820. smalltalk.IRReturnInliner);
  821. smalltalk.addMethod(
  822. "_inlinedSequence",
  823. smalltalk.method({
  824. selector: "inlinedSequence",
  825. fn: function (){
  826. var self=this;
  827. return smalltalk.send((smalltalk.IRReturningInlinedSequence || IRReturningInlinedSequence),"_new",[]);
  828. }
  829. }),
  830. smalltalk.IRReturnInliner);
  831. smalltalk.addClass('IRNonLocalReturnInliner', smalltalk.IRReturnInliner, [], 'Compiler-Inlining');
  832. smalltalk.addMethod(
  833. "_inlinedReturn",
  834. smalltalk.method({
  835. selector: "inlinedReturn",
  836. fn: function (){
  837. var self=this;
  838. return smalltalk.send((smalltalk.IRInlinedNonLocalReturn || IRInlinedNonLocalReturn),"_new",[]);
  839. }
  840. }),
  841. smalltalk.IRNonLocalReturnInliner);
  842. smalltalk.addMethod(
  843. "_inlinedSequence",
  844. smalltalk.method({
  845. selector: "inlinedSequence",
  846. fn: function (){
  847. var self=this;
  848. return smalltalk.send((smalltalk.IRNonLocalReturningInlinedSequence || IRNonLocalReturningInlinedSequence),"_new",[]);
  849. }
  850. }),
  851. smalltalk.IRNonLocalReturnInliner);
  852. smalltalk.addClass('InliningCodeGenerator', smalltalk.CodeGenerator, [], 'Compiler-Inlining');
  853. smalltalk.addMethod(
  854. "_compileNode_",
  855. smalltalk.method({
  856. selector: "compileNode:",
  857. fn: function (aNode){
  858. var self=this;
  859. var $1,$2;
  860. var ir;
  861. var stream;
  862. smalltalk.send(smalltalk.send(self,"_semanticAnalyzer",[]),"_visit_",[aNode]);
  863. ir=smalltalk.send(smalltalk.send(self,"_translator",[]),"_visit_",[aNode]);
  864. smalltalk.send(smalltalk.send(self,"_inliner",[]),"_visit_",[ir]);
  865. $1=smalltalk.send(self,"_irTranslator",[]);
  866. smalltalk.send($1,"_visit_",[ir]);
  867. $2=smalltalk.send($1,"_contents",[]);
  868. return $2;
  869. }
  870. }),
  871. smalltalk.InliningCodeGenerator);
  872. smalltalk.addMethod(
  873. "_inliner",
  874. smalltalk.method({
  875. selector: "inliner",
  876. fn: function (){
  877. var self=this;
  878. return smalltalk.send((smalltalk.IRInliner || IRInliner),"_new",[]);
  879. }
  880. }),
  881. smalltalk.InliningCodeGenerator);
  882. smalltalk.addMethod(
  883. "_irTranslator",
  884. smalltalk.method({
  885. selector: "irTranslator",
  886. fn: function (){
  887. var self=this;
  888. return smalltalk.send((smalltalk.IRInliningJSTranslator || IRInliningJSTranslator),"_new",[]);
  889. }
  890. }),
  891. smalltalk.InliningCodeGenerator);