📄 opt_deadcode.c
字号:
#line 84 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_deadcode.mx"#line 86 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_deadcode.mx"#include "mal_config.h"#include "opt_deadcode.h"static int OPTdeadcodeImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){ int i, k, se,limit; InstrPtr p=0, *old= mb->stmt; int actions = 0; (void) pci; (void) stk; /* to fool compilers */ setLifespan(mb);#ifdef DEBUG_OPT_DEAD stream_printf(GDKout,"ENTERING DEAD CODE ELIMINATION\n"); printFunction(GDKout,mb,LIST_MAL_ALL);#endif limit= mb->stop; newMalBlkStmt(mb, mb->stop); /* a new statement stack */ pushInstruction(mb, old[0]); for (i = 1; i < limit; i++) { p= old[i]; se = p->token == ENDsymbol; if( se){ pushInstruction(mb,p); for(i++; i<limit; i++) pushInstruction(mb,old[i]); break; } if( p->token != NOOPsymbol) for (k = 0; k < p->retc; k++) if( isVarUsed(mb,getArg(p,k)) ){ se++; break; } if (se || hasSideEffects(p, FALSE) ) pushInstruction(mb,p); else { freeInstruction(p); actions++; } } /* we may have uncovered new use-less operations */ if( actions) i= OPTdeadcodeImplementation(mb, stk, pci);#ifdef DEBUG_OPT_DEAD stream_printf(GDKout,"LEAVING DEAD CODE ELIMINATION\n"); printFunction(GDKout,mb,LIST_MAL_ALL);#endif return actions+i;}#line 147 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_deadcode.mx"#line 145 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_deadcode.mx"/* #define _DEBUG_OPTIMIZER_*/str OPTdeadcode(MalBlkPtr mb, MalStkPtr stk, InstrPtr p){ str modnme; str fcnnme; Module scope=NULL; Symbol s= NULL; lng clk= GDKusec(); int actions = 0; optimizerInit(); if( p ) removeInstruction(mb, p);#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"apply deadcode\n"); printFunction(GDKout,mb,LIST_MAL_ALL);#endif if( p && p->argc > 1 && getFunctionId(p) != multiplexRef){#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"locate function deadcode\n");#endif if( getArgType(mb,p,1) != TYPE_str || getArgType(mb,p,2) != TYPE_str || !isConstant(mb,getArg(p,1)) || !isConstant(mb,getArg(p,2)) ) { char buf[1024]; snprintf(buf,1024, "Optimizer requires constant string arguments\n"); throw(MAL, "optimizer.deadcode",buf); } if( stk != 0){ modnme= (str)getArgValue(stk,p,1); fcnnme= (str)getArgValue(stk,p,2); } else { modnme= getArgDefault(mb,p,1); fcnnme= getArgDefault(mb,p,2); } scope = findModule(MCgetClient()->nspace,putName(modnme,strlen(modnme)) ); if( scope) s= findSymbolInModule(scope,putName(fcnnme,strlen(fcnnme))); if( s == NULL) { char buf[1024]; snprintf(buf,1024, "Could not find %s.%s\n",modnme,fcnnme); throw(MAL, "optimizer.deadcode",buf); }#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"deadcode %s %d\n",modnme,fcnnme);#endif mb = s->def; stk= 0; } if( mb->errors ) return MAL_SUCCEED; addtoMalBlkHistory(mb); actions= OPTdeadcodeImplementation(mb,stk,p);#ifdef _DEBUG_OPTIMIZER_ stream_printf(GDKout,"finished deadcode %d\n",actions); printFunction(GDKout,mb,LIST_MAL_ALL);#endif optimizerCheck(mb, "optimizer.deadcode", actions, GDKusec() - clk,OPT_CHECK_ALL); return MAL_SUCCEED;}#line 147 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_deadcode.mx"#line 149 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_deadcode.mx"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -