Changeset: 712f0fb51f07 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=712f0fb51f07
Modified Files:
        monetdb5/mal/mal.mx
        monetdb5/mal/mal_box.mx
        monetdb5/mal/mal_builder.mx
        monetdb5/mal/mal_debugger.mx
        monetdb5/mal/mal_factory.mx
        monetdb5/mal/mal_function.mx
        monetdb5/mal/mal_instruction.mx
        monetdb5/mal/mal_interpreter.mx
        monetdb5/mal/mal_profiler.mx
        monetdb5/mal/mal_recycle.mx
        monetdb5/mal/mal_resolve.mx
        monetdb5/mal/mal_session.mx
        monetdb5/mal/mal_stack.mx
        monetdb5/mal/mal_utils.mx
        monetdb5/mal/mal_xml.mx
        monetdb5/modules/mal/batExtensions.mx
        monetdb5/modules/mal/bpm.mx
        monetdb5/modules/mal/inspect.mx
        monetdb5/modules/mal/mal_io.mx
        monetdb5/modules/mal/remote.mx
        monetdb5/optimizer/opt_accumulators.mx
        monetdb5/optimizer/opt_costModel.mx
        monetdb5/optimizer/opt_emptySet.mx
        monetdb5/optimizer/opt_evaluate.mx
        monetdb5/optimizer/opt_garbageCollector.mx
        monetdb5/optimizer/opt_mapreduce.mx
        monetdb5/optimizer/opt_mergetable.mx
        monetdb5/optimizer/opt_multiplex.mx
        monetdb5/optimizer/opt_octopus.mx
        monetdb5/optimizer/opt_partitions.mx
        monetdb5/optimizer/opt_recycler.mx
        monetdb5/optimizer/opt_remap.mx
        monetdb5/optimizer/opt_remoteQueries.mx
        monetdb5/optimizer/opt_replication.mx
        monetdb5/optimizer/opt_support.mx
Branch: headless
Log Message:

mal_stack cleanup
Running backwards from the mal_utilities a code clean up is done.
Where necessary, renamings are propagated immediately


diffs (truncated from 4606 to 300 lines):

diff --git a/monetdb5/mal/mal.mx b/monetdb5/mal/mal.mx
--- a/monetdb5/mal/mal.mx
+++ b/monetdb5/mal/mal.mx
@@ -182,6 +182,10 @@
 #include <gdk.h>
 #include <gdk_utils.h>
 
+#ifdef HAVE_SYS_TIMES_H
+#include <sys/times.h>
+#endif
+
 #ifdef WIN32
 #if !defined(LIBMAL) && !defined(LIBATOMS) && !defined(LIBKERNEL) && 
!defined(LIBMAL) && !defined(LIBOPTIMIZER) && !defined(LIBSCHEDULER) && 
!defined(LIBMONETDB5)
 #define mal_export extern __declspec(dllimport)
diff --git a/monetdb5/mal/mal_box.mx b/monetdb5/mal/mal_box.mx
--- a/monetdb5/mal/mal_box.mx
+++ b/monetdb5/mal/mal_box.mx
@@ -246,7 +246,7 @@
        obj= (Box) GDKzalloc(sizeof(BoxRecord));
        obj->name= GDKstrdup(name);
        obj->sym=  newMalBlk(MAXVARS,STMT_INCREMENT);
-       obj->val = newGlobalStack(MAXVARS);
+       obj->val = newStack(MAXVARS);
        if ( obj->val == NULL)
                showException(MAL,"box.new", MAL_MALLOC_FAIL);
        MT_lock_init(&obj->lock,"M5_box_lock");
@@ -416,7 +416,8 @@
                return 0;
        if (i < 0) {
                i = newVariable(box->sym, GDKstrdup(name), type);
-               chkStack(box->val, i);
+               if (stk->stksize <= i)
+                       box->val = reallocStack(stk, STACKINCR);
        }
        v = &box->val->stk[i];
        VALclear(v);
