Changeset: b5633540a8c5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b5633540a8c5
Modified Files:
        monetdb5/mal/mal_interpreter.mx
        monetdb5/mal/mal_stack.c
Branch: default
Log Message:

Merge with Aug2011 branch.


diffs (truncated from 479 to 300 lines):

diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -1913,28 +1913,27 @@
        char *color;
        char *info;
 } Encoding[] = {
-       {
-       '.', "0x00FFFDFE", "free"}, {
-       '0', "0x000035FC", "thread stack space of thread 0"}, {
-       '1', "0x000067FE", "thread stack space of thread 1"}, {
-       '2', "0x000095FE", "thread stack space of thread 2"}, {
-       '3', "0x0000BDFC", "thread stack space of thread 3"}, {
-       '4', "0x0000DCF8", "thread stack space of thread 4"}, {
-       '5', "0x002735FC", "thread stack space of thread 5"}, {
-       '6', "0x002767FE", "thread stack space of thread 6"}, {
-       '7', "0x002795FE", "thread stack space of thread 7"}, {
-       '8', "0x0027BDFC", "thread stack space of thread 8"}, {
-       '9', "0x0027DCF8", "thread stack space of thread 9"}, {
-       'B', "0x0000672D", "in use for a large BAT heap."}, {
-       'b', "0x004EF2A7", "free (last usage was B)"}, {
-       'S', "0x00B4006E", "in use for a malloc block"}, {
-       's', "0x00F2BDE0", "free (last usage was S)"}, {
-       'P', "0x00F26716", "in use for the BBP array"}, {
-       'p', "0x00F2BD16", "free (last usage was P)"}, {
-       'M', "0x00959516", "in use as memory mapped region"}, {
-       'm', "0x00CEDC16", "free (last usage was M)"}, {
-       'c', "0x00FFFD2D", "free (last usage was M)"}, {
-       0, "0x00FFFDFE", "free"}
+       {'.', "0x00FFFDFE", "free"},
+       {'0', "0x000035FC", "thread stack space of thread 0"},
+       {'1', "0x000067FE", "thread stack space of thread 1"},
+       {'2', "0x000095FE", "thread stack space of thread 2"},
+       {'3', "0x0000BDFC", "thread stack space of thread 3"},
+       {'4', "0x0000DCF8", "thread stack space of thread 4"},
+       {'5', "0x002735FC", "thread stack space of thread 5"},
+       {'6', "0x002767FE", "thread stack space of thread 6"},
+       {'7', "0x002795FE", "thread stack space of thread 7"},
+       {'8', "0x0027BDFC", "thread stack space of thread 8"},
+       {'9', "0x0027DCF8", "thread stack space of thread 9"},
+       {'B', "0x0000672D", "in use for a large BAT heap."},
+       {'b', "0x004EF2A7", "free (last usage was B)"},
+       {'S', "0x00B4006E", "in use for a malloc block"},
+       {'s', "0x00F2BDE0", "free (last usage was S)"},
+       {'P', "0x00F26716", "in use for the BBP array"},
+       {'p', "0x00F2BD16", "free (last usage was P)"},
+       {'M', "0x00959516", "in use as memory mapped region"},
+       {'m', "0x00CEDC16", "free (last usage was M)"},
+       {'c', "0x00FFFD2D", "free (last usage was M)"},
+       {0, "0x00FFFDFE", "free"}
 };
 #endif
 
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
@@ -425,7 +425,8 @@
                return 0;
        if (i < 0) {
                i = newVariable(box->sym, GDKstrdup(name), type);
-               chkStack(box->val, i);
+               if (box->val->stksize <= i) 
+                       box->val =reallocStack(box->val, STACKINCR);
        }
        v = &box->val->stk[i];
        VALclear(v);
diff --git a/monetdb5/mal/mal_interpreter.mx b/monetdb5/mal/mal_interpreter.mx
--- a/monetdb5/mal/mal_interpreter.mx
+++ b/monetdb5/mal/mal_interpreter.mx
@@ -449,9 +449,9 @@
 #if FAST
        int stamp = -1;
 #endif
