Compiler-Inlining.deploy.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  1. (function(smalltalk,nil,_st){
  2. smalltalk.addPackage('Compiler-Inlining');
  3. smalltalk.addClass('IRInlinedAssignment', smalltalk.IRAssignment, [], 'Compiler-Inlining');
  4. smalltalk.addMethod(
  5. smalltalk.method({
  6. selector: "accept:",
  7. fn: function (aVisitor){
  8. var self=this;
  9. return smalltalk.withContext(function($ctx1) {
  10. var $1;
  11. $1=_st(aVisitor)._visitIRInlinedAssignment_(self);
  12. return $1;
  13. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedAssignment)})},
  14. messageSends: ["visitIRInlinedAssignment:"]}),
  15. smalltalk.IRInlinedAssignment);
  16. smalltalk.addMethod(
  17. smalltalk.method({
  18. selector: "isInlined",
  19. fn: function (){
  20. var self=this;
  21. return smalltalk.withContext(function($ctx1) {
  22. return true;
  23. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedAssignment)})},
  24. messageSends: []}),
  25. smalltalk.IRInlinedAssignment);
  26. smalltalk.addClass('IRInlinedClosure', smalltalk.IRClosure, [], 'Compiler-Inlining');
  27. smalltalk.addMethod(
  28. smalltalk.method({
  29. selector: "accept:",
  30. fn: function (aVisitor){
  31. var self=this;
  32. return smalltalk.withContext(function($ctx1) {
  33. _st(aVisitor)._visitIRInlinedClosure_(self);
  34. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedClosure)})},
  35. messageSends: ["visitIRInlinedClosure:"]}),
  36. smalltalk.IRInlinedClosure);
  37. smalltalk.addMethod(
  38. smalltalk.method({
  39. selector: "isInlined",
  40. fn: function (){
  41. var self=this;
  42. return smalltalk.withContext(function($ctx1) {
  43. return true;
  44. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedClosure)})},
  45. messageSends: []}),
  46. smalltalk.IRInlinedClosure);
  47. smalltalk.addClass('IRInlinedReturn', smalltalk.IRReturn, [], 'Compiler-Inlining');
  48. smalltalk.addMethod(
  49. smalltalk.method({
  50. selector: "accept:",
  51. fn: function (aVisitor){
  52. var self=this;
  53. return smalltalk.withContext(function($ctx1) {
  54. var $1;
  55. $1=_st(aVisitor)._visitIRInlinedReturn_(self);
  56. return $1;
  57. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedReturn)})},
  58. messageSends: ["visitIRInlinedReturn:"]}),
  59. smalltalk.IRInlinedReturn);
  60. smalltalk.addMethod(
  61. smalltalk.method({
  62. selector: "isInlined",
  63. fn: function (){
  64. var self=this;
  65. return smalltalk.withContext(function($ctx1) {
  66. return true;
  67. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedReturn)})},
  68. messageSends: []}),
  69. smalltalk.IRInlinedReturn);
  70. smalltalk.addClass('IRInlinedSend', smalltalk.IRSend, [], 'Compiler-Inlining');
  71. smalltalk.addMethod(
  72. smalltalk.method({
  73. selector: "accept:",
  74. fn: function (aVisitor){
  75. var self=this;
  76. return smalltalk.withContext(function($ctx1) {
  77. _st(aVisitor)._visitInlinedSend_(self);
  78. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedSend)})},
  79. messageSends: ["visitInlinedSend:"]}),
  80. smalltalk.IRInlinedSend);
  81. smalltalk.addMethod(
  82. smalltalk.method({
  83. selector: "isInlined",
  84. fn: function (){
  85. var self=this;
  86. return smalltalk.withContext(function($ctx1) {
  87. return true;
  88. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedSend)})},
  89. messageSends: []}),
  90. smalltalk.IRInlinedSend);
  91. smalltalk.addClass('IRInlinedIfFalse', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  92. smalltalk.addMethod(
  93. smalltalk.method({
  94. selector: "accept:",
  95. fn: function (aVisitor){
  96. var self=this;
  97. return smalltalk.withContext(function($ctx1) {
  98. _st(aVisitor)._visitIRInlinedIfFalse_(self);
  99. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedIfFalse)})},
  100. messageSends: ["visitIRInlinedIfFalse:"]}),
  101. smalltalk.IRInlinedIfFalse);
  102. smalltalk.addClass('IRInlinedIfNilIfNotNil', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  103. smalltalk.addMethod(
  104. smalltalk.method({
  105. selector: "accept:",
  106. fn: function (aVisitor){
  107. var self=this;
  108. return smalltalk.withContext(function($ctx1) {
  109. _st(aVisitor)._visitIRInlinedIfNilIfNotNil_(self);
  110. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedIfNilIfNotNil)})},
  111. messageSends: ["visitIRInlinedIfNilIfNotNil:"]}),
  112. smalltalk.IRInlinedIfNilIfNotNil);
  113. smalltalk.addClass('IRInlinedIfTrue', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  114. smalltalk.addMethod(
  115. smalltalk.method({
  116. selector: "accept:",
  117. fn: function (aVisitor){
  118. var self=this;
  119. return smalltalk.withContext(function($ctx1) {
  120. _st(aVisitor)._visitIRInlinedIfTrue_(self);
  121. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedIfTrue)})},
  122. messageSends: ["visitIRInlinedIfTrue:"]}),
  123. smalltalk.IRInlinedIfTrue);
  124. smalltalk.addClass('IRInlinedIfTrueIfFalse', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
  125. smalltalk.addMethod(
  126. smalltalk.method({
  127. selector: "accept:",
  128. fn: function (aVisitor){
  129. var self=this;
  130. return smalltalk.withContext(function($ctx1) {
  131. _st(aVisitor)._visitIRInlinedIfTrueIfFalse_(self);
  132. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedIfTrueIfFalse)})},
  133. messageSends: ["visitIRInlinedIfTrueIfFalse:"]}),
  134. smalltalk.IRInlinedIfTrueIfFalse);
  135. smalltalk.addClass('IRInlinedSequence', smalltalk.IRBlockSequence, [], 'Compiler-Inlining');
  136. smalltalk.addMethod(
  137. smalltalk.method({
  138. selector: "accept:",
  139. fn: function (aVisitor){
  140. var self=this;
  141. return smalltalk.withContext(function($ctx1) {
  142. _st(aVisitor)._visitIRInlinedSequence_(self);
  143. return self}, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},smalltalk.IRInlinedSequence)})},
  144. messageSends: ["visitIRInlinedSequence:"]}),
  145. smalltalk.IRInlinedSequence);
  146. smalltalk.addMethod(
  147. smalltalk.method({
  148. selector: "isInlined",
  149. fn: function (){
  150. var self=this;
  151. return smalltalk.withContext(function($ctx1) {
  152. return true;
  153. }, function($ctx1) {$ctx1.fill(self,"isInlined",{},smalltalk.IRInlinedSequence)})},
  154. messageSends: []}),
  155. smalltalk.IRInlinedSequence);
  156. smalltalk.addClass('IRInliner', smalltalk.IRVisitor, [], 'Compiler-Inlining');
  157. smalltalk.addMethod(
  158. smalltalk.method({
  159. selector: "assignmentInliner",
  160. fn: function (){
  161. var self=this;
  162. function $IRAssignmentInliner(){return smalltalk.IRAssignmentInliner||(typeof IRAssignmentInliner=="undefined"?nil:IRAssignmentInliner)}
  163. return smalltalk.withContext(function($ctx1) {
  164. var $2,$3,$1;
  165. $2=_st($IRAssignmentInliner())._new();
  166. _st($2)._translator_(self);
  167. $3=_st($2)._yourself();
  168. $1=$3;
  169. return $1;
  170. }, function($ctx1) {$ctx1.fill(self,"assignmentInliner",{},smalltalk.IRInliner)})},
  171. messageSends: ["translator:", "new", "yourself"]}),
  172. smalltalk.IRInliner);
  173. smalltalk.addMethod(
  174. smalltalk.method({
  175. selector: "returnInliner",
  176. fn: function (){
  177. var self=this;
  178. function $IRReturnInliner(){return smalltalk.IRReturnInliner||(typeof IRReturnInliner=="undefined"?nil:IRReturnInliner)}
  179. return smalltalk.withContext(function($ctx1) {
  180. var $2,$3,$1;
  181. $2=_st($IRReturnInliner())._new();
  182. _st($2)._translator_(self);
  183. $3=_st($2)._yourself();
  184. $1=$3;
  185. return $1;
  186. }, function($ctx1) {$ctx1.fill(self,"returnInliner",{},smalltalk.IRInliner)})},
  187. messageSends: ["translator:", "new", "yourself"]}),
  188. smalltalk.IRInliner);
  189. smalltalk.addMethod(
  190. smalltalk.method({
  191. selector: "sendInliner",
  192. fn: function (){
  193. var self=this;
  194. function $IRSendInliner(){return smalltalk.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
  195. return smalltalk.withContext(function($ctx1) {
  196. var $2,$3,$1;
  197. $2=_st($IRSendInliner())._new();
  198. _st($2)._translator_(self);
  199. $3=_st($2)._yourself();
  200. $1=$3;
  201. return $1;
  202. }, function($ctx1) {$ctx1.fill(self,"sendInliner",{},smalltalk.IRInliner)})},
  203. messageSends: ["translator:", "new", "yourself"]}),
  204. smalltalk.IRInliner);
  205. smalltalk.addMethod(
  206. smalltalk.method({
  207. selector: "shouldInlineAssignment:",
  208. fn: function (anIRAssignment){
  209. var self=this;
  210. return smalltalk.withContext(function($ctx1) {
  211. var $1;
  212. $1=_st(_st(_st(anIRAssignment)._isInlined())._not())._and_((function(){
  213. return smalltalk.withContext(function($ctx2) {
  214. return _st(_st(_st(_st(anIRAssignment)._instructions())._last())._isSend())._and_((function(){
  215. return smalltalk.withContext(function($ctx3) {
  216. return self._shouldInlineSend_(_st(_st(anIRAssignment)._instructions())._last());
  217. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  218. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  219. return $1;
  220. }, function($ctx1) {$ctx1.fill(self,"shouldInlineAssignment:",{anIRAssignment:anIRAssignment},smalltalk.IRInliner)})},
  221. messageSends: ["and:", "shouldInlineSend:", "last", "instructions", "isSend", "not", "isInlined"]}),
  222. smalltalk.IRInliner);
  223. smalltalk.addMethod(
  224. smalltalk.method({
  225. selector: "shouldInlineReturn:",
  226. fn: function (anIRReturn){
  227. var self=this;
  228. return smalltalk.withContext(function($ctx1) {
  229. var $1;
  230. $1=_st(_st(_st(anIRReturn)._isInlined())._not())._and_((function(){
  231. return smalltalk.withContext(function($ctx2) {
  232. return _st(_st(_st(_st(anIRReturn)._instructions())._first())._isSend())._and_((function(){
  233. return smalltalk.withContext(function($ctx3) {
  234. return self._shouldInlineSend_(_st(_st(anIRReturn)._instructions())._first());
  235. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  236. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  237. return $1;
  238. }, function($ctx1) {$ctx1.fill(self,"shouldInlineReturn:",{anIRReturn:anIRReturn},smalltalk.IRInliner)})},
  239. messageSends: ["and:", "shouldInlineSend:", "first", "instructions", "isSend", "not", "isInlined"]}),
  240. smalltalk.IRInliner);
  241. smalltalk.addMethod(
  242. smalltalk.method({
  243. selector: "shouldInlineSend:",
  244. fn: function (anIRSend){
  245. var self=this;
  246. function $IRSendInliner(){return smalltalk.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
  247. return smalltalk.withContext(function($ctx1) {
  248. var $1;
  249. $1=_st(_st(_st(anIRSend)._isInlined())._not())._and_((function(){
  250. return smalltalk.withContext(function($ctx2) {
  251. return _st($IRSendInliner())._shouldInline_(anIRSend);
  252. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  253. return $1;
  254. }, function($ctx1) {$ctx1.fill(self,"shouldInlineSend:",{anIRSend:anIRSend},smalltalk.IRInliner)})},
  255. messageSends: ["and:", "shouldInline:", "not", "isInlined"]}),
  256. smalltalk.IRInliner);
  257. smalltalk.addMethod(
  258. smalltalk.method({
  259. selector: "transformNonLocalReturn:",
  260. fn: function (anIRNonLocalReturn){
  261. var self=this;
  262. var localReturn;
  263. function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
  264. return smalltalk.withContext(function($ctx1) {
  265. var $1,$2,$3,$4,$5;
  266. $1=_st(_st(anIRNonLocalReturn)._scope())._canInlineNonLocalReturns();
  267. if(smalltalk.assert($1)){
  268. _st(_st(_st(anIRNonLocalReturn)._scope())._methodScope())._removeNonLocalReturn_(_st(anIRNonLocalReturn)._scope());
  269. $2=_st($IRReturn())._new();
  270. _st($2)._scope_(_st(anIRNonLocalReturn)._scope());
  271. $3=_st($2)._yourself();
  272. localReturn=$3;
  273. localReturn;
  274. _st(_st(anIRNonLocalReturn)._instructions())._do_((function(each){
  275. return smalltalk.withContext(function($ctx2) {
  276. return _st(localReturn)._add_(each);
  277. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  278. _st(anIRNonLocalReturn)._replaceWith_(localReturn);
  279. $4=localReturn;
  280. return $4;
  281. };
  282. $5=smalltalk.IRInliner.superclass.fn.prototype._visitIRNonLocalReturn_.apply(_st(self), [anIRNonLocalReturn]);
  283. return $5;
  284. }, function($ctx1) {$ctx1.fill(self,"transformNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn,localReturn:localReturn},smalltalk.IRInliner)})},
  285. messageSends: ["ifTrue:", "removeNonLocalReturn:", "scope", "methodScope", "scope:", "new", "yourself", "do:", "add:", "instructions", "replaceWith:", "canInlineNonLocalReturns", "visitIRNonLocalReturn:"]}),
  286. smalltalk.IRInliner);
  287. smalltalk.addMethod(
  288. smalltalk.method({
  289. selector: "visitIRAssignment:",
  290. fn: function (anIRAssignment){
  291. var self=this;
  292. return smalltalk.withContext(function($ctx1) {
  293. var $2,$1;
  294. $2=self._shouldInlineAssignment_(anIRAssignment);
  295. if(smalltalk.assert($2)){
  296. $1=_st(self._assignmentInliner())._inlineAssignment_(anIRAssignment);
  297. } else {
  298. $1=smalltalk.IRInliner.superclass.fn.prototype._visitIRAssignment_.apply(_st(self), [anIRAssignment]);
  299. };
  300. return $1;
  301. }, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment},smalltalk.IRInliner)})},
  302. messageSends: ["ifTrue:ifFalse:", "inlineAssignment:", "assignmentInliner", "visitIRAssignment:", "shouldInlineAssignment:"]}),
  303. smalltalk.IRInliner);
  304. smalltalk.addMethod(
  305. smalltalk.method({
  306. selector: "visitIRNonLocalReturn:",
  307. fn: function (anIRNonLocalReturn){
  308. var self=this;
  309. return smalltalk.withContext(function($ctx1) {
  310. var $1;
  311. $1=self._transformNonLocalReturn_(anIRNonLocalReturn);
  312. return $1;
  313. }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn},smalltalk.IRInliner)})},
  314. messageSends: ["transformNonLocalReturn:"]}),
  315. smalltalk.IRInliner);
  316. smalltalk.addMethod(
  317. smalltalk.method({
  318. selector: "visitIRReturn:",
  319. fn: function (anIRReturn){
  320. var self=this;
  321. return smalltalk.withContext(function($ctx1) {
  322. var $2,$1;
  323. $2=self._shouldInlineReturn_(anIRReturn);
  324. if(smalltalk.assert($2)){
  325. $1=_st(self._returnInliner())._inlineReturn_(anIRReturn);
  326. } else {
  327. $1=smalltalk.IRInliner.superclass.fn.prototype._visitIRReturn_.apply(_st(self), [anIRReturn]);
  328. };
  329. return $1;
  330. }, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn},smalltalk.IRInliner)})},
  331. messageSends: ["ifTrue:ifFalse:", "inlineReturn:", "returnInliner", "visitIRReturn:", "shouldInlineReturn:"]}),
  332. smalltalk.IRInliner);
  333. smalltalk.addMethod(
  334. smalltalk.method({
  335. selector: "visitIRSend:",
  336. fn: function (anIRSend){
  337. var self=this;
  338. return smalltalk.withContext(function($ctx1) {
  339. var $2,$1;
  340. $2=self._shouldInlineSend_(anIRSend);
  341. if(smalltalk.assert($2)){
  342. $1=_st(self._sendInliner())._inlineSend_(anIRSend);
  343. } else {
  344. $1=smalltalk.IRInliner.superclass.fn.prototype._visitIRSend_.apply(_st(self), [anIRSend]);
  345. };
  346. return $1;
  347. }, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend},smalltalk.IRInliner)})},
  348. messageSends: ["ifTrue:ifFalse:", "inlineSend:", "sendInliner", "visitIRSend:", "shouldInlineSend:"]}),
  349. smalltalk.IRInliner);
  350. smalltalk.addClass('IRInliningJSTranslator', smalltalk.IRJSTranslator, [], 'Compiler-Inlining');
  351. smalltalk.addMethod(
  352. smalltalk.method({
  353. selector: "visitIRInlinedAssignment:",
  354. fn: function (anIRInlinedAssignment){
  355. var self=this;
  356. return smalltalk.withContext(function($ctx1) {
  357. self._visit_(_st(_st(anIRInlinedAssignment)._instructions())._last());
  358. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedAssignment:",{anIRInlinedAssignment:anIRInlinedAssignment},smalltalk.IRInliningJSTranslator)})},
  359. messageSends: ["visit:", "last", "instructions"]}),
  360. smalltalk.IRInliningJSTranslator);
  361. smalltalk.addMethod(
  362. smalltalk.method({
  363. selector: "visitIRInlinedClosure:",
  364. fn: function (anIRInlinedClosure){
  365. var self=this;
  366. return smalltalk.withContext(function($ctx1) {
  367. _st(self._stream())._nextPutVars_(_st(_st(anIRInlinedClosure)._tempDeclarations())._collect_((function(each){
  368. return smalltalk.withContext(function($ctx2) {
  369. return _st(_st(each)._name())._asVariableName();
  370. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})})));
  371. _st(_st(anIRInlinedClosure)._instructions())._do_((function(each){
  372. return smalltalk.withContext(function($ctx2) {
  373. return self._visit_(each);
  374. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  375. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure},smalltalk.IRInliningJSTranslator)})},
  376. messageSends: ["nextPutVars:", "collect:", "asVariableName", "name", "tempDeclarations", "stream", "do:", "visit:", "instructions"]}),
  377. smalltalk.IRInliningJSTranslator);
  378. smalltalk.addMethod(
  379. smalltalk.method({
  380. selector: "visitIRInlinedIfFalse:",
  381. fn: function (anIRInlinedIfFalse){
  382. var self=this;
  383. return smalltalk.withContext(function($ctx1) {
  384. _st(self._stream())._nextPutIf_with_((function(){
  385. return smalltalk.withContext(function($ctx2) {
  386. _st(self._stream())._nextPutAll_("! smalltalk.assert(");
  387. self._visit_(_st(_st(anIRInlinedIfFalse)._instructions())._first());
  388. return _st(self._stream())._nextPutAll_(")");
  389. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(){
  390. return smalltalk.withContext(function($ctx2) {
  391. return self._visit_(_st(_st(anIRInlinedIfFalse)._instructions())._last());
  392. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  393. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfFalse:",{anIRInlinedIfFalse:anIRInlinedIfFalse},smalltalk.IRInliningJSTranslator)})},
  394. messageSends: ["nextPutIf:with:", "nextPutAll:", "stream", "visit:", "first", "instructions", "last"]}),
  395. smalltalk.IRInliningJSTranslator);
  396. smalltalk.addMethod(
  397. smalltalk.method({
  398. selector: "visitIRInlinedIfNil:",
  399. fn: function (anIRInlinedIfNil){
  400. var self=this;
  401. return smalltalk.withContext(function($ctx1) {
  402. _st(self._stream())._nextPutIf_with_((function(){
  403. return smalltalk.withContext(function($ctx2) {
  404. _st(self._stream())._nextPutAll_("($receiver = ");
  405. self._visit_(_st(_st(anIRInlinedIfNil)._instructions())._first());
  406. return _st(self._stream())._nextPutAll_(") == nil || $receiver == undefined");
  407. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(){
  408. return smalltalk.withContext(function($ctx2) {
  409. return self._visit_(_st(_st(anIRInlinedIfNil)._instructions())._last());
  410. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  411. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNil:",{anIRInlinedIfNil:anIRInlinedIfNil},smalltalk.IRInliningJSTranslator)})},
  412. messageSends: ["nextPutIf:with:", "nextPutAll:", "stream", "visit:", "first", "instructions", "last"]}),
  413. smalltalk.IRInliningJSTranslator);
  414. smalltalk.addMethod(
  415. smalltalk.method({
  416. selector: "visitIRInlinedIfNilIfNotNil:",
  417. fn: function (anIRInlinedIfNilIfNotNil){
  418. var self=this;
  419. return smalltalk.withContext(function($ctx1) {
  420. _st(self._stream())._nextPutIfElse_with_with_((function(){
  421. return smalltalk.withContext(function($ctx2) {
  422. _st(self._stream())._nextPutAll_("($receiver = ");
  423. self._visit_(_st(_st(anIRInlinedIfNilIfNotNil)._instructions())._first());
  424. return _st(self._stream())._nextPutAll_(") == nil || $receiver == undefined");
  425. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(){
  426. return smalltalk.withContext(function($ctx2) {
  427. return self._visit_(_st(_st(anIRInlinedIfNilIfNotNil)._instructions())._second());
  428. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(){
  429. return smalltalk.withContext(function($ctx2) {
  430. return self._visit_(_st(_st(anIRInlinedIfNilIfNotNil)._instructions())._third());
  431. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  432. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNilIfNotNil:",{anIRInlinedIfNilIfNotNil:anIRInlinedIfNilIfNotNil},smalltalk.IRInliningJSTranslator)})},
  433. messageSends: ["nextPutIfElse:with:with:", "nextPutAll:", "stream", "visit:", "first", "instructions", "second", "third"]}),
  434. smalltalk.IRInliningJSTranslator);
  435. smalltalk.addMethod(
  436. smalltalk.method({
  437. selector: "visitIRInlinedIfTrue:",
  438. fn: function (anIRInlinedIfTrue){
  439. var self=this;
  440. return smalltalk.withContext(function($ctx1) {
  441. _st(self._stream())._nextPutIf_with_((function(){
  442. return smalltalk.withContext(function($ctx2) {
  443. _st(self._stream())._nextPutAll_("smalltalk.assert(");
  444. self._visit_(_st(_st(anIRInlinedIfTrue)._instructions())._first());
  445. return _st(self._stream())._nextPutAll_(")");
  446. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(){
  447. return smalltalk.withContext(function($ctx2) {
  448. return self._visit_(_st(_st(anIRInlinedIfTrue)._instructions())._last());
  449. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  450. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrue:",{anIRInlinedIfTrue:anIRInlinedIfTrue},smalltalk.IRInliningJSTranslator)})},
  451. messageSends: ["nextPutIf:with:", "nextPutAll:", "stream", "visit:", "first", "instructions", "last"]}),
  452. smalltalk.IRInliningJSTranslator);
  453. smalltalk.addMethod(
  454. smalltalk.method({
  455. selector: "visitIRInlinedIfTrueIfFalse:",
  456. fn: function (anIRInlinedIfTrueIfFalse){
  457. var self=this;
  458. return smalltalk.withContext(function($ctx1) {
  459. _st(self._stream())._nextPutIfElse_with_with_((function(){
  460. return smalltalk.withContext(function($ctx2) {
  461. _st(self._stream())._nextPutAll_("smalltalk.assert(");
  462. self._visit_(_st(_st(anIRInlinedIfTrueIfFalse)._instructions())._first());
  463. return _st(self._stream())._nextPutAll_(")");
  464. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(){
  465. return smalltalk.withContext(function($ctx2) {
  466. return self._visit_(_st(_st(anIRInlinedIfTrueIfFalse)._instructions())._second());
  467. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}),(function(){
  468. return smalltalk.withContext(function($ctx2) {
  469. return self._visit_(_st(_st(anIRInlinedIfTrueIfFalse)._instructions())._third());
  470. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  471. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrueIfFalse:",{anIRInlinedIfTrueIfFalse:anIRInlinedIfTrueIfFalse},smalltalk.IRInliningJSTranslator)})},
  472. messageSends: ["nextPutIfElse:with:with:", "nextPutAll:", "stream", "visit:", "first", "instructions", "second", "third"]}),
  473. smalltalk.IRInliningJSTranslator);
  474. smalltalk.addMethod(
  475. smalltalk.method({
  476. selector: "visitIRInlinedNonLocalReturn:",
  477. fn: function (anIRInlinedReturn){
  478. var self=this;
  479. return smalltalk.withContext(function($ctx1) {
  480. _st(self._stream())._nextPutStatementWith_((function(){
  481. return smalltalk.withContext(function($ctx2) {
  482. return self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
  483. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  484. _st(self._stream())._nextPutNonLocalReturnWith_((function(){
  485. return smalltalk.withContext(function($ctx2) {
  486. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  487. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedNonLocalReturn:",{anIRInlinedReturn:anIRInlinedReturn},smalltalk.IRInliningJSTranslator)})},
  488. messageSends: ["nextPutStatementWith:", "visit:", "last", "instructions", "stream", "nextPutNonLocalReturnWith:"]}),
  489. smalltalk.IRInliningJSTranslator);
  490. smalltalk.addMethod(
  491. smalltalk.method({
  492. selector: "visitIRInlinedReturn:",
  493. fn: function (anIRInlinedReturn){
  494. var self=this;
  495. return smalltalk.withContext(function($ctx1) {
  496. self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
  497. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedReturn:",{anIRInlinedReturn:anIRInlinedReturn},smalltalk.IRInliningJSTranslator)})},
  498. messageSends: ["visit:", "last", "instructions"]}),
  499. smalltalk.IRInliningJSTranslator);
  500. smalltalk.addMethod(
  501. smalltalk.method({
  502. selector: "visitIRInlinedSequence:",
  503. fn: function (anIRInlinedSequence){
  504. var self=this;
  505. return smalltalk.withContext(function($ctx1) {
  506. _st(_st(anIRInlinedSequence)._instructions())._do_((function(each){
  507. return smalltalk.withContext(function($ctx2) {
  508. return _st(self._stream())._nextPutStatementWith_((function(){
  509. return smalltalk.withContext(function($ctx3) {
  510. return self._visit_(each);
  511. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  512. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  513. return self}, function($ctx1) {$ctx1.fill(self,"visitIRInlinedSequence:",{anIRInlinedSequence:anIRInlinedSequence},smalltalk.IRInliningJSTranslator)})},
  514. messageSends: ["do:", "nextPutStatementWith:", "visit:", "stream", "instructions"]}),
  515. smalltalk.IRInliningJSTranslator);
  516. smalltalk.addClass('IRSendInliner', smalltalk.Object, ['send', 'translator'], 'Compiler-Inlining');
  517. smalltalk.addMethod(
  518. smalltalk.method({
  519. selector: "ifFalse:",
  520. fn: function (anIRInstruction){
  521. var self=this;
  522. function $IRInlinedIfFalse(){return smalltalk.IRInlinedIfFalse||(typeof IRInlinedIfFalse=="undefined"?nil:IRInlinedIfFalse)}
  523. return smalltalk.withContext(function($ctx1) {
  524. var $1;
  525. $1=self._inlinedSend_with_(_st($IRInlinedIfFalse())._new(),anIRInstruction);
  526. return $1;
  527. }, function($ctx1) {$ctx1.fill(self,"ifFalse:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  528. messageSends: ["inlinedSend:with:", "new"]}),
  529. smalltalk.IRSendInliner);
  530. smalltalk.addMethod(
  531. smalltalk.method({
  532. selector: "ifFalse:ifTrue:",
  533. fn: function (anIRInstruction,anotherIRInstruction){
  534. var self=this;
  535. return smalltalk.withContext(function($ctx1) {
  536. var $1;
  537. $1=self._perform_withArguments_("ifTrue:ifFalse:",[anotherIRInstruction,anIRInstruction]);
  538. return $1;
  539. }, function($ctx1) {$ctx1.fill(self,"ifFalse:ifTrue:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  540. messageSends: ["perform:withArguments:"]}),
  541. smalltalk.IRSendInliner);
  542. smalltalk.addMethod(
  543. smalltalk.method({
  544. selector: "ifNil:",
  545. fn: function (anIRInstruction){
  546. var self=this;
  547. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  548. function $IRClosure(){return smalltalk.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
  549. function $IRBlockSequence(){return smalltalk.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
  550. return smalltalk.withContext(function($ctx1) {
  551. var $2,$3,$4,$5,$1;
  552. $2=_st($IRClosure())._new();
  553. _st($2)._scope_(_st(_st(anIRInstruction)._scope())._copy());
  554. $3=_st($IRBlockSequence())._new();
  555. _st($3)._add_(_st(_st(self._send())._instructions())._first());
  556. $4=_st($3)._yourself();
  557. _st($2)._add_($4);
  558. $5=_st($2)._yourself();
  559. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anIRInstruction,$5);
  560. return $1;
  561. }, function($ctx1) {$ctx1.fill(self,"ifNil:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  562. messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"]}),
  563. smalltalk.IRSendInliner);
  564. smalltalk.addMethod(
  565. smalltalk.method({
  566. selector: "ifNil:ifNotNil:",
  567. fn: function (anIRInstruction,anotherIRInstruction){
  568. var self=this;
  569. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  570. return smalltalk.withContext(function($ctx1) {
  571. var $1;
  572. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anIRInstruction,anotherIRInstruction);
  573. return $1;
  574. }, function($ctx1) {$ctx1.fill(self,"ifNil:ifNotNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  575. messageSends: ["inlinedSend:with:with:", "new"]}),
  576. smalltalk.IRSendInliner);
  577. smalltalk.addMethod(
  578. smalltalk.method({
  579. selector: "ifNotNil:",
  580. fn: function (anIRInstruction){
  581. var self=this;
  582. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  583. function $IRClosure(){return smalltalk.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
  584. function $IRBlockSequence(){return smalltalk.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
  585. return smalltalk.withContext(function($ctx1) {
  586. var $2,$3,$4,$5,$1;
  587. $2=_st($IRClosure())._new();
  588. _st($2)._scope_(_st(_st(anIRInstruction)._scope())._copy());
  589. $3=_st($IRBlockSequence())._new();
  590. _st($3)._add_(_st(_st(self._send())._instructions())._first());
  591. $4=_st($3)._yourself();
  592. _st($2)._add_($4);
  593. $5=_st($2)._yourself();
  594. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),$5,anIRInstruction);
  595. return $1;
  596. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  597. messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"]}),
  598. smalltalk.IRSendInliner);
  599. smalltalk.addMethod(
  600. smalltalk.method({
  601. selector: "ifNotNil:ifNil:",
  602. fn: function (anIRInstruction,anotherIRInstruction){
  603. var self=this;
  604. function $IRInlinedIfNilIfNotNil(){return smalltalk.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  605. return smalltalk.withContext(function($ctx1) {
  606. var $1;
  607. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anotherIRInstruction,anIRInstruction);
  608. return $1;
  609. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:ifNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  610. messageSends: ["inlinedSend:with:with:", "new"]}),
  611. smalltalk.IRSendInliner);
  612. smalltalk.addMethod(
  613. smalltalk.method({
  614. selector: "ifTrue:",
  615. fn: function (anIRInstruction){
  616. var self=this;
  617. function $IRInlinedIfTrue(){return smalltalk.IRInlinedIfTrue||(typeof IRInlinedIfTrue=="undefined"?nil:IRInlinedIfTrue)}
  618. return smalltalk.withContext(function($ctx1) {
  619. var $1;
  620. $1=self._inlinedSend_with_(_st($IRInlinedIfTrue())._new(),anIRInstruction);
  621. return $1;
  622. }, function($ctx1) {$ctx1.fill(self,"ifTrue:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner)})},
  623. messageSends: ["inlinedSend:with:", "new"]}),
  624. smalltalk.IRSendInliner);
  625. smalltalk.addMethod(
  626. smalltalk.method({
  627. selector: "ifTrue:ifFalse:",
  628. fn: function (anIRInstruction,anotherIRInstruction){
  629. var self=this;
  630. function $IRInlinedIfTrueIfFalse(){return smalltalk.IRInlinedIfTrueIfFalse||(typeof IRInlinedIfTrueIfFalse=="undefined"?nil:IRInlinedIfTrueIfFalse)}
  631. return smalltalk.withContext(function($ctx1) {
  632. var $1;
  633. $1=self._inlinedSend_with_with_(_st($IRInlinedIfTrueIfFalse())._new(),anIRInstruction,anotherIRInstruction);
  634. return $1;
  635. }, function($ctx1) {$ctx1.fill(self,"ifTrue:ifFalse:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},smalltalk.IRSendInliner)})},
  636. messageSends: ["inlinedSend:with:with:", "new"]}),
  637. smalltalk.IRSendInliner);
  638. smalltalk.addMethod(
  639. smalltalk.method({
  640. selector: "inlineClosure:",
  641. fn: function (anIRClosure){
  642. var self=this;
  643. var inlinedClosure,sequence,statements;
  644. function $IRTempDeclaration(){return smalltalk.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
  645. function $AliasVar(){return smalltalk.AliasVar||(typeof AliasVar=="undefined"?nil:AliasVar)}
  646. function $IRVariable(){return smalltalk.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
  647. function $IRAssignment(){return smalltalk.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
  648. return smalltalk.withContext(function($ctx1) {
  649. var $1,$2,$3,$4,$5,$6,$7,$8,$9,$10;
  650. inlinedClosure=self._inlinedClosure();
  651. _st(inlinedClosure)._scope_(_st(anIRClosure)._scope());
  652. _st(_st(anIRClosure)._tempDeclarations())._do_((function(each){
  653. return smalltalk.withContext(function($ctx2) {
  654. return _st(inlinedClosure)._add_(each);
  655. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  656. sequence=self._inlinedSequence();
  657. _st(_st(anIRClosure)._arguments())._do_((function(each){
  658. return smalltalk.withContext(function($ctx2) {
  659. $1=_st($IRTempDeclaration())._new();
  660. _st($1)._name_(each);
  661. $2=_st($1)._yourself();
  662. _st(inlinedClosure)._add_($2);
  663. $3=_st($IRAssignment())._new();
  664. $4=_st($AliasVar())._new();
  665. _st($4)._scope_(_st(inlinedClosure)._scope());
  666. _st($4)._name_(each);
  667. $5=_st($4)._yourself();
  668. _st($3)._add_(_st(_st($IRVariable())._new())._variable_($5));
  669. $6=_st($AliasVar())._new();
  670. _st($6)._scope_(_st(inlinedClosure)._scope());
  671. _st($6)._name_("$receiver");
  672. $7=_st($6)._yourself();
  673. _st($3)._add_(_st(_st($IRVariable())._new())._variable_($7));
  674. $8=_st($3)._yourself();
  675. return _st(sequence)._add_($8);
  676. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  677. _st(inlinedClosure)._add_(sequence);
  678. statements=_st(_st(_st(anIRClosure)._instructions())._last())._instructions();
  679. _st(statements)._ifNotEmpty_((function(){
  680. return smalltalk.withContext(function($ctx2) {
  681. _st(_st(statements)._allButLast())._do_((function(each){
  682. return smalltalk.withContext(function($ctx3) {
  683. return _st(sequence)._add_(each);
  684. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2)})}));
  685. $9=_st(_st(_st(statements)._last())._isReturn())._and_((function(){
  686. return smalltalk.withContext(function($ctx3) {
  687. return _st(_st(statements)._last())._isBlockReturn();
  688. }, function($ctx3) {$ctx3.fillBlock({},$ctx2)})}));
  689. if(smalltalk.assert($9)){
  690. return _st(sequence)._add_(_st(_st(_st(statements)._last())._instructions())._first());
  691. } else {
  692. return _st(sequence)._add_(_st(statements)._last());
  693. };
  694. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  695. $10=inlinedClosure;
  696. return $10;
  697. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,sequence:sequence,statements:statements},smalltalk.IRSendInliner)})},
  698. messageSends: ["inlinedClosure", "scope:", "scope", "do:", "add:", "tempDeclarations", "inlinedSequence", "name:", "new", "yourself", "variable:", "arguments", "instructions", "last", "ifNotEmpty:", "allButLast", "ifTrue:ifFalse:", "first", "and:", "isBlockReturn", "isReturn"]}),
  699. smalltalk.IRSendInliner);
  700. smalltalk.addMethod(
  701. smalltalk.method({
  702. selector: "inlineSend:",
  703. fn: function (anIRSend){
  704. var self=this;
  705. return smalltalk.withContext(function($ctx1) {
  706. var $1;
  707. self._send_(anIRSend);
  708. $1=self._perform_withArguments_(_st(self._send())._selector(),_st(_st(self._send())._instructions())._allButFirst());
  709. return $1;
  710. }, function($ctx1) {$ctx1.fill(self,"inlineSend:",{anIRSend:anIRSend},smalltalk.IRSendInliner)})},
  711. messageSends: ["send:", "perform:withArguments:", "selector", "send", "allButFirst", "instructions"]}),
  712. smalltalk.IRSendInliner);
  713. smalltalk.addMethod(
  714. smalltalk.method({
  715. selector: "inlinedClosure",
  716. fn: function (){
  717. var self=this;
  718. function $IRInlinedClosure(){return smalltalk.IRInlinedClosure||(typeof IRInlinedClosure=="undefined"?nil:IRInlinedClosure)}
  719. return smalltalk.withContext(function($ctx1) {
  720. var $1;
  721. $1=_st($IRInlinedClosure())._new();
  722. return $1;
  723. }, function($ctx1) {$ctx1.fill(self,"inlinedClosure",{},smalltalk.IRSendInliner)})},
  724. messageSends: ["new"]}),
  725. smalltalk.IRSendInliner);
  726. smalltalk.addMethod(
  727. smalltalk.method({
  728. selector: "inlinedSend:with:",
  729. fn: function (inlinedSend,anIRInstruction){
  730. var self=this;
  731. var inlinedClosure;
  732. return smalltalk.withContext(function($ctx1) {
  733. var $1,$2,$3,$4,$5;
  734. $1=_st(anIRInstruction)._isClosure();
  735. if(! smalltalk.assert($1)){
  736. self._inliningError_("Message argument should be a block");
  737. };
  738. $2=_st(_st(_st(anIRInstruction)._arguments())._size()).__eq((0));
  739. if(! smalltalk.assert($2)){
  740. self._inliningError_("Inlined block should have zero argument");
  741. };
  742. inlinedClosure=_st(self._translator())._visit_(self._inlineClosure_(anIRInstruction));
  743. $3=inlinedSend;
  744. _st($3)._add_(_st(_st(self._send())._instructions())._first());
  745. $4=_st($3)._add_(inlinedClosure);
  746. _st(self._send())._replaceWith_(inlinedSend);
  747. $5=inlinedSend;
  748. return $5;
  749. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,inlinedClosure:inlinedClosure},smalltalk.IRSendInliner)})},
  750. messageSends: ["ifFalse:", "inliningError:", "isClosure", "=", "size", "arguments", "visit:", "inlineClosure:", "translator", "add:", "first", "instructions", "send", "replaceWith:"]}),
  751. smalltalk.IRSendInliner);
  752. smalltalk.addMethod(
  753. smalltalk.method({
  754. selector: "inlinedSend:with:with:",
  755. fn: function (inlinedSend,anIRInstruction,anotherIRInstruction){
  756. var self=this;
  757. var inlinedClosure1,inlinedClosure2;
  758. return smalltalk.withContext(function($ctx1) {
  759. var $1,$2,$3,$4,$5;
  760. $1=_st(anIRInstruction)._isClosure();
  761. if(! smalltalk.assert($1)){
  762. self._inliningError_("Message argument should be a block");
  763. };
  764. $2=_st(anotherIRInstruction)._isClosure();
  765. if(! smalltalk.assert($2)){
  766. self._inliningError_("Message argument should be a block");
  767. };
  768. inlinedClosure1=_st(self._translator())._visit_(self._inlineClosure_(anIRInstruction));
  769. inlinedClosure2=_st(self._translator())._visit_(self._inlineClosure_(anotherIRInstruction));
  770. $3=inlinedSend;
  771. _st($3)._add_(_st(_st(self._send())._instructions())._first());
  772. _st($3)._add_(inlinedClosure1);
  773. $4=_st($3)._add_(inlinedClosure2);
  774. _st(self._send())._replaceWith_(inlinedSend);
  775. $5=inlinedSend;
  776. return $5;
  777. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction,inlinedClosure1:inlinedClosure1,inlinedClosure2:inlinedClosure2},smalltalk.IRSendInliner)})},
  778. messageSends: ["ifFalse:", "inliningError:", "isClosure", "visit:", "inlineClosure:", "translator", "add:", "first", "instructions", "send", "replaceWith:"]}),
  779. smalltalk.IRSendInliner);
  780. smalltalk.addMethod(
  781. smalltalk.method({
  782. selector: "inlinedSequence",
  783. fn: function (){
  784. var self=this;
  785. function $IRInlinedSequence(){return smalltalk.IRInlinedSequence||(typeof IRInlinedSequence=="undefined"?nil:IRInlinedSequence)}
  786. return smalltalk.withContext(function($ctx1) {
  787. var $1;
  788. $1=_st($IRInlinedSequence())._new();
  789. return $1;
  790. }, function($ctx1) {$ctx1.fill(self,"inlinedSequence",{},smalltalk.IRSendInliner)})},
  791. messageSends: ["new"]}),
  792. smalltalk.IRSendInliner);
  793. smalltalk.addMethod(
  794. smalltalk.method({
  795. selector: "inliningError:",
  796. fn: function (aString){
  797. var self=this;
  798. function $InliningError(){return smalltalk.InliningError||(typeof InliningError=="undefined"?nil:InliningError)}
  799. return smalltalk.withContext(function($ctx1) {
  800. _st($InliningError())._signal_(aString);
  801. return self}, function($ctx1) {$ctx1.fill(self,"inliningError:",{aString:aString},smalltalk.IRSendInliner)})},
  802. messageSends: ["signal:"]}),
  803. smalltalk.IRSendInliner);
  804. smalltalk.addMethod(
  805. smalltalk.method({
  806. selector: "send",
  807. fn: function (){
  808. var self=this;
  809. return smalltalk.withContext(function($ctx1) {
  810. var $1;
  811. $1=self["@send"];
  812. return $1;
  813. }, function($ctx1) {$ctx1.fill(self,"send",{},smalltalk.IRSendInliner)})},
  814. messageSends: []}),
  815. smalltalk.IRSendInliner);
  816. smalltalk.addMethod(
  817. smalltalk.method({
  818. selector: "send:",
  819. fn: function (anIRSend){
  820. var self=this;
  821. return smalltalk.withContext(function($ctx1) {
  822. self["@send"]=anIRSend;
  823. return self}, function($ctx1) {$ctx1.fill(self,"send:",{anIRSend:anIRSend},smalltalk.IRSendInliner)})},
  824. messageSends: []}),
  825. smalltalk.IRSendInliner);
  826. smalltalk.addMethod(
  827. smalltalk.method({
  828. selector: "translator",
  829. fn: function (){
  830. var self=this;
  831. return smalltalk.withContext(function($ctx1) {
  832. var $1;
  833. $1=self["@translator"];
  834. return $1;
  835. }, function($ctx1) {$ctx1.fill(self,"translator",{},smalltalk.IRSendInliner)})},
  836. messageSends: []}),
  837. smalltalk.IRSendInliner);
  838. smalltalk.addMethod(
  839. smalltalk.method({
  840. selector: "translator:",
  841. fn: function (anASTTranslator){
  842. var self=this;
  843. return smalltalk.withContext(function($ctx1) {
  844. self["@translator"]=anASTTranslator;
  845. return self}, function($ctx1) {$ctx1.fill(self,"translator:",{anASTTranslator:anASTTranslator},smalltalk.IRSendInliner)})},
  846. messageSends: []}),
  847. smalltalk.IRSendInliner);
  848. smalltalk.addMethod(
  849. smalltalk.method({
  850. selector: "inlinedSelectors",
  851. fn: function (){
  852. var self=this;
  853. return smalltalk.withContext(function($ctx1) {
  854. var $1;
  855. $1=["ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:", "ifNil:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"];
  856. return $1;
  857. }, function($ctx1) {$ctx1.fill(self,"inlinedSelectors",{},smalltalk.IRSendInliner.klass)})},
  858. messageSends: []}),
  859. smalltalk.IRSendInliner.klass);
  860. smalltalk.addMethod(
  861. smalltalk.method({
  862. selector: "shouldInline:",
  863. fn: function (anIRInstruction){
  864. var self=this;
  865. return smalltalk.withContext(function($ctx1) {
  866. var $1,$2;
  867. var $early={};
  868. try {
  869. $1=_st(self._inlinedSelectors())._includes_(_st(anIRInstruction)._selector());
  870. if(! smalltalk.assert($1)){
  871. return false;
  872. };
  873. _st(_st(_st(anIRInstruction)._instructions())._allButFirst())._do_((function(each){
  874. return smalltalk.withContext(function($ctx2) {
  875. $2=_st(each)._isClosure();
  876. if(! smalltalk.assert($2)){
  877. throw $early=[false];
  878. };
  879. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  880. return true;
  881. }
  882. catch(e) {if(e===$early)return e[0]; throw e}
  883. }, function($ctx1) {$ctx1.fill(self,"shouldInline:",{anIRInstruction:anIRInstruction},smalltalk.IRSendInliner.klass)})},
  884. messageSends: ["ifFalse:", "includes:", "selector", "inlinedSelectors", "do:", "isClosure", "allButFirst", "instructions"]}),
  885. smalltalk.IRSendInliner.klass);
  886. smalltalk.addClass('IRAssignmentInliner', smalltalk.IRSendInliner, ['assignment'], 'Compiler-Inlining');
  887. smalltalk.addMethod(
  888. smalltalk.method({
  889. selector: "assignment",
  890. fn: function (){
  891. var self=this;
  892. return smalltalk.withContext(function($ctx1) {
  893. var $1;
  894. $1=self["@assignment"];
  895. return $1;
  896. }, function($ctx1) {$ctx1.fill(self,"assignment",{},smalltalk.IRAssignmentInliner)})},
  897. messageSends: []}),
  898. smalltalk.IRAssignmentInliner);
  899. smalltalk.addMethod(
  900. smalltalk.method({
  901. selector: "assignment:",
  902. fn: function (aNode){
  903. var self=this;
  904. return smalltalk.withContext(function($ctx1) {
  905. self["@assignment"]=aNode;
  906. return self}, function($ctx1) {$ctx1.fill(self,"assignment:",{aNode:aNode},smalltalk.IRAssignmentInliner)})},
  907. messageSends: []}),
  908. smalltalk.IRAssignmentInliner);
  909. smalltalk.addMethod(
  910. smalltalk.method({
  911. selector: "inlineAssignment:",
  912. fn: function (anIRAssignment){
  913. var self=this;
  914. var inlinedAssignment;
  915. function $IRInlinedAssignment(){return smalltalk.IRInlinedAssignment||(typeof IRInlinedAssignment=="undefined"?nil:IRInlinedAssignment)}
  916. return smalltalk.withContext(function($ctx1) {
  917. var $1;
  918. self._assignment_(anIRAssignment);
  919. inlinedAssignment=_st($IRInlinedAssignment())._new();
  920. _st(_st(anIRAssignment)._instructions())._do_((function(each){
  921. return smalltalk.withContext(function($ctx2) {
  922. return _st(inlinedAssignment)._add_(each);
  923. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  924. _st(anIRAssignment)._replaceWith_(inlinedAssignment);
  925. self._inlineSend_(_st(_st(inlinedAssignment)._instructions())._last());
  926. $1=inlinedAssignment;
  927. return $1;
  928. }, function($ctx1) {$ctx1.fill(self,"inlineAssignment:",{anIRAssignment:anIRAssignment,inlinedAssignment:inlinedAssignment},smalltalk.IRAssignmentInliner)})},
  929. messageSends: ["assignment:", "new", "do:", "add:", "instructions", "replaceWith:", "inlineSend:", "last"]}),
  930. smalltalk.IRAssignmentInliner);
  931. smalltalk.addMethod(
  932. smalltalk.method({
  933. selector: "inlineClosure:",
  934. fn: function (anIRClosure){
  935. var self=this;
  936. var inlinedClosure,statements;
  937. function $IRAssignment(){return smalltalk.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
  938. return smalltalk.withContext(function($ctx1) {
  939. var $1,$2,$3,$4;
  940. inlinedClosure=smalltalk.IRAssignmentInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]);
  941. statements=_st(_st(_st(inlinedClosure)._instructions())._last())._instructions();
  942. _st(statements)._ifNotEmpty_((function(){
  943. return smalltalk.withContext(function($ctx2) {
  944. $1=_st(_st(statements)._last())._canBeAssigned();
  945. if(smalltalk.assert($1)){
  946. $2=_st($IRAssignment())._new();
  947. _st($2)._add_(_st(_st(self._assignment())._instructions())._first());
  948. _st($2)._add_(_st(_st(statements)._last())._copy());
  949. $3=_st($2)._yourself();
  950. return _st(_st(statements)._last())._replaceWith_($3);
  951. };
  952. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  953. $4=inlinedClosure;
  954. return $4;
  955. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,statements:statements},smalltalk.IRAssignmentInliner)})},
  956. messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifTrue:", "replaceWith:", "add:", "first", "assignment", "new", "copy", "yourself", "canBeAssigned"]}),
  957. smalltalk.IRAssignmentInliner);
  958. smalltalk.addClass('IRReturnInliner', smalltalk.IRSendInliner, [], 'Compiler-Inlining');
  959. smalltalk.addMethod(
  960. smalltalk.method({
  961. selector: "inlineClosure:",
  962. fn: function (anIRClosure){
  963. var self=this;
  964. var closure,statements;
  965. function $IRReturn(){return smalltalk.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
  966. return smalltalk.withContext(function($ctx1) {
  967. var $1,$2,$3,$4;
  968. closure=smalltalk.IRReturnInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]);
  969. statements=_st(_st(_st(closure)._instructions())._last())._instructions();
  970. _st(statements)._ifNotEmpty_((function(){
  971. return smalltalk.withContext(function($ctx2) {
  972. $1=_st(_st(statements)._last())._isReturn();
  973. if(! smalltalk.assert($1)){
  974. $2=_st($IRReturn())._new();
  975. _st($2)._add_(_st(_st(statements)._last())._copy());
  976. $3=_st($2)._yourself();
  977. return _st(_st(statements)._last())._replaceWith_($3);
  978. };
  979. }, function($ctx2) {$ctx2.fillBlock({},$ctx1)})}));
  980. $4=closure;
  981. return $4;
  982. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,closure:closure,statements:statements},smalltalk.IRReturnInliner)})},
  983. messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifFalse:", "replaceWith:", "add:", "copy", "new", "yourself", "isReturn"]}),
  984. smalltalk.IRReturnInliner);
  985. smalltalk.addMethod(
  986. smalltalk.method({
  987. selector: "inlineReturn:",
  988. fn: function (anIRReturn){
  989. var self=this;
  990. var return_;
  991. return smalltalk.withContext(function($ctx1) {
  992. var $1;
  993. return_=self._inlinedReturn();
  994. _st(_st(anIRReturn)._instructions())._do_((function(each){
  995. return smalltalk.withContext(function($ctx2) {
  996. return _st(return_)._add_(each);
  997. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1)})}));
  998. _st(anIRReturn)._replaceWith_(return_);
  999. self._inlineSend_(_st(_st(return_)._instructions())._last());
  1000. $1=return_;
  1001. return $1;
  1002. }, function($ctx1) {$ctx1.fill(self,"inlineReturn:",{anIRReturn:anIRReturn,return_:return_},smalltalk.IRReturnInliner)})},
  1003. messageSends: ["inlinedReturn", "do:", "add:", "instructions", "replaceWith:", "inlineSend:", "last"]}),
  1004. smalltalk.IRReturnInliner);
  1005. smalltalk.addMethod(
  1006. smalltalk.method({
  1007. selector: "inlinedReturn",
  1008. fn: function (){
  1009. var self=this;
  1010. function $IRInlinedReturn(){return smalltalk.IRInlinedReturn||(typeof IRInlinedReturn=="undefined"?nil:IRInlinedReturn)}
  1011. return smalltalk.withContext(function($ctx1) {
  1012. var $1;
  1013. $1=_st($IRInlinedReturn())._new();
  1014. return $1;
  1015. }, function($ctx1) {$ctx1.fill(self,"inlinedReturn",{},smalltalk.IRReturnInliner)})},
  1016. messageSends: ["new"]}),
  1017. smalltalk.IRReturnInliner);
  1018. smalltalk.addClass('InliningCodeGenerator', smalltalk.CodeGenerator, [], 'Compiler-Inlining');
  1019. smalltalk.addMethod(
  1020. smalltalk.method({
  1021. selector: "compileNode:",
  1022. fn: function (aNode){
  1023. var self=this;
  1024. var ir,stream;
  1025. return smalltalk.withContext(function($ctx1) {
  1026. var $2,$3,$1;
  1027. _st(self._semanticAnalyzer())._visit_(aNode);
  1028. ir=_st(self._translator())._visit_(aNode);
  1029. _st(self._inliner())._visit_(ir);
  1030. $2=self._irTranslator();
  1031. _st($2)._currentClass_(self._currentClass());
  1032. _st($2)._visit_(ir);
  1033. $3=_st($2)._contents();
  1034. $1=$3;
  1035. return $1;
  1036. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},smalltalk.InliningCodeGenerator)})},
  1037. messageSends: ["visit:", "semanticAnalyzer", "translator", "inliner", "currentClass:", "currentClass", "irTranslator", "contents"]}),
  1038. smalltalk.InliningCodeGenerator);
  1039. smalltalk.addMethod(
  1040. smalltalk.method({
  1041. selector: "inliner",
  1042. fn: function (){
  1043. var self=this;
  1044. function $IRInliner(){return smalltalk.IRInliner||(typeof IRInliner=="undefined"?nil:IRInliner)}
  1045. return smalltalk.withContext(function($ctx1) {
  1046. var $1;
  1047. $1=_st($IRInliner())._new();
  1048. return $1;
  1049. }, function($ctx1) {$ctx1.fill(self,"inliner",{},smalltalk.InliningCodeGenerator)})},
  1050. messageSends: ["new"]}),
  1051. smalltalk.InliningCodeGenerator);
  1052. smalltalk.addMethod(
  1053. smalltalk.method({
  1054. selector: "irTranslator",
  1055. fn: function (){
  1056. var self=this;
  1057. function $IRInliningJSTranslator(){return smalltalk.IRInliningJSTranslator||(typeof IRInliningJSTranslator=="undefined"?nil:IRInliningJSTranslator)}
  1058. return smalltalk.withContext(function($ctx1) {
  1059. var $1;
  1060. $1=_st($IRInliningJSTranslator())._new();
  1061. return $1;
  1062. }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},smalltalk.InliningCodeGenerator)})},
  1063. messageSends: ["new"]}),
  1064. smalltalk.InliningCodeGenerator);
  1065. })(smalltalk,nil,_st);