Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3728
Modified Files:
opt_accumulators.mx opt_aliases.mx opt_coercion.mx
opt_commonTerms.mx opt_crack.mx opt_deadcode.mx
opt_emptySet.mx opt_evaluate.mx opt_factorize.mx
opt_garbageCollector.mx opt_heuristics.mx optimizer.mx
optimizerWrapper.mx opt_joinselect.mx opt_macro.mx
opt_multiplex.mx opt_partitions.mx opt_peephole.mx
opt_pushranges.mx opt_qep.mx opt_reduce.mx opt_remap.mx
opt_remoteQueries.mx opt_singleton.mx opt_strengthReduction.mx
opt_support.mx
Log Message:
The naming of the functions dealing with variables have been cleaned
and stratified.
A related issue is that Lifespan analysis has been separated out,
to save space and since it is only needed by a limited number of optimizers.
It still leads to a segfault in opt_evaluate. Fix pending
Index: opt_peephole.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_peephole.mx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- opt_peephole.mx 31 Oct 2007 10:36:26 -0000 1.13
+++ opt_peephole.mx 2 Jan 2008 08:21:14 -0000 1.14
@@ -90,6 +90,7 @@
{
InstrPtr p, q, r, *old;
int i, limit, slimit, doit, actions = 0;
+ Lifespan span= newLifespan(mb);
#ifdef DEBUG_OPT_PEEPHOLE
stream_printf(GDKout, "Peephole optimizer started\n");
@@ -98,7 +99,7 @@
(void) pci;
actions = 0;
doit = 0;
- setLifespan(mb);
+ setLifespan(mb,span);
limit = mb->stop;
slimit = mb->ssize;
old = mb->stmt;
@@ -110,7 +111,7 @@
if (q && match(p, batRef, reverseRef) &&
match(q, batRef, reverseRef) &&
getArg(p, 0) == getArg(q, 1) &&
- getEndLifespan(mb,getArg(p,0)) == i +
1) {
+ getEndLifespan(span,getArg(p,0)) == i +
1) {
#ifdef DEBUG_OPT_PEEPHOLE
printf("PEEPHOLE reverse-reverse\n");
printInstruction(GDKout, mb, p, LIST_MAL_ALL);
@@ -136,12 +137,12 @@
GDKfree(old);
if (doit) {
chkProgram(MCgetClient()->nspace, mb);
- setLifespan(mb);
#ifdef DEBUG_OPT_PEEPHOLE
stream_printf(GDKout, "PEEPHOLE %d\n", doit);
printFunction(GDKout, mb, LIST_MAL_ALL);
#endif
}
+ GDKfree(span);
return actions;
}
Index: opt_remoteQueries.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_remoteQueries.mx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- opt_remoteQueries.mx 31 Oct 2007 12:31:54 -0000 1.14
+++ opt_remoteQueries.mx 2 Jan 2008 08:21:19 -0000 1.15
@@ -132,7 +132,7 @@
len= strlen(msg);
for (k = 0; k < p->retc; k++) {
VarPtr v = getVar(mb, getArg(p, k));
- if( v->isudftype){
+ if( isVarUDFtype(mb, getArg(p,k)) ){
str tpe = getTypeName(getVarType(mb, getArg(p, k)));
sprintf(msg+len, "%s:%s ", v->name, tpe);
GDKfree(tpe);
@@ -154,7 +154,7 @@
len = strlen(msg);
for (k = p->retc; k < p->argc; k++) {
VarPtr v = getVar(mb, getArg(p, k));
- if( isConstant(mb, getArg(p,k)) ){
+ if( isVarConstant(mb, getArg(p,k)) ){
if( v->type == TYPE_void) {
sprintf(msg+len, "nil");
} else {
@@ -190,8 +190,8 @@
/* lookup the server connection */
if( location[getArg(p,0)] == 0){
db = 0;
- if( isConstant(mb,getArg(p,@1)) )
- db= getConstant(mb, getArg(p,@1)).val.sval;
+ if( isVarConstant(mb,getArg(p,@1)) )
+ db= getVarConstant(mb, getArg(p,@1)).val.sval;
for(k=0; k<dbtop; k++)
if( strcmp(db, dbalias[k].dbname)== 0)
break;
@@ -218,7 +218,7 @@
@= putRemoteVariables
for(j=p->retc; j<p->argc; j++)
- if( location[getArg(p,j)] == 0 && !isConstant(mb,getArg(p,j)) ){
+ if( location[getArg(p,j)] == 0 && !isVarConstant(mb,getArg(p,j)) ){
q= newStmt(mb,mserverRef,putRef);
getArg(q,0)= newTmpVariable(mb, TYPE_void);
q= pushArgument(mb,q,location[getArg(p,j)]);
@@ -259,7 +259,6 @@
(void) stk;
(void) pci;
- setLifespan(mb);
limit = mb->stop;
slimit = mb->ssize;
old = mb->stmt;
@@ -285,7 +284,7 @@
if( (getModuleId(p)== mserverRef && getFunctionId(p)==bindRef)){
if( p->argc == 3 && getArgType(mb,p,1) == TYPE_int ) {
int tpe;
- freezeVarType(mb,getArg(p,0));
+ setVarUDFtype(mb,getArg(p,0));
j = getArg(p,1); /* lookupServer with key */
tpe = getArgType(mb,p,0);
/* result is remote */
@@ -328,7 +327,7 @@
if( p->argc == 6 && getArgType(mb,p,4) == TYPE_str ) {
int tpe;
- freezeVarType(mb,getArg(p,0));
+ setVarUDFtype(mb,getArg(p,0));
j = getArg(p,1); /* lookupServer with key */
tpe = getArgType(mb,p,0);
@@ -421,7 +420,7 @@
r= pushArgument(mb, r, remoteSite);
for(j=p->retc; j<p->argc; j++)
- if( location[getArg(p,j)] == 0 &&
!isConstant(mb,getArg(p,j)) ){
+ if( location[getArg(p,j)] == 0 &&
!isVarConstant(mb,getArg(p,j)) ){
q= newStmt(mb,mserverRef,putRef);
getArg(q,0)= newTmpVariable(mb,
TYPE_void);
q= pushArgument(mb, q, remoteSite);
Index: opt_singleton.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_singleton.mx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- opt_singleton.mx 9 Dec 2007 16:21:15 -0000 1.16
+++ opt_singleton.mx 2 Jan 2008 08:21:20 -0000 1.17
@@ -116,9 +116,9 @@
p = newFcnCall(mb, batRef, unpackRef);
getArg(p, 0) = tuples[varid].hidx;
- setVarUsed(mb,getArg(p,0),TRUE);
+ setVarUsed(mb,getArg(p,0));
setArgument(mb, p, 1, tuples[varid].tidx);
- setVarUsed(mb,getArg(p,1),TRUE);
+ setVarUsed(mb,getArg(p,1));
p->retc++;
p= pushArgument(mb, p, tuples[varid].vidx);
tuples[varid].packed = 0;
@@ -210,9 +210,9 @@
k = STnewTuple(mb, getArg(p, 0), &top, tuples);
tuples[k].packed = 0;
p->argv[0] = tuples[k].hidx;
- setVarUsed(mb,getArg(p,0),TRUE);
+ setVarUsed(mb,getArg(p,0));
p->argv[1] = tuples[k].tidx;
- setVarUsed(mb,getArg(p,1),TRUE);
+ setVarUsed(mb,getArg(p,1));
p->token = ASSIGNsymbol;
p->fcn = NULL;
actions++;
@@ -227,9 +227,9 @@
k = STnewTuple(mb, getArg(p, 0), &top, tuples);
tuples[k].packed = 0;
p->argv[0] = tuples[k].hidx;
- setVarUsed(mb,getArg(p,0),TRUE);
+ setVarUsed(mb,getArg(p,0));
p->argv[1] = tuples[k].tidx;
- setVarUsed(mb,getArg(p,1),TRUE);
+ setVarUsed(mb,getArg(p,1));
p->token = ASSIGNsymbol;
p->fcn = NULL;
actions++;
Index: optimizerWrapper.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/optimizerWrapper.mx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- optimizerWrapper.mx 24 Dec 2007 12:28:25 -0000 1.14
+++ optimizerWrapper.mx 2 Jan 2008 08:21:12 -0000 1.15
@@ -51,8 +51,8 @@
#endif
if( getArgType(mb,p,1) != TYPE_str ||
getArgType(mb,p,2) != TYPE_str ||
- !isConstant(mb,getArg(p,1)) ||
- !isConstant(mb,getArg(p,2))
+ !isVarConstant(mb,getArg(p,1)) ||
+ !isVarConstant(mb,getArg(p,2))
) {
char buf[1024];
snprintf(buf,1024, "Optimizer requires constant string
arguments\n");
Index: opt_garbageCollector.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_garbageCollector.mx,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- opt_garbageCollector.mx 9 Dec 2007 16:21:10 -0000 1.29
+++ opt_garbageCollector.mx 2 Jan 2008 08:21:11 -0000 1.30
@@ -170,13 +170,14 @@
InstrPtr p, q, *old;
Module s = MCgetClient()->nspace;
int actions = 0;
+ Lifespan span= newLifespan(mb);
(void) pci;
(void) stk; /* to fool compilers */
if (varGetProp(mb, getArg(mb->stmt[0], 0), inlineProp) != NULL)
return 0;
- setLifespan(mb);
+ setLifespan(mb,span);
old= mb->stmt;
limit = mb->stop;
@@ -188,8 +189,8 @@
pushInstruction(mb, p);
for (j = p->retc; j < p->argc; j++) {
- if (getEndLifespan(mb,getArg(p,j))>
getBeginLifespan(mb,getArg(p,j)) &&
- getEndLifespan(mb,getArg(p,j)) == i &&
+ if (getEndLifespan(span,getArg(p,j))>
getBeginLifespan(span,getArg(p,j)) &&
+ getEndLifespan(span,getArg(p,j)) == i &&
isaBatType(getArgType(mb, p, j))) {
/* avoid duplicate releases */
done = 0;
@@ -218,6 +219,7 @@
if( old[i])
freeInstruction(old[i]);
GDKfree(old);
+ GDKfree(span);
return actions;
}
Index: opt_multiplex.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_multiplex.mx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- opt_multiplex.mx 31 Oct 2007 10:36:25 -0000 1.27
+++ opt_multiplex.mx 2 Jan 2008 08:21:14 -0000 1.28
@@ -165,9 +165,9 @@
return createException(MAL, "optimizer.multiplex", "Target tail
type is missing");
setVarType(mb, getArg(q, 0), newBatType(ht, tt));
q = pushNil(mb, q, ht);
- freezeVarType(mb,getArg(q,q->argc-1));
+ setVarUDFtype(mb,getArg(q,q->argc-1));
q = pushNil(mb, q, tt);
- freezeVarType(mb,getArg(q,q->argc-1));
+ setVarUDFtype(mb,getArg(q,q->argc-1));
/* barrier (mloop,h,r) := newIterator(refBat); */
q = newFcnCall(mb, batRef, "newIterator");
q->barrier = BARRIERsymbol;
@@ -220,7 +220,7 @@
/* catch MALException and ignore them and replace value with nil */
q = newInstruction(mb,CATCHsymbol);
k = newVariable(mb, GDKstrdup(exceptionToString(MAL)), TYPE_str);
- getVar(mb,k)->isudftype = 1;
+ setVarUDFtype(mb,k);
q= pushReturn(mb, q, k);
pushInstruction(mb, q);
@@ -277,8 +277,7 @@
OPTmultiplexImplementation(mb, 0, 0);
chkTypes(cntxt->nspace, mb);
chkFlow(mb);
- chkDeclarations(mb, TRUE);
- setLifespan(mb);
+ chkDeclarations(mb);
}
return 0;
}
Index: opt_commonTerms.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_commonTerms.mx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- opt_commonTerms.mx 30 Dec 2007 18:14:22 -0000 1.24
+++ opt_commonTerms.mx 2 Jan 2008 08:21:02 -0000 1.25
@@ -101,6 +101,7 @@
int *mask,*alias,limit, slimit;
InstrPtr *old;
int c;
+ Lifespan span= newLifespan(mb);
(void) stk;
(void) pci;
@@ -111,7 +112,7 @@
for(i=0; i<mb->vtop; i++)
alias[i]=i;
- setLifespan(mb);
+ setLifespan(mb,span);
old = mb->stmt;
limit = mb->stop;
slimit = mb->ssize;
@@ -132,9 +133,9 @@
if (p->token == NOOPsymbol)
continue;
if (OPTisAlias(p)){
- if (getLastUpdate(mb,getArg(p,0)) == i &&
- getBeginLifespan(mb,getArg(p,0)) == i &&
- getLastUpdate(mb,getArg(p,1)) < i){
+ if (getLastUpdate(span,getArg(p,0)) == i &&
+ getBeginLifespan(span,getArg(p,0)) == i &&
+ getLastUpdate(span,getArg(p,1)) < i){
alias[getArg(p,0)] = alias[getArg(p,1)];
freeInstruction(p);
mb->stop--;
@@ -153,7 +154,7 @@
c = p->argc;
for(j=p->retc; j<p->argc; j++){
c *= 4;
- if (!isConstant(mb,getArg(p,j)))
+ if (!isVarConstant(mb,getArg(p,j)))
c += getArg(p,j);
}
c &= 1023;
@@ -168,8 +169,8 @@
@c
last=1;
for (j = p->retc; j<p->argc; j++)
- if( getBeginLifespan(mb,getArg(p,j)) > last )
- last = getBeginLifespan(mb,getArg(p,j));
+ if( getBeginLifespan(span,getArg(p,j)) > last )
+ last =
getBeginLifespan(span,getArg(p,j));
for (j = (n-1) - 1; j >= last-(i-(n-1)) && j>0; j--)
if (mask[j] == c ){
@@ -201,7 +202,7 @@
!hasCommonResults(p, q) &&
!hasSideEffects(p, TRUE) &&
isLinearFlow(p) &&
- allTargetsVisible(mb,j,n-1)
+ allTargetsVisible(mb,span,j,n-1)
) {
#ifdef DEBUG_OPT_COMMONTERMS
stream_printf(GDKout, "Found a common
expression " "%d <-> %d\n", j, i);
@@ -217,9 +218,9 @@
#endif
actions++;
if( p->argc== 2 &&
- getLastUpdate(mb,getArg(p,0))
== i &&
-
getBeginLifespan(mb,getArg(p,0)) == i &&
- getLastUpdate(mb,getArg(p,1)) <
i){
+ getLastUpdate(span,getArg(p,0))
== i &&
+
getBeginLifespan(span,getArg(p,0)) == i &&
+ getLastUpdate(span,getArg(p,1))
< i){
alias[getArg(p,0)]=
alias[getArg(p,1)];
freeInstruction(p);
mb->stop--;
@@ -236,6 +237,7 @@
if( old[i])
freeInstruction(old[i]);
GDKfree(old);
+ GDKfree(span);
return actions;
}
Index: opt_strengthReduction.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_strengthReduction.mx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- opt_strengthReduction.mx 31 Oct 2007 10:36:27 -0000 1.11
+++ opt_strengthReduction.mx 2 Jan 2008 08:21:20 -0000 1.12
@@ -122,6 +122,7 @@
InstrPtr p;
int bk, ik, blk, blkbegin, blkexit, actions = 0;
InstrPtr *before, *within;
+ Lifespan span= newLifespan(mb);
(void) pci;
(void) stk; /* to fool compilers */
@@ -141,7 +142,7 @@
before[i] = within[i] = 0;
before[bk++] = getInstrPtr(mb, 0); /* to become a factory */
- setLifespan(mb);
+ setLifespan(mb,span);
for (i = 1; i < mb->stop - 1; i++) {
p = getInstrPtr(mb, i);
if (blockStart(p)) {
@@ -214,11 +215,12 @@
after the loop, because then you may not simple move an expression.
@c
for (k = 0; k < p->retc; k++)
- if ( getBeginLifespan(mb, getArg(p, k))<= blkbegin ||
- getEndLifespan(mb, getArg(p, k))>= blkexit) {
+ if ( getBeginLifespan(span, getArg(p, k))<= blkbegin ||
+ getEndLifespan(span, getArg(p, k))> blkexit) {
se = TRUE;
#ifdef DEBUG_OPT_STRENGTHREDUCTION
- stream_printf(GDKout, "variable may not be used
out %d\n", getArg(p, k));
+ stream_printf(GDKout, "variable %d may not be
moved %d-%d\n",
+ getArg(p, k),getBeginLifespan(span, getArg(p,
k)), getEndLifespan(span, getArg(p, k)));
#endif
goto noreduction;
}
@@ -247,6 +249,7 @@
for (i = 0; i < bk; i++)
if( before[i])
pushInstruction(mb, before[i]);
+ GDKfree(span);
return actions;
}
@include optimizerWrapper.mx
Index: opt_factorize.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_factorize.mx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- opt_factorize.mx 31 Oct 2007 08:27:38 -0000 1.13
+++ opt_factorize.mx 2 Jan 2008 08:21:11 -0000 1.14
@@ -119,11 +119,12 @@
int fk = 0, sk = 0, blk = 0, blkstart = 0;
int *varused, returnseen = 0;
InstrPtr *first, *second;
+ Lifespan span= newLifespan(mb);
(void) pci;
(void) stk; /* to fool compilers */
- setLifespan(mb);
+ setLifespan(mb,span);
varused = GDKmalloc(mb->vtop * sizeof(int));
for (i = 0; i < mb->vtop; i++)
varused[i] = 0;
@@ -161,7 +162,7 @@
/* beware, none of the target variables may live
before the cut point. */
for (k = 0; k < p->retc; k++)
- if (getBeginLifespan(mb, p->argv[k])< i ||
!OPTallowed(p))
+ if (getBeginLifespan(span, p->argv[k])< i ||
!OPTallowed(p))
se = 0;
if (p->barrier == RETURNsymbol) {
se = 1;
@@ -190,6 +191,7 @@
GDKfree(varused);
GDKfree(first);
GDKfree(second);
+ GDKfree(span);
/* remove the FToptimizer request */
return 1;
}
@@ -237,9 +239,9 @@
GDKfree(varused);
GDKfree(first);
GDKfree(second);
+ GDKfree(span);
return 1;
}
-
@include optimizerWrapper.mx
@h
@:exportOptimizer(factorize)@
Index: opt_remap.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_remap.mx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- opt_remap.mx 27 Dec 2007 19:04:44 -0000 1.19
+++ opt_remap.mx 2 Jan 2008 08:21:19 -0000 1.20
@@ -280,23 +280,23 @@
if( getModuleId(pci)!= malRef &&
getFunctionId(pci) != multiplexRef &&
- !isConstant(mb,getArg(pci,1)) &&
- !isConstant(mb,getArg(pci,2)) &&
- !isConstant(mb,getArg(pci,4)) &&
+ !isVarConstant(mb,getArg(pci,1)) &&
+ !isVarConstant(mb,getArg(pci,2)) &&
+ !isVarConstant(mb,getArg(pci,4)) &&
pci->argc != 5)
return 0;
fcn = VALget(&getVar(mb, getArg(pci, 2))->value);
for(i=0;OperatorMap[i].src;i++)
if( strcmp(fcn,OperatorMap[i].src)==0){
/* found a candidate for a switch */
- getConstant(mb, getArg(pci, 2)).val.sval =
putName(OperatorMap[i].dst,OperatorMap[i].len);
- getConstant(mb, getArg(pci, 2)).len = OperatorMap[i].len;
+ getVarConstant(mb, getArg(pci, 2)).val.sval =
putName(OperatorMap[i].dst,OperatorMap[i].len);
+ getVarConstant(mb, getArg(pci, 2)).len = OperatorMap[i].len;
r= getArg(pci,3); getArg(pci,3)=getArg(pci,4);getArg(pci,4)=r;
r= OPTremapDirect(mb, stk, pci, scope);
/* always restore the allocated function name */
- getConstant(mb, getArg(pci, 2)).val.sval= fcn;
- getConstant(mb, getArg(pci, 2)).len= strlen(fcn);
+ getVarConstant(mb, getArg(pci, 2)).val.sval= fcn;
+ getVarConstant(mb, getArg(pci, 2)).len= strlen(fcn);
if (r) return 1;
Index: opt_macro.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_macro.mx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- opt_macro.mx 30 Dec 2007 18:14:22 -0000 1.28
+++ opt_macro.mx 2 Jan 2008 08:21:13 -0000 1.29
@@ -244,16 +244,22 @@
if (isExceptionVariable(mc->var[n]->name)) {
nv[n] =
newVariable(mb,GDKstrdup(mc->var[n]->name),TYPE_str);
/* keep the properties */
- getVar(mb,nv[n])->isudftype= getVar(mc,n)->isudftype;
- getVar(mb,nv[n])->isused= getVar(mc,n)->isused;
- } else if (isTypeVar(mc,n))
+ if( isVarUDFtype(mc,n))
+ setVarUDFtype(mb,nv[n]);
+ if( isVarUsed(mc,n))
+ setVarUsed(mb,nv[n]);
+ } else
+ if( isVarTypedef(mc,n) )
nv[n] = newTypeVariable(mb,getVarType(mc,n));
- else if (mc->var[n]->isaconstant) {
+ else
+ if ( isVarConstant(mc,n)){
nv[n] = cpyConstant(mb,getVar(mc,n));
} else {
nv[n] = newTmpVariable(mb, getVarType(mc, n));
- getVar(mb,nv[n])->isudftype= getVar(mc,n)->isudftype;
- getVar(mb,nv[n])->isused= getVar(mc,n)->isused;
+ if( isVarUDFtype(mc,n))
+ setVarUDFtype(mb,nv[n]);
+ if( isVarUsed(mc,n))
+ setVarUsed(mb,nv[n]);
}
}
Index: opt_joinselect.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_joinselect.mx,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- opt_joinselect.mx 9 Dec 2007 16:21:12 -0000 1.14
+++ opt_joinselect.mx 2 Jan 2008 08:21:13 -0000 1.15
@@ -65,7 +65,6 @@
(void) stk;
(void) pci;
- setLifespan(mb);
limit = mb->stop;
slimit = mb->ssize;
old = mb->stmt;
Index: opt_reduce.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_reduce.mx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- opt_reduce.mx 30 Dec 2007 18:14:22 -0000 1.17
+++ opt_reduce.mx 2 Jan 2008 08:21:18 -0000 1.18
@@ -66,7 +66,7 @@
alias= (int*) alloca(mb->vtop *sizeof(int));
for(i = 0; i< mb->vtop; i++)
- if (isConstant(mb,i)){
+ if (isVarConstant(mb,i)){
alias[i] = i;
for(j=0; j<top; j++) {
if (getVarType(mb,i) == getVarType(mb,cst[j]) &&
@@ -83,7 +83,7 @@
InstrPtr p = getInstrPtr(mb,i);
for(j=p->retc; j < p->argc; j++)
- if (isConstant(mb, getArg(p,j)))
+ if (isVarConstant(mb, getArg(p,j)))
getArg(p,j) = alias[getArg(p,j)];
}
for( i=0; i< mb->ptop; i++){
Index: opt_aliases.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_aliases.mx,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- opt_aliases.mx 20 Dec 2007 08:46:03 -0000 1.18
+++ opt_aliases.mx 2 Jan 2008 08:21:01 -0000 1.19
@@ -111,34 +111,34 @@
{
int i,k=1, limit, actions=0;
int *alias;
+ Lifespan span= newLifespan(mb);
(void) stk;
alias= (int*) alloca(sizeof(int)* mb->vtop);
for(i=0; i<mb->vtop; i++) alias[i]=i;
- setLifespan(mb);
+ setLifespan(mb,span);
limit = mb->stop;
for (i = 1; i < limit; i++){
p= getInstrPtr(mb,i);
mb->stmt[k++] = p;
if (OPTisAlias(p)){
- if( getLastUpdate(mb,getArg(p,0)) == i &&
- getBeginLifespan(mb,getArg(p,0)) == i &&
- getLastUpdate(mb,getArg(p,1)) < i ){
+ if( getLastUpdate(span,getArg(p,0)) == i &&
+ getBeginLifespan(span,getArg(p,0)) == i &&
+ getLastUpdate(span,getArg(p,1)) <= i ){
alias[getArg(p,0)]= alias[getArg(p,1)];
freeInstruction(p);
actions++;
k--;
- } else {
+ } else
OPTaliasRemap(p,alias);
- }
- } else {
+ } else
OPTaliasRemap(p,alias);
- }
}
for(i=k; i<limit; i++)
mb->stmt[i]= NULL;
mb->stop= k;
+ GDKfree(span);
return actions;
}
@include optimizerWrapper.mx
Index: opt_emptySet.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_emptySet.mx,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- opt_emptySet.mx 30 Dec 2007 18:14:22 -0000 1.44
+++ opt_emptySet.mx 2 Jan 2008 08:21:03 -0000 1.45
@@ -95,7 +95,7 @@
#include "opt_prelude.h"
#include "opt_support.h"
-/* #define DEBUG_OPT_EMPTYSET show partial result */
+/*#define DEBUG_OPT_EMPTYSET show partial result */
@c
#include "mal_config.h"
#include "opt_emptySet.h"
@@ -104,7 +104,7 @@
#include "mal_interpreter.h" /* for showErrors() */
#include "mal_builder.h"
-#define propagate(X) {p->token= ASSIGNsymbol; setVarUsed(mb,getArg(p,1),TRUE);
\
+#define propagate(X) {p->token= ASSIGNsymbol; setVarUsed(mb,getArg(p,1)); \
getArg(p,1)= getArg(p,X); p->argc = 2; p->fcn = 0; actions++;\
p->typechk=TYPE_UNKNOWN; p->fcn= NULL; \
if(getArgType(mb,p,0)== getArgType(mb,p,X)){\
@@ -175,10 +175,10 @@
if( f == bindRef && runonce == FALSE) {
for( j=ctop-1; j>=0; j--){
q= constraints[j];
- if(
strcmp(getConstant(mb,getArg(q,1)).val.sval,
getConstant(mb,getArg(p,1)).val.sval)==0 &&
-
strcmp(getConstant(mb,getArg(q,2)).val.sval,
getConstant(mb,getArg(p,2)).val.sval)==0 &&
-
getConstant(mb,getArg(p,4)).val.ival<=2 && /* no updates etc */
-
getConstant(mb,getArg(q,4)).val.ival == getConstant(mb,getArg(p,4)).val.ival
+ if(
strcmp(getVarConstant(mb,getArg(q,1)).val.sval,
getVarConstant(mb,getArg(p,1)).val.sval)==0 &&
+
strcmp(getVarConstant(mb,getArg(q,2)).val.sval,
getVarConstant(mb,getArg(p,2)).val.sval)==0 &&
+
getVarConstant(mb,getArg(p,4)).val.ival<=2 && /* no updates etc */
+
getVarConstant(mb,getArg(q,4)).val.ival ==
getVarConstant(mb,getArg(p,4)).val.ival
)
/* don't generate the assertion
*/
goto ignoreConstraint;
Index: opt_partitions.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_partitions.mx,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- opt_partitions.mx 26 Dec 2007 14:31:12 -0000 1.36
+++ opt_partitions.mx 2 Jan 2008 08:21:14 -0000 1.37
@@ -169,6 +169,11 @@
alias[getArg(p,0)]= getArg(q,0);
garbage[getArg(q,0)]= 1;
+ /* declare the target at the outer level */
+ q= newAssignment(mb);
+ getArg(q,0)= getArg(p,0);
+ pushNil(mb,q, getArgType(mb,p,0));
+
/* dump the iterators */
OPTbarrierList(mb,p,alias);
@@ -189,7 +194,7 @@
@c
static int bindTest(MalBlkPtr mb, InstrPtr p){
ValPtr v;
- v= &getConstant(mb,getArg(p,4));
+ v= &getVarConstant(mb,getArg(p,4));
return v->val.ival>0;
}
@-
@@ -241,16 +246,16 @@
q = newStmt(mb,"bpm","unfold");
q->argv[0]=
localVar(mb,"bpm",getArg(p,0), getVarType(mb,
getArg(p,0)));
- freezeVarType(mb,q->argv[0]);
+ setVarUDFtype(mb,q->argv[0]);
alias[getArg(p,0)]= getArg(q,0);
#ifdef DEBUG_OPT_PARTITIONED
printf("1 alias[%d]=%d\n",getArg(p,0),getArg(q,0));
#endif
/*
snprintf(name,1024,"%s_%s_%s",
- getConstant(mb, getArg(p,1)).val.sval,
- getConstant(mb, getArg(p,2)).val.sval,
- getConstant(mb, getArg(p,3)).val.sval );
+ getVarConstant(mb, getArg(p,1)).val.sval,
+ getVarConstant(mb, getArg(p,2)).val.sval,
+ getVarConstant(mb, getArg(p,3)).val.sval );
q= pushStr(mb, q,name);
*/
q= pushArgument(mb,q,getArg(p,0));
Index: optimizer.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/optimizer.mx,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- optimizer.mx 24 Dec 2007 12:28:25 -0000 1.71
+++ optimizer.mx 2 Jan 2008 08:21:12 -0000 1.72
@@ -250,7 +250,7 @@
}
}
chkFlow(mb);
- chkDeclarations(mb,TRUE);
+ chkDeclarations(mb);
return msg;
}
opt_export str [EMAIL PROTECTED]( MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
@@ -281,7 +281,7 @@
}
}
chkFlow(mb);
- chkDeclarations(mb,TRUE);
+ chkDeclarations(mb);
return msg;
}
opt_export str [EMAIL PROTECTED]( MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
@@ -310,7 +310,7 @@
}
(void) stk;
chkFlow(mb);
- chkDeclarations(mb,TRUE);
+ chkDeclarations(mb);
return msg;
}
@c
Index: opt_evaluate.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_evaluate.mx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- opt_evaluate.mx 30 Dec 2007 18:14:22 -0000 1.12
+++ opt_evaluate.mx 2 Jan 2008 08:21:05 -0000 1.13
@@ -68,7 +68,7 @@
int i;
for( i= p->retc; i < p->argc; i++)
- if( isConstant(mb, getArg(p,i)) == FALSE)
+ if( isVarConstant(mb, getArg(p,i)) == FALSE)
return FALSE;
for( i=0; i<p->retc; i++)
if( isaBatType(getArgType(mb,p,i)))
@@ -86,8 +86,9 @@
MalStkPtr env = NULL;
str msg;
int debugstate= c->itrace;
- c->itrace= 0;
+ Lifespan span= newLifespan(mb);
+ c->itrace= 0;
(void) stk;
(void) pci;
@@ -97,11 +98,11 @@
#ifdef DEBUG_OPT_CX
stream_printf(GDKout,"Constant expression optimizer started\n");
#endif
- setLifespan(mb);
env= prepareMALstack(mb);
env->keepAlive= TRUE;
do {
+ setLifespan(mb,span);
again = 0;
limit = mb->stop;
nxt= first;
@@ -112,11 +113,11 @@
#ifdef DEBUG_OPT_CX
stream_printf(GDKout,"Constants:%d\n",j);
stream_printf(GDKout,"retc %d var
%s\n",p->retc,getVarName(mb,getArg(p,0)));
- stream_printf(GDKout,"last update:%d\n",
getLastUpdate(mb,getArg(p,0)));
+ stream_printf(GDKout,"last update:%d\n",
getLastUpdate(span,getArg(p,0)));
printInstruction(GDKout, mb, p, LIST_MAL_ALL);
#endif
if( j && p->retc== 1 && p->barrier == 0 &&
- getLastUpdate(mb,getArg(p,0)) == i &&
+ getLastUpdate(span,getArg(p,0)) == i &&
!isUnsafeFunction(p)){
msg = reenterMAL(c,mb,i,i+1,env,0,0);
#ifdef DEBUG_OPT_CX
@@ -127,10 +128,10 @@
The last assignment of a constant expression turns the variable into
a constant itself.
@c
- isConstant(mb,getArg(p,0))= TRUE;
- setVarCleanup(mb,getArg(p,0))= FALSE;
- setFixed(mb,getArg(p,0));
- getConstant(mb,getArg(p,0)) =
env->stk[getArg(p,0)];
+ setVarConstant(mb,getArg(p,0));
+ clrVarCleanup(mb,getArg(p,0));
+ setVarFixed(mb,getArg(p,0));
+ getVarConstant(mb,getArg(p,0)) =
env->stk[getArg(p,0)];
env->stk[getArg(p,0)].vtype= TYPE_int;
/* no garbage */
freeInstruction(p);
#ifdef DEBUG_OPT_CX
@@ -149,14 +150,10 @@
if (k <= i)
mb->stmt[i] = NULL;
}
- if( k != mb->stop) {
- mb->stop = k;
- setLifespan(mb); /* the lastUpdate property
changes */
- } else {
- mb->stop= k;
- }
+ mb->stop= k;
first = nxt;
} while( again );
+ GDKfree(span);
freeStack(env);
c->itrace= debugstate;
return 1;
Index: opt_pushranges.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_pushranges.mx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- opt_pushranges.mx 9 Dec 2007 16:21:12 -0000 1.11
+++ opt_pushranges.mx 2 Jan 2008 08:21:15 -0000 1.12
@@ -150,11 +150,11 @@
@c
x= getArg(p,1);
y= getArg(p,2);
- if( range[x].lcst && isConstant(mb,y) ){
+ if( range[x].lcst && isVarConstant(mb,y) ){
/* merge lowerbound */
if( ATOMcmp( getVarType(mb,y),
- VALptr(
&getConstant(mb,range[x].lcst)),
- VALptr( &getConstant(mb,y)) ) >
0){
+ VALptr(
&getVarConstant(mb,range[x].lcst)),
+ VALptr( &getVarConstant(mb,y))
) > 0){
getArg(p,2)= range[x].lcst;
z= range[x].srcvar;
if( getArg(p,1) == x &&
@@ -166,10 +166,10 @@
y= getArg(p,3);
/* merge higherbound */
if( ATOMcmp( getVarType(mb,y),
- VALptr(
&getConstant(mb,range[x].hcst)),
- VALptr( &getConstant(mb,y)) ) <
0 ||
+ VALptr(
&getVarConstant(mb,range[x].hcst)),
+ VALptr( &getVarConstant(mb,y))
) < 0 ||
ATOMcmp( getVarType(mb,y),
- VALptr( &getConstant(mb,y)),
+ VALptr( &getVarConstant(mb,y)),
ATOMnilptr(getVarType(mb,y)) )
== 0){
getArg(p,3)= range[x].hcst;
z= range[x].srcvar;
@@ -184,12 +184,12 @@
result variable.
@c
x= getArg(p,0);
- if( isConstant(mb, getArg(p,2)) ){
+ if( isVarConstant(mb, getArg(p,2)) ){
range[x].lcst = getArg(p,2);
range[x].srcvar= getArg(p,1);
range[x].lastupdate= range[x].lastrange = i;
}
- if( isConstant(mb, getArg(p,3)) ){
+ if( isVarConstant(mb, getArg(p,3)) ){
range[x].hcst = getArg(p,3);
range[x].srcvar= getArg(p,1);
range[x].lastupdate= range[x].lastrange = i;
@@ -200,16 +200,16 @@
@c
x= getArg(p,2);
y= getArg(p,3);
- if( isConstant(mb, x) &&
- isConstant(mb, y) ){
+ if( isVarConstant(mb, x) &&
+ isVarConstant(mb, y) ){
z =ATOMcmp( getVarType(mb,y),
- VALptr( &getConstant(mb,x)),
- VALptr( &getConstant(mb,y)));
+ VALptr( &getVarConstant(mb,x)),
+ VALptr( &getVarConstant(mb,y)));
x= p->argc > 4;
- x= x && isConstant(mb,getArg(p,4));
- x= x && isConstant(mb,getArg(p,5));
- x= x && getConstant(mb,getArg(p,4)).val.cval[0];
- x= x && getConstant(mb,getArg(p,5)).val.cval[0];
+ x= x && isVarConstant(mb,getArg(p,4));
+ x= x && isVarConstant(mb,getArg(p,5));
+ x= x &&
getVarConstant(mb,getArg(p,4)).val.cval[0];
+ x= x &&
getVarConstant(mb,getArg(p,5)).val.cval[0];
if( z > 0 || (z==0 && p->argc>4 && !x)) {
int var = getArg(p, 0);
lng zero = 0;
@@ -223,9 +223,7 @@
getModuleId(p)= batRef;
getFunctionId(p)= newRef;
p= pushArgument(mb,p,
typ=newTypeVariable(mb, getHeadType(x)));
- isConstant(mb,typ)= TRUE;
p= pushArgument(mb,p,
typ=newTypeVariable(mb, getTailType(x)));
- isConstant(mb,typ)= TRUE;
actions++;
}
}
Index: opt_crack.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_crack.mx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- opt_crack.mx 9 Dec 2007 16:21:09 -0000 1.8
+++ opt_crack.mx 2 Jan 2008 08:21:02 -0000 1.9
@@ -103,6 +103,7 @@
}
return actions;
}
+
@include optimizerWrapper.mx
@h
@:exportOptimizer(crack)@
Index: opt_coercion.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_coercion.mx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- opt_coercion.mx 16 Jul 2007 10:52:27 -0000 1.9
+++ opt_coercion.mx 2 Jan 2008 08:21:02 -0000 1.10
@@ -55,15 +55,21 @@
static int
coercionOptimizerStep(MalBlkPtr mb, int i, InstrPtr p)
{
- int t, a, b;
+ int t, k, a, b;
a = getArg(p, 0);
b = getArg(p, 1);
t = getVarType(mb, b);
if( getVarType(mb,a) != t) return 0;
if (strcmp(getFunctionId(p), ATOMname(t)) == 0) {
- removeInstruction(mb, p);
- replaceAlias(mb, i, mb->stop, a, b);
+ removeInstruction(mb, p); /* dead code */
+ for(; i< mb->stop; i++){
+ p= getInstrPtr(mb,i);
+ for( k= p->retc; k < p->argc; k++)
+ if( p->argv[k]== a) {
+ p->argv[k]= b;
+ }
+ }
return 1;
}
return 0;
Index: opt_deadcode.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_deadcode.mx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- opt_deadcode.mx 30 Dec 2007 18:14:22 -0000 1.30
+++ opt_deadcode.mx 2 Jan 2008 08:21:03 -0000 1.31
@@ -96,12 +96,13 @@
if (varGetProp(mb, getArg(mb->stmt[0], 0), inlineProp) != NULL)
return 0;
- setLifespan(mb);
#ifdef DEBUG_OPT_DEAD
stream_printf(GDKout,"ENTERING DEAD CODE ELIMINATION\n");
printFunction(GDKout,mb,LIST_MAL_ALL);
#endif
+ clrDeclarations(mb);
+ chkDeclarations(mb);
limit= mb->stop;
slimit = mb->ssize;
newMalBlkStmt(mb, mb->ssize); /* a new statement stack */
@@ -126,7 +127,7 @@
}
if( getModuleId(p)== sqlRef && getFunctionId(p)== assertRef &&
- isConstant(mb,getArg(p,1)) &&
getConstant(mb,getArg(p,1)).val.ival==0){
+ isVarConstant(mb,getArg(p,1)) &&
getVarConstant(mb,getArg(p,1)).val.ival==0){
freeInstruction(p);
actions++;
} else
Index: opt_qep.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_qep.mx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- opt_qep.mx 16 Jul 2007 10:52:56 -0000 1.11
+++ opt_qep.mx 2 Jan 2008 08:21:18 -0000 1.12
@@ -225,7 +225,7 @@
p= getInstrPtr(mb,i);
q= QEPnewNode(mb,p);
for( k=p->retc; k<p->argc; k++)
- if( ! isConstant(mb, getArg(p,k)) ){
+ if( ! isVarConstant(mb, getArg(p,k)) ){
status[getArg(p,k)]= LEAFNODE;
if( vq[getArg(p,k)] )
QEPappend(q, vq[getArg(p,k)]);
Index: opt_support.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_support.mx,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- opt_support.mx 27 Dec 2007 17:27:09 -0000 1.54
+++ opt_support.mx 2 Jan 2008 08:21:20 -0000 1.55
@@ -515,7 +515,6 @@
opt_export str optimizeMALBlock(MalBlkPtr mb);
opt_export void showOptimizerStep(str fnme,int i, int flg);
opt_export void showOptimizerHistory(void);
-opt_export void replaceAlias(MalBlkPtr mb, int pc, int pcl, int src, int
alias);
opt_export int isUnsafeInstruction(InstrPtr q);
opt_export int isUnsafeFunction(InstrPtr q);
@@ -531,12 +530,7 @@
opt_export int isSideEffectFree(MalBlkPtr mb);
opt_export int isBlocking(InstrPtr p);
opt_export int isFragmentGroup(InstrPtr q);
-opt_export int allArgumentsVisible(MalBlkPtr mb, int pc,int qc);
-opt_export int allTargetsVisible(MalBlkPtr mb, int pc, int qc);
-
-#define isAlife(M,I,X) ( getBeginLifespan(M,I)<=X && \
- getEndLifespan(M,I)>=X)
-#define isSinglepoint(M,I) (getBeginLifespan(M,I)== getEndLifespan(M,I))
+opt_export int allTargetsVisible(MalBlkPtr mb, Lifespan span, int pc,int qc);
@}
@-
@node Framework, Lifespan Analysis, Building Blocks, The MAL Optimizer
@@ -610,9 +604,8 @@
#define OPT_CHECK_FLOW 1
#define OPT_CHECK_TYPES 2
#define OPT_CHECK_DECL 4
-#define OPT_CHECK_SPAN 8
-#define OPT_CHECK_ALL (OPT_CHECK_FLOW | OPT_CHECK_TYPES | OPT_CHECK_DECL |
OPT_CHECK_SPAN)
+#define OPT_CHECK_ALL (OPT_CHECK_FLOW | OPT_CHECK_TYPES | OPT_CHECK_DECL )
@c
int
optimizerCheck(MalBlkPtr mb, str name, int actions, lng usec, int flag)
@@ -621,8 +614,7 @@
if( actions > 0){
if( flag & OPT_CHECK_TYPES) chkTypes(cntxt->nspace, mb);
if( flag & OPT_CHECK_FLOW) chkFlow(mb);
- if( flag & OPT_CHECK_DECL) chkDeclarations(mb, TRUE);
- if( flag & OPT_CHECK_SPAN) setLifespan(mb);
+ if( flag & OPT_CHECK_DECL) chkDeclarations(mb);
}
if( cntxt->debugOptimizer){
/* keep the actions take as post block comments */
@@ -726,10 +718,10 @@
return FALSE;
for(k=p->retc; k<p->argc;k++)
if( q->argv[k]!= p->argv[k]){
- if( isConstant(mb,getArg(p,k)) &&
isConstant(mb,getArg(q,k)) ) {
+ if( isVarConstant(mb,getArg(p,k)) &&
isVarConstant(mb,getArg(q,k)) ) {
ValPtr w,u;
- w= &getConstant(mb,getArg(p,k));
- u= &getConstant(mb,getArg(q,k));
+ w= &getVarConstant(mb,getArg(p,k));
+ u= &getVarConstant(mb,getArg(q,k));
if( ATOMcmp(w->vtype, VALptr(w),
VALptr(u)) == 0)
continue;
@@ -766,6 +758,7 @@
if( getArg(q,i)== getArg(p,j)) return TRUE;
return FALSE;
}
[EMAIL PROTECTED]
@-
See is all arguments mentioned in the instruction at point pc
are still visible at instruction qc and have not been updated
@@ -774,7 +767,7 @@
a block. This can be calculated using the BARRIER/CATCH
and EXIT pairs.
@c
-int
+static int
countBlocks(MalBlkPtr mb, int start, int stop){
int i,cnt =0;
InstrPtr p;
@@ -788,7 +781,7 @@
return cnt;
}
int
-allArgumentsVisible(MalBlkPtr mb, int pc,int qc){
+allArgumentsVisible(MalBlkPtr mb, Lifespan span, int pc,int qc){
int i;
InstrPtr p;
@@ -796,14 +789,14 @@
return FALSE;
p= getInstrPtr(mb,pc);
for(i=p->retc; i< p->argc; i++){
- if( getLastUpdate(mb,getArg(p,i)) >
getBeginLifespan(mb,getArg(p,i)) &&
- qc > getLastUpdate(mb,getArg(p,i)) )
+ if( getLastUpdate(span,getArg(p,i)) >
getBeginLifespan(span,getArg(p,i)) &&
+ qc > getLastUpdate(span,getArg(p,i)) )
return FALSE;
}
return TRUE;
}
int
-allTargetsVisible(MalBlkPtr mb, int pc,int qc){
+allTargetsVisible(MalBlkPtr mb, Lifespan span, int pc,int qc){
int i;
InstrPtr p;
@@ -811,13 +804,12 @@
return FALSE;
p= getInstrPtr(mb,pc);
for(i=0; i < p->retc; i++){
- if( getLastUpdate(mb,getArg(p,i))>
getBeginLifespan(mb,getArg(p,i)) &&
- qc > getLastUpdate(mb,getArg(p,i)) )
+ if( getLastUpdate(span,getArg(p,i))>
getBeginLifespan(span,getArg(p,i)) &&
+ qc > getLastUpdate(span,getArg(p,i)) )
return FALSE;
}
return TRUE;
}
[EMAIL PROTECTED]
@-
The safety property should be relatively easy to determine for
each MAL function. This calls for accessing the function MAL block
@@ -1176,23 +1168,6 @@
return TRUE;
return FALSE;
}
-
-void
-replaceAlias(MalBlkPtr mb, int pc, int pcl, int src, int alias)
-{
- InstrPtr p;
- int k;
-
- for (; pc < pcl; pc++) {
- p = getInstrPtr(mb, pc);
- for (k = p->retc; k < p->argc; k++)
- if (p->argv[k] == src) {
- p->argv[k] = alias;
- if (pc > getEndLifespan(mb,alias))
- getEndLifespan(mb,alias)= pc;
- }
- }
-}
@-
Used in the merge table optimizer. It is build incrementally
and should be conservative.
Index: opt_heuristics.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_heuristics.mx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- opt_heuristics.mx 16 Jul 2007 10:52:41 -0000 1.9
+++ opt_heuristics.mx 2 Jan 2008 08:21:12 -0000 1.10
@@ -87,7 +87,7 @@
p = pushArgument(mb, p, q->argv[3]);
removeInstruction(mb, q);
chkFlow(mb);
- chkDeclarations(mb, TRUE);
+ chkDeclarations(mb);
return 1;
}
}
@@ -119,7 +119,7 @@
/* process the combinators */
for (i = 0; i < mb->stop - 1; i++) {
p = getInstrPtr(mb, i);
- for (k = i + 1; k < mb->stop && isAlife(mb, p->argv[0], k); k++)
+ for (k = i + 1; k < mb->stop; k++)
if (SPcombi000(mb, i, k)) {
#ifdef DEBUG_OPT_OPTIMIZER
stream_printf(GDKout, "Combinator found\n");
@@ -127,13 +127,12 @@
#endif
combis++;
k--; /* an instruction has been removed */
- setLifespan(mb); /* expensive but needed
*/
}
}
/* process the squeezers */
for (i = 0; i < mb->stop - 1; i++) {
p = getInstrPtr(mb, i);
- for (k = i + 1; k < mb->stop && isAlife(mb, p->argv[0], k); k++)
+ for (k = i + 1; k < mb->stop; k++)
if (SPsqueezer000(mb, i, k)) {
#ifdef DEBUG_OPT_OPTIMIZER
stream_printf(GDKout, "Squeezer found\n");
Index: opt_accumulators.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_accumulators.mx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- opt_accumulators.mx 31 Oct 2007 07:16:25 -0000 1.20
+++ opt_accumulators.mx 2 Jan 2008 08:21:01 -0000 1.21
@@ -75,10 +75,11 @@
char *available;
int *alias;
InstrPtr *old;
+ Lifespan span= newLifespan(mb);
(void) pci;
(void) stk; /* to fool compilers */
- setLifespan(mb);
+ setLifespan(mb,span);
alias= (int*) alloca(sizeof(int)*mb->vtop);
for(j=0;j< mb->vtop; j++)
alias[j]=j;
@@ -134,24 +135,24 @@
b = getArg(p, 0);
valid= 0;
- if( available[getArg(p,1)] &&
getEndLifespan(mb,getArg(p,1))<=i){
+ if( available[getArg(p,1)] &&
getEndLifespan(span,getArg(p,1))<=i){
v = getVar(mb, a = getArg(p, 1));
valid= v->type == getVarType(mb,b);
}
- if(!valid && available[getArg(p,2)] &&
getEndLifespan(mb,getArg(p,2))<=i){
+ if(!valid && available[getArg(p,2)] &&
getEndLifespan(span,getArg(p,2))<=i){
v = getVar(mb, a = getArg(p, 2));
valid= v->type == getVarType(mb,b);
}
- if(!valid && getEndLifespan(mb,getArg(p,1))<=i){
+ if(!valid && getEndLifespan(span,getArg(p,1))<=i){
v = getVar(mb, a = getArg(p, 1));
valid= v->type == getVarType(mb,b);
}
- if( !valid && getEndLifespan(mb,getArg(p,2)) <= i){
+ if( !valid && getEndLifespan(span,getArg(p,2)) <= i){
v = getVar(mb, a = getArg(p, 2));
valid=v->type == getVarType(mb,b);
}
- if( getLastUpdate(mb,b) != i || !valid ||
!isaBatType(v->type)) {
+ if( getLastUpdate(span,b) != i || !valid ||
!isaBatType(v->type)) {
pushInstruction(mb,p);
continue;
}
@@ -179,7 +180,7 @@
/* unary operation, check first argument and return
type */
v = getVar(mb, a = getArg(p, 1));
b = getArg(p, 0);
- if( getLastUpdate(mb,b) != i || getEndLifespan(mb,a) >
i ||
+ if( getLastUpdate(span,b) != i ||
getEndLifespan(span,a) > i ||
!isaBatType(v->type) || v->type!=
getVarType(mb,b) ) {
pushInstruction(mb,p);
continue;
@@ -200,6 +201,7 @@
if(old[i])
freeInstruction(old[i]);
GDKfree(old);
+ GDKfree(span);
return actions;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins