Compiler-Inlining.js 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624
  1. define("amber_core/Compiler-Inlining", ["amber/boot", "amber_core/Compiler-IR", "amber_core/Kernel-Objects", "amber_core/Compiler-Core"], function($boot){
  2. var smalltalk=$boot.vm,nil=$boot.nil,_st=$boot.asReceiver,globals=$boot.globals;
  3. smalltalk.addPackage('Compiler-Inlining');
  4. smalltalk.packages["Compiler-Inlining"].transport = {"type":"amd","amdNamespace":"amber_core"};
  5. smalltalk.addClass('IRInlinedAssignment', globals.IRAssignment, [], 'Compiler-Inlining');
  6. //>>excludeStart("ide", pragmas.excludeIdeData);
  7. globals.IRInlinedAssignment.comment="I represent an inlined assignment instruction.";
  8. //>>excludeEnd("ide");
  9. smalltalk.addMethod(
  10. smalltalk.method({
  11. selector: "accept:",
  12. protocol: 'visiting',
  13. fn: function (aVisitor){
  14. var self=this;
  15. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  16. return smalltalk.withContext(function($ctx1) {
  17. //>>excludeEnd("ctx");
  18. var $1;
  19. $1=_st(aVisitor)._visitIRInlinedAssignment_(self);
  20. return $1;
  21. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  22. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedAssignment)});
  23. //>>excludeEnd("ctx");
  24. },
  25. //>>excludeStart("ide", pragmas.excludeIdeData);
  26. args: ["aVisitor"],
  27. source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInlinedAssignment: self",
  28. referencedClasses: [],
  29. //>>excludeEnd("ide");
  30. messageSends: ["visitIRInlinedAssignment:"]
  31. }),
  32. globals.IRInlinedAssignment);
  33. smalltalk.addMethod(
  34. smalltalk.method({
  35. selector: "isInlined",
  36. protocol: 'testing',
  37. fn: function (){
  38. var self=this;
  39. return true;
  40. },
  41. //>>excludeStart("ide", pragmas.excludeIdeData);
  42. args: [],
  43. source: "isInlined\x0a\x09^ true",
  44. referencedClasses: [],
  45. //>>excludeEnd("ide");
  46. messageSends: []
  47. }),
  48. globals.IRInlinedAssignment);
  49. smalltalk.addClass('IRInlinedClosure', globals.IRClosure, [], 'Compiler-Inlining');
  50. //>>excludeStart("ide", pragmas.excludeIdeData);
  51. globals.IRInlinedClosure.comment="I represent an inlined closure instruction.";
  52. //>>excludeEnd("ide");
  53. smalltalk.addMethod(
  54. smalltalk.method({
  55. selector: "accept:",
  56. protocol: 'visiting',
  57. fn: function (aVisitor){
  58. var self=this;
  59. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  60. return smalltalk.withContext(function($ctx1) {
  61. //>>excludeEnd("ctx");
  62. _st(aVisitor)._visitIRInlinedClosure_(self);
  63. return self;
  64. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  65. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedClosure)});
  66. //>>excludeEnd("ctx");
  67. },
  68. //>>excludeStart("ide", pragmas.excludeIdeData);
  69. args: ["aVisitor"],
  70. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedClosure: self",
  71. referencedClasses: [],
  72. //>>excludeEnd("ide");
  73. messageSends: ["visitIRInlinedClosure:"]
  74. }),
  75. globals.IRInlinedClosure);
  76. smalltalk.addMethod(
  77. smalltalk.method({
  78. selector: "isInlined",
  79. protocol: 'testing',
  80. fn: function (){
  81. var self=this;
  82. return true;
  83. },
  84. //>>excludeStart("ide", pragmas.excludeIdeData);
  85. args: [],
  86. source: "isInlined\x0a\x09^ true",
  87. referencedClasses: [],
  88. //>>excludeEnd("ide");
  89. messageSends: []
  90. }),
  91. globals.IRInlinedClosure);
  92. smalltalk.addClass('IRInlinedReturn', globals.IRReturn, [], 'Compiler-Inlining');
  93. //>>excludeStart("ide", pragmas.excludeIdeData);
  94. globals.IRInlinedReturn.comment="I represent an inlined local return instruction.";
  95. //>>excludeEnd("ide");
  96. smalltalk.addMethod(
  97. smalltalk.method({
  98. selector: "accept:",
  99. protocol: 'visiting',
  100. fn: function (aVisitor){
  101. var self=this;
  102. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  103. return smalltalk.withContext(function($ctx1) {
  104. //>>excludeEnd("ctx");
  105. var $1;
  106. $1=_st(aVisitor)._visitIRInlinedReturn_(self);
  107. return $1;
  108. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  109. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedReturn)});
  110. //>>excludeEnd("ctx");
  111. },
  112. //>>excludeStart("ide", pragmas.excludeIdeData);
  113. args: ["aVisitor"],
  114. source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInlinedReturn: self",
  115. referencedClasses: [],
  116. //>>excludeEnd("ide");
  117. messageSends: ["visitIRInlinedReturn:"]
  118. }),
  119. globals.IRInlinedReturn);
  120. smalltalk.addMethod(
  121. smalltalk.method({
  122. selector: "isInlined",
  123. protocol: 'testing',
  124. fn: function (){
  125. var self=this;
  126. return true;
  127. },
  128. //>>excludeStart("ide", pragmas.excludeIdeData);
  129. args: [],
  130. source: "isInlined\x0a\x09^ true",
  131. referencedClasses: [],
  132. //>>excludeEnd("ide");
  133. messageSends: []
  134. }),
  135. globals.IRInlinedReturn);
  136. smalltalk.addClass('IRInlinedSend', globals.IRSend, [], 'Compiler-Inlining');
  137. //>>excludeStart("ide", pragmas.excludeIdeData);
  138. globals.IRInlinedSend.comment="I am the abstract super class of inlined message send instructions.";
  139. //>>excludeEnd("ide");
  140. smalltalk.addMethod(
  141. smalltalk.method({
  142. selector: "accept:",
  143. protocol: 'visiting',
  144. fn: function (aVisitor){
  145. var self=this;
  146. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  147. return smalltalk.withContext(function($ctx1) {
  148. //>>excludeEnd("ctx");
  149. _st(aVisitor)._visitInlinedSend_(self);
  150. return self;
  151. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  152. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedSend)});
  153. //>>excludeEnd("ctx");
  154. },
  155. //>>excludeStart("ide", pragmas.excludeIdeData);
  156. args: ["aVisitor"],
  157. source: "accept: aVisitor\x0a\x09aVisitor visitInlinedSend: self",
  158. referencedClasses: [],
  159. //>>excludeEnd("ide");
  160. messageSends: ["visitInlinedSend:"]
  161. }),
  162. globals.IRInlinedSend);
  163. smalltalk.addMethod(
  164. smalltalk.method({
  165. selector: "internalVariables",
  166. protocol: 'accessing',
  167. fn: function (){
  168. var self=this;
  169. var $1;
  170. $1=[];
  171. return $1;
  172. },
  173. //>>excludeStart("ide", pragmas.excludeIdeData);
  174. args: [],
  175. source: "internalVariables\x0a\x09\x22Answer a collection of internal variables required \x0a\x09to perform the inlining\x22\x0a\x09\x0a\x09^ #()",
  176. referencedClasses: [],
  177. //>>excludeEnd("ide");
  178. messageSends: []
  179. }),
  180. globals.IRInlinedSend);
  181. smalltalk.addMethod(
  182. smalltalk.method({
  183. selector: "isInlined",
  184. protocol: 'testing',
  185. fn: function (){
  186. var self=this;
  187. return true;
  188. },
  189. //>>excludeStart("ide", pragmas.excludeIdeData);
  190. args: [],
  191. source: "isInlined\x0a\x09^ true",
  192. referencedClasses: [],
  193. //>>excludeEnd("ide");
  194. messageSends: []
  195. }),
  196. globals.IRInlinedSend);
  197. smalltalk.addClass('IRInlinedIfFalse', globals.IRInlinedSend, [], 'Compiler-Inlining');
  198. //>>excludeStart("ide", pragmas.excludeIdeData);
  199. globals.IRInlinedIfFalse.comment="I represent an inlined `#ifFalse:` message send instruction.";
  200. //>>excludeEnd("ide");
  201. smalltalk.addMethod(
  202. smalltalk.method({
  203. selector: "accept:",
  204. protocol: 'visiting',
  205. fn: function (aVisitor){
  206. var self=this;
  207. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  208. return smalltalk.withContext(function($ctx1) {
  209. //>>excludeEnd("ctx");
  210. _st(aVisitor)._visitIRInlinedIfFalse_(self);
  211. return self;
  212. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  213. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedIfFalse)});
  214. //>>excludeEnd("ctx");
  215. },
  216. //>>excludeStart("ide", pragmas.excludeIdeData);
  217. args: ["aVisitor"],
  218. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfFalse: self",
  219. referencedClasses: [],
  220. //>>excludeEnd("ide");
  221. messageSends: ["visitIRInlinedIfFalse:"]
  222. }),
  223. globals.IRInlinedIfFalse);
  224. smalltalk.addClass('IRInlinedIfNilIfNotNil', globals.IRInlinedSend, [], 'Compiler-Inlining');
  225. //>>excludeStart("ide", pragmas.excludeIdeData);
  226. globals.IRInlinedIfNilIfNotNil.comment="I represent an inlined `#ifNil:ifNotNil:` message send instruction.";
  227. //>>excludeEnd("ide");
  228. smalltalk.addMethod(
  229. smalltalk.method({
  230. selector: "accept:",
  231. protocol: 'visiting',
  232. fn: function (aVisitor){
  233. var self=this;
  234. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  235. return smalltalk.withContext(function($ctx1) {
  236. //>>excludeEnd("ctx");
  237. _st(aVisitor)._visitIRInlinedIfNilIfNotNil_(self);
  238. return self;
  239. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  240. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedIfNilIfNotNil)});
  241. //>>excludeEnd("ctx");
  242. },
  243. //>>excludeStart("ide", pragmas.excludeIdeData);
  244. args: ["aVisitor"],
  245. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfNilIfNotNil: self",
  246. referencedClasses: [],
  247. //>>excludeEnd("ide");
  248. messageSends: ["visitIRInlinedIfNilIfNotNil:"]
  249. }),
  250. globals.IRInlinedIfNilIfNotNil);
  251. smalltalk.addMethod(
  252. smalltalk.method({
  253. selector: "internalVariables",
  254. protocol: 'accessing',
  255. fn: function (){
  256. var self=this;
  257. function $Array(){return globals.Array||(typeof Array=="undefined"?nil:Array)}
  258. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  259. return smalltalk.withContext(function($ctx1) {
  260. //>>excludeEnd("ctx");
  261. var $1;
  262. $1=_st($Array())._with_(self._receiverInternalVariable());
  263. return $1;
  264. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  265. }, function($ctx1) {$ctx1.fill(self,"internalVariables",{},globals.IRInlinedIfNilIfNotNil)});
  266. //>>excludeEnd("ctx");
  267. },
  268. //>>excludeStart("ide", pragmas.excludeIdeData);
  269. args: [],
  270. source: "internalVariables\x0a\x09^ Array with: self receiverInternalVariable",
  271. referencedClasses: ["Array"],
  272. //>>excludeEnd("ide");
  273. messageSends: ["with:", "receiverInternalVariable"]
  274. }),
  275. globals.IRInlinedIfNilIfNotNil);
  276. smalltalk.addMethod(
  277. smalltalk.method({
  278. selector: "receiverInternalVariable",
  279. protocol: 'accessing',
  280. fn: function (){
  281. var self=this;
  282. function $IRVariable(){return globals.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
  283. function $AliasVar(){return globals.AliasVar||(typeof AliasVar=="undefined"?nil:AliasVar)}
  284. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  285. return smalltalk.withContext(function($ctx1) {
  286. //>>excludeEnd("ctx");
  287. var $2,$3,$1;
  288. $2=_st($IRVariable())._new();
  289. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  290. $ctx1.sendIdx["new"]=1;
  291. //>>excludeEnd("ctx");
  292. _st($2)._variable_(_st(_st($AliasVar())._new())._name_(self._receiverInternalVariableName()));
  293. $3=_st($2)._yourself();
  294. $1=$3;
  295. return $1;
  296. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  297. }, function($ctx1) {$ctx1.fill(self,"receiverInternalVariable",{},globals.IRInlinedIfNilIfNotNil)});
  298. //>>excludeEnd("ctx");
  299. },
  300. //>>excludeStart("ide", pragmas.excludeIdeData);
  301. args: [],
  302. source: "receiverInternalVariable\x0a\x09^ IRVariable new\x0a\x09\x09variable: (AliasVar new name: self receiverInternalVariableName);\x0a\x09\x09yourself.",
  303. referencedClasses: ["IRVariable", "AliasVar"],
  304. //>>excludeEnd("ide");
  305. messageSends: ["variable:", "new", "name:", "receiverInternalVariableName", "yourself"]
  306. }),
  307. globals.IRInlinedIfNilIfNotNil);
  308. smalltalk.addMethod(
  309. smalltalk.method({
  310. selector: "receiverInternalVariableName",
  311. protocol: 'accessing',
  312. fn: function (){
  313. var self=this;
  314. return "$receiver";
  315. },
  316. //>>excludeStart("ide", pragmas.excludeIdeData);
  317. args: [],
  318. source: "receiverInternalVariableName\x0a\x09^ '$receiver'",
  319. referencedClasses: [],
  320. //>>excludeEnd("ide");
  321. messageSends: []
  322. }),
  323. globals.IRInlinedIfNilIfNotNil);
  324. smalltalk.addClass('IRInlinedIfTrue', globals.IRInlinedSend, [], 'Compiler-Inlining');
  325. //>>excludeStart("ide", pragmas.excludeIdeData);
  326. globals.IRInlinedIfTrue.comment="I represent an inlined `#ifTrue:` message send instruction.";
  327. //>>excludeEnd("ide");
  328. smalltalk.addMethod(
  329. smalltalk.method({
  330. selector: "accept:",
  331. protocol: 'visiting',
  332. fn: function (aVisitor){
  333. var self=this;
  334. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  335. return smalltalk.withContext(function($ctx1) {
  336. //>>excludeEnd("ctx");
  337. _st(aVisitor)._visitIRInlinedIfTrue_(self);
  338. return self;
  339. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  340. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedIfTrue)});
  341. //>>excludeEnd("ctx");
  342. },
  343. //>>excludeStart("ide", pragmas.excludeIdeData);
  344. args: ["aVisitor"],
  345. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrue: self",
  346. referencedClasses: [],
  347. //>>excludeEnd("ide");
  348. messageSends: ["visitIRInlinedIfTrue:"]
  349. }),
  350. globals.IRInlinedIfTrue);
  351. smalltalk.addClass('IRInlinedIfTrueIfFalse', globals.IRInlinedSend, [], 'Compiler-Inlining');
  352. //>>excludeStart("ide", pragmas.excludeIdeData);
  353. globals.IRInlinedIfTrueIfFalse.comment="I represent an inlined `#ifTrue:ifFalse:` message send instruction.";
  354. //>>excludeEnd("ide");
  355. smalltalk.addMethod(
  356. smalltalk.method({
  357. selector: "accept:",
  358. protocol: 'visiting',
  359. fn: function (aVisitor){
  360. var self=this;
  361. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  362. return smalltalk.withContext(function($ctx1) {
  363. //>>excludeEnd("ctx");
  364. _st(aVisitor)._visitIRInlinedIfTrueIfFalse_(self);
  365. return self;
  366. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  367. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedIfTrueIfFalse)});
  368. //>>excludeEnd("ctx");
  369. },
  370. //>>excludeStart("ide", pragmas.excludeIdeData);
  371. args: ["aVisitor"],
  372. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrueIfFalse: self",
  373. referencedClasses: [],
  374. //>>excludeEnd("ide");
  375. messageSends: ["visitIRInlinedIfTrueIfFalse:"]
  376. }),
  377. globals.IRInlinedIfTrueIfFalse);
  378. smalltalk.addClass('IRInlinedSequence', globals.IRBlockSequence, [], 'Compiler-Inlining');
  379. //>>excludeStart("ide", pragmas.excludeIdeData);
  380. globals.IRInlinedSequence.comment="I represent a (block) sequence inside an inlined closure instruction (instance of `IRInlinedClosure`).";
  381. //>>excludeEnd("ide");
  382. smalltalk.addMethod(
  383. smalltalk.method({
  384. selector: "accept:",
  385. protocol: 'visiting',
  386. fn: function (aVisitor){
  387. var self=this;
  388. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  389. return smalltalk.withContext(function($ctx1) {
  390. //>>excludeEnd("ctx");
  391. _st(aVisitor)._visitIRInlinedSequence_(self);
  392. return self;
  393. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  394. }, function($ctx1) {$ctx1.fill(self,"accept:",{aVisitor:aVisitor},globals.IRInlinedSequence)});
  395. //>>excludeEnd("ctx");
  396. },
  397. //>>excludeStart("ide", pragmas.excludeIdeData);
  398. args: ["aVisitor"],
  399. source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedSequence: self",
  400. referencedClasses: [],
  401. //>>excludeEnd("ide");
  402. messageSends: ["visitIRInlinedSequence:"]
  403. }),
  404. globals.IRInlinedSequence);
  405. smalltalk.addMethod(
  406. smalltalk.method({
  407. selector: "isInlined",
  408. protocol: 'testing',
  409. fn: function (){
  410. var self=this;
  411. return true;
  412. },
  413. //>>excludeStart("ide", pragmas.excludeIdeData);
  414. args: [],
  415. source: "isInlined\x0a\x09^ true",
  416. referencedClasses: [],
  417. //>>excludeEnd("ide");
  418. messageSends: []
  419. }),
  420. globals.IRInlinedSequence);
  421. smalltalk.addClass('IRInliner', globals.IRVisitor, [], 'Compiler-Inlining');
  422. //>>excludeStart("ide", pragmas.excludeIdeData);
  423. globals.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`";
  424. //>>excludeEnd("ide");
  425. smalltalk.addMethod(
  426. smalltalk.method({
  427. selector: "assignmentInliner",
  428. protocol: 'factory',
  429. fn: function (){
  430. var self=this;
  431. function $IRAssignmentInliner(){return globals.IRAssignmentInliner||(typeof IRAssignmentInliner=="undefined"?nil:IRAssignmentInliner)}
  432. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  433. return smalltalk.withContext(function($ctx1) {
  434. //>>excludeEnd("ctx");
  435. var $2,$3,$1;
  436. $2=_st($IRAssignmentInliner())._new();
  437. _st($2)._translator_(self);
  438. $3=_st($2)._yourself();
  439. $1=$3;
  440. return $1;
  441. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  442. }, function($ctx1) {$ctx1.fill(self,"assignmentInliner",{},globals.IRInliner)});
  443. //>>excludeEnd("ctx");
  444. },
  445. //>>excludeStart("ide", pragmas.excludeIdeData);
  446. args: [],
  447. source: "assignmentInliner\x0a\x09^ IRAssignmentInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  448. referencedClasses: ["IRAssignmentInliner"],
  449. //>>excludeEnd("ide");
  450. messageSends: ["translator:", "new", "yourself"]
  451. }),
  452. globals.IRInliner);
  453. smalltalk.addMethod(
  454. smalltalk.method({
  455. selector: "returnInliner",
  456. protocol: 'factory',
  457. fn: function (){
  458. var self=this;
  459. function $IRReturnInliner(){return globals.IRReturnInliner||(typeof IRReturnInliner=="undefined"?nil:IRReturnInliner)}
  460. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  461. return smalltalk.withContext(function($ctx1) {
  462. //>>excludeEnd("ctx");
  463. var $2,$3,$1;
  464. $2=_st($IRReturnInliner())._new();
  465. _st($2)._translator_(self);
  466. $3=_st($2)._yourself();
  467. $1=$3;
  468. return $1;
  469. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  470. }, function($ctx1) {$ctx1.fill(self,"returnInliner",{},globals.IRInliner)});
  471. //>>excludeEnd("ctx");
  472. },
  473. //>>excludeStart("ide", pragmas.excludeIdeData);
  474. args: [],
  475. source: "returnInliner\x0a\x09^ IRReturnInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  476. referencedClasses: ["IRReturnInliner"],
  477. //>>excludeEnd("ide");
  478. messageSends: ["translator:", "new", "yourself"]
  479. }),
  480. globals.IRInliner);
  481. smalltalk.addMethod(
  482. smalltalk.method({
  483. selector: "sendInliner",
  484. protocol: 'factory',
  485. fn: function (){
  486. var self=this;
  487. function $IRSendInliner(){return globals.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
  488. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  489. return smalltalk.withContext(function($ctx1) {
  490. //>>excludeEnd("ctx");
  491. var $2,$3,$1;
  492. $2=_st($IRSendInliner())._new();
  493. _st($2)._translator_(self);
  494. $3=_st($2)._yourself();
  495. $1=$3;
  496. return $1;
  497. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  498. }, function($ctx1) {$ctx1.fill(self,"sendInliner",{},globals.IRInliner)});
  499. //>>excludeEnd("ctx");
  500. },
  501. //>>excludeStart("ide", pragmas.excludeIdeData);
  502. args: [],
  503. source: "sendInliner\x0a\x09^ IRSendInliner new\x0a\x09\x09translator: self;\x0a\x09\x09yourself",
  504. referencedClasses: ["IRSendInliner"],
  505. //>>excludeEnd("ide");
  506. messageSends: ["translator:", "new", "yourself"]
  507. }),
  508. globals.IRInliner);
  509. smalltalk.addMethod(
  510. smalltalk.method({
  511. selector: "shouldInlineAssignment:",
  512. protocol: 'testing',
  513. fn: function (anIRAssignment){
  514. var self=this;
  515. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  516. return smalltalk.withContext(function($ctx1) {
  517. //>>excludeEnd("ctx");
  518. var $4,$3,$2,$1;
  519. $1=_st(_st(_st(anIRAssignment)._isInlined())._not())._and_((function(){
  520. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  521. return smalltalk.withContext(function($ctx2) {
  522. //>>excludeEnd("ctx");
  523. $4=_st(anIRAssignment)._instructions();
  524. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  525. $ctx2.sendIdx["instructions"]=1;
  526. //>>excludeEnd("ctx");
  527. $3=_st($4)._last();
  528. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  529. $ctx2.sendIdx["last"]=1;
  530. //>>excludeEnd("ctx");
  531. $2=_st($3)._isSend();
  532. return _st($2)._and_((function(){
  533. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  534. return smalltalk.withContext(function($ctx3) {
  535. //>>excludeEnd("ctx");
  536. return self._shouldInlineSend_(_st(_st(anIRAssignment)._instructions())._last());
  537. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  538. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  539. //>>excludeEnd("ctx");
  540. }));
  541. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  542. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  543. //>>excludeEnd("ctx");
  544. }));
  545. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  546. $ctx1.sendIdx["and:"]=1;
  547. //>>excludeEnd("ctx");
  548. return $1;
  549. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  550. }, function($ctx1) {$ctx1.fill(self,"shouldInlineAssignment:",{anIRAssignment:anIRAssignment},globals.IRInliner)});
  551. //>>excludeEnd("ctx");
  552. },
  553. //>>excludeStart("ide", pragmas.excludeIdeData);
  554. args: ["anIRAssignment"],
  555. source: "shouldInlineAssignment: anIRAssignment\x0a\x09^ anIRAssignment isInlined not and: [\x0a\x09\x09anIRAssignment instructions last isSend and: [\x0a\x09\x09\x09self shouldInlineSend: (anIRAssignment instructions last) ]]",
  556. referencedClasses: [],
  557. //>>excludeEnd("ide");
  558. messageSends: ["and:", "not", "isInlined", "isSend", "last", "instructions", "shouldInlineSend:"]
  559. }),
  560. globals.IRInliner);
  561. smalltalk.addMethod(
  562. smalltalk.method({
  563. selector: "shouldInlineReturn:",
  564. protocol: 'testing',
  565. fn: function (anIRReturn){
  566. var self=this;
  567. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  568. return smalltalk.withContext(function($ctx1) {
  569. //>>excludeEnd("ctx");
  570. var $4,$3,$2,$1;
  571. $1=_st(_st(_st(anIRReturn)._isInlined())._not())._and_((function(){
  572. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  573. return smalltalk.withContext(function($ctx2) {
  574. //>>excludeEnd("ctx");
  575. $4=_st(anIRReturn)._instructions();
  576. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  577. $ctx2.sendIdx["instructions"]=1;
  578. //>>excludeEnd("ctx");
  579. $3=_st($4)._first();
  580. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  581. $ctx2.sendIdx["first"]=1;
  582. //>>excludeEnd("ctx");
  583. $2=_st($3)._isSend();
  584. return _st($2)._and_((function(){
  585. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  586. return smalltalk.withContext(function($ctx3) {
  587. //>>excludeEnd("ctx");
  588. return self._shouldInlineSend_(_st(_st(anIRReturn)._instructions())._first());
  589. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  590. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  591. //>>excludeEnd("ctx");
  592. }));
  593. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  594. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  595. //>>excludeEnd("ctx");
  596. }));
  597. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  598. $ctx1.sendIdx["and:"]=1;
  599. //>>excludeEnd("ctx");
  600. return $1;
  601. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  602. }, function($ctx1) {$ctx1.fill(self,"shouldInlineReturn:",{anIRReturn:anIRReturn},globals.IRInliner)});
  603. //>>excludeEnd("ctx");
  604. },
  605. //>>excludeStart("ide", pragmas.excludeIdeData);
  606. args: ["anIRReturn"],
  607. source: "shouldInlineReturn: anIRReturn\x0a\x09^ anIRReturn isInlined not and: [\x0a\x09\x09anIRReturn instructions first isSend and: [\x0a\x09\x09\x09self shouldInlineSend: (anIRReturn instructions first) ]]",
  608. referencedClasses: [],
  609. //>>excludeEnd("ide");
  610. messageSends: ["and:", "not", "isInlined", "isSend", "first", "instructions", "shouldInlineSend:"]
  611. }),
  612. globals.IRInliner);
  613. smalltalk.addMethod(
  614. smalltalk.method({
  615. selector: "shouldInlineSend:",
  616. protocol: 'testing',
  617. fn: function (anIRSend){
  618. var self=this;
  619. function $IRSendInliner(){return globals.IRSendInliner||(typeof IRSendInliner=="undefined"?nil:IRSendInliner)}
  620. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  621. return smalltalk.withContext(function($ctx1) {
  622. //>>excludeEnd("ctx");
  623. var $1;
  624. $1=_st(_st(_st(anIRSend)._isInlined())._not())._and_((function(){
  625. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  626. return smalltalk.withContext(function($ctx2) {
  627. //>>excludeEnd("ctx");
  628. return _st($IRSendInliner())._shouldInline_(anIRSend);
  629. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  630. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  631. //>>excludeEnd("ctx");
  632. }));
  633. return $1;
  634. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  635. }, function($ctx1) {$ctx1.fill(self,"shouldInlineSend:",{anIRSend:anIRSend},globals.IRInliner)});
  636. //>>excludeEnd("ctx");
  637. },
  638. //>>excludeStart("ide", pragmas.excludeIdeData);
  639. args: ["anIRSend"],
  640. source: "shouldInlineSend: anIRSend\x0a\x09^ anIRSend isInlined not and: [\x0a\x09\x09IRSendInliner shouldInline: anIRSend ]",
  641. referencedClasses: ["IRSendInliner"],
  642. //>>excludeEnd("ide");
  643. messageSends: ["and:", "not", "isInlined", "shouldInline:"]
  644. }),
  645. globals.IRInliner);
  646. smalltalk.addMethod(
  647. smalltalk.method({
  648. selector: "transformNonLocalReturn:",
  649. protocol: 'visiting',
  650. fn: function (anIRNonLocalReturn){
  651. var self=this;
  652. var localReturn;
  653. function $IRReturn(){return globals.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
  654. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  655. return smalltalk.withContext(function($ctx1) {
  656. //>>excludeEnd("ctx");
  657. var $2,$1,$4,$3,$5,$6,$7,$8,$9;
  658. $2=_st(anIRNonLocalReturn)._scope();
  659. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  660. $ctx1.sendIdx["scope"]=1;
  661. //>>excludeEnd("ctx");
  662. $1=_st($2)._canInlineNonLocalReturns();
  663. if(smalltalk.assert($1)){
  664. $4=_st(anIRNonLocalReturn)._scope();
  665. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  666. $ctx1.sendIdx["scope"]=2;
  667. //>>excludeEnd("ctx");
  668. $3=_st($4)._methodScope();
  669. $5=_st(anIRNonLocalReturn)._scope();
  670. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  671. $ctx1.sendIdx["scope"]=3;
  672. //>>excludeEnd("ctx");
  673. _st($3)._removeNonLocalReturn_($5);
  674. $6=_st($IRReturn())._new();
  675. _st($6)._scope_(_st(anIRNonLocalReturn)._scope());
  676. $7=_st($6)._yourself();
  677. localReturn=$7;
  678. localReturn;
  679. _st(_st(anIRNonLocalReturn)._instructions())._do_((function(each){
  680. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  681. return smalltalk.withContext(function($ctx2) {
  682. //>>excludeEnd("ctx");
  683. return _st(localReturn)._add_(each);
  684. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  685. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  686. //>>excludeEnd("ctx");
  687. }));
  688. _st(anIRNonLocalReturn)._replaceWith_(localReturn);
  689. $8=localReturn;
  690. return $8;
  691. };
  692. $9=(
  693. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  694. $ctx1.supercall = true,
  695. //>>excludeEnd("ctx");
  696. globals.IRInliner.superclass.fn.prototype._visitIRNonLocalReturn_.apply(_st(self), [anIRNonLocalReturn]));
  697. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  698. $ctx1.supercall = false;
  699. //>>excludeEnd("ctx");;
  700. return $9;
  701. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  702. }, function($ctx1) {$ctx1.fill(self,"transformNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn,localReturn:localReturn},globals.IRInliner)});
  703. //>>excludeEnd("ctx");
  704. },
  705. //>>excludeStart("ide", pragmas.excludeIdeData);
  706. args: ["anIRNonLocalReturn"],
  707. 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",
  708. referencedClasses: ["IRReturn"],
  709. //>>excludeEnd("ide");
  710. messageSends: ["ifTrue:", "canInlineNonLocalReturns", "scope", "removeNonLocalReturn:", "methodScope", "scope:", "new", "yourself", "do:", "instructions", "add:", "replaceWith:", "visitIRNonLocalReturn:"]
  711. }),
  712. globals.IRInliner);
  713. smalltalk.addMethod(
  714. smalltalk.method({
  715. selector: "visitIRAssignment:",
  716. protocol: 'visiting',
  717. fn: function (anIRAssignment){
  718. var self=this;
  719. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  720. return smalltalk.withContext(function($ctx1) {
  721. //>>excludeEnd("ctx");
  722. var $2,$1;
  723. $2=self._shouldInlineAssignment_(anIRAssignment);
  724. if(smalltalk.assert($2)){
  725. $1=_st(self._assignmentInliner())._inlineAssignment_(anIRAssignment);
  726. } else {
  727. $1=(
  728. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  729. $ctx1.supercall = true,
  730. //>>excludeEnd("ctx");
  731. globals.IRInliner.superclass.fn.prototype._visitIRAssignment_.apply(_st(self), [anIRAssignment]));
  732. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  733. $ctx1.supercall = false;
  734. //>>excludeEnd("ctx");;
  735. };
  736. return $1;
  737. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  738. }, function($ctx1) {$ctx1.fill(self,"visitIRAssignment:",{anIRAssignment:anIRAssignment},globals.IRInliner)});
  739. //>>excludeEnd("ctx");
  740. },
  741. //>>excludeStart("ide", pragmas.excludeIdeData);
  742. args: ["anIRAssignment"],
  743. source: "visitIRAssignment: anIRAssignment\x0a\x09^ (self shouldInlineAssignment: anIRAssignment)\x0a\x09\x09ifTrue: [ self assignmentInliner inlineAssignment: anIRAssignment ]\x0a\x09\x09ifFalse: [ super visitIRAssignment: anIRAssignment ]",
  744. referencedClasses: [],
  745. //>>excludeEnd("ide");
  746. messageSends: ["ifTrue:ifFalse:", "shouldInlineAssignment:", "inlineAssignment:", "assignmentInliner", "visitIRAssignment:"]
  747. }),
  748. globals.IRInliner);
  749. smalltalk.addMethod(
  750. smalltalk.method({
  751. selector: "visitIRNonLocalReturn:",
  752. protocol: 'visiting',
  753. fn: function (anIRNonLocalReturn){
  754. var self=this;
  755. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  756. return smalltalk.withContext(function($ctx1) {
  757. //>>excludeEnd("ctx");
  758. var $1;
  759. $1=self._transformNonLocalReturn_(anIRNonLocalReturn);
  760. return $1;
  761. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  762. }, function($ctx1) {$ctx1.fill(self,"visitIRNonLocalReturn:",{anIRNonLocalReturn:anIRNonLocalReturn},globals.IRInliner)});
  763. //>>excludeEnd("ctx");
  764. },
  765. //>>excludeStart("ide", pragmas.excludeIdeData);
  766. args: ["anIRNonLocalReturn"],
  767. source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09^ self transformNonLocalReturn: anIRNonLocalReturn",
  768. referencedClasses: [],
  769. //>>excludeEnd("ide");
  770. messageSends: ["transformNonLocalReturn:"]
  771. }),
  772. globals.IRInliner);
  773. smalltalk.addMethod(
  774. smalltalk.method({
  775. selector: "visitIRReturn:",
  776. protocol: 'visiting',
  777. fn: function (anIRReturn){
  778. var self=this;
  779. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  780. return smalltalk.withContext(function($ctx1) {
  781. //>>excludeEnd("ctx");
  782. var $2,$1;
  783. $2=self._shouldInlineReturn_(anIRReturn);
  784. if(smalltalk.assert($2)){
  785. $1=_st(self._returnInliner())._inlineReturn_(anIRReturn);
  786. } else {
  787. $1=(
  788. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  789. $ctx1.supercall = true,
  790. //>>excludeEnd("ctx");
  791. globals.IRInliner.superclass.fn.prototype._visitIRReturn_.apply(_st(self), [anIRReturn]));
  792. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  793. $ctx1.supercall = false;
  794. //>>excludeEnd("ctx");;
  795. };
  796. return $1;
  797. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  798. }, function($ctx1) {$ctx1.fill(self,"visitIRReturn:",{anIRReturn:anIRReturn},globals.IRInliner)});
  799. //>>excludeEnd("ctx");
  800. },
  801. //>>excludeStart("ide", pragmas.excludeIdeData);
  802. args: ["anIRReturn"],
  803. source: "visitIRReturn: anIRReturn\x0a\x09^ (self shouldInlineReturn: anIRReturn)\x0a\x09\x09ifTrue: [ self returnInliner inlineReturn: anIRReturn ]\x0a\x09\x09ifFalse: [ super visitIRReturn: anIRReturn ]",
  804. referencedClasses: [],
  805. //>>excludeEnd("ide");
  806. messageSends: ["ifTrue:ifFalse:", "shouldInlineReturn:", "inlineReturn:", "returnInliner", "visitIRReturn:"]
  807. }),
  808. globals.IRInliner);
  809. smalltalk.addMethod(
  810. smalltalk.method({
  811. selector: "visitIRSend:",
  812. protocol: 'visiting',
  813. fn: function (anIRSend){
  814. var self=this;
  815. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  816. return smalltalk.withContext(function($ctx1) {
  817. //>>excludeEnd("ctx");
  818. var $2,$1;
  819. $2=self._shouldInlineSend_(anIRSend);
  820. if(smalltalk.assert($2)){
  821. $1=_st(self._sendInliner())._inlineSend_(anIRSend);
  822. } else {
  823. $1=(
  824. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  825. $ctx1.supercall = true,
  826. //>>excludeEnd("ctx");
  827. globals.IRInliner.superclass.fn.prototype._visitIRSend_.apply(_st(self), [anIRSend]));
  828. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  829. $ctx1.supercall = false;
  830. //>>excludeEnd("ctx");;
  831. };
  832. return $1;
  833. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  834. }, function($ctx1) {$ctx1.fill(self,"visitIRSend:",{anIRSend:anIRSend},globals.IRInliner)});
  835. //>>excludeEnd("ctx");
  836. },
  837. //>>excludeStart("ide", pragmas.excludeIdeData);
  838. args: ["anIRSend"],
  839. source: "visitIRSend: anIRSend\x0a\x09^ (self shouldInlineSend: anIRSend)\x0a\x09\x09ifTrue: [ self sendInliner inlineSend: anIRSend ]\x0a\x09\x09ifFalse: [ super visitIRSend: anIRSend ]",
  840. referencedClasses: [],
  841. //>>excludeEnd("ide");
  842. messageSends: ["ifTrue:ifFalse:", "shouldInlineSend:", "inlineSend:", "sendInliner", "visitIRSend:"]
  843. }),
  844. globals.IRInliner);
  845. smalltalk.addClass('IRInliningJSTranslator', globals.IRJSTranslator, [], 'Compiler-Inlining');
  846. //>>excludeStart("ide", pragmas.excludeIdeData);
  847. globals.IRInliningJSTranslator.comment="I am a specialized JavaScript translator able to write inlined IR instructions to JavaScript stream (`JSStream` instance).";
  848. //>>excludeEnd("ide");
  849. smalltalk.addMethod(
  850. smalltalk.method({
  851. selector: "visitIRInlinedAssignment:",
  852. protocol: 'visiting',
  853. fn: function (anIRInlinedAssignment){
  854. var self=this;
  855. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  856. return smalltalk.withContext(function($ctx1) {
  857. //>>excludeEnd("ctx");
  858. self._visit_(_st(_st(anIRInlinedAssignment)._instructions())._last());
  859. return self;
  860. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  861. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedAssignment:",{anIRInlinedAssignment:anIRInlinedAssignment},globals.IRInliningJSTranslator)});
  862. //>>excludeEnd("ctx");
  863. },
  864. //>>excludeStart("ide", pragmas.excludeIdeData);
  865. args: ["anIRInlinedAssignment"],
  866. source: "visitIRInlinedAssignment: anIRInlinedAssignment\x0a\x09self visit: anIRInlinedAssignment instructions last",
  867. referencedClasses: [],
  868. //>>excludeEnd("ide");
  869. messageSends: ["visit:", "last", "instructions"]
  870. }),
  871. globals.IRInliningJSTranslator);
  872. smalltalk.addMethod(
  873. smalltalk.method({
  874. selector: "visitIRInlinedClosure:",
  875. protocol: 'visiting',
  876. fn: function (anIRInlinedClosure){
  877. var self=this;
  878. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  879. return smalltalk.withContext(function($ctx1) {
  880. //>>excludeEnd("ctx");
  881. _st(self._stream())._nextPutVars_(_st(_st(anIRInlinedClosure)._tempDeclarations())._collect_((function(each){
  882. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  883. return smalltalk.withContext(function($ctx2) {
  884. //>>excludeEnd("ctx");
  885. return _st(_st(each)._name())._asVariableName();
  886. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  887. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  888. //>>excludeEnd("ctx");
  889. })));
  890. _st(_st(anIRInlinedClosure)._instructions())._do_((function(each){
  891. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  892. return smalltalk.withContext(function($ctx2) {
  893. //>>excludeEnd("ctx");
  894. return self._visit_(each);
  895. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  896. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  897. //>>excludeEnd("ctx");
  898. }));
  899. return self;
  900. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  901. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedClosure:",{anIRInlinedClosure:anIRInlinedClosure},globals.IRInliningJSTranslator)});
  902. //>>excludeEnd("ctx");
  903. },
  904. //>>excludeStart("ide", pragmas.excludeIdeData);
  905. args: ["anIRInlinedClosure"],
  906. 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 ]",
  907. referencedClasses: [],
  908. //>>excludeEnd("ide");
  909. messageSends: ["nextPutVars:", "stream", "collect:", "tempDeclarations", "asVariableName", "name", "do:", "instructions", "visit:"]
  910. }),
  911. globals.IRInliningJSTranslator);
  912. smalltalk.addMethod(
  913. smalltalk.method({
  914. selector: "visitIRInlinedIfFalse:",
  915. protocol: 'visiting',
  916. fn: function (anIRInlinedIfFalse){
  917. var self=this;
  918. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  919. return smalltalk.withContext(function($ctx1) {
  920. //>>excludeEnd("ctx");
  921. var $1,$2,$4,$3;
  922. $1=self._stream();
  923. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  924. $ctx1.sendIdx["stream"]=1;
  925. //>>excludeEnd("ctx");
  926. _st($1)._nextPutIf_with_((function(){
  927. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  928. return smalltalk.withContext(function($ctx2) {
  929. //>>excludeEnd("ctx");
  930. $2=self._stream();
  931. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  932. $ctx2.sendIdx["stream"]=2;
  933. //>>excludeEnd("ctx");
  934. _st($2)._nextPutAll_("! smalltalk.assert(");
  935. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  936. $ctx2.sendIdx["nextPutAll:"]=1;
  937. //>>excludeEnd("ctx");
  938. $4=_st(anIRInlinedIfFalse)._instructions();
  939. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  940. $ctx2.sendIdx["instructions"]=1;
  941. //>>excludeEnd("ctx");
  942. $3=_st($4)._first();
  943. self._visit_($3);
  944. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  945. $ctx2.sendIdx["visit:"]=1;
  946. //>>excludeEnd("ctx");
  947. return _st(self._stream())._nextPutAll_(")");
  948. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  949. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  950. //>>excludeEnd("ctx");
  951. }),(function(){
  952. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  953. return smalltalk.withContext(function($ctx2) {
  954. //>>excludeEnd("ctx");
  955. return self._visit_(_st(_st(anIRInlinedIfFalse)._instructions())._last());
  956. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  957. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  958. //>>excludeEnd("ctx");
  959. }));
  960. return self;
  961. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  962. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfFalse:",{anIRInlinedIfFalse:anIRInlinedIfFalse},globals.IRInliningJSTranslator)});
  963. //>>excludeEnd("ctx");
  964. },
  965. //>>excludeStart("ide", pragmas.excludeIdeData);
  966. args: ["anIRInlinedIfFalse"],
  967. 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 ]",
  968. referencedClasses: [],
  969. //>>excludeEnd("ide");
  970. messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"]
  971. }),
  972. globals.IRInliningJSTranslator);
  973. smalltalk.addMethod(
  974. smalltalk.method({
  975. selector: "visitIRInlinedIfNilIfNotNil:",
  976. protocol: 'visiting',
  977. fn: function (anIRInlinedIfNilIfNotNil){
  978. var self=this;
  979. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  980. return smalltalk.withContext(function($ctx1) {
  981. //>>excludeEnd("ctx");
  982. var $1,$2,$3,$5,$4,$7,$6;
  983. $1=self._stream();
  984. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  985. $ctx1.sendIdx["stream"]=1;
  986. //>>excludeEnd("ctx");
  987. _st($1)._nextPutIfElse_with_with_((function(){
  988. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  989. return smalltalk.withContext(function($ctx2) {
  990. //>>excludeEnd("ctx");
  991. $2=self._stream();
  992. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  993. $ctx2.sendIdx["stream"]=2;
  994. //>>excludeEnd("ctx");
  995. $3=_st("(".__comma(_st(anIRInlinedIfNilIfNotNil)._receiverInternalVariableName())).__comma(" = ");
  996. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  997. $ctx2.sendIdx[","]=1;
  998. //>>excludeEnd("ctx");
  999. _st($2)._nextPutAll_($3);
  1000. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1001. $ctx2.sendIdx["nextPutAll:"]=1;
  1002. //>>excludeEnd("ctx");
  1003. $5=_st(anIRInlinedIfNilIfNotNil)._instructions();
  1004. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1005. $ctx2.sendIdx["instructions"]=1;
  1006. //>>excludeEnd("ctx");
  1007. $4=_st($5)._first();
  1008. self._visit_($4);
  1009. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1010. $ctx2.sendIdx["visit:"]=1;
  1011. //>>excludeEnd("ctx");
  1012. return _st(self._stream())._nextPutAll_(") == null || $receiver.isNil");
  1013. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1014. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1015. //>>excludeEnd("ctx");
  1016. }),(function(){
  1017. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1018. return smalltalk.withContext(function($ctx2) {
  1019. //>>excludeEnd("ctx");
  1020. $7=_st(anIRInlinedIfNilIfNotNil)._instructions();
  1021. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1022. $ctx2.sendIdx["instructions"]=2;
  1023. //>>excludeEnd("ctx");
  1024. $6=_st($7)._second();
  1025. return self._visit_($6);
  1026. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1027. $ctx2.sendIdx["visit:"]=2;
  1028. //>>excludeEnd("ctx");
  1029. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1030. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1031. //>>excludeEnd("ctx");
  1032. }),(function(){
  1033. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1034. return smalltalk.withContext(function($ctx2) {
  1035. //>>excludeEnd("ctx");
  1036. return self._visit_(_st(_st(anIRInlinedIfNilIfNotNil)._instructions())._third());
  1037. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1038. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1039. //>>excludeEnd("ctx");
  1040. }));
  1041. return self;
  1042. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1043. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfNilIfNotNil:",{anIRInlinedIfNilIfNotNil:anIRInlinedIfNilIfNotNil},globals.IRInliningJSTranslator)});
  1044. //>>excludeEnd("ctx");
  1045. },
  1046. //>>excludeStart("ide", pragmas.excludeIdeData);
  1047. args: ["anIRInlinedIfNilIfNotNil"],
  1048. source: "visitIRInlinedIfNilIfNotNil: anIRInlinedIfNilIfNotNil\x0a\x09self stream\x0a\x09\x09nextPutIfElse: [\x0a\x09\x09\x09self stream nextPutAll: '(', anIRInlinedIfNilIfNotNil receiverInternalVariableName, ' = '.\x0a\x09\x09\x09self visit: anIRInlinedIfNilIfNotNil instructions first.\x0a\x09\x09\x09self stream nextPutAll: ') == null || $receiver.isNil' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfNilIfNotNil instructions second ]\x0a\x09\x09with: [ self visit: anIRInlinedIfNilIfNotNil instructions third ]",
  1049. referencedClasses: [],
  1050. //>>excludeEnd("ide");
  1051. messageSends: ["nextPutIfElse:with:with:", "stream", "nextPutAll:", ",", "receiverInternalVariableName", "visit:", "first", "instructions", "second", "third"]
  1052. }),
  1053. globals.IRInliningJSTranslator);
  1054. smalltalk.addMethod(
  1055. smalltalk.method({
  1056. selector: "visitIRInlinedIfTrue:",
  1057. protocol: 'visiting',
  1058. fn: function (anIRInlinedIfTrue){
  1059. var self=this;
  1060. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1061. return smalltalk.withContext(function($ctx1) {
  1062. //>>excludeEnd("ctx");
  1063. var $1,$2,$4,$3;
  1064. $1=self._stream();
  1065. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1066. $ctx1.sendIdx["stream"]=1;
  1067. //>>excludeEnd("ctx");
  1068. _st($1)._nextPutIf_with_((function(){
  1069. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1070. return smalltalk.withContext(function($ctx2) {
  1071. //>>excludeEnd("ctx");
  1072. $2=self._stream();
  1073. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1074. $ctx2.sendIdx["stream"]=2;
  1075. //>>excludeEnd("ctx");
  1076. _st($2)._nextPutAll_("smalltalk.assert(");
  1077. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1078. $ctx2.sendIdx["nextPutAll:"]=1;
  1079. //>>excludeEnd("ctx");
  1080. $4=_st(anIRInlinedIfTrue)._instructions();
  1081. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1082. $ctx2.sendIdx["instructions"]=1;
  1083. //>>excludeEnd("ctx");
  1084. $3=_st($4)._first();
  1085. self._visit_($3);
  1086. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1087. $ctx2.sendIdx["visit:"]=1;
  1088. //>>excludeEnd("ctx");
  1089. return _st(self._stream())._nextPutAll_(")");
  1090. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1091. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1092. //>>excludeEnd("ctx");
  1093. }),(function(){
  1094. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1095. return smalltalk.withContext(function($ctx2) {
  1096. //>>excludeEnd("ctx");
  1097. return self._visit_(_st(_st(anIRInlinedIfTrue)._instructions())._last());
  1098. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1099. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1100. //>>excludeEnd("ctx");
  1101. }));
  1102. return self;
  1103. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1104. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrue:",{anIRInlinedIfTrue:anIRInlinedIfTrue},globals.IRInliningJSTranslator)});
  1105. //>>excludeEnd("ctx");
  1106. },
  1107. //>>excludeStart("ide", pragmas.excludeIdeData);
  1108. args: ["anIRInlinedIfTrue"],
  1109. 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 ]",
  1110. referencedClasses: [],
  1111. //>>excludeEnd("ide");
  1112. messageSends: ["nextPutIf:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "last"]
  1113. }),
  1114. globals.IRInliningJSTranslator);
  1115. smalltalk.addMethod(
  1116. smalltalk.method({
  1117. selector: "visitIRInlinedIfTrueIfFalse:",
  1118. protocol: 'visiting',
  1119. fn: function (anIRInlinedIfTrueIfFalse){
  1120. var self=this;
  1121. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1122. return smalltalk.withContext(function($ctx1) {
  1123. //>>excludeEnd("ctx");
  1124. var $1,$2,$4,$3,$6,$5;
  1125. $1=self._stream();
  1126. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1127. $ctx1.sendIdx["stream"]=1;
  1128. //>>excludeEnd("ctx");
  1129. _st($1)._nextPutIfElse_with_with_((function(){
  1130. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1131. return smalltalk.withContext(function($ctx2) {
  1132. //>>excludeEnd("ctx");
  1133. $2=self._stream();
  1134. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1135. $ctx2.sendIdx["stream"]=2;
  1136. //>>excludeEnd("ctx");
  1137. _st($2)._nextPutAll_("smalltalk.assert(");
  1138. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1139. $ctx2.sendIdx["nextPutAll:"]=1;
  1140. //>>excludeEnd("ctx");
  1141. $4=_st(anIRInlinedIfTrueIfFalse)._instructions();
  1142. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1143. $ctx2.sendIdx["instructions"]=1;
  1144. //>>excludeEnd("ctx");
  1145. $3=_st($4)._first();
  1146. self._visit_($3);
  1147. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1148. $ctx2.sendIdx["visit:"]=1;
  1149. //>>excludeEnd("ctx");
  1150. return _st(self._stream())._nextPutAll_(")");
  1151. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1152. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1153. //>>excludeEnd("ctx");
  1154. }),(function(){
  1155. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1156. return smalltalk.withContext(function($ctx2) {
  1157. //>>excludeEnd("ctx");
  1158. $6=_st(anIRInlinedIfTrueIfFalse)._instructions();
  1159. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1160. $ctx2.sendIdx["instructions"]=2;
  1161. //>>excludeEnd("ctx");
  1162. $5=_st($6)._second();
  1163. return self._visit_($5);
  1164. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1165. $ctx2.sendIdx["visit:"]=2;
  1166. //>>excludeEnd("ctx");
  1167. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1168. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,2)});
  1169. //>>excludeEnd("ctx");
  1170. }),(function(){
  1171. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1172. return smalltalk.withContext(function($ctx2) {
  1173. //>>excludeEnd("ctx");
  1174. return self._visit_(_st(_st(anIRInlinedIfTrueIfFalse)._instructions())._third());
  1175. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1176. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1177. //>>excludeEnd("ctx");
  1178. }));
  1179. return self;
  1180. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1181. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedIfTrueIfFalse:",{anIRInlinedIfTrueIfFalse:anIRInlinedIfTrueIfFalse},globals.IRInliningJSTranslator)});
  1182. //>>excludeEnd("ctx");
  1183. },
  1184. //>>excludeStart("ide", pragmas.excludeIdeData);
  1185. args: ["anIRInlinedIfTrueIfFalse"],
  1186. 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 ]",
  1187. referencedClasses: [],
  1188. //>>excludeEnd("ide");
  1189. messageSends: ["nextPutIfElse:with:with:", "stream", "nextPutAll:", "visit:", "first", "instructions", "second", "third"]
  1190. }),
  1191. globals.IRInliningJSTranslator);
  1192. smalltalk.addMethod(
  1193. smalltalk.method({
  1194. selector: "visitIRInlinedNonLocalReturn:",
  1195. protocol: 'visiting',
  1196. fn: function (anIRInlinedReturn){
  1197. var self=this;
  1198. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1199. return smalltalk.withContext(function($ctx1) {
  1200. //>>excludeEnd("ctx");
  1201. var $1;
  1202. $1=self._stream();
  1203. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1204. $ctx1.sendIdx["stream"]=1;
  1205. //>>excludeEnd("ctx");
  1206. _st($1)._nextPutStatementWith_((function(){
  1207. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1208. return smalltalk.withContext(function($ctx2) {
  1209. //>>excludeEnd("ctx");
  1210. return self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
  1211. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1212. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  1213. //>>excludeEnd("ctx");
  1214. }));
  1215. _st(self._stream())._nextPutNonLocalReturnWith_((function(){
  1216. }));
  1217. return self;
  1218. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1219. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedNonLocalReturn:",{anIRInlinedReturn:anIRInlinedReturn},globals.IRInliningJSTranslator)});
  1220. //>>excludeEnd("ctx");
  1221. },
  1222. //>>excludeStart("ide", pragmas.excludeIdeData);
  1223. args: ["anIRInlinedReturn"],
  1224. source: "visitIRInlinedNonLocalReturn: anIRInlinedReturn\x0a\x09self stream nextPutStatementWith: [\x0a\x09\x09self visit: anIRInlinedReturn instructions last ].\x0a\x09self stream nextPutNonLocalReturnWith: [ ]",
  1225. referencedClasses: [],
  1226. //>>excludeEnd("ide");
  1227. messageSends: ["nextPutStatementWith:", "stream", "visit:", "last", "instructions", "nextPutNonLocalReturnWith:"]
  1228. }),
  1229. globals.IRInliningJSTranslator);
  1230. smalltalk.addMethod(
  1231. smalltalk.method({
  1232. selector: "visitIRInlinedReturn:",
  1233. protocol: 'visiting',
  1234. fn: function (anIRInlinedReturn){
  1235. var self=this;
  1236. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1237. return smalltalk.withContext(function($ctx1) {
  1238. //>>excludeEnd("ctx");
  1239. self._visit_(_st(_st(anIRInlinedReturn)._instructions())._last());
  1240. return self;
  1241. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1242. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedReturn:",{anIRInlinedReturn:anIRInlinedReturn},globals.IRInliningJSTranslator)});
  1243. //>>excludeEnd("ctx");
  1244. },
  1245. //>>excludeStart("ide", pragmas.excludeIdeData);
  1246. args: ["anIRInlinedReturn"],
  1247. source: "visitIRInlinedReturn: anIRInlinedReturn\x0a\x09self visit: anIRInlinedReturn instructions last",
  1248. referencedClasses: [],
  1249. //>>excludeEnd("ide");
  1250. messageSends: ["visit:", "last", "instructions"]
  1251. }),
  1252. globals.IRInliningJSTranslator);
  1253. smalltalk.addMethod(
  1254. smalltalk.method({
  1255. selector: "visitIRInlinedSequence:",
  1256. protocol: 'visiting',
  1257. fn: function (anIRInlinedSequence){
  1258. var self=this;
  1259. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1260. return smalltalk.withContext(function($ctx1) {
  1261. //>>excludeEnd("ctx");
  1262. _st(_st(anIRInlinedSequence)._instructions())._do_((function(each){
  1263. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1264. return smalltalk.withContext(function($ctx2) {
  1265. //>>excludeEnd("ctx");
  1266. return _st(self._stream())._nextPutStatementWith_((function(){
  1267. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1268. return smalltalk.withContext(function($ctx3) {
  1269. //>>excludeEnd("ctx");
  1270. return self._visit_(each);
  1271. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1272. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
  1273. //>>excludeEnd("ctx");
  1274. }));
  1275. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1276. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1277. //>>excludeEnd("ctx");
  1278. }));
  1279. return self;
  1280. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1281. }, function($ctx1) {$ctx1.fill(self,"visitIRInlinedSequence:",{anIRInlinedSequence:anIRInlinedSequence},globals.IRInliningJSTranslator)});
  1282. //>>excludeEnd("ctx");
  1283. },
  1284. //>>excludeStart("ide", pragmas.excludeIdeData);
  1285. args: ["anIRInlinedSequence"],
  1286. source: "visitIRInlinedSequence: anIRInlinedSequence\x0a\x09anIRInlinedSequence instructions do: [ :each |\x0a\x09\x09self stream nextPutStatementWith: [ self visit: each ]]",
  1287. referencedClasses: [],
  1288. //>>excludeEnd("ide");
  1289. messageSends: ["do:", "instructions", "nextPutStatementWith:", "stream", "visit:"]
  1290. }),
  1291. globals.IRInliningJSTranslator);
  1292. smalltalk.addClass('IRSendInliner', globals.Object, ['send', 'translator'], 'Compiler-Inlining');
  1293. //>>excludeStart("ide", pragmas.excludeIdeData);
  1294. globals.IRSendInliner.comment="I inline some message sends and block closure arguments. I heavily rely on #perform: to dispatch inlining methods.";
  1295. //>>excludeEnd("ide");
  1296. smalltalk.addMethod(
  1297. smalltalk.method({
  1298. selector: "ifFalse:",
  1299. protocol: 'inlining',
  1300. fn: function (anIRInstruction){
  1301. var self=this;
  1302. function $IRInlinedIfFalse(){return globals.IRInlinedIfFalse||(typeof IRInlinedIfFalse=="undefined"?nil:IRInlinedIfFalse)}
  1303. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1304. return smalltalk.withContext(function($ctx1) {
  1305. //>>excludeEnd("ctx");
  1306. var $1;
  1307. $1=self._inlinedSend_with_(_st($IRInlinedIfFalse())._new(),anIRInstruction);
  1308. return $1;
  1309. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1310. }, function($ctx1) {$ctx1.fill(self,"ifFalse:",{anIRInstruction:anIRInstruction},globals.IRSendInliner)});
  1311. //>>excludeEnd("ctx");
  1312. },
  1313. //>>excludeStart("ide", pragmas.excludeIdeData);
  1314. args: ["anIRInstruction"],
  1315. source: "ifFalse: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfFalse new with: anIRInstruction",
  1316. referencedClasses: ["IRInlinedIfFalse"],
  1317. //>>excludeEnd("ide");
  1318. messageSends: ["inlinedSend:with:", "new"]
  1319. }),
  1320. globals.IRSendInliner);
  1321. smalltalk.addMethod(
  1322. smalltalk.method({
  1323. selector: "ifFalse:ifTrue:",
  1324. protocol: 'inlining',
  1325. fn: function (anIRInstruction,anotherIRInstruction){
  1326. var self=this;
  1327. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1328. return smalltalk.withContext(function($ctx1) {
  1329. //>>excludeEnd("ctx");
  1330. var $1;
  1331. $1=self._perform_withArguments_("ifTrue:ifFalse:",[anotherIRInstruction,anIRInstruction]);
  1332. return $1;
  1333. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1334. }, function($ctx1) {$ctx1.fill(self,"ifFalse:ifTrue:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},globals.IRSendInliner)});
  1335. //>>excludeEnd("ctx");
  1336. },
  1337. //>>excludeStart("ide", pragmas.excludeIdeData);
  1338. args: ["anIRInstruction", "anotherIRInstruction"],
  1339. source: "ifFalse: anIRInstruction ifTrue: anotherIRInstruction\x0a\x09^ self perform: #ifTrue:ifFalse: withArguments: { anotherIRInstruction. anIRInstruction }",
  1340. referencedClasses: [],
  1341. //>>excludeEnd("ide");
  1342. messageSends: ["perform:withArguments:"]
  1343. }),
  1344. globals.IRSendInliner);
  1345. smalltalk.addMethod(
  1346. smalltalk.method({
  1347. selector: "ifNil:",
  1348. protocol: 'inlining',
  1349. fn: function (anIRInstruction){
  1350. var self=this;
  1351. function $IRInlinedIfNilIfNotNil(){return globals.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  1352. function $IRClosure(){return globals.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
  1353. function $IRBlockSequence(){return globals.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
  1354. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1355. return smalltalk.withContext(function($ctx1) {
  1356. //>>excludeEnd("ctx");
  1357. var $2,$4,$5,$7,$8,$6,$9,$3,$1;
  1358. $2=_st($IRInlinedIfNilIfNotNil())._new();
  1359. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1360. $ctx1.sendIdx["new"]=1;
  1361. //>>excludeEnd("ctx");
  1362. $4=_st($IRClosure())._new();
  1363. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1364. $ctx1.sendIdx["new"]=2;
  1365. //>>excludeEnd("ctx");
  1366. _st($4)._scope_(_st(_st(anIRInstruction)._scope())._copy());
  1367. $5=$4;
  1368. $7=_st($IRBlockSequence())._new();
  1369. _st($7)._add_(_st(_st(self._send())._instructions())._first());
  1370. $8=_st($7)._yourself();
  1371. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1372. $ctx1.sendIdx["yourself"]=1;
  1373. //>>excludeEnd("ctx");
  1374. $6=$8;
  1375. _st($5)._add_($6);
  1376. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1377. $ctx1.sendIdx["add:"]=1;
  1378. //>>excludeEnd("ctx");
  1379. $9=_st($4)._yourself();
  1380. $3=$9;
  1381. $1=self._inlinedSend_with_with_($2,anIRInstruction,$3);
  1382. return $1;
  1383. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1384. }, function($ctx1) {$ctx1.fill(self,"ifNil:",{anIRInstruction:anIRInstruction},globals.IRSendInliner)});
  1385. //>>excludeEnd("ctx");
  1386. },
  1387. //>>excludeStart("ide", pragmas.excludeIdeData);
  1388. args: ["anIRInstruction"],
  1389. 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)",
  1390. referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"],
  1391. //>>excludeEnd("ide");
  1392. messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"]
  1393. }),
  1394. globals.IRSendInliner);
  1395. smalltalk.addMethod(
  1396. smalltalk.method({
  1397. selector: "ifNil:ifNotNil:",
  1398. protocol: 'inlining',
  1399. fn: function (anIRInstruction,anotherIRInstruction){
  1400. var self=this;
  1401. function $IRInlinedIfNilIfNotNil(){return globals.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  1402. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1403. return smalltalk.withContext(function($ctx1) {
  1404. //>>excludeEnd("ctx");
  1405. var $1;
  1406. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anIRInstruction,anotherIRInstruction);
  1407. return $1;
  1408. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1409. }, function($ctx1) {$ctx1.fill(self,"ifNil:ifNotNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},globals.IRSendInliner)});
  1410. //>>excludeEnd("ctx");
  1411. },
  1412. //>>excludeStart("ide", pragmas.excludeIdeData);
  1413. args: ["anIRInstruction", "anotherIRInstruction"],
  1414. source: "ifNil: anIRInstruction ifNotNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new with: anIRInstruction with: anotherIRInstruction",
  1415. referencedClasses: ["IRInlinedIfNilIfNotNil"],
  1416. //>>excludeEnd("ide");
  1417. messageSends: ["inlinedSend:with:with:", "new"]
  1418. }),
  1419. globals.IRSendInliner);
  1420. smalltalk.addMethod(
  1421. smalltalk.method({
  1422. selector: "ifNotNil:",
  1423. protocol: 'inlining',
  1424. fn: function (anIRInstruction){
  1425. var self=this;
  1426. function $IRInlinedIfNilIfNotNil(){return globals.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  1427. function $IRClosure(){return globals.IRClosure||(typeof IRClosure=="undefined"?nil:IRClosure)}
  1428. function $IRBlockSequence(){return globals.IRBlockSequence||(typeof IRBlockSequence=="undefined"?nil:IRBlockSequence)}
  1429. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1430. return smalltalk.withContext(function($ctx1) {
  1431. //>>excludeEnd("ctx");
  1432. var $2,$4,$5,$7,$8,$6,$9,$3,$1;
  1433. $2=_st($IRInlinedIfNilIfNotNil())._new();
  1434. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1435. $ctx1.sendIdx["new"]=1;
  1436. //>>excludeEnd("ctx");
  1437. $4=_st($IRClosure())._new();
  1438. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1439. $ctx1.sendIdx["new"]=2;
  1440. //>>excludeEnd("ctx");
  1441. _st($4)._scope_(_st(_st(anIRInstruction)._scope())._copy());
  1442. $5=$4;
  1443. $7=_st($IRBlockSequence())._new();
  1444. _st($7)._add_(_st(_st(self._send())._instructions())._first());
  1445. $8=_st($7)._yourself();
  1446. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1447. $ctx1.sendIdx["yourself"]=1;
  1448. //>>excludeEnd("ctx");
  1449. $6=$8;
  1450. _st($5)._add_($6);
  1451. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1452. $ctx1.sendIdx["add:"]=1;
  1453. //>>excludeEnd("ctx");
  1454. $9=_st($4)._yourself();
  1455. $3=$9;
  1456. $1=self._inlinedSend_with_with_($2,$3,anIRInstruction);
  1457. return $1;
  1458. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1459. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:",{anIRInstruction:anIRInstruction},globals.IRSendInliner)});
  1460. //>>excludeEnd("ctx");
  1461. },
  1462. //>>excludeStart("ide", pragmas.excludeIdeData);
  1463. args: ["anIRInstruction"],
  1464. 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",
  1465. referencedClasses: ["IRInlinedIfNilIfNotNil", "IRClosure", "IRBlockSequence"],
  1466. //>>excludeEnd("ide");
  1467. messageSends: ["inlinedSend:with:with:", "new", "scope:", "copy", "scope", "add:", "first", "instructions", "send", "yourself"]
  1468. }),
  1469. globals.IRSendInliner);
  1470. smalltalk.addMethod(
  1471. smalltalk.method({
  1472. selector: "ifNotNil:ifNil:",
  1473. protocol: 'inlining',
  1474. fn: function (anIRInstruction,anotherIRInstruction){
  1475. var self=this;
  1476. function $IRInlinedIfNilIfNotNil(){return globals.IRInlinedIfNilIfNotNil||(typeof IRInlinedIfNilIfNotNil=="undefined"?nil:IRInlinedIfNilIfNotNil)}
  1477. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1478. return smalltalk.withContext(function($ctx1) {
  1479. //>>excludeEnd("ctx");
  1480. var $1;
  1481. $1=self._inlinedSend_with_with_(_st($IRInlinedIfNilIfNotNil())._new(),anotherIRInstruction,anIRInstruction);
  1482. return $1;
  1483. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1484. }, function($ctx1) {$ctx1.fill(self,"ifNotNil:ifNil:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},globals.IRSendInliner)});
  1485. //>>excludeEnd("ctx");
  1486. },
  1487. //>>excludeStart("ide", pragmas.excludeIdeData);
  1488. args: ["anIRInstruction", "anotherIRInstruction"],
  1489. source: "ifNotNil: anIRInstruction ifNil: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNilIfNotNil new with: anotherIRInstruction with: anIRInstruction",
  1490. referencedClasses: ["IRInlinedIfNilIfNotNil"],
  1491. //>>excludeEnd("ide");
  1492. messageSends: ["inlinedSend:with:with:", "new"]
  1493. }),
  1494. globals.IRSendInliner);
  1495. smalltalk.addMethod(
  1496. smalltalk.method({
  1497. selector: "ifTrue:",
  1498. protocol: 'inlining',
  1499. fn: function (anIRInstruction){
  1500. var self=this;
  1501. function $IRInlinedIfTrue(){return globals.IRInlinedIfTrue||(typeof IRInlinedIfTrue=="undefined"?nil:IRInlinedIfTrue)}
  1502. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1503. return smalltalk.withContext(function($ctx1) {
  1504. //>>excludeEnd("ctx");
  1505. var $1;
  1506. $1=self._inlinedSend_with_(_st($IRInlinedIfTrue())._new(),anIRInstruction);
  1507. return $1;
  1508. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1509. }, function($ctx1) {$ctx1.fill(self,"ifTrue:",{anIRInstruction:anIRInstruction},globals.IRSendInliner)});
  1510. //>>excludeEnd("ctx");
  1511. },
  1512. //>>excludeStart("ide", pragmas.excludeIdeData);
  1513. args: ["anIRInstruction"],
  1514. source: "ifTrue: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrue new with: anIRInstruction",
  1515. referencedClasses: ["IRInlinedIfTrue"],
  1516. //>>excludeEnd("ide");
  1517. messageSends: ["inlinedSend:with:", "new"]
  1518. }),
  1519. globals.IRSendInliner);
  1520. smalltalk.addMethod(
  1521. smalltalk.method({
  1522. selector: "ifTrue:ifFalse:",
  1523. protocol: 'inlining',
  1524. fn: function (anIRInstruction,anotherIRInstruction){
  1525. var self=this;
  1526. function $IRInlinedIfTrueIfFalse(){return globals.IRInlinedIfTrueIfFalse||(typeof IRInlinedIfTrueIfFalse=="undefined"?nil:IRInlinedIfTrueIfFalse)}
  1527. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1528. return smalltalk.withContext(function($ctx1) {
  1529. //>>excludeEnd("ctx");
  1530. var $1;
  1531. $1=self._inlinedSend_with_with_(_st($IRInlinedIfTrueIfFalse())._new(),anIRInstruction,anotherIRInstruction);
  1532. return $1;
  1533. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1534. }, function($ctx1) {$ctx1.fill(self,"ifTrue:ifFalse:",{anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction},globals.IRSendInliner)});
  1535. //>>excludeEnd("ctx");
  1536. },
  1537. //>>excludeStart("ide", pragmas.excludeIdeData);
  1538. args: ["anIRInstruction", "anotherIRInstruction"],
  1539. source: "ifTrue: anIRInstruction ifFalse: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrueIfFalse new with: anIRInstruction with: anotherIRInstruction",
  1540. referencedClasses: ["IRInlinedIfTrueIfFalse"],
  1541. //>>excludeEnd("ide");
  1542. messageSends: ["inlinedSend:with:with:", "new"]
  1543. }),
  1544. globals.IRSendInliner);
  1545. smalltalk.addMethod(
  1546. smalltalk.method({
  1547. selector: "inlineClosure:",
  1548. protocol: 'inlining',
  1549. fn: function (anIRClosure){
  1550. var self=this;
  1551. var inlinedClosure,sequence,statements;
  1552. function $IRTempDeclaration(){return globals.IRTempDeclaration||(typeof IRTempDeclaration=="undefined"?nil:IRTempDeclaration)}
  1553. function $IRAssignment(){return globals.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
  1554. function $IRVariable(){return globals.IRVariable||(typeof IRVariable=="undefined"?nil:IRVariable)}
  1555. function $AliasVar(){return globals.AliasVar||(typeof AliasVar=="undefined"?nil:AliasVar)}
  1556. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1557. return smalltalk.withContext(function($ctx1) {
  1558. //>>excludeEnd("ctx");
  1559. var $1,$2,$3,$4,$5,$7,$8,$6,$9,$11,$12,$14,$16,$17,$18,$19,$15,$13,$20,$22,$24,$25,$23,$21,$26,$10,$28,$27,$31,$30,$32,$29,$33,$36,$35,$34,$37;
  1560. inlinedClosure=self._inlinedClosure();
  1561. $1=inlinedClosure;
  1562. $2=$1;
  1563. $3=_st(anIRClosure)._scope();
  1564. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1565. $ctx1.sendIdx["scope"]=1;
  1566. //>>excludeEnd("ctx");
  1567. _st($2)._scope_($3);
  1568. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1569. $ctx1.sendIdx["scope:"]=1;
  1570. //>>excludeEnd("ctx");
  1571. $4=_st($1)._parent_(_st(anIRClosure)._parent());
  1572. _st(_st(anIRClosure)._tempDeclarations())._do_((function(each){
  1573. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1574. return smalltalk.withContext(function($ctx2) {
  1575. //>>excludeEnd("ctx");
  1576. return _st(inlinedClosure)._add_(each);
  1577. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1578. $ctx2.sendIdx["add:"]=1;
  1579. //>>excludeEnd("ctx");
  1580. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1581. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  1582. //>>excludeEnd("ctx");
  1583. }));
  1584. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1585. $ctx1.sendIdx["do:"]=1;
  1586. //>>excludeEnd("ctx");
  1587. sequence=self._inlinedSequence();
  1588. _st(_st(anIRClosure)._arguments())._do_((function(each){
  1589. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1590. return smalltalk.withContext(function($ctx2) {
  1591. //>>excludeEnd("ctx");
  1592. $5=inlinedClosure;
  1593. $7=_st($IRTempDeclaration())._new();
  1594. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1595. $ctx2.sendIdx["new"]=1;
  1596. //>>excludeEnd("ctx");
  1597. _st($7)._name_(each);
  1598. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1599. $ctx2.sendIdx["name:"]=1;
  1600. //>>excludeEnd("ctx");
  1601. $8=_st($7)._yourself();
  1602. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1603. $ctx2.sendIdx["yourself"]=1;
  1604. //>>excludeEnd("ctx");
  1605. $6=$8;
  1606. _st($5)._add_($6);
  1607. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1608. $ctx2.sendIdx["add:"]=2;
  1609. //>>excludeEnd("ctx");
  1610. $9=sequence;
  1611. $11=_st($IRAssignment())._new();
  1612. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1613. $ctx2.sendIdx["new"]=2;
  1614. //>>excludeEnd("ctx");
  1615. $12=$11;
  1616. $14=_st($IRVariable())._new();
  1617. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1618. $ctx2.sendIdx["new"]=3;
  1619. //>>excludeEnd("ctx");
  1620. $16=_st($AliasVar())._new();
  1621. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1622. $ctx2.sendIdx["new"]=4;
  1623. //>>excludeEnd("ctx");
  1624. $17=$16;
  1625. $18=_st(inlinedClosure)._scope();
  1626. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1627. $ctx2.sendIdx["scope"]=2;
  1628. //>>excludeEnd("ctx");
  1629. _st($17)._scope_($18);
  1630. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1631. $ctx2.sendIdx["scope:"]=2;
  1632. //>>excludeEnd("ctx");
  1633. _st($16)._name_(each);
  1634. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1635. $ctx2.sendIdx["name:"]=2;
  1636. //>>excludeEnd("ctx");
  1637. $19=_st($16)._yourself();
  1638. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1639. $ctx2.sendIdx["yourself"]=2;
  1640. //>>excludeEnd("ctx");
  1641. $15=$19;
  1642. $13=_st($14)._variable_($15);
  1643. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1644. $ctx2.sendIdx["variable:"]=1;
  1645. //>>excludeEnd("ctx");
  1646. _st($12)._add_($13);
  1647. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1648. $ctx2.sendIdx["add:"]=4;
  1649. //>>excludeEnd("ctx");
  1650. $20=$11;
  1651. $22=_st($IRVariable())._new();
  1652. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1653. $ctx2.sendIdx["new"]=5;
  1654. //>>excludeEnd("ctx");
  1655. $24=_st($AliasVar())._new();
  1656. _st($24)._scope_(_st(inlinedClosure)._scope());
  1657. _st($24)._name_("$receiver");
  1658. $25=_st($24)._yourself();
  1659. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1660. $ctx2.sendIdx["yourself"]=3;
  1661. //>>excludeEnd("ctx");
  1662. $23=$25;
  1663. $21=_st($22)._variable_($23);
  1664. _st($20)._add_($21);
  1665. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1666. $ctx2.sendIdx["add:"]=5;
  1667. //>>excludeEnd("ctx");
  1668. $26=_st($11)._yourself();
  1669. $10=$26;
  1670. return _st($9)._add_($10);
  1671. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1672. $ctx2.sendIdx["add:"]=3;
  1673. //>>excludeEnd("ctx");
  1674. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1675. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  1676. //>>excludeEnd("ctx");
  1677. }));
  1678. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1679. $ctx1.sendIdx["do:"]=2;
  1680. //>>excludeEnd("ctx");
  1681. _st(inlinedClosure)._add_(sequence);
  1682. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1683. $ctx1.sendIdx["add:"]=6;
  1684. //>>excludeEnd("ctx");
  1685. $28=_st(anIRClosure)._instructions();
  1686. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1687. $ctx1.sendIdx["instructions"]=2;
  1688. //>>excludeEnd("ctx");
  1689. $27=_st($28)._last();
  1690. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1691. $ctx1.sendIdx["last"]=1;
  1692. //>>excludeEnd("ctx");
  1693. statements=_st($27)._instructions();
  1694. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1695. $ctx1.sendIdx["instructions"]=1;
  1696. //>>excludeEnd("ctx");
  1697. _st(statements)._ifNotEmpty_((function(){
  1698. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1699. return smalltalk.withContext(function($ctx2) {
  1700. //>>excludeEnd("ctx");
  1701. _st(_st(statements)._allButLast())._do_((function(each){
  1702. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1703. return smalltalk.withContext(function($ctx3) {
  1704. //>>excludeEnd("ctx");
  1705. return _st(sequence)._add_(each);
  1706. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1707. $ctx3.sendIdx["add:"]=7;
  1708. //>>excludeEnd("ctx");
  1709. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1710. }, function($ctx3) {$ctx3.fillBlock({each:each},$ctx2,4)});
  1711. //>>excludeEnd("ctx");
  1712. }));
  1713. $31=_st(statements)._last();
  1714. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1715. $ctx2.sendIdx["last"]=2;
  1716. //>>excludeEnd("ctx");
  1717. $30=_st($31)._isReturn();
  1718. $29=_st($30)._and_((function(){
  1719. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1720. return smalltalk.withContext(function($ctx3) {
  1721. //>>excludeEnd("ctx");
  1722. $32=_st(statements)._last();
  1723. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1724. $ctx3.sendIdx["last"]=3;
  1725. //>>excludeEnd("ctx");
  1726. return _st($32)._isBlockReturn();
  1727. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1728. }, function($ctx3) {$ctx3.fillBlock({},$ctx2,5)});
  1729. //>>excludeEnd("ctx");
  1730. }));
  1731. if(smalltalk.assert($29)){
  1732. $33=sequence;
  1733. $36=_st(statements)._last();
  1734. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1735. $ctx2.sendIdx["last"]=4;
  1736. //>>excludeEnd("ctx");
  1737. $35=_st($36)._instructions();
  1738. $34=_st($35)._first();
  1739. return _st($33)._add_($34);
  1740. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1741. $ctx2.sendIdx["add:"]=8;
  1742. //>>excludeEnd("ctx");
  1743. } else {
  1744. return _st(sequence)._add_(_st(statements)._last());
  1745. };
  1746. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1747. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,3)});
  1748. //>>excludeEnd("ctx");
  1749. }));
  1750. $37=inlinedClosure;
  1751. return $37;
  1752. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1753. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,sequence:sequence,statements:statements},globals.IRSendInliner)});
  1754. //>>excludeEnd("ctx");
  1755. },
  1756. //>>excludeStart("ide", pragmas.excludeIdeData);
  1757. args: ["anIRClosure"],
  1758. source: "inlineClosure: anIRClosure\x0a\x09| inlinedClosure sequence statements |\x0a\x0a\x09inlinedClosure := self inlinedClosure.\x0a\x09inlinedClosure \x0a\x09\x09scope: anIRClosure scope;\x0a\x09\x09parent: anIRClosure parent.\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",
  1759. referencedClasses: ["IRTempDeclaration", "IRAssignment", "IRVariable", "AliasVar"],
  1760. //>>excludeEnd("ide");
  1761. messageSends: ["inlinedClosure", "scope:", "scope", "parent:", "parent", "do:", "tempDeclarations", "add:", "inlinedSequence", "arguments", "name:", "new", "yourself", "variable:", "instructions", "last", "ifNotEmpty:", "allButLast", "ifTrue:ifFalse:", "and:", "isReturn", "isBlockReturn", "first"]
  1762. }),
  1763. globals.IRSendInliner);
  1764. smalltalk.addMethod(
  1765. smalltalk.method({
  1766. selector: "inlineSend:",
  1767. protocol: 'inlining',
  1768. fn: function (anIRSend){
  1769. var self=this;
  1770. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1771. return smalltalk.withContext(function($ctx1) {
  1772. //>>excludeEnd("ctx");
  1773. var $3,$2,$1;
  1774. self._send_(anIRSend);
  1775. $3=self._send();
  1776. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1777. $ctx1.sendIdx["send"]=1;
  1778. //>>excludeEnd("ctx");
  1779. $2=_st($3)._selector();
  1780. $1=self._perform_withArguments_($2,_st(_st(self._send())._instructions())._allButFirst());
  1781. return $1;
  1782. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1783. }, function($ctx1) {$ctx1.fill(self,"inlineSend:",{anIRSend:anIRSend},globals.IRSendInliner)});
  1784. //>>excludeEnd("ctx");
  1785. },
  1786. //>>excludeStart("ide", pragmas.excludeIdeData);
  1787. args: ["anIRSend"],
  1788. source: "inlineSend: anIRSend\x0a\x09self send: anIRSend.\x0a\x09^ self\x0a\x09\x09perform: self send selector\x0a\x09\x09withArguments: self send instructions allButFirst",
  1789. referencedClasses: [],
  1790. //>>excludeEnd("ide");
  1791. messageSends: ["send:", "perform:withArguments:", "selector", "send", "allButFirst", "instructions"]
  1792. }),
  1793. globals.IRSendInliner);
  1794. smalltalk.addMethod(
  1795. smalltalk.method({
  1796. selector: "inlinedClosure",
  1797. protocol: 'factory',
  1798. fn: function (){
  1799. var self=this;
  1800. function $IRInlinedClosure(){return globals.IRInlinedClosure||(typeof IRInlinedClosure=="undefined"?nil:IRInlinedClosure)}
  1801. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1802. return smalltalk.withContext(function($ctx1) {
  1803. //>>excludeEnd("ctx");
  1804. var $1;
  1805. $1=_st($IRInlinedClosure())._new();
  1806. return $1;
  1807. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1808. }, function($ctx1) {$ctx1.fill(self,"inlinedClosure",{},globals.IRSendInliner)});
  1809. //>>excludeEnd("ctx");
  1810. },
  1811. //>>excludeStart("ide", pragmas.excludeIdeData);
  1812. args: [],
  1813. source: "inlinedClosure\x0a\x09^ IRInlinedClosure new",
  1814. referencedClasses: ["IRInlinedClosure"],
  1815. //>>excludeEnd("ide");
  1816. messageSends: ["new"]
  1817. }),
  1818. globals.IRSendInliner);
  1819. smalltalk.addMethod(
  1820. smalltalk.method({
  1821. selector: "inlinedSend:with:",
  1822. protocol: 'inlining',
  1823. fn: function (inlinedSend,anIRInstruction){
  1824. var self=this;
  1825. var inlinedClosure;
  1826. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1827. return smalltalk.withContext(function($ctx1) {
  1828. //>>excludeEnd("ctx");
  1829. var $1,$2,$5,$4,$3,$6,$7;
  1830. $1=_st(anIRInstruction)._isClosure();
  1831. if(! smalltalk.assert($1)){
  1832. self._inliningError_("Message argument should be a block");
  1833. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1834. $ctx1.sendIdx["inliningError:"]=1;
  1835. //>>excludeEnd("ctx");
  1836. };
  1837. $2=_st(_st(_st(anIRInstruction)._arguments())._size()).__eq((0));
  1838. if(! smalltalk.assert($2)){
  1839. self._inliningError_("Inlined block should have zero argument");
  1840. };
  1841. inlinedClosure=_st(self._translator())._visit_(self._inlineClosure_(anIRInstruction));
  1842. $5=self._send();
  1843. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1844. $ctx1.sendIdx["send"]=1;
  1845. //>>excludeEnd("ctx");
  1846. $4=_st($5)._instructions();
  1847. $3=_st($4)._first();
  1848. _st(inlinedSend)._add_($3);
  1849. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1850. $ctx1.sendIdx["add:"]=1;
  1851. //>>excludeEnd("ctx");
  1852. $6=_st(inlinedSend)._add_(inlinedClosure);
  1853. _st(self._send())._replaceWith_(inlinedSend);
  1854. $7=_st(_st(inlinedSend)._method())._internalVariables();
  1855. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1856. $ctx1.sendIdx["internalVariables"]=1;
  1857. //>>excludeEnd("ctx");
  1858. _st($7)._addAll_(_st(inlinedSend)._internalVariables());
  1859. return inlinedSend;
  1860. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1861. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,inlinedClosure:inlinedClosure},globals.IRSendInliner)});
  1862. //>>excludeEnd("ctx");
  1863. },
  1864. //>>excludeStart("ide", pragmas.excludeIdeData);
  1865. args: ["inlinedSend", "anIRInstruction"],
  1866. 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\x09inlinedSend method internalVariables \x0a\x09\x09addAll: inlinedSend internalVariables.\x0a\x0a\x09^ inlinedSend",
  1867. referencedClasses: [],
  1868. //>>excludeEnd("ide");
  1869. messageSends: ["ifFalse:", "isClosure", "inliningError:", "=", "size", "arguments", "visit:", "translator", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:", "addAll:", "internalVariables", "method"]
  1870. }),
  1871. globals.IRSendInliner);
  1872. smalltalk.addMethod(
  1873. smalltalk.method({
  1874. selector: "inlinedSend:with:with:",
  1875. protocol: 'inlining',
  1876. fn: function (inlinedSend,anIRInstruction,anotherIRInstruction){
  1877. var self=this;
  1878. var inlinedClosure1,inlinedClosure2;
  1879. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1880. return smalltalk.withContext(function($ctx1) {
  1881. //>>excludeEnd("ctx");
  1882. var $1,$2,$3,$4,$7,$6,$5,$8,$9;
  1883. $1=_st(anIRInstruction)._isClosure();
  1884. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1885. $ctx1.sendIdx["isClosure"]=1;
  1886. //>>excludeEnd("ctx");
  1887. if(! smalltalk.assert($1)){
  1888. self._inliningError_("Message argument should be a block");
  1889. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1890. $ctx1.sendIdx["inliningError:"]=1;
  1891. //>>excludeEnd("ctx");
  1892. };
  1893. $2=_st(anotherIRInstruction)._isClosure();
  1894. if(! smalltalk.assert($2)){
  1895. self._inliningError_("Message argument should be a block");
  1896. };
  1897. $3=self._translator();
  1898. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1899. $ctx1.sendIdx["translator"]=1;
  1900. //>>excludeEnd("ctx");
  1901. $4=self._inlineClosure_(anIRInstruction);
  1902. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1903. $ctx1.sendIdx["inlineClosure:"]=1;
  1904. //>>excludeEnd("ctx");
  1905. inlinedClosure1=_st($3)._visit_($4);
  1906. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1907. $ctx1.sendIdx["visit:"]=1;
  1908. //>>excludeEnd("ctx");
  1909. inlinedClosure2=_st(self._translator())._visit_(self._inlineClosure_(anotherIRInstruction));
  1910. $7=self._send();
  1911. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1912. $ctx1.sendIdx["send"]=1;
  1913. //>>excludeEnd("ctx");
  1914. $6=_st($7)._instructions();
  1915. $5=_st($6)._first();
  1916. _st(inlinedSend)._add_($5);
  1917. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1918. $ctx1.sendIdx["add:"]=1;
  1919. //>>excludeEnd("ctx");
  1920. _st(inlinedSend)._add_(inlinedClosure1);
  1921. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1922. $ctx1.sendIdx["add:"]=2;
  1923. //>>excludeEnd("ctx");
  1924. $8=_st(inlinedSend)._add_(inlinedClosure2);
  1925. _st(self._send())._replaceWith_(inlinedSend);
  1926. $9=_st(_st(inlinedSend)._method())._internalVariables();
  1927. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1928. $ctx1.sendIdx["internalVariables"]=1;
  1929. //>>excludeEnd("ctx");
  1930. _st($9)._addAll_(_st(inlinedSend)._internalVariables());
  1931. return inlinedSend;
  1932. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1933. }, function($ctx1) {$ctx1.fill(self,"inlinedSend:with:with:",{inlinedSend:inlinedSend,anIRInstruction:anIRInstruction,anotherIRInstruction:anotherIRInstruction,inlinedClosure1:inlinedClosure1,inlinedClosure2:inlinedClosure2},globals.IRSendInliner)});
  1934. //>>excludeEnd("ctx");
  1935. },
  1936. //>>excludeStart("ide", pragmas.excludeIdeData);
  1937. args: ["inlinedSend", "anIRInstruction", "anotherIRInstruction"],
  1938. 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\x09inlinedSend method internalVariables \x0a\x09\x09addAll: inlinedSend internalVariables.\x0a\x09\x09\x0a\x09^ inlinedSend",
  1939. referencedClasses: [],
  1940. //>>excludeEnd("ide");
  1941. messageSends: ["ifFalse:", "isClosure", "inliningError:", "visit:", "translator", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:", "addAll:", "internalVariables", "method"]
  1942. }),
  1943. globals.IRSendInliner);
  1944. smalltalk.addMethod(
  1945. smalltalk.method({
  1946. selector: "inlinedSequence",
  1947. protocol: 'factory',
  1948. fn: function (){
  1949. var self=this;
  1950. function $IRInlinedSequence(){return globals.IRInlinedSequence||(typeof IRInlinedSequence=="undefined"?nil:IRInlinedSequence)}
  1951. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1952. return smalltalk.withContext(function($ctx1) {
  1953. //>>excludeEnd("ctx");
  1954. var $1;
  1955. $1=_st($IRInlinedSequence())._new();
  1956. return $1;
  1957. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1958. }, function($ctx1) {$ctx1.fill(self,"inlinedSequence",{},globals.IRSendInliner)});
  1959. //>>excludeEnd("ctx");
  1960. },
  1961. //>>excludeStart("ide", pragmas.excludeIdeData);
  1962. args: [],
  1963. source: "inlinedSequence\x0a\x09^ IRInlinedSequence new",
  1964. referencedClasses: ["IRInlinedSequence"],
  1965. //>>excludeEnd("ide");
  1966. messageSends: ["new"]
  1967. }),
  1968. globals.IRSendInliner);
  1969. smalltalk.addMethod(
  1970. smalltalk.method({
  1971. selector: "inliningError:",
  1972. protocol: 'error handling',
  1973. fn: function (aString){
  1974. var self=this;
  1975. function $InliningError(){return globals.InliningError||(typeof InliningError=="undefined"?nil:InliningError)}
  1976. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1977. return smalltalk.withContext(function($ctx1) {
  1978. //>>excludeEnd("ctx");
  1979. _st($InliningError())._signal_(aString);
  1980. return self;
  1981. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  1982. }, function($ctx1) {$ctx1.fill(self,"inliningError:",{aString:aString},globals.IRSendInliner)});
  1983. //>>excludeEnd("ctx");
  1984. },
  1985. //>>excludeStart("ide", pragmas.excludeIdeData);
  1986. args: ["aString"],
  1987. source: "inliningError: aString\x0a\x09InliningError signal: aString",
  1988. referencedClasses: ["InliningError"],
  1989. //>>excludeEnd("ide");
  1990. messageSends: ["signal:"]
  1991. }),
  1992. globals.IRSendInliner);
  1993. smalltalk.addMethod(
  1994. smalltalk.method({
  1995. selector: "send",
  1996. protocol: 'accessing',
  1997. fn: function (){
  1998. var self=this;
  1999. var $1;
  2000. $1=self["@send"];
  2001. return $1;
  2002. },
  2003. //>>excludeStart("ide", pragmas.excludeIdeData);
  2004. args: [],
  2005. source: "send\x0a\x09^ send",
  2006. referencedClasses: [],
  2007. //>>excludeEnd("ide");
  2008. messageSends: []
  2009. }),
  2010. globals.IRSendInliner);
  2011. smalltalk.addMethod(
  2012. smalltalk.method({
  2013. selector: "send:",
  2014. protocol: 'accessing',
  2015. fn: function (anIRSend){
  2016. var self=this;
  2017. self["@send"]=anIRSend;
  2018. return self;
  2019. },
  2020. //>>excludeStart("ide", pragmas.excludeIdeData);
  2021. args: ["anIRSend"],
  2022. source: "send: anIRSend\x0a\x09send := anIRSend",
  2023. referencedClasses: [],
  2024. //>>excludeEnd("ide");
  2025. messageSends: []
  2026. }),
  2027. globals.IRSendInliner);
  2028. smalltalk.addMethod(
  2029. smalltalk.method({
  2030. selector: "translator",
  2031. protocol: 'accessing',
  2032. fn: function (){
  2033. var self=this;
  2034. var $1;
  2035. $1=self["@translator"];
  2036. return $1;
  2037. },
  2038. //>>excludeStart("ide", pragmas.excludeIdeData);
  2039. args: [],
  2040. source: "translator\x0a\x09^ translator",
  2041. referencedClasses: [],
  2042. //>>excludeEnd("ide");
  2043. messageSends: []
  2044. }),
  2045. globals.IRSendInliner);
  2046. smalltalk.addMethod(
  2047. smalltalk.method({
  2048. selector: "translator:",
  2049. protocol: 'accessing',
  2050. fn: function (anASTTranslator){
  2051. var self=this;
  2052. self["@translator"]=anASTTranslator;
  2053. return self;
  2054. },
  2055. //>>excludeStart("ide", pragmas.excludeIdeData);
  2056. args: ["anASTTranslator"],
  2057. source: "translator: anASTTranslator\x0a\x09translator := anASTTranslator",
  2058. referencedClasses: [],
  2059. //>>excludeEnd("ide");
  2060. messageSends: []
  2061. }),
  2062. globals.IRSendInliner);
  2063. smalltalk.addMethod(
  2064. smalltalk.method({
  2065. selector: "inlinedSelectors",
  2066. protocol: 'accessing',
  2067. fn: function (){
  2068. var self=this;
  2069. var $1;
  2070. $1=["ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:", "ifNil:", "ifNotNil:", "ifNil:ifNotNil:", "ifNotNil:ifNil:"];
  2071. return $1;
  2072. },
  2073. //>>excludeStart("ide", pragmas.excludeIdeData);
  2074. args: [],
  2075. source: "inlinedSelectors\x0a\x09^ #('ifTrue:' 'ifFalse:' 'ifTrue:ifFalse:' 'ifFalse:ifTrue:' 'ifNil:' 'ifNotNil:' 'ifNil:ifNotNil:' 'ifNotNil:ifNil:')",
  2076. referencedClasses: [],
  2077. //>>excludeEnd("ide");
  2078. messageSends: []
  2079. }),
  2080. globals.IRSendInliner.klass);
  2081. smalltalk.addMethod(
  2082. smalltalk.method({
  2083. selector: "shouldInline:",
  2084. protocol: 'accessing',
  2085. fn: function (anIRInstruction){
  2086. var self=this;
  2087. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2088. return smalltalk.withContext(function($ctx1) {
  2089. //>>excludeEnd("ctx");
  2090. var $1,$2;
  2091. var $early={};
  2092. try {
  2093. $1=_st(self._inlinedSelectors())._includes_(_st(anIRInstruction)._selector());
  2094. if(! smalltalk.assert($1)){
  2095. return false;
  2096. };
  2097. _st(_st(_st(anIRInstruction)._instructions())._allButFirst())._do_((function(each){
  2098. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2099. return smalltalk.withContext(function($ctx2) {
  2100. //>>excludeEnd("ctx");
  2101. $2=_st(each)._isClosure();
  2102. if(! smalltalk.assert($2)){
  2103. throw $early=[false];
  2104. };
  2105. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2106. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,2)});
  2107. //>>excludeEnd("ctx");
  2108. }));
  2109. return true;
  2110. }
  2111. catch(e) {if(e===$early)return e[0]; throw e}
  2112. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2113. }, function($ctx1) {$ctx1.fill(self,"shouldInline:",{anIRInstruction:anIRInstruction},globals.IRSendInliner.klass)});
  2114. //>>excludeEnd("ctx");
  2115. },
  2116. //>>excludeStart("ide", pragmas.excludeIdeData);
  2117. args: ["anIRInstruction"],
  2118. 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",
  2119. referencedClasses: [],
  2120. //>>excludeEnd("ide");
  2121. messageSends: ["ifFalse:", "includes:", "inlinedSelectors", "selector", "do:", "allButFirst", "instructions", "isClosure"]
  2122. }),
  2123. globals.IRSendInliner.klass);
  2124. smalltalk.addClass('IRAssignmentInliner', globals.IRSendInliner, ['assignment'], 'Compiler-Inlining');
  2125. //>>excludeStart("ide", pragmas.excludeIdeData);
  2126. globals.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};";
  2127. //>>excludeEnd("ide");
  2128. smalltalk.addMethod(
  2129. smalltalk.method({
  2130. selector: "assignment",
  2131. protocol: 'accessing',
  2132. fn: function (){
  2133. var self=this;
  2134. var $1;
  2135. $1=self["@assignment"];
  2136. return $1;
  2137. },
  2138. //>>excludeStart("ide", pragmas.excludeIdeData);
  2139. args: [],
  2140. source: "assignment\x0a\x09^ assignment",
  2141. referencedClasses: [],
  2142. //>>excludeEnd("ide");
  2143. messageSends: []
  2144. }),
  2145. globals.IRAssignmentInliner);
  2146. smalltalk.addMethod(
  2147. smalltalk.method({
  2148. selector: "assignment:",
  2149. protocol: 'accessing',
  2150. fn: function (aNode){
  2151. var self=this;
  2152. self["@assignment"]=aNode;
  2153. return self;
  2154. },
  2155. //>>excludeStart("ide", pragmas.excludeIdeData);
  2156. args: ["aNode"],
  2157. source: "assignment: aNode\x0a\x09assignment := aNode",
  2158. referencedClasses: [],
  2159. //>>excludeEnd("ide");
  2160. messageSends: []
  2161. }),
  2162. globals.IRAssignmentInliner);
  2163. smalltalk.addMethod(
  2164. smalltalk.method({
  2165. selector: "inlineAssignment:",
  2166. protocol: 'inlining',
  2167. fn: function (anIRAssignment){
  2168. var self=this;
  2169. var inlinedAssignment;
  2170. function $IRInlinedAssignment(){return globals.IRInlinedAssignment||(typeof IRInlinedAssignment=="undefined"?nil:IRInlinedAssignment)}
  2171. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2172. return smalltalk.withContext(function($ctx1) {
  2173. //>>excludeEnd("ctx");
  2174. var $1,$2;
  2175. self._assignment_(anIRAssignment);
  2176. inlinedAssignment=_st($IRInlinedAssignment())._new();
  2177. $1=_st(anIRAssignment)._instructions();
  2178. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2179. $ctx1.sendIdx["instructions"]=1;
  2180. //>>excludeEnd("ctx");
  2181. _st($1)._do_((function(each){
  2182. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2183. return smalltalk.withContext(function($ctx2) {
  2184. //>>excludeEnd("ctx");
  2185. return _st(inlinedAssignment)._add_(each);
  2186. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2187. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2188. //>>excludeEnd("ctx");
  2189. }));
  2190. _st(anIRAssignment)._replaceWith_(inlinedAssignment);
  2191. self._inlineSend_(_st(_st(inlinedAssignment)._instructions())._last());
  2192. $2=inlinedAssignment;
  2193. return $2;
  2194. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2195. }, function($ctx1) {$ctx1.fill(self,"inlineAssignment:",{anIRAssignment:anIRAssignment,inlinedAssignment:inlinedAssignment},globals.IRAssignmentInliner)});
  2196. //>>excludeEnd("ctx");
  2197. },
  2198. //>>excludeStart("ide", pragmas.excludeIdeData);
  2199. args: ["anIRAssignment"],
  2200. 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",
  2201. referencedClasses: ["IRInlinedAssignment"],
  2202. //>>excludeEnd("ide");
  2203. messageSends: ["assignment:", "new", "do:", "instructions", "add:", "replaceWith:", "inlineSend:", "last"]
  2204. }),
  2205. globals.IRAssignmentInliner);
  2206. smalltalk.addMethod(
  2207. smalltalk.method({
  2208. selector: "inlineClosure:",
  2209. protocol: 'inlining',
  2210. fn: function (anIRClosure){
  2211. var self=this;
  2212. var inlinedClosure,statements;
  2213. function $IRAssignment(){return globals.IRAssignment||(typeof IRAssignment=="undefined"?nil:IRAssignment)}
  2214. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2215. return smalltalk.withContext(function($ctx1) {
  2216. //>>excludeEnd("ctx");
  2217. var $2,$1,$4,$3,$5,$7,$8,$6,$9;
  2218. inlinedClosure=(
  2219. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2220. $ctx1.supercall = true,
  2221. //>>excludeEnd("ctx");
  2222. globals.IRAssignmentInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]));
  2223. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2224. $ctx1.supercall = false;
  2225. //>>excludeEnd("ctx");;
  2226. $2=_st(inlinedClosure)._instructions();
  2227. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2228. $ctx1.sendIdx["instructions"]=2;
  2229. //>>excludeEnd("ctx");
  2230. $1=_st($2)._last();
  2231. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2232. $ctx1.sendIdx["last"]=1;
  2233. //>>excludeEnd("ctx");
  2234. statements=_st($1)._instructions();
  2235. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2236. $ctx1.sendIdx["instructions"]=1;
  2237. //>>excludeEnd("ctx");
  2238. _st(statements)._ifNotEmpty_((function(){
  2239. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2240. return smalltalk.withContext(function($ctx2) {
  2241. //>>excludeEnd("ctx");
  2242. $4=_st(statements)._last();
  2243. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2244. $ctx2.sendIdx["last"]=2;
  2245. //>>excludeEnd("ctx");
  2246. $3=_st($4)._canBeAssigned();
  2247. if(smalltalk.assert($3)){
  2248. $5=_st(statements)._last();
  2249. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2250. $ctx2.sendIdx["last"]=3;
  2251. //>>excludeEnd("ctx");
  2252. $7=_st($IRAssignment())._new();
  2253. _st($7)._add_(_st(_st(self._assignment())._instructions())._first());
  2254. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2255. $ctx2.sendIdx["add:"]=1;
  2256. //>>excludeEnd("ctx");
  2257. _st($7)._add_(_st(_st(statements)._last())._copy());
  2258. $8=_st($7)._yourself();
  2259. $6=$8;
  2260. return _st($5)._replaceWith_($6);
  2261. };
  2262. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2263. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2264. //>>excludeEnd("ctx");
  2265. }));
  2266. $9=inlinedClosure;
  2267. return $9;
  2268. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2269. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,inlinedClosure:inlinedClosure,statements:statements},globals.IRAssignmentInliner)});
  2270. //>>excludeEnd("ctx");
  2271. },
  2272. //>>excludeStart("ide", pragmas.excludeIdeData);
  2273. args: ["anIRClosure"],
  2274. 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",
  2275. referencedClasses: ["IRAssignment"],
  2276. //>>excludeEnd("ide");
  2277. messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifTrue:", "canBeAssigned", "replaceWith:", "add:", "new", "first", "assignment", "copy", "yourself"]
  2278. }),
  2279. globals.IRAssignmentInliner);
  2280. smalltalk.addClass('IRReturnInliner', globals.IRSendInliner, [], 'Compiler-Inlining');
  2281. //>>excludeStart("ide", pragmas.excludeIdeData);
  2282. globals.IRReturnInliner.comment="I inline message sends with inlined closure together with a return instruction.";
  2283. //>>excludeEnd("ide");
  2284. smalltalk.addMethod(
  2285. smalltalk.method({
  2286. selector: "inlineClosure:",
  2287. protocol: 'inlining',
  2288. fn: function (anIRClosure){
  2289. var self=this;
  2290. var closure,statements;
  2291. function $IRReturn(){return globals.IRReturn||(typeof IRReturn=="undefined"?nil:IRReturn)}
  2292. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2293. return smalltalk.withContext(function($ctx1) {
  2294. //>>excludeEnd("ctx");
  2295. var $1,$3,$2,$4,$5,$6,$7;
  2296. closure=(
  2297. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2298. $ctx1.supercall = true,
  2299. //>>excludeEnd("ctx");
  2300. globals.IRReturnInliner.superclass.fn.prototype._inlineClosure_.apply(_st(self), [anIRClosure]));
  2301. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2302. $ctx1.supercall = false;
  2303. //>>excludeEnd("ctx");;
  2304. $1=_st(_st(closure)._instructions())._last();
  2305. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2306. $ctx1.sendIdx["last"]=1;
  2307. //>>excludeEnd("ctx");
  2308. statements=_st($1)._instructions();
  2309. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2310. $ctx1.sendIdx["instructions"]=1;
  2311. //>>excludeEnd("ctx");
  2312. _st(statements)._ifNotEmpty_((function(){
  2313. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2314. return smalltalk.withContext(function($ctx2) {
  2315. //>>excludeEnd("ctx");
  2316. $3=_st(statements)._last();
  2317. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2318. $ctx2.sendIdx["last"]=2;
  2319. //>>excludeEnd("ctx");
  2320. $2=_st($3)._isReturn();
  2321. if(! smalltalk.assert($2)){
  2322. $4=_st(statements)._last();
  2323. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2324. $ctx2.sendIdx["last"]=3;
  2325. //>>excludeEnd("ctx");
  2326. $5=_st($IRReturn())._new();
  2327. _st($5)._add_(_st(_st(statements)._last())._copy());
  2328. $6=_st($5)._yourself();
  2329. return _st($4)._replaceWith_($6);
  2330. };
  2331. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2332. }, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)});
  2333. //>>excludeEnd("ctx");
  2334. }));
  2335. $7=closure;
  2336. return $7;
  2337. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2338. }, function($ctx1) {$ctx1.fill(self,"inlineClosure:",{anIRClosure:anIRClosure,closure:closure,statements:statements},globals.IRReturnInliner)});
  2339. //>>excludeEnd("ctx");
  2340. },
  2341. //>>excludeStart("ide", pragmas.excludeIdeData);
  2342. args: ["anIRClosure"],
  2343. 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",
  2344. referencedClasses: ["IRReturn"],
  2345. //>>excludeEnd("ide");
  2346. messageSends: ["inlineClosure:", "instructions", "last", "ifNotEmpty:", "ifFalse:", "isReturn", "replaceWith:", "add:", "new", "copy", "yourself"]
  2347. }),
  2348. globals.IRReturnInliner);
  2349. smalltalk.addMethod(
  2350. smalltalk.method({
  2351. selector: "inlineReturn:",
  2352. protocol: 'inlining',
  2353. fn: function (anIRReturn){
  2354. var self=this;
  2355. var return_;
  2356. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2357. return smalltalk.withContext(function($ctx1) {
  2358. //>>excludeEnd("ctx");
  2359. var $1,$2;
  2360. return_=self._inlinedReturn();
  2361. $1=_st(anIRReturn)._instructions();
  2362. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2363. $ctx1.sendIdx["instructions"]=1;
  2364. //>>excludeEnd("ctx");
  2365. _st($1)._do_((function(each){
  2366. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2367. return smalltalk.withContext(function($ctx2) {
  2368. //>>excludeEnd("ctx");
  2369. return _st(return_)._add_(each);
  2370. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2371. }, function($ctx2) {$ctx2.fillBlock({each:each},$ctx1,1)});
  2372. //>>excludeEnd("ctx");
  2373. }));
  2374. _st(anIRReturn)._replaceWith_(return_);
  2375. self._inlineSend_(_st(_st(return_)._instructions())._last());
  2376. $2=return_;
  2377. return $2;
  2378. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2379. }, function($ctx1) {$ctx1.fill(self,"inlineReturn:",{anIRReturn:anIRReturn,return_:return_},globals.IRReturnInliner)});
  2380. //>>excludeEnd("ctx");
  2381. },
  2382. //>>excludeStart("ide", pragmas.excludeIdeData);
  2383. args: ["anIRReturn"],
  2384. 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",
  2385. referencedClasses: [],
  2386. //>>excludeEnd("ide");
  2387. messageSends: ["inlinedReturn", "do:", "instructions", "add:", "replaceWith:", "inlineSend:", "last"]
  2388. }),
  2389. globals.IRReturnInliner);
  2390. smalltalk.addMethod(
  2391. smalltalk.method({
  2392. selector: "inlinedReturn",
  2393. protocol: 'factory',
  2394. fn: function (){
  2395. var self=this;
  2396. function $IRInlinedReturn(){return globals.IRInlinedReturn||(typeof IRInlinedReturn=="undefined"?nil:IRInlinedReturn)}
  2397. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2398. return smalltalk.withContext(function($ctx1) {
  2399. //>>excludeEnd("ctx");
  2400. var $1;
  2401. $1=_st($IRInlinedReturn())._new();
  2402. return $1;
  2403. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2404. }, function($ctx1) {$ctx1.fill(self,"inlinedReturn",{},globals.IRReturnInliner)});
  2405. //>>excludeEnd("ctx");
  2406. },
  2407. //>>excludeStart("ide", pragmas.excludeIdeData);
  2408. args: [],
  2409. source: "inlinedReturn\x0a\x09^ IRInlinedReturn new",
  2410. referencedClasses: ["IRInlinedReturn"],
  2411. //>>excludeEnd("ide");
  2412. messageSends: ["new"]
  2413. }),
  2414. globals.IRReturnInliner);
  2415. smalltalk.addClass('InliningCodeGenerator', globals.CodeGenerator, [], 'Compiler-Inlining');
  2416. //>>excludeStart("ide", pragmas.excludeIdeData);
  2417. globals.InliningCodeGenerator.comment="I am a specialized code generator that uses inlining to produce more optimized JavaScript output";
  2418. //>>excludeEnd("ide");
  2419. smalltalk.addMethod(
  2420. smalltalk.method({
  2421. selector: "compileNode:",
  2422. protocol: 'compiling',
  2423. fn: function (aNode){
  2424. var self=this;
  2425. var ir,stream;
  2426. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2427. return smalltalk.withContext(function($ctx1) {
  2428. //>>excludeEnd("ctx");
  2429. var $2,$3,$1;
  2430. _st(self._semanticAnalyzer())._visit_(aNode);
  2431. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2432. $ctx1.sendIdx["visit:"]=1;
  2433. //>>excludeEnd("ctx");
  2434. ir=_st(self._translator())._visit_(aNode);
  2435. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2436. $ctx1.sendIdx["visit:"]=2;
  2437. //>>excludeEnd("ctx");
  2438. _st(self._inliner())._visit_(ir);
  2439. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2440. $ctx1.sendIdx["visit:"]=3;
  2441. //>>excludeEnd("ctx");
  2442. $2=self._irTranslator();
  2443. _st($2)._currentClass_(self._currentClass());
  2444. _st($2)._visit_(ir);
  2445. $3=_st($2)._contents();
  2446. $1=$3;
  2447. return $1;
  2448. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2449. }, function($ctx1) {$ctx1.fill(self,"compileNode:",{aNode:aNode,ir:ir,stream:stream},globals.InliningCodeGenerator)});
  2450. //>>excludeEnd("ctx");
  2451. },
  2452. //>>excludeStart("ide", pragmas.excludeIdeData);
  2453. args: ["aNode"],
  2454. 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",
  2455. referencedClasses: [],
  2456. //>>excludeEnd("ide");
  2457. messageSends: ["visit:", "semanticAnalyzer", "translator", "inliner", "currentClass:", "irTranslator", "currentClass", "contents"]
  2458. }),
  2459. globals.InliningCodeGenerator);
  2460. smalltalk.addMethod(
  2461. smalltalk.method({
  2462. selector: "inliner",
  2463. protocol: 'compiling',
  2464. fn: function (){
  2465. var self=this;
  2466. function $IRInliner(){return globals.IRInliner||(typeof IRInliner=="undefined"?nil:IRInliner)}
  2467. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2468. return smalltalk.withContext(function($ctx1) {
  2469. //>>excludeEnd("ctx");
  2470. var $1;
  2471. $1=_st($IRInliner())._new();
  2472. return $1;
  2473. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2474. }, function($ctx1) {$ctx1.fill(self,"inliner",{},globals.InliningCodeGenerator)});
  2475. //>>excludeEnd("ctx");
  2476. },
  2477. //>>excludeStart("ide", pragmas.excludeIdeData);
  2478. args: [],
  2479. source: "inliner\x0a\x09^ IRInliner new",
  2480. referencedClasses: ["IRInliner"],
  2481. //>>excludeEnd("ide");
  2482. messageSends: ["new"]
  2483. }),
  2484. globals.InliningCodeGenerator);
  2485. smalltalk.addMethod(
  2486. smalltalk.method({
  2487. selector: "irTranslator",
  2488. protocol: 'compiling',
  2489. fn: function (){
  2490. var self=this;
  2491. function $IRInliningJSTranslator(){return globals.IRInliningJSTranslator||(typeof IRInliningJSTranslator=="undefined"?nil:IRInliningJSTranslator)}
  2492. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2493. return smalltalk.withContext(function($ctx1) {
  2494. //>>excludeEnd("ctx");
  2495. var $1;
  2496. $1=_st($IRInliningJSTranslator())._new();
  2497. return $1;
  2498. //>>excludeStart("ctx", pragmas.excludeDebugContexts);
  2499. }, function($ctx1) {$ctx1.fill(self,"irTranslator",{},globals.InliningCodeGenerator)});
  2500. //>>excludeEnd("ctx");
  2501. },
  2502. //>>excludeStart("ide", pragmas.excludeIdeData);
  2503. args: [],
  2504. source: "irTranslator\x0a\x09^ IRInliningJSTranslator new",
  2505. referencedClasses: ["IRInliningJSTranslator"],
  2506. //>>excludeEnd("ide");
  2507. messageSends: ["new"]
  2508. }),
  2509. globals.InliningCodeGenerator);
  2510. });