-       bat *backup = (bat*)alloca(mb->maxarg * sizeof(bat));
-       str *sbackup = (str*)alloca(mb->maxarg * sizeof(str));
-       int *garbage = (int*)alloca(mb->maxarg * sizeof(int));
+       bat *backup = (bat*)GDKzalloc(mb->maxarg * sizeof(bat));
+       str *sbackup = (str*)GDKzalloc(mb->maxarg * sizeof(str));
+       int *garbage = (int*)GDKzalloc(mb->maxarg * sizeof(int));
        lng oldtimer = 0;
        struct Mallinfo oldMemory;
        int stkpc = 0;
@@ -545,6 +545,9 @@
                }
        }
        @:MALwrapup@
+       GDKfree(backup);
+       GDKfree(sbackup);
+       GDKfree(garbage);
        return ret;
 }
 @h
@@ -921,9 +924,9 @@
 #if FAST
        int stamp = -1;
 #endif
-       bat *backup = (bat*)alloca(fs->mb->maxarg * sizeof(bat));
-       str *sbackup = (str*)alloca(fs->mb->maxarg * sizeof(str));
-       int *garbage = (int*)alloca(fs->mb->maxarg * sizeof(int));
+       bat *backup = (bat*)GDKzalloc(fs->mb->maxarg * sizeof(bat));
+       str *sbackup = (str*)GDKzalloc(fs->mb->maxarg * sizeof(str));
+       int *garbage = (int*)GDKzalloc(fs->mb->maxarg * sizeof(int));
        Client cntxt = fs->cntxt;
        MalBlkPtr mb = fs->mb;
        MalStkPtr stk = fs->stk;
@@ -966,6 +969,9 @@
                        /* need a way to skip */
                        stkpc = mb->stop;
                        fs->state = -1;
+                       GDKfree(backup);
+                       GDKfree(sbackup);
+                       GDKfree(garbage);
                        return ret;
                }
                if (oldtimer) {
@@ -991,19 +997,19 @@
                 */
                switch (pci->token) {
                case ASSIGNsymbol: 
-                       @:assignStmt(FAST,fs->pc = -fs->pc; return ret,t)@ 
+                       @:assignStmt(FAST,fs->pc = -fs->pc; GDKfree(backup); 
GDKfree(sbackup);GDKfree(garbage); return ret,t)@ 
                        break;
                case PATcall: 
-                       @:patterncall(FAST,fs->pc = -fs->pc; return ret,t)@ 
+                       @:patterncall(FAST,fs->pc = -fs->pc; GDKfree(backup); 
GDKfree(sbackup);GDKfree(garbage); return ret,t)@ 
                        break;
                case CMDcall: 
-                       @:commandcall(FAST,fs->pc = -fs->pc; return ret,t)@ 
+                       @:commandcall(FAST,fs->pc = -fs->pc; GDKfree(backup); 
GDKfree(sbackup);GDKfree(garbage); return ret,t)@ 
                        break;
                case FACcall: 
-                       @:factorycall(FAST,fs->pc = -fs->pc; return ret,t)@ 
+                       @:factorycall(FAST,fs->pc = -fs->pc; GDKfree(backup); 
GDKfree(sbackup);GDKfree(garbage); return ret,t)@ 
                        break;
                case FCNcall: 
-                       @:functioncall(FAST,fs->pc = -fs->pc; return ret,t)@ 
+                       @:functioncall(FAST,fs->pc = -fs->pc; GDKfree(backup); 
GDKfree(sbackup);GDKfree(garbage); return ret,t)@ 
                        break;
                case NOOPsymbol:
                case REMsymbol:
@@ -1020,6 +1026,9 @@
        @:endProfile(t)@
        if (ret)
                fs->pc = -fs->pc;
+       GDKfree(backup);
+       GDKfree(sbackup);
+       GDKfree(garbage);
        return ret;
 }
 
diff --git a/monetdb5/mal/mal_resolve.mx b/monetdb5/mal/mal_resolve.mx
--- a/monetdb5/mal/mal_resolve.mx
+++ b/monetdb5/mal/mal_resolve.mx
@@ -139,7 +139,7 @@
        int i, k, unmatched = 0, s1;
        /* int foundbutwrong=0;*/
        int polytype[MAXTYPEVAR];
-       int *returntype;
+       int *returntype= NULL;
        /*
         * @-
         * Within a module find the subscope to locate the element in its list
@@ -357,7 +357,7 @@
                 * the resulting type can not be determined.
                 */
                s1 = 0;
-               returntype = (int*)alloca(p->retc * sizeof(int));
+               returntype= (int*) GDKzalloc(p->retc * sizeof(int));
                if (sig->polymorphic)
                        for (k = i = 0; i < p->retc; k++, i++) {
                                int actual = getArgType(mb, p, i);
@@ -412,7 +412,7 @@
                                showScriptException(mb, getPC(mb, p), TYPE, 
"Assignment to constant");
                                p->typechk = TYPE_UNKNOWN;
                                mb->errors++;
-                               return -3;
+                               goto wrapup;
                        }
                        if (!isVarFixed(mb, getArg(p, i)) && ts >= 0) {
                                setVarType(mb, getArg(p, i), ts);
@@ -459,7 +459,8 @@
                        }
                        if (cnt == 0 && s->kind != COMMANDsymbol && s->kind != 
PATTERNsymbol) {
                                s = cloneFunction(scope, s, mb, p);
-                               if (s->def->errors) return -3;
+                               if (s->def->errors)
+                                       goto wrapup;
                        }
                }
 /*
@@ -473,7 +474,7 @@
        if (s->def->errors) {
                p->typechk = TYPE_UNKNOWN;
                mb->errors++;
-               return -3;
+               goto wrapup;
        }
        if (p->token == ASSIGNsymbol) {
                switch (getSignature(s)->token) {
@@ -486,7 +487,7 @@
                                        p->modname, p->fcnname);
                                p->typechk = TYPE_UNKNOWN;
                                mb->errors++;
-                               return -3;
+                               goto wrapup;
                        }
                        break;
                case PATTERNsymbol:
@@ -507,7 +508,7 @@
                                showScriptException(mb, getPC(mb, p), MAL,
                                        "MALresolve: unexpected token type");
                        mb->errors++;
-                       return -3;
+                       goto wrapup;
                }
                }
                p->blk = s->def;
@@ -538,6 +539,8 @@
                        mnstr_printf(GDKout, "Finished matching\n");
                }
 #endif
+               if ( returntype)
+                       GDKfree(returntype);
                return s1;
        } /* while */
        /*
@@ -546,12 +549,15 @@
         * that we found an instruction with the proper arguments, but that 
clashes
         * with one of the target variables.
         */
