Compiler-Inlining.deploy.js 46 KB

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