Compiler-Inlining.deploy.js 49 KB

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