@@ -710,12 +711,10 @@
                        BAT *b = (BAT *) BATdescriptor(v->val.bval);
                        if (b) {
                                if (b->batPersistence == PERSISTENT){
-                                       str ht = 
getTypeName(getHeadType(getVarType(box->sym,i)));
-                                       str tt = 
getTypeName(getTailType(getVarType(box->sym,i)));
-                                       mnstr_printf(f, "%s:bat[:%s,:%s]:= 
%s.bind(%d);\n", 
-                                               getVarName(box->sym, i),  ht, 
tt,
+                                       str tt = 
getTypeName(getColType(getVarType(box->sym,i)));
+                                       mnstr_printf(f, "%s:col[:%s]:= 
%s.bind(%d);\n", 
+                                               getVarName(box->sym, i),  tt,
                                                box->name, b->batCacheid);
-                                       GDKfree(ht);
                                        GDKfree(tt);
                                        BATsave(b);
                                } 
diff --git a/monetdb5/mal/mal_builder.mx b/monetdb5/mal/mal_builder.mx
--- a/monetdb5/mal/mal_builder.mx
+++ b/monetdb5/mal/mal_builder.mx
@@ -347,7 +347,7 @@
        int _t;
        ValRecord cst;
 
-       if( !isaBatType(tpe) && tpe != TYPE_bat ) {
+       if( !isaColType(tpe) && tpe != TYPE_bat ) {
                assert(tpe < MAXATOMS); /* in particular, tpe!=TYPE_any */
                if (!tpe) {
                        cst.vtype=TYPE_void;
diff --git a/monetdb5/mal/mal_debugger.mx b/monetdb5/mal/mal_debugger.mx
--- a/monetdb5/mal/mal_debugger.mx
+++ b/monetdb5/mal/mal_debugger.mx
@@ -1383,7 +1383,7 @@
                                        mnstr_printf(out, "%s Symbol not 
found\n", "#mdb ");
                                continue;
                        }
-                       if (isaBatType(getVarType(mb,i)) && upper =='p'){
+                       if (isaColType(getVarType(mb,i)) && upper =='p'){
                                printStackHdr(out,  mb, stk->stk + i, i);
                                printBATelm(out, stk->stk[i].val.bval, size, 
first);
                        } else
@@ -1575,7 +1575,7 @@
        for (i=1; i < mb->vtop; i++){
                n= getVar(mb,i);
                v= stk->stk+i;
-               if (isaBatType(n->type) && v->val.ival) {
+               if (isaColType(n->type) && v->val.ival) {
                        int i = v->val.ival;
                        BAT *b;
 
@@ -1584,7 +1584,7 @@
                                b = BATmirror(b);
                        if (b) {
                                nme = getTypeName(n->type);
-                               nmeOnStk = getTypeName(newBatType(b->htype, 
b->ttype));
+                               nmeOnStk = getTypeName(newColType(b->ttype));
                                if (strcmp(nme, nmeOnStk)) {
                                        
printTraceCall(cntxt->fdout,mb,stk,pc,cntxt->flags);
                                        mnstr_printf(cntxt->fdout, "!ERROR: %s 
!= :%s\n",
@@ -1804,7 +1804,7 @@
 
        b = BATdescriptor(i);
        if (b) {
-               tpe = getTypeName(newBatType(b->htype, b->ttype));
+               tpe = getTypeName(newColType(b->ttype));
                mnstr_printf(f, ":%s ",tpe);
                printBATproperties(f,b);
                /* perform property checking */
@@ -1868,7 +1868,7 @@
                if (i < 0)
                        b = BATmirror(b);
                if (b){
-                       nme= getTypeName(newBatType(b->htype, b->ttype));
+                       nme= getTypeName(newColType(b->ttype));
                        mnstr_printf(f, " :%s rows="BUNFMT, nme, BATcount(b));
                } else {
                        nme = getTypeName(n->type);
@@ -1898,7 +1898,7 @@
        mnstr_printf(f, "\n");
        GDKfree(nmeOnStk);
 
-       if (cnt && v && (isaBatType(n->type) || v->vtype== TYPE_bat) && 
v->val.ival) {
+       if (cnt && v && (isaColType(n->type) || v->vtype== TYPE_bat) && 
v->val.ival) {
                BAT *b, *bs;
 
                b = BATdescriptor(v->val.ival);
@@ -1943,14 +1943,14 @@
 void
 printBatInfo(stream *f, VarPtr n, ValPtr v)
 {
-       if (isaBatType(n->type) && v->val.ival) 
+       if (isaColType(n->type) && v->val.ival) 
                printBatDetails(f,v->val.ival);
 }
 
 void
 printBatProperties(stream *f, VarPtr n, ValPtr v, str props)
 {
-       if (isaBatType(n->type) && v->val.ival) {
+       if (isaColType(n->type) && v->val.ival) {
                int bid;
                int ret;
                MALfcn fcn;
diff --git a/monetdb5/mal/mal_factory.mx b/monetdb5/mal/mal_factory.mx
--- a/monetdb5/mal/mal_factory.mx
+++ b/monetdb5/mal/mal_factory.mx
@@ -502,7 +502,7 @@
        plim = plants + lastPlant;
        for (p = plants; p < plim && p->factory; p++)
                ;
-       stk = newGlobalStack(mb->vsize);
+       stk = newStack(mb->vsize);
        if (lastPlant == MAXPLANTS || stk == NULL)
                return 0;
        if (p == plim)
diff --git a/monetdb5/mal/mal_function.mx b/monetdb5/mal/mal_function.mx
--- a/monetdb5/mal/mal_function.mx
+++ b/monetdb5/mal/mal_function.mx
@@ -234,7 +234,7 @@
                            getVarType(mb,v) != TYPE_lng && 
                            getVarType(mb,v) != TYPE_oid && 
                            getVarType(mb,v) != TYPE_sht && 
-                           !isaBatType(getVarType(mb,v)) &&
+                           !isaColType(getVarType(mb,v)) &&
                            getVarType(mb,v) != TYPE_chr && 
                            getVarType(mb,v) != TYPE_bte && 
                            getVarType(mb,v) != TYPE_wrd 
@@ -492,24 +492,17 @@
        if( p->polymorphic)
        for(i=0;i<p->argc; i++)
        if( isPolymorphic(x= getArgType(mb,p,i))) {
-               if( isaBatType(x)){
-                       int head,tail;
-                       int hx,tx;
-                       head = getHeadType(x);
-                       tail = getTailType(x);
-                       hx = getHeadIndex(x);
-                       tx = getTailIndex(x);
-                       if(v && hx == v && head == TYPE_any){
-                           hx =0;
-                           head =t;
-                       }
+               if( isaColType(x)){
+                       int tail;
+                       int tx;
+                       tail = getColType(x);
+                       tx = getColIndex(x);
                        if(v && tx == v && tail == TYPE_any){
                            tx= 0;
                            tail = t;
                        }
-                       y= newBatType(head,tail);
-                       setAnyHeadIndex(y,hx);
-                       setAnyTailIndex(y,tx);
+                       y= newColType(tail);
+                       setColIndex(y,tx);
                        setArgType(mb,p,i,y);
 #ifdef DEBUG_MAL_FCN
                mnstr_printf(GDKout," %d replaced %s->%s 
\n",i,getTypeName(x),getTypeName(y));
@@ -561,7 +554,7 @@
 
                if ( v== TYPE_any)
                        replaceTypeVar(new->def, pp, v, t);
-               if( isaBatType(v) ){
+               if( isaColType(v) ){
                        if( getHeadIndex(v) )
                                replaceTypeVar(new->def, pp, getHeadIndex(v), 
getHeadType(t));
                        if( getTailIndex(v) )
diff --git a/monetdb5/mal/mal_instruction.mx b/monetdb5/mal/mal_instruction.mx
--- a/monetdb5/mal/mal_instruction.mx
+++ b/monetdb5/mal/mal_instruction.mx
@@ -509,7 +509,6 @@
 mal_export void insertInstruction(MalBlkPtr mb, InstrPtr p, int pc);
 mal_export void removeInstruction(MalBlkPtr mb, InstrPtr p);
 mal_export void removeInstructionBlock(MalBlkPtr mb, int pc, int cnt);
-mal_export str operatorName(int i);
 
 mal_export int findVariable(MalBlkPtr mb, str name);
 mal_export int findTmpVariable(MalBlkPtr mb, int type);
@@ -1802,7 +1801,7 @@
                        throw(SYNTAX, "convertConstant", "coercion failed in 
'%s'", vr->val.sval);
        }
        
-       if (type== TYPE_bat ||isaBatType(type)){
+       if (type== TYPE_bat ||isaColType(type)){
                /* BAT variables can only be set to nil */
                vr->vtype = type;
                vr->val.bval = 0;
@@ -1899,7 +1898,7 @@
                int ll = 0;
                ptr d = NULL;
 
-               if( isaBatType(type)){
+               if( isaColType(type)){
                        VALinit(vr, TYPE_bat, ATOMnilptr(TYPE_bat));
                        break;
                }
@@ -1990,7 +1989,7 @@
        ValPtr vr;
        str msg;
 
-       if (cst->vtype != type && !isaBatType(type) && !isPolyType(type)){
+       if (cst->vtype != type && !isaColType(type) && !isPolyType(type)){
                ValRecord vr = *cst;
                int otype = cst->vtype;
                assert(type != TYPE_any);  /* help Coverity */
@@ -2237,7 +2236,7 @@
 
        if (force == FALSE && tpe == TYPE_any)
                return;
-       if (isaBatType(tpe)) {
+       if (isaColType(tpe)) {
                if (getHeadIndex(tpe) > 0)
                        c1 = getHeadIndex(tpe);
                else if (getHeadType(tpe) == TYPE_any)
@@ -2477,7 +2476,7 @@
 str
 fcnClass(InstrPtr p)
 {
-       return operatorName(p->token);
+       return getSymbolName(p->token);
 }
 
 str
@@ -2539,41 +2538,6 @@
        return s;
 }
 
-str
-operatorName(int i)
-{
-       switch (i) {
-       case ASSIGNsymbol:
-               return ":=";
-       case BARRIERsymbol:
-               return "barrier";
-       case REDOsymbol:
-               return "redo";
-       case LEAVEsymbol:
-               return "leave";
-       case EXITsymbol:
-               return "exit";
-       case RETURNsymbol:
-               return "return";
-       case YIELDsymbol:
-               return "yield";
-       case CATCHsymbol:
-               return "catch";
-       case RAISEsymbol:
-               return "raise";
-       case ENDsymbol:
-               return "end";
-       case FUNCTIONsymbol:
-               return "function";
-       case FACTORYsymbol:
-               return "factory";
-       case COMMANDsymbol:
-               return "command";
-       case PATTERNsymbol:
-               return "pattern";
-       }
-       return "Undefined";
-}
 
 @= showVariableProperties
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to