+wrapup:
        /* foundbutwrong has not been changed, commented out code above
        if( foundbutwrong && !silent){
                showScriptException(mb, getPC(mb, p), TYPE,
                        "type conflict in assignment");
        }
        */
+       if ( returntype)
+               GDKfree(returntype);
        return -3;
 }
 
@@ -847,6 +853,7 @@
                        @:bindFunction@
                }
        }
+wrapup:
        return 0;
 }
 /*
diff --git a/monetdb5/mal/mal_stack.c b/monetdb5/mal/mal_stack.c
--- a/monetdb5/mal/mal_stack.c
+++ b/monetdb5/mal/mal_stack.c
@@ -95,7 +95,6 @@
        return s;
 }
 
-#if 0
 /* dark code, we need quite some lux to shed a little light on this */
 MalStkPtr
 reallocStack(MalStkPtr s, int cnt)
@@ -106,16 +105,12 @@
        if (s->stksize > cnt)
                return s;
        k = ((cnt / STACKINCR) + 1) * STACKINCR;
-       s = (MalStkPtr) alloca(stackSize(k));
-       memset((char *) s, 0, stackSize(k));
+       s = (MalStkPtr) GDKzalloc(stackSize(k));
        memcpy(s, old, stackSize(old->stksize));
        s->stksize = k;
-       /* cannot gdk free, alloca data */
-       assert(0);
        GDKfree(old);
        return s;
 }
-#endif
 
 /*
  * @-
@@ -125,19 +120,6 @@
  * runtime stack.
  */
 void
-chkStack(MalStkPtr stk, int i)
-{
-#if 0
-/* avoid the darkness */
-       if (stk->stksize <= i) {
-               reallocStack(stk, STACKINCR);
-       }
-#else
-       (void)stk;
-       (void)i;
-#endif
-}
-void
 freeStack(MalStkPtr stk)
 {
        clearStack(stk);
diff --git a/monetdb5/mal/mal_stack.h b/monetdb5/mal/mal_stack.h
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to