1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534 |
- smalltalk.addPackage('Compiler-Inlining', {});
- smalltalk.addClass('IRInlinedAssignment', smalltalk.IRAssignment, [], 'Compiler-Inlining');
- smalltalk.IRInlinedAssignment.comment="I represent an inlined assignment instruction."
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- return smalltalk.send(aVisitor,"_visitIRInlinedAssignment_",[self]);
- },
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInlinedAssignment: self",
- messageSends: ["visitIRInlinedAssignment:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedAssignment);
- smalltalk.addMethod(
- "_isInlined",
- smalltalk.method({
- selector: "isInlined",
- category: 'testing',
- fn: function () {
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRInlinedAssignment);
- smalltalk.addClass('IRInlinedClosure', smalltalk.IRClosure, [], 'Compiler-Inlining');
- smalltalk.IRInlinedClosure.comment="I represent an inlined closure instruction."
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- smalltalk.send(aVisitor,"_visitIRInlinedClosure_",[self]);
- return self;},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedClosure: self",
- messageSends: ["visitIRInlinedClosure:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedClosure);
- smalltalk.addMethod(
- "_isInlined",
- smalltalk.method({
- selector: "isInlined",
- category: 'testing',
- fn: function () {
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRInlinedClosure);
- smalltalk.addClass('IRInlinedReturn', smalltalk.IRReturn, [], 'Compiler-Inlining');
- smalltalk.IRInlinedReturn.comment="I represent an inlined local return instruction."
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- return smalltalk.send(aVisitor,"_visitIRInlinedReturn_",[self]);
- },
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInlinedReturn: self",
- messageSends: ["visitIRInlinedReturn:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedReturn);
- smalltalk.addMethod(
- "_isInlined",
- smalltalk.method({
- selector: "isInlined",
- category: 'testing',
- fn: function () {
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRInlinedReturn);
- smalltalk.addClass('IRInlinedNonLocalReturn', smalltalk.IRInlinedReturn, [], 'Compiler-Inlining');
- smalltalk.IRInlinedNonLocalReturn.comment="I represent an inlined non local return instruction."
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- return smalltalk.send(aVisitor,"_visitIRInlinedNonLocalReturn_",[self]);
- },
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRInlinedNonLocalReturn: self",
- messageSends: ["visitIRInlinedNonLocalReturn:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedNonLocalReturn);
- smalltalk.addMethod(
- "_isInlined",
- smalltalk.method({
- selector: "isInlined",
- category: 'testing',
- fn: function () {
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRInlinedNonLocalReturn);
- smalltalk.addClass('IRInlinedSend', smalltalk.IRSend, [], 'Compiler-Inlining');
- smalltalk.IRInlinedSend.comment="I am the abstract super class of inlined message send instructions."
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- smalltalk.send(aVisitor,"_visitInlinedSend_",[self]);
- return self;},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitInlinedSend: self",
- messageSends: ["visitInlinedSend:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedSend);
- smalltalk.addMethod(
- "_isInlined",
- smalltalk.method({
- selector: "isInlined",
- category: 'testing',
- fn: function () {
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRInlinedSend);
- smalltalk.addClass('IRInlinedIfFalse', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- smalltalk.send(aVisitor,"_visitIRInlinedIfFalse_",[self]);
- return self;},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfFalse: self",
- messageSends: ["visitIRInlinedIfFalse:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedIfFalse);
- smalltalk.addClass('IRInlinedIfNil', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- smalltalk.send(aVisitor,"_visitIRInlinedIfNil_",[self]);
- return self;},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfNil: self",
- messageSends: ["visitIRInlinedIfNil:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedIfNil);
- smalltalk.addClass('IRInlinedIfTrue', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- smalltalk.send(aVisitor,"_visitIRInlinedIfTrue_",[self]);
- return self;},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrue: self",
- messageSends: ["visitIRInlinedIfTrue:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedIfTrue);
- smalltalk.addClass('IRInlinedIfTrueIfFalse', smalltalk.IRInlinedSend, [], 'Compiler-Inlining');
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- smalltalk.send(aVisitor,"_visitIRInlinedIfTrueIfFalse_",[self]);
- return self;},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedIfTrueIfFalse: self",
- messageSends: ["visitIRInlinedIfTrueIfFalse:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedIfTrueIfFalse);
- smalltalk.addClass('IRInlinedSequence', smalltalk.IRBlockSequence, [], 'Compiler-Inlining');
- smalltalk.IRInlinedSequence.comment="I represent a (block) sequence inside an inlined closure instruction (instance of `IRInlinedClosure`)."
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- smalltalk.send(aVisitor,"_visitIRInlinedSequence_",[self]);
- return self;},
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09aVisitor visitIRInlinedSequence: self",
- messageSends: ["visitIRInlinedSequence:"],
- referencedClasses: []
- }),
- smalltalk.IRInlinedSequence);
- smalltalk.addMethod(
- "_isInlined",
- smalltalk.method({
- selector: "isInlined",
- category: 'testing',
- fn: function () {
- var self=this;
- return true;
- },
- args: [],
- source: "isInlined\x0a\x09^ true",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRInlinedSequence);
- smalltalk.addClass('IRAssigningInlinedSequence', smalltalk.IRInlinedSequence, ['assignTo'], 'Compiler-Inlining');
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'accessing',
- fn: function (aVisitor) {
- var self=this;
- return smalltalk.send(aVisitor,"_visitIRAssigningInlinedSequence_",[self]);
- },
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRAssigningInlinedSequence: self",
- messageSends: ["visitIRAssigningInlinedSequence:"],
- referencedClasses: []
- }),
- smalltalk.IRAssigningInlinedSequence);
- smalltalk.addMethod(
- "_assignTo",
- smalltalk.method({
- selector: "assignTo",
- category: 'accessing',
- fn: function () {
- var self=this;
- return self["@assignTo"];
- },
- args: [],
- source: "assignTo\x0a\x09^ assignTo",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRAssigningInlinedSequence);
- smalltalk.addMethod(
- "_assignTo_",
- smalltalk.method({
- selector: "assignTo:",
- category: 'accessing',
- fn: function (anIRInstruction) {
- var self=this;
- self["@assignTo"]=anIRInstruction;
- return self;},
- args: ["anIRInstruction"],
- source: "assignTo: anIRInstruction\x0a\x09assignTo := anIRInstruction",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRAssigningInlinedSequence);
- smalltalk.addClass('IRReturningInlinedSequence', smalltalk.IRInlinedSequence, [], 'Compiler-Inlining');
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- return smalltalk.send(aVisitor,"_visitIRReturningInlinedSequence_",[self]);
- },
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRReturningInlinedSequence: self",
- messageSends: ["visitIRReturningInlinedSequence:"],
- referencedClasses: []
- }),
- smalltalk.IRReturningInlinedSequence);
- smalltalk.addClass('IRNonLocalReturningInlinedSequence', smalltalk.IRReturningInlinedSequence, [], 'Compiler-Inlining');
- smalltalk.addMethod(
- "_accept_",
- smalltalk.method({
- selector: "accept:",
- category: 'visiting',
- fn: function (aVisitor) {
- var self=this;
- return smalltalk.send(aVisitor,"_visitIRNonLocalReturningInlinedSequence_",[self]);
- },
- args: ["aVisitor"],
- source: "accept: aVisitor\x0a\x09^ aVisitor visitIRNonLocalReturningInlinedSequence: self",
- messageSends: ["visitIRNonLocalReturningInlinedSequence:"],
- referencedClasses: []
- }),
- smalltalk.IRNonLocalReturningInlinedSequence);
- smalltalk.addClass('IRInliner', smalltalk.IRVisitor, [], 'Compiler-Inlining');
- smalltalk.IRInliner.comment="I visit an IR tree, inlining message sends and block closures.\x0a\x0aMessage selectors that can be inlined are answered by `IRSendInliner >> #inlinedSelectors`"
- smalltalk.addMethod(
- "_assignmentInliner",
- smalltalk.method({
- selector: "assignmentInliner",
- category: 'factory',
- fn: function () {
- var self=this;
- var $1,$2;
- $1=smalltalk.send((smalltalk.IRAssignmentInliner || IRAssignmentInliner),"_new",[]);
- smalltalk.send($1,"_translator_",[self]);
- $2=smalltalk.send($1,"_yourself",[]);
- return $2;
- },
- args: [],
- source: "assignmentInliner\x0a\x09^ IRAssignmentInliner new \x0a\x09\x09translator: self;\x0a\x09\x09yourself",
- messageSends: ["translator:", "new", "yourself"],
- referencedClasses: ["IRAssignmentInliner"]
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_nonLocalReturnInliner",
- smalltalk.method({
- selector: "nonLocalReturnInliner",
- category: 'factory',
- fn: function () {
- var self=this;
- var $1,$2;
- $1=smalltalk.send((smalltalk.IRNonLocalReturnInliner || IRNonLocalReturnInliner),"_new",[]);
- smalltalk.send($1,"_translator_",[self]);
- $2=smalltalk.send($1,"_yourself",[]);
- return $2;
- },
- args: [],
- source: "nonLocalReturnInliner\x0a\x09^ IRNonLocalReturnInliner new \x0a\x09\x09translator: self;\x0a\x09\x09yourself",
- messageSends: ["translator:", "new", "yourself"],
- referencedClasses: ["IRNonLocalReturnInliner"]
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_returnInliner",
- smalltalk.method({
- selector: "returnInliner",
- category: 'factory',
- fn: function () {
- var self=this;
- var $1,$2;
- $1=smalltalk.send((smalltalk.IRReturnInliner || IRReturnInliner),"_new",[]);
- smalltalk.send($1,"_translator_",[self]);
- $2=smalltalk.send($1,"_yourself",[]);
- return $2;
- },
- args: [],
- source: "returnInliner\x0a\x09^ IRReturnInliner new \x0a\x09\x09translator: self;\x0a\x09\x09yourself",
- messageSends: ["translator:", "new", "yourself"],
- referencedClasses: ["IRReturnInliner"]
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_sendInliner",
- smalltalk.method({
- selector: "sendInliner",
- category: 'factory',
- fn: function () {
- var self=this;
- var $1,$2;
- $1=smalltalk.send((smalltalk.IRSendInliner || IRSendInliner),"_new",[]);
- smalltalk.send($1,"_translator_",[self]);
- $2=smalltalk.send($1,"_yourself",[]);
- return $2;
- },
- args: [],
- source: "sendInliner\x0a\x09^ IRSendInliner new \x0a\x09\x09translator: self;\x0a\x09\x09yourself",
- messageSends: ["translator:", "new", "yourself"],
- referencedClasses: ["IRSendInliner"]
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_shouldInlineAssignment_",
- smalltalk.method({
- selector: "shouldInlineAssignment:",
- category: 'testing',
- fn: function (anIRAssignment) {
- var self=this;
- return smalltalk.send(smalltalk.send(smalltalk.send(anIRAssignment,"_isInlined",[]),"_not",[]),"_and_",[(function(){
- return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRAssignment,"_instructions",[]),"_last",[]),"_isSend",[]),"_and_",[(function(){
- return smalltalk.send(self,"_shouldInlineSend_",[smalltalk.send(smalltalk.send(anIRAssignment,"_instructions",[]),"_last",[])]);
- })]);
- })]);
- },
- args: ["anIRAssignment"],
- source: "shouldInlineAssignment: anIRAssignment\x0a\x09^ anIRAssignment isInlined not and: [ \x0a\x09\x09anIRAssignment instructions last isSend and: [\x09\x0a\x09\x09\x09self shouldInlineSend: (anIRAssignment instructions last) ]]",
- messageSends: ["and:", "shouldInlineSend:", "last", "instructions", "isSend", "not", "isInlined"],
- referencedClasses: []
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_shouldInlineReturn_",
- smalltalk.method({
- selector: "shouldInlineReturn:",
- category: 'testing',
- fn: function (anIRReturn) {
- var self=this;
- return smalltalk.send(smalltalk.send(smalltalk.send(anIRReturn,"_isInlined",[]),"_not",[]),"_and_",[(function(){
- return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRReturn,"_instructions",[]),"_first",[]),"_isSend",[]),"_and_",[(function(){
- return smalltalk.send(self,"_shouldInlineSend_",[smalltalk.send(smalltalk.send(anIRReturn,"_instructions",[]),"_first",[])]);
- })]);
- })]);
- },
- args: ["anIRReturn"],
- source: "shouldInlineReturn: anIRReturn\x0a\x09^ anIRReturn isInlined not and: [ \x0a\x09\x09anIRReturn instructions first isSend and: [\x09\x0a\x09\x09\x09self shouldInlineSend: (anIRReturn instructions first) ]]",
- messageSends: ["and:", "shouldInlineSend:", "first", "instructions", "isSend", "not", "isInlined"],
- referencedClasses: []
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_shouldInlineSend_",
- smalltalk.method({
- selector: "shouldInlineSend:",
- category: 'testing',
- fn: function (anIRSend) {
- var self=this;
- return smalltalk.send(smalltalk.send(smalltalk.send(anIRSend,"_isInlined",[]),"_not",[]),"_and_",[(function(){
- return smalltalk.send((smalltalk.IRSendInliner || IRSendInliner),"_shouldInline_",[anIRSend]);
- })]);
- },
- args: ["anIRSend"],
- source: "shouldInlineSend: anIRSend\x0a\x09^ anIRSend isInlined not and: [\x0a\x09\x09IRSendInliner shouldInline: anIRSend ]",
- messageSends: ["and:", "shouldInline:", "not", "isInlined"],
- referencedClasses: ["IRSendInliner"]
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_transformNonLocalReturn_",
- smalltalk.method({
- selector: "transformNonLocalReturn:",
- category: 'visiting',
- fn: function (anIRNonLocalReturn) {
- var self=this;
- var $1,$2;
- var localReturn;
- if(smalltalk.assert(smalltalk.send(smalltalk.send(anIRNonLocalReturn,"_scope",[]),"_canInlineNonLocalReturns",[]))){
- smalltalk.send(smalltalk.send(smalltalk.send(anIRNonLocalReturn,"_scope",[]),"_methodScope",[]),"_removeNonLocalReturn_",[smalltalk.send(anIRNonLocalReturn,"_scope",[])]);
- $1=smalltalk.send((smalltalk.IRReturn || IRReturn),"_new",[]);
- smalltalk.send($1,"_scope_",[smalltalk.send(anIRNonLocalReturn,"_scope",[])]);
- $2=smalltalk.send($1,"_yourself",[]);
- localReturn=$2;
- localReturn;
- smalltalk.send(smalltalk.send(anIRNonLocalReturn,"_instructions",[]),"_do_",[(function(each){
- return smalltalk.send(localReturn,"_add_",[each]);
- })]);
- smalltalk.send(anIRNonLocalReturn,"_replaceWith_",[localReturn]);
- return localReturn;
- };
- return smalltalk.send(self,"_visitIRNonLocalReturn_",[anIRNonLocalReturn],smalltalk.IRVisitor);
- },
- args: ["anIRNonLocalReturn"],
- 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",
- messageSends: ["ifTrue:", "removeNonLocalReturn:", "scope", "methodScope", "scope:", "new", "yourself", "do:", "add:", "instructions", "replaceWith:", "canInlineNonLocalReturns", "visitIRNonLocalReturn:"],
- referencedClasses: ["IRReturn"]
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_visitIRAssignment_",
- smalltalk.method({
- selector: "visitIRAssignment:",
- category: 'visiting',
- fn: function (anIRAssignment) {
- var self=this;
- return smalltalk.send(smalltalk.send(self,"_shouldInlineAssignment_",[anIRAssignment]),"_ifTrue_ifFalse_",[(function(){
- return smalltalk.send(smalltalk.send(self,"_assignmentInliner",[]),"_inlineAssignment_",[anIRAssignment]);
- }),(function(){
- return smalltalk.send(self,"_visitIRAssignment_",[anIRAssignment],smalltalk.IRVisitor);
- })]);
- },
- args: ["anIRAssignment"],
- source: "visitIRAssignment: anIRAssignment\x0a\x09^ (self shouldInlineAssignment: anIRAssignment) \x0a\x09\x09ifTrue: [ self assignmentInliner inlineAssignment: anIRAssignment ]\x0a\x09\x09ifFalse: [ super visitIRAssignment: anIRAssignment ]",
- messageSends: ["ifTrue:ifFalse:", "inlineAssignment:", "assignmentInliner", "visitIRAssignment:", "shouldInlineAssignment:"],
- referencedClasses: []
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_visitIRNonLocalReturn_",
- smalltalk.method({
- selector: "visitIRNonLocalReturn:",
- category: 'visiting',
- fn: function (anIRNonLocalReturn) {
- var self=this;
- return smalltalk.send(smalltalk.send(self,"_shouldInlineReturn_",[anIRNonLocalReturn]),"_ifTrue_ifFalse_",[(function(){
- return smalltalk.send(smalltalk.send(self,"_nonLocalReturnInliner",[]),"_inlineReturn_",[anIRNonLocalReturn]);
- }),(function(){
- return smalltalk.send(self,"_transformNonLocalReturn_",[anIRNonLocalReturn]);
- })]);
- },
- args: ["anIRNonLocalReturn"],
- source: "visitIRNonLocalReturn: anIRNonLocalReturn\x0a\x09^ (self shouldInlineReturn: anIRNonLocalReturn) \x0a\x09\x09ifTrue: [ self nonLocalReturnInliner inlineReturn: anIRNonLocalReturn ]\x0a\x09\x09ifFalse: [ self transformNonLocalReturn: anIRNonLocalReturn ]",
- messageSends: ["ifTrue:ifFalse:", "inlineReturn:", "nonLocalReturnInliner", "transformNonLocalReturn:", "shouldInlineReturn:"],
- referencedClasses: []
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_visitIRReturn_",
- smalltalk.method({
- selector: "visitIRReturn:",
- category: 'visiting',
- fn: function (anIRReturn) {
- var self=this;
- return smalltalk.send(smalltalk.send(self,"_shouldInlineReturn_",[anIRReturn]),"_ifTrue_ifFalse_",[(function(){
- return smalltalk.send(smalltalk.send(self,"_returnInliner",[]),"_inlineReturn_",[anIRReturn]);
- }),(function(){
- return smalltalk.send(self,"_visitIRReturn_",[anIRReturn],smalltalk.IRVisitor);
- })]);
- },
- args: ["anIRReturn"],
- source: "visitIRReturn: anIRReturn\x0a\x09^ (self shouldInlineReturn: anIRReturn) \x0a\x09\x09ifTrue: [ self returnInliner inlineReturn: anIRReturn ]\x0a\x09\x09ifFalse: [ super visitIRReturn: anIRReturn ]",
- messageSends: ["ifTrue:ifFalse:", "inlineReturn:", "returnInliner", "visitIRReturn:", "shouldInlineReturn:"],
- referencedClasses: []
- }),
- smalltalk.IRInliner);
- smalltalk.addMethod(
- "_visitIRSend_",
- smalltalk.method({
- selector: "visitIRSend:",
- category: 'visiting',
- fn: function (anIRSend) {
- var self=this;
- return smalltalk.send(smalltalk.send(self,"_shouldInlineSend_",[anIRSend]),"_ifTrue_ifFalse_",[(function(){
- return smalltalk.send(smalltalk.send(self,"_sendInliner",[]),"_inlineSend_",[anIRSend]);
- }),(function(){
- return smalltalk.send(self,"_visitIRSend_",[anIRSend],smalltalk.IRVisitor);
- })]);
- },
- args: ["anIRSend"],
- source: "visitIRSend: anIRSend\x0a\x09^ (self shouldInlineSend: anIRSend)\x0a\x09\x09ifTrue: [ self sendInliner inlineSend: anIRSend ]\x0a\x09\x09ifFalse: [ super visitIRSend: anIRSend ]",
- messageSends: ["ifTrue:ifFalse:", "inlineSend:", "sendInliner", "visitIRSend:", "shouldInlineSend:"],
- referencedClasses: []
- }),
- smalltalk.IRInliner);
- smalltalk.addClass('IRInliningJSTranslator', smalltalk.IRJSTranslator, [], 'Compiler-Inlining');
- smalltalk.IRInliningJSTranslator.comment="I am a specialized JavaScript translator able to write inlined IR instructions to JavaScript stream (`JSStream` instance)."
- smalltalk.addMethod(
- "_visitIRAssigningInlinedSequence_",
- smalltalk.method({
- selector: "visitIRAssigningInlinedSequence:",
- category: 'visiting',
- fn: function (anIRInlinedSequence) {
- var self=this;
- var $1,$2;
- smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_allButLast",[]),"_do_",[(function(each){
- return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
- return smalltalk.send(self,"_visit_",[each]);
- })]);
- })]);
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
- return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[]),"_canBeAssigned",[]),"_ifTrue_ifFalse_",[(function(){
- $1=smalltalk.send(self,"_stream",[]);
- smalltalk.send($1,"_nextPutAll_",[smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_assignTo",[]),"_variable",[]),"_alias",[])]);
- $2=smalltalk.send($1,"_nextPutAssignment",[]);
- $2;
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
- }),(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
- })]);
- })]);
- return self;},
- args: ["anIRInlinedSequence"],
- source: "visitIRAssigningInlinedSequence: anIRInlinedSequence\x0a\x0a\x09anIRInlinedSequence instructions allButLast do: [ :each | \x0a\x09\x09self stream nextPutStatementWith: [ self visit: each ]].\x0a\x0a\x09self stream nextPutStatementWith: [\x0a\x09\x09anIRInlinedSequence instructions last canBeAssigned \x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09self stream \x0a\x09\x09\x09\x09\x09nextPutAll: anIRInlinedSequence assignTo variable alias;\x0a \x09nextPutAssignment.\x0a\x09\x09\x09\x09self visit: anIRInlinedSequence instructions last ]\x0a\x09\x09\x09ifFalse: [ self visit: anIRInlinedSequence instructions last ]]",
- messageSends: ["do:", "nextPutStatementWith:", "visit:", "stream", "allButLast", "instructions", "ifTrue:ifFalse:", "nextPutAll:", "alias", "variable", "assignTo", "nextPutAssignment", "last", "canBeAssigned"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRInlinedAssignment_",
- smalltalk.method({
- selector: "visitIRInlinedAssignment:",
- category: 'visiting',
- fn: function (anIRInlinedAssignment) {
- var self=this;
- smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedAssignment,"_instructions",[]),"_last",[])]);
- return self;},
- args: ["anIRInlinedAssignment"],
- source: "visitIRInlinedAssignment: anIRInlinedAssignment\x0a\x09self visit: anIRInlinedAssignment instructions last",
- messageSends: ["visit:", "last", "instructions"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRInlinedClosure_",
- smalltalk.method({
- selector: "visitIRInlinedClosure:",
- category: 'visiting',
- fn: function (anIRInlinedClosure) {
- var self=this;
- smalltalk.send(smalltalk.send(anIRInlinedClosure,"_instructions",[]),"_do_",[(function(each){
- return smalltalk.send(self,"_visit_",[each]);
- })]);
- return self;},
- args: ["anIRInlinedClosure"],
- source: "visitIRInlinedClosure: anIRInlinedClosure\x0a\x09anIRInlinedClosure instructions do: [ :each |\x0a\x09\x09self visit: each ]",
- messageSends: ["do:", "visit:", "instructions"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRInlinedIfFalse_",
- smalltalk.method({
- selector: "visitIRInlinedIfFalse:",
- category: 'visiting',
- fn: function (anIRInlinedIfFalse) {
- var self=this;
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutIf_with_",[(function(){
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",["! smalltalk.assert("]);
- smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfFalse,"_instructions",[]),"_first",[])]);
- return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",[")"]);
- }),(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfFalse,"_instructions",[]),"_last",[])]);
- })]);
- return self;},
- args: ["anIRInlinedIfFalse"],
- 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 ]",
- messageSends: ["nextPutIf:with:", "nextPutAll:", "stream", "visit:", "first", "instructions", "last"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRInlinedIfNil_",
- smalltalk.method({
- selector: "visitIRInlinedIfNil:",
- category: 'visiting',
- fn: function (anIRInlinedIfNil) {
- var self=this;
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutIf_with_",[(function(){
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",["($receiver = "]);
- smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfNil,"_instructions",[]),"_first",[])]);
- return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",[") == nil || $receiver == undefined"]);
- }),(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfNil,"_instructions",[]),"_last",[])]);
- })]);
- return self;},
- args: ["anIRInlinedIfNil"],
- source: "visitIRInlinedIfNil: anIRInlinedIfNil\x0a\x09self stream nextPutIf: [ \x0a\x09\x09self stream nextPutAll: '($receiver = '. \x0a\x09\x09self visit: anIRInlinedIfNil instructions first.\x0a\x09\x09self stream nextPutAll: ') == nil || $receiver == undefined' ]\x0a\x09\x09with: [ self visit: anIRInlinedIfNil instructions last ]",
- messageSends: ["nextPutIf:with:", "nextPutAll:", "stream", "visit:", "first", "instructions", "last"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRInlinedIfTrue_",
- smalltalk.method({
- selector: "visitIRInlinedIfTrue:",
- category: 'visiting',
- fn: function (anIRInlinedIfTrue) {
- var self=this;
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutIf_with_",[(function(){
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",["smalltalk.assert("]);
- smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfTrue,"_instructions",[]),"_first",[])]);
- return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",[")"]);
- }),(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfTrue,"_instructions",[]),"_last",[])]);
- })]);
- return self;},
- args: ["anIRInlinedIfTrue"],
- 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 ]",
- messageSends: ["nextPutIf:with:", "nextPutAll:", "stream", "visit:", "first", "instructions", "last"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRInlinedIfTrueIfFalse_",
- smalltalk.method({
- selector: "visitIRInlinedIfTrueIfFalse:",
- category: 'visiting',
- fn: function (anIRInlinedIfTrueIfFalse) {
- var self=this;
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutIfElse_with_with_",[(function(){
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",["smalltalk.assert("]);
- smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfTrueIfFalse,"_instructions",[]),"_first",[])]);
- return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutAll_",[")"]);
- }),(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfTrueIfFalse,"_instructions",[]),"_second",[])]);
- }),(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedIfTrueIfFalse,"_instructions",[]),"_third",[])]);
- })]);
- return self;},
- args: ["anIRInlinedIfTrueIfFalse"],
- 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 ]",
- messageSends: ["nextPutIfElse:with:with:", "nextPutAll:", "stream", "visit:", "first", "instructions", "second", "third"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRInlinedNonLocalReturn_",
- smalltalk.method({
- selector: "visitIRInlinedNonLocalReturn:",
- category: 'visiting',
- fn: function (anIRInlinedReturn) {
- var self=this;
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedReturn,"_instructions",[]),"_last",[])]);
- })]);
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutNonLocalReturnWith_",[(function(){
- })]);
- return self;},
- args: ["anIRInlinedReturn"],
- source: "visitIRInlinedNonLocalReturn: anIRInlinedReturn\x0a\x09self stream nextPutStatementWith: [\x0a\x09\x09self visit: anIRInlinedReturn instructions last ].\x0a\x09self stream nextPutNonLocalReturnWith: [ ]",
- messageSends: ["nextPutStatementWith:", "visit:", "last", "instructions", "stream", "nextPutNonLocalReturnWith:"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRInlinedReturn_",
- smalltalk.method({
- selector: "visitIRInlinedReturn:",
- category: 'visiting',
- fn: function (anIRInlinedReturn) {
- var self=this;
- smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedReturn,"_instructions",[]),"_last",[])]);
- return self;},
- args: ["anIRInlinedReturn"],
- source: "visitIRInlinedReturn: anIRInlinedReturn\x0a\x09self visit: anIRInlinedReturn instructions last",
- messageSends: ["visit:", "last", "instructions"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRInlinedSequence_",
- smalltalk.method({
- selector: "visitIRInlinedSequence:",
- category: 'visiting',
- fn: function (anIRInlinedSequence) {
- var self=this;
- smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_do_",[(function(each){
- return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
- return smalltalk.send(self,"_visit_",[each]);
- })]);
- })]);
- return self;},
- args: ["anIRInlinedSequence"],
- source: "visitIRInlinedSequence: anIRInlinedSequence\x0a\x09anIRInlinedSequence instructions do: [ :each | \x0a\x09\x09self stream nextPutStatementWith: [ self visit: each ]]",
- messageSends: ["do:", "nextPutStatementWith:", "visit:", "stream", "instructions"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRNonLocalReturningInlinedSequence_",
- smalltalk.method({
- selector: "visitIRNonLocalReturningInlinedSequence:",
- category: 'visiting',
- fn: function (anIRInlinedSequence) {
- var self=this;
- smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_allButLast",[]),"_do_",[(function(each){
- return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
- return smalltalk.send(self,"_visit_",[each]);
- })]);
- })]);
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
- return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[]),"_canBeAssigned",[]),"_ifTrue_ifFalse_",[(function(){
- return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutNonLocalReturnWith_",[(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
- })]);
- }),(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
- })]);
- })]);
- return self;},
- args: ["anIRInlinedSequence"],
- source: "visitIRNonLocalReturningInlinedSequence: anIRInlinedSequence\x0a\x0a\x09anIRInlinedSequence instructions allButLast do: [ :each | \x0a\x09\x09self stream nextPutStatementWith: [ self visit: each ]].\x0a\x0a\x09self stream nextPutStatementWith: [\x0a\x09\x09anIRInlinedSequence instructions last canBeAssigned \x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09self stream nextPutNonLocalReturnWith: [\x0a\x09\x09\x09\x09\x09self visit: anIRInlinedSequence instructions last ]]\x0a\x09\x09\x09ifFalse: [ self visit: anIRInlinedSequence instructions last ]]",
- messageSends: ["do:", "nextPutStatementWith:", "visit:", "stream", "allButLast", "instructions", "ifTrue:ifFalse:", "nextPutNonLocalReturnWith:", "last", "canBeAssigned"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addMethod(
- "_visitIRReturningInlinedSequence_",
- smalltalk.method({
- selector: "visitIRReturningInlinedSequence:",
- category: 'visiting',
- fn: function (anIRInlinedSequence) {
- var self=this;
- smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_allButLast",[]),"_do_",[(function(each){
- return smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
- return smalltalk.send(self,"_visit_",[each]);
- })]);
- })]);
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutStatementWith_",[(function(){
- return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[]),"_canBeAssigned",[]),"_ifTrue_ifFalse_",[(function(){
- smalltalk.send(smalltalk.send(self,"_stream",[]),"_nextPutReturn",[]);
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
- }),(function(){
- return smalltalk.send(self,"_visit_",[smalltalk.send(smalltalk.send(anIRInlinedSequence,"_instructions",[]),"_last",[])]);
- })]);
- })]);
- return self;},
- args: ["anIRInlinedSequence"],
- source: "visitIRReturningInlinedSequence: anIRInlinedSequence\x0a\x0a\x09anIRInlinedSequence instructions allButLast do: [ :each | \x0a\x09\x09self stream nextPutStatementWith: [ self visit: each ]].\x0a\x0a\x09self stream nextPutStatementWith: [\x0a\x09\x09anIRInlinedSequence instructions last canBeAssigned \x0a\x09\x09\x09ifTrue: [\x0a\x09\x09\x09\x09self stream nextPutReturn.\x0a\x09\x09\x09\x09self visit: anIRInlinedSequence instructions last ]\x0a\x09\x09\x09ifFalse: [ self visit: anIRInlinedSequence instructions last ]]",
- messageSends: ["do:", "nextPutStatementWith:", "visit:", "stream", "allButLast", "instructions", "ifTrue:ifFalse:", "nextPutReturn", "last", "canBeAssigned"],
- referencedClasses: []
- }),
- smalltalk.IRInliningJSTranslator);
- smalltalk.addClass('IRSendInliner', smalltalk.Object, ['send', 'translator'], 'Compiler-Inlining');
- smalltalk.IRSendInliner.comment="I inline some message sends and block closure arguments. I heavily rely on #perform: to dispatch inlining methods."
- smalltalk.addMethod(
- "_ifFalse_",
- smalltalk.method({
- selector: "ifFalse:",
- category: 'inlining',
- fn: function (anIRInstruction) {
- var self=this;
- return smalltalk.send(self,"_inlinedSend_with_",[smalltalk.send((smalltalk.IRInlinedIfFalse || IRInlinedIfFalse),"_new",[]),anIRInstruction]);
- },
- args: ["anIRInstruction"],
- source: "ifFalse: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfFalse new with: anIRInstruction",
- messageSends: ["inlinedSend:with:", "new"],
- referencedClasses: ["IRInlinedIfFalse"]
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_ifFalse_ifTrue_",
- smalltalk.method({
- selector: "ifFalse:ifTrue:",
- category: 'inlining',
- fn: function (anIRInstruction, anotherIRInstruction) {
- var self=this;
- return smalltalk.send(self,"_perform_withArguments_",[smalltalk.symbolFor("ifTrue:ifFalse:"),[anotherIRInstruction,anIRInstruction]]);
- },
- args: ["anIRInstruction", "anotherIRInstruction"],
- source: "ifFalse: anIRInstruction ifTrue: anotherIRInstruction\x0a\x09^ self perform: #ifTrue:ifFalse: withArguments: { anotherIRInstruction. anIRInstruction }",
- messageSends: ["perform:withArguments:"],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_ifNil_",
- smalltalk.method({
- selector: "ifNil:",
- category: 'inlining',
- fn: function (anIRInstruction) {
- var self=this;
- return smalltalk.send(self,"_inlinedSend_with_",[smalltalk.send((smalltalk.IRInlinedIfNil || IRInlinedIfNil),"_new",[]),anIRInstruction]);
- },
- args: ["anIRInstruction"],
- source: "ifNil: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfNil new with: anIRInstruction",
- messageSends: ["inlinedSend:with:", "new"],
- referencedClasses: ["IRInlinedIfNil"]
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_ifTrue_",
- smalltalk.method({
- selector: "ifTrue:",
- category: 'inlining',
- fn: function (anIRInstruction) {
- var self=this;
- return smalltalk.send(self,"_inlinedSend_with_",[smalltalk.send((smalltalk.IRInlinedIfTrue || IRInlinedIfTrue),"_new",[]),anIRInstruction]);
- },
- args: ["anIRInstruction"],
- source: "ifTrue: anIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrue new with: anIRInstruction",
- messageSends: ["inlinedSend:with:", "new"],
- referencedClasses: ["IRInlinedIfTrue"]
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_ifTrue_ifFalse_",
- smalltalk.method({
- selector: "ifTrue:ifFalse:",
- category: 'inlining',
- fn: function (anIRInstruction, anotherIRInstruction) {
- var self=this;
- return smalltalk.send(self,"_inlinedSend_with_with_",[smalltalk.send((smalltalk.IRInlinedIfTrueIfFalse || IRInlinedIfTrueIfFalse),"_new",[]),anIRInstruction,anotherIRInstruction]);
- },
- args: ["anIRInstruction", "anotherIRInstruction"],
- source: "ifTrue: anIRInstruction ifFalse: anotherIRInstruction\x0a\x09^ self inlinedSend: IRInlinedIfTrueIfFalse new with: anIRInstruction with: anotherIRInstruction",
- messageSends: ["inlinedSend:with:with:", "new"],
- referencedClasses: ["IRInlinedIfTrueIfFalse"]
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_inlineClosure_",
- smalltalk.method({
- selector: "inlineClosure:",
- category: 'inlining',
- fn: function (anIRClosure) {
- var self=this;
- var inlinedClosure;
- var sequence;
- var statements;
- inlinedClosure=smalltalk.send(self,"_inlinedClosure",[]);
- smalltalk.send(inlinedClosure,"_scope_",[smalltalk.send(anIRClosure,"_scope",[])]);
- smalltalk.send(smalltalk.send(anIRClosure,"_instructions",[]),"_do_",[(function(each){
- if(! smalltalk.assert(smalltalk.send(each,"_isSequence",[]))){
- return smalltalk.send(inlinedClosure,"_add_",[each]);
- };
- })]);
- sequence=smalltalk.send(self,"_inlinedSequence",[]);
- smalltalk.send(inlinedClosure,"_add_",[sequence]);
- statements=smalltalk.send(smalltalk.send(smalltalk.send(anIRClosure,"_instructions",[]),"_last",[]),"_instructions",[]);
- smalltalk.send(statements,"_ifNotEmpty_",[(function(){
- smalltalk.send(smalltalk.send(statements,"_allButLast",[]),"_do_",[(function(each){
- return smalltalk.send(sequence,"_add_",[smalltalk.send(smalltalk.send(self,"_translator",[]),"_visit_",[each])]);
- })]);
- return smalltalk.send(smalltalk.send(smalltalk.send(statements,"_last",[]),"_isLocalReturn",[]),"_ifTrue_ifFalse_",[(function(){
- return smalltalk.send(sequence,"_add_",[smalltalk.send(smalltalk.send(self,"_translator",[]),"_visit_",[smalltalk.send(smalltalk.send(smalltalk.send(statements,"_last",[]),"_instructions",[]),"_first",[])])]);
- }),(function(){
- return smalltalk.send(sequence,"_add_",[smalltalk.send(smalltalk.send(self,"_translator",[]),"_visit_",[smalltalk.send(statements,"_last",[])])]);
- })]);
- })]);
- return inlinedClosure;
- },
- args: ["anIRClosure"],
- source: "inlineClosure: anIRClosure\x0a\x09| inlinedClosure sequence statements |\x0a\x09inlinedClosure := self inlinedClosure.\x0a\x09inlinedClosure scope: anIRClosure scope.\x0a\x0a\x09\x22Add the possible temp declarations\x22\x0a\x09anIRClosure instructions do: [ :each | \x0a\x09\x09each isSequence ifFalse: [\x0a\x09\x09\x09inlinedClosure add: each ]].\x0a\x0a\x09\x22Add a block sequence\x22\x0a\x09sequence := self inlinedSequence.\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: (self translator visit: each) ].\x0a\x09\x09\x22Inlined closures don't have implicit local returns\x22\x0a\x09\x09statements last isLocalReturn \x0a\x09\x09\x09ifTrue: [ sequence add: (self translator visit: statements last instructions first) ]\x0a\x09\x09\x09ifFalse: [ sequence add: (self translator visit: statements last) ]].\x0a\x0a\x09^ inlinedClosure",
- messageSends: ["inlinedClosure", "scope:", "scope", "do:", "ifFalse:", "add:", "isSequence", "instructions", "inlinedSequence", "last", "ifNotEmpty:", "visit:", "translator", "allButLast", "ifTrue:ifFalse:", "first", "isLocalReturn"],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_inlineMessageBlock_with_",
- smalltalk.method({
- selector: "inlineMessageBlock:with:",
- category: 'inlining',
- fn: function (anIRInstruction, anotherIRInstruction) {
- var self=this;
- var $1;
- var inlinedSend;
- var inlinedClosure;
- if(! smalltalk.assert(smalltalk.send(anIRInstruction,"_isClosure",[]))){
- smalltalk.send(self,"_inliningError_",["Message argument should be a block"]);
- };
- if(! smalltalk.assert(smalltalk.send(smalltalk.send(smalltalk.send(anIRInstruction,"_arguments",[]),"_size",[]),"__eq",[(0)]))){
- smalltalk.send(self,"_inliningError_",["Inlined block should have zero argument"]);
- };
- inlinedClosure=smalltalk.send(self,"_inlineClosure_",[anIRInstruction]);
- inlinedSend=anotherIRInstruction;
- smalltalk.send(inlinedSend,"_add_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_send",[]),"_instructions",[]),"_first",[])]);
- $1=smalltalk.send(inlinedSend,"_add_",[inlinedClosure]);
- smalltalk.send(smalltalk.send(self,"_send",[]),"_replaceWith_",[inlinedSend]);
- return inlinedSend;
- },
- args: ["anIRInstruction", "anotherIRInstruction"],
- source: "inlineMessageBlock: anIRInstruction with: anotherIRInstruction\x0a\x09| inlinedSend 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 inlineClosure: anIRInstruction.\x0a\x0a\x09inlinedSend := anotherIRInstruction.\x0a\x09inlinedSend\x0a\x09\x09add: self send instructions first;\x0a\x09\x09add: inlinedClosure.\x0a\x0a\x09self send replaceWith: inlinedSend.\x0a\x09^ inlinedSend",
- messageSends: ["ifFalse:", "inliningError:", "isClosure", "=", "size", "arguments", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:"],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_inlineSend_",
- smalltalk.method({
- selector: "inlineSend:",
- category: 'inlining',
- fn: function (anIRSend) {
- var self=this;
- smalltalk.send(self,"_send_",[anIRSend]);
- return smalltalk.send(self,"_perform_withArguments_",[smalltalk.send(smalltalk.send(self,"_send",[]),"_selector",[]),smalltalk.send(smalltalk.send(smalltalk.send(self,"_send",[]),"_instructions",[]),"_allButFirst",[])]);
- },
- args: ["anIRSend"],
- source: "inlineSend: anIRSend\x0a\x09self send: anIRSend.\x0a\x09^ self perform: self send selector withArguments: self send instructions allButFirst",
- messageSends: ["send:", "perform:withArguments:", "selector", "send", "allButFirst", "instructions"],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_inlinedClosure",
- smalltalk.method({
- selector: "inlinedClosure",
- category: 'factory',
- fn: function () {
- var self=this;
- return smalltalk.send((smalltalk.IRInlinedClosure || IRInlinedClosure),"_new",[]);
- },
- args: [],
- source: "inlinedClosure\x0a\x09^ IRInlinedClosure new",
- messageSends: ["new"],
- referencedClasses: ["IRInlinedClosure"]
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_inlinedSend_with_",
- smalltalk.method({
- selector: "inlinedSend:with:",
- category: 'inlining',
- fn: function (inlinedSend, anIRInstruction) {
- var self=this;
- var $1;
- var inlinedClosure;
- if(! smalltalk.assert(smalltalk.send(anIRInstruction,"_isClosure",[]))){
- smalltalk.send(self,"_inliningError_",["Message argument should be a block"]);
- };
- if(! smalltalk.assert(smalltalk.send(smalltalk.send(smalltalk.send(anIRInstruction,"_arguments",[]),"_size",[]),"__eq",[(0)]))){
- smalltalk.send(self,"_inliningError_",["Inlined block should have zero argument"]);
- };
- inlinedClosure=smalltalk.send(self,"_inlineClosure_",[anIRInstruction]);
- smalltalk.send(inlinedSend,"_add_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_send",[]),"_instructions",[]),"_first",[])]);
- $1=smalltalk.send(inlinedSend,"_add_",[inlinedClosure]);
- smalltalk.send(smalltalk.send(self,"_send",[]),"_replaceWith_",[inlinedSend]);
- return inlinedSend;
- },
- args: ["inlinedSend", "anIRInstruction"],
- 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 inlineClosure: anIRInstruction.\x0a\x0a\x09inlinedSend\x0a\x09\x09add: self send instructions first;\x0a\x09\x09add: inlinedClosure.\x0a\x0a\x09self send replaceWith: inlinedSend.\x0a\x09^ inlinedSend",
- messageSends: ["ifFalse:", "inliningError:", "isClosure", "=", "size", "arguments", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:"],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_inlinedSend_with_with_",
- smalltalk.method({
- selector: "inlinedSend:with:with:",
- category: 'inlining',
- fn: function (inlinedSend, anIRInstruction, anotherIRInstruction) {
- var self=this;
- var $1;
- var inlinedClosure1;
- var inclinedClosure2;
- if(! smalltalk.assert(smalltalk.send(anIRInstruction,"_isClosure",[]))){
- smalltalk.send(self,"_inliningError_",["Message argument should be a block"]);
- };
- if(! smalltalk.assert(smalltalk.send(smalltalk.send(smalltalk.send(anIRInstruction,"_arguments",[]),"_size",[]),"__eq",[(0)]))){
- smalltalk.send(self,"_inliningError_",["Inlined block should have zero argument"]);
- };
- if(! smalltalk.assert(smalltalk.send(anotherIRInstruction,"_isClosure",[]))){
- smalltalk.send(self,"_inliningError_",["Message argument should be a block"]);
- };
- if(! smalltalk.assert(smalltalk.send(smalltalk.send(smalltalk.send(anotherIRInstruction,"_arguments",[]),"_size",[]),"__eq",[(0)]))){
- smalltalk.send(self,"_inliningError_",["Inlined block should have zero argument"]);
- };
- inlinedClosure=smalltalk.send(self,"_inlineClosure_",[anIRInstruction]);
- inlinedClosure2=smalltalk.send(self,"_inlineClosure_",[anotherIRInstruction]);
- smalltalk.send(inlinedSend,"_add_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_send",[]),"_instructions",[]),"_first",[])]);
- smalltalk.send(inlinedSend,"_add_",[inlinedClosure]);
- $1=smalltalk.send(inlinedSend,"_add_",[inlinedClosure2]);
- smalltalk.send(smalltalk.send(self,"_send",[]),"_replaceWith_",[inlinedSend]);
- return inlinedSend;
- },
- args: ["inlinedSend", "anIRInstruction", "anotherIRInstruction"],
- source: "inlinedSend: inlinedSend with: anIRInstruction with: anotherIRInstruction\x0a\x09| inlinedClosure1 inclinedClosure2 |\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\x09anotherIRInstruction isClosure ifFalse: [ self inliningError: 'Message argument should be a block' ].\x0a\x09anotherIRInstruction arguments size = 0 ifFalse: [ self inliningError: 'Inlined block should have zero argument' ].\x0a\x0a\x09inlinedClosure := self inlineClosure: anIRInstruction.\x0a\x09inlinedClosure2 := self inlineClosure: anotherIRInstruction.\x0a\x0a\x09inlinedSend\x0a\x09\x09add: self send instructions first;\x0a\x09\x09add: inlinedClosure;\x0a\x09\x09add: inlinedClosure2.\x0a\x0a\x09self send replaceWith: inlinedSend.\x0a\x09^ inlinedSend",
- messageSends: ["ifFalse:", "inliningError:", "isClosure", "=", "size", "arguments", "inlineClosure:", "add:", "first", "instructions", "send", "replaceWith:"],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_inlinedSequence",
- smalltalk.method({
- selector: "inlinedSequence",
- category: 'factory',
- fn: function () {
- var self=this;
- return smalltalk.send((smalltalk.IRInlinedSequence || IRInlinedSequence),"_new",[]);
- },
- args: [],
- source: "inlinedSequence\x0a\x09^ IRInlinedSequence new",
- messageSends: ["new"],
- referencedClasses: ["IRInlinedSequence"]
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_inliningError_",
- smalltalk.method({
- selector: "inliningError:",
- category: 'error handling',
- fn: function (aString) {
- var self=this;
- smalltalk.send((smalltalk.InliningError || InliningError),"_signal_",[aString]);
- return self;},
- args: ["aString"],
- source: "inliningError: aString\x0a\x09InliningError signal: aString",
- messageSends: ["signal:"],
- referencedClasses: ["InliningError"]
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_send",
- smalltalk.method({
- selector: "send",
- category: 'accessing',
- fn: function () {
- var self=this;
- return self["@send"];
- },
- args: [],
- source: "send\x0a\x09^ send",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_send_",
- smalltalk.method({
- selector: "send:",
- category: 'accessing',
- fn: function (anIRSend) {
- var self=this;
- self["@send"]=anIRSend;
- return self;},
- args: ["anIRSend"],
- source: "send: anIRSend\x0a\x09send := anIRSend",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_translator",
- smalltalk.method({
- selector: "translator",
- category: 'accessing',
- fn: function () {
- var self=this;
- return self["@translator"];
- },
- args: [],
- source: "translator\x0a\x09^ translator",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_translator_",
- smalltalk.method({
- selector: "translator:",
- category: 'accessing',
- fn: function (anASTTranslator) {
- var self=this;
- self["@translator"]=anASTTranslator;
- return self;},
- args: ["anASTTranslator"],
- source: "translator: anASTTranslator\x0a\x09translator := anASTTranslator",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner);
- smalltalk.addMethod(
- "_inlinedSelectors",
- smalltalk.method({
- selector: "inlinedSelectors",
- category: 'accessing',
- fn: function () {
- var self=this;
- return ["ifTrue:", "ifFalse:", "ifTrue:ifFalse:", "ifFalse:ifTrue:", "ifNil:"];
- },
- args: [],
- source: "inlinedSelectors\x0a\x09^ #('ifTrue:' 'ifFalse:' 'ifTrue:ifFalse:' 'ifFalse:ifTrue:' 'ifNil:')",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner.klass);
- smalltalk.addMethod(
- "_shouldInline_",
- smalltalk.method({
- selector: "shouldInline:",
- category: 'accessing',
- fn: function (anIRInstruction) {
- var self=this;
- var $early={};
- try {
- if(! smalltalk.assert(smalltalk.send(smalltalk.send(self,"_inlinedSelectors",[]),"_includes_",[smalltalk.send(anIRInstruction,"_selector",[])]))){
- return false;
- };
- smalltalk.send(smalltalk.send(smalltalk.send(anIRInstruction,"_instructions",[]),"_allButFirst",[]),"_do_",[(function(each){
- if(! smalltalk.assert(smalltalk.send(each,"_isClosure",[]))){
- throw $early=[false];
- };
- })]);
- return true;
- }
- catch(e) {if(e===$early)return e[0]; throw e}
- },
- args: ["anIRInstruction"],
- 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",
- messageSends: ["ifFalse:", "includes:", "selector", "inlinedSelectors", "do:", "isClosure", "allButFirst", "instructions"],
- referencedClasses: []
- }),
- smalltalk.IRSendInliner.klass);
- smalltalk.addClass('IRAssignmentInliner', smalltalk.IRSendInliner, ['assignment'], 'Compiler-Inlining');
- smalltalk.IRAssignmentInliner.comment="I inline message sends together with assignments by moving them around into the inline closure instructions. \x0a\x0a##Example\x0a\x0a\x09foo\x0a\x09\x09| a |\x0a\x09\x09a := true ifTrue: [ 1 ]\x0a\x0aWill produce:\x0a\x0a\x09if(smalltalk.assert(true) {\x0a\x09\x09a = 1;\x0a\x09};"
- smalltalk.addMethod(
- "_assignment",
- smalltalk.method({
- selector: "assignment",
- category: 'accessing',
- fn: function () {
- var self=this;
- return self["@assignment"];
- },
- args: [],
- source: "assignment\x0a\x09^ assignment",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRAssignmentInliner);
- smalltalk.addMethod(
- "_assignment_",
- smalltalk.method({
- selector: "assignment:",
- category: 'accessing',
- fn: function (aNode) {
- var self=this;
- self["@assignment"]=aNode;
- return self;},
- args: ["aNode"],
- source: "assignment: aNode\x0a\x09assignment := aNode",
- messageSends: [],
- referencedClasses: []
- }),
- smalltalk.IRAssignmentInliner);
- smalltalk.addMethod(
- "_inlineAssignment_",
- smalltalk.method({
- selector: "inlineAssignment:",
- category: 'inlining',
- fn: function (anIRAssignment) {
- var self=this;
- var inlinedAssignment;
- smalltalk.send(self,"_assignment_",[anIRAssignment]);
- inlinedAssignment=smalltalk.send((smalltalk.IRInlinedAssignment || IRInlinedAssignment),"_new",[]);
- smalltalk.send(smalltalk.send(anIRAssignment,"_instructions",[]),"_do_",[(function(each){
- return smalltalk.send(inlinedAssignment,"_add_",[each]);
- })]);
- smalltalk.send(anIRAssignment,"_replaceWith_",[inlinedAssignment]);
- smalltalk.send(self,"_inlineSend_",[smalltalk.send(smalltalk.send(inlinedAssignment,"_instructions",[]),"_last",[])]);
- return inlinedAssignment;
- },
- args: ["anIRAssignment"],
- 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",
- messageSends: ["assignment:", "new", "do:", "add:", "instructions", "replaceWith:", "inlineSend:", "last"],
- referencedClasses: ["IRInlinedAssignment"]
- }),
- smalltalk.IRAssignmentInliner);
- smalltalk.addMethod(
- "_inlinedSequence",
- smalltalk.method({
- selector: "inlinedSequence",
- category: 'factory',
- fn: function () {
- var self=this;
- var $1,$2;
- $1=smalltalk.send((smalltalk.IRAssigningInlinedSequence || IRAssigningInlinedSequence),"_new",[]);
- smalltalk.send($1,"_assignTo_",[smalltalk.send(smalltalk.send(smalltalk.send(self,"_assignment",[]),"_instructions",[]),"_first",[])]);
- $2=smalltalk.send($1,"_yourself",[]);
- return $2;
- },
- args: [],
- source: "inlinedSequence\x0a\x09^ IRAssigningInlinedSequence new\x0a\x09\x09assignTo: self assignment instructions first;\x0a\x09\x09yourself",
- messageSends: ["assignTo:", "first", "instructions", "assignment", "new", "yourself"],
- referencedClasses: ["IRAssigningInlinedSequence"]
- }),
- smalltalk.IRAssignmentInliner);
- smalltalk.addClass('IRReturnInliner', smalltalk.IRSendInliner, [], 'Compiler-Inlining');
- smalltalk.IRReturnInliner.comment="I inline message sends with inlined closure together with a return instruction."
- smalltalk.addMethod(
- "_inlineReturn_",
- smalltalk.method({
- selector: "inlineReturn:",
- category: 'inlining',
- fn: function (anIRReturn) {
- var self=this;
- var return_;
- return_=smalltalk.send(self,"_inlinedReturn",[]);
- smalltalk.send(smalltalk.send(anIRReturn,"_instructions",[]),"_do_",[(function(each){
- return smalltalk.send(return_,"_add_",[each]);
- })]);
- smalltalk.send(anIRReturn,"_replaceWith_",[return_]);
- smalltalk.send(self,"_inlineSend_",[smalltalk.send(smalltalk.send(return_,"_instructions",[]),"_last",[])]);
- return return_;
- },
- args: ["anIRReturn"],
- 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",
- messageSends: ["inlinedReturn", "do:", "add:", "instructions", "replaceWith:", "inlineSend:", "last"],
- referencedClasses: []
- }),
- smalltalk.IRReturnInliner);
- smalltalk.addMethod(
- "_inlinedReturn",
- smalltalk.method({
- selector: "inlinedReturn",
- category: 'factory',
- fn: function () {
- var self=this;
- return smalltalk.send((smalltalk.IRInlinedReturn || IRInlinedReturn),"_new",[]);
- },
- args: [],
- source: "inlinedReturn\x0a\x09^ IRInlinedReturn new",
- messageSends: ["new"],
- referencedClasses: ["IRInlinedReturn"]
- }),
- smalltalk.IRReturnInliner);
- smalltalk.addMethod(
- "_inlinedSequence",
- smalltalk.method({
- selector: "inlinedSequence",
- category: 'factory',
- fn: function () {
- var self=this;
- return smalltalk.send((smalltalk.IRReturningInlinedSequence || IRReturningInlinedSequence),"_new",[]);
- },
- args: [],
- source: "inlinedSequence\x0a\x09^ IRReturningInlinedSequence new",
- messageSends: ["new"],
- referencedClasses: ["IRReturningInlinedSequence"]
- }),
- smalltalk.IRReturnInliner);
- smalltalk.addClass('IRNonLocalReturnInliner', smalltalk.IRReturnInliner, [], 'Compiler-Inlining');
- smalltalk.addMethod(
- "_inlinedReturn",
- smalltalk.method({
- selector: "inlinedReturn",
- category: 'factory',
- fn: function () {
- var self=this;
- return smalltalk.send((smalltalk.IRInlinedNonLocalReturn || IRInlinedNonLocalReturn),"_new",[]);
- },
- args: [],
- source: "inlinedReturn\x0a\x09^ IRInlinedNonLocalReturn new",
- messageSends: ["new"],
- referencedClasses: ["IRInlinedNonLocalReturn"]
- }),
- smalltalk.IRNonLocalReturnInliner);
- smalltalk.addMethod(
- "_inlinedSequence",
- smalltalk.method({
- selector: "inlinedSequence",
- category: 'factory',
- fn: function () {
- var self=this;
- return smalltalk.send((smalltalk.IRNonLocalReturningInlinedSequence || IRNonLocalReturningInlinedSequence),"_new",[]);
- },
- args: [],
- source: "inlinedSequence\x0a\x09^ IRNonLocalReturningInlinedSequence new",
- messageSends: ["new"],
- referencedClasses: ["IRNonLocalReturningInlinedSequence"]
- }),
- smalltalk.IRNonLocalReturnInliner);
- smalltalk.addClass('InliningCodeGenerator', smalltalk.CodeGenerator, [], 'Compiler-Inlining');
- smalltalk.InliningCodeGenerator.comment="I am a specialized code generator that uses inlining to produce more optimized JavaScript output"
- smalltalk.addMethod(
- "_compileNode_",
- smalltalk.method({
- selector: "compileNode:",
- category: 'compiling',
- fn: function (aNode) {
- var self=this;
- var $1,$2;
- var ir;
- var stream;
- smalltalk.send(smalltalk.send(self,"_semanticAnalyzer",[]),"_visit_",[aNode]);
- ir=smalltalk.send(smalltalk.send(self,"_translator",[]),"_visit_",[aNode]);
- smalltalk.send(smalltalk.send(self,"_inliner",[]),"_visit_",[ir]);
- $1=smalltalk.send(self,"_irTranslator",[]);
- smalltalk.send($1,"_visit_",[ir]);
- $2=smalltalk.send($1,"_contents",[]);
- return $2;
- },
- args: ["aNode"],
- source: "compileNode: aNode\x0a\x09| ir stream |\x0a\x09self semanticAnalyzer visit: aNode.\x0a\x09ir := self translator visit: aNode.\x0a\x09self inliner visit: ir.\x0a\x09^ self irTranslator\x0a\x09\x09visit: ir;\x0a\x09\x09contents",
- messageSends: ["visit:", "semanticAnalyzer", "translator", "inliner", "irTranslator", "contents"],
- referencedClasses: []
- }),
- smalltalk.InliningCodeGenerator);
- smalltalk.addMethod(
- "_inliner",
- smalltalk.method({
- selector: "inliner",
- category: 'compiling',
- fn: function () {
- var self=this;
- return smalltalk.send((smalltalk.IRInliner || IRInliner),"_new",[]);
- },
- args: [],
- source: "inliner\x0a\x09^ IRInliner new",
- messageSends: ["new"],
- referencedClasses: ["IRInliner"]
- }),
- smalltalk.InliningCodeGenerator);
- smalltalk.addMethod(
- "_irTranslator",
- smalltalk.method({
- selector: "irTranslator",
- category: 'compiling',
- fn: function () {
- var self=this;
- return smalltalk.send((smalltalk.IRInliningJSTranslator || IRInliningJSTranslator),"_new",[]);
- },
- args: [],
- source: "irTranslator\x0a\x09^ IRInliningJSTranslator new",
- messageSends: ["new"],
- referencedClasses: ["IRInliningJSTranslator"]
- }),
- smalltalk.InliningCodeGenerator);
|