Compiler-Inlining.js 71 KB

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