Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv18890

Modified Files:
        mal_instruction.mx mal_interpreter.mx 
Log Message:
The compilation error in opt_crackers indicates that the number
of arguments in the mal_instruction record should have been handled 
differently.
Also the backup buffers in mal_interpreter had hardwired MAXARG.
The solution is to also keep a maxarg in the MalBlk.


Index: mal_interpreter.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_interpreter.mx,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -d -r1.194 -r1.195
--- mal_interpreter.mx  8 Aug 2007 14:01:29 -0000       1.194
+++ mal_interpreter.mx  4 Sep 2007 07:40:35 -0000       1.195
@@ -403,8 +403,8 @@
        int exceptionVar, exceptionPC;
        str ret=0;
        int stamp= -1;
-       int backup[MAXARG];
-       str sbackup[MAXARG];
+       short *backup= (short*) alloca(mb->maxarg * sizeof(short));
+       str *sbackup= (str*) alloca(mb->maxarg * sizeof(str));
        lng oldtimer=0;
        struct mallinfo oldMemory;
 #ifdef HAVE_SYS_RESOURCE_H
@@ -569,8 +569,8 @@
        int exceptionVar, exceptionPC;
        str ret=0;
        int stamp= -1;
-       int backup[MAXARG];
-       str sbackup[MAXARG];
+       short *backup= (short*) alloca(mb->maxarg * sizeof(short));
+       str *sbackup= (str*) alloca(mb->maxarg * sizeof(str));
        lng oldtimer=0;
        struct mallinfo oldMemory;
 #ifdef HAVE_SYS_RESOURCE_H
@@ -935,6 +935,7 @@
        printInstruction(GDKout,mb,pci, LIST_MAL_ALL);
 #endif
        if( needsCleanup(pci) ){ 
+               assert(pci->retc <= mb->maxarg); 
                for(i=0; i<pci->retc; i++) {
                        sbackup[i]= 0;  
                        backup[i]= 0;  

Index: mal_instruction.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_instruction.mx,v
retrieving revision 1.285
retrieving revision 1.286
diff -u -d -r1.285 -r1.286
--- mal_instruction.mx  3 Sep 2007 07:40:06 -0000       1.285
+++ mal_instruction.mx  4 Sep 2007 07:40:35 -0000       1.286
@@ -366,7 +366,7 @@
        str modname;            /* module context */
        str fcnname;            /* function name */
        short argc, retc, maxarg;       /* total and result argument count */
-       short argv[MAXARG];             /* at least a few entries */
+       short argv[];           /* at least a few entries */
 } *InstrPtr, InstrRecord;
 
 @-
@@ -407,6 +407,7 @@
        struct MALBLK *history;/* of optimizer actions */
        int keephistory;        /* do we need the history at all */
        str marker;                     /* history points are marked for 
backtracking */
+       int maxarg;                     /* keep track on the maximal arguments 
used */
 } *MalBlkPtr, MalBlkRecord;
 
 @-
@@ -644,6 +645,7 @@
        mb->history = NULL;
        mb->keephistory = 0;
        mb->marker = 0;
+       mb->maxarg = MAXARG; /* the minimum for each instruction */
        mb->typefixed = 0;
        mb->flowfixed = 0;
        mb->profiler = NULL;
@@ -746,6 +748,7 @@
        mb->errors = old->errors;
        mb->typefixed = old->typefixed;
        mb->flowfixed = old->flowfixed;
+       mb->maxarg= old->maxarg;
        /* copy the properties as well */
        if (mb->props)
                mb->props = cpyPropertySet(old->props);
@@ -906,7 +909,7 @@
                mb->stmt[mb->stop] = NULL;
        }
        if (p == NULL) {
-               p = GDKmalloc(sizeof(InstrRecord));
+               p = GDKmalloc(MAXARG * sizeof(short) + sizeof(InstrRecord));
                p->maxarg = MAXARG;
        }
        p->typechk = TYPE_UNKNOWN;
@@ -952,7 +955,7 @@
 copyInstruction(InstrPtr p)
 {
        InstrPtr new;
-       new = (InstrPtr) GDKmalloc(sizeof(InstrRecord) + sizeof(short) * 
(p->maxarg - MAXARG));
+       new = (InstrPtr) GDKmalloc(sizeof(InstrRecord) + p->maxarg * 
sizeof(short));
        oldmoveInstruction(new, p);
        return new;
 }
@@ -969,7 +972,7 @@
 clrInstruction(InstrPtr p)
 {
        clrFunction(p);
-       memset((char *) p, 0, sizeof(InstrRecord) + (p->maxarg - MAXARG) * 
sizeof(int));
+       memset((char *) p, 0, sizeof(InstrRecord) + p->maxarg * sizeof(short));
 }
 
 void
@@ -988,7 +991,7 @@
 {
        int space;
 
-       space = sizeof(InstrRecord) + sizeof(short) * (p->maxarg-MAXARG);
+       space = sizeof(InstrRecord) + p->maxarg * sizeof(short);
        memcpy((char *) new, (char *) p, space);
        setFunctionId(new, getFunctionId(p));
        setModuleId(new, getModuleId(p));
@@ -1829,7 +1832,7 @@
        if (p->argc == p->maxarg) {
                InstrPtr pn;
                int pc = 0,pclimit;
-               int space = (p->maxarg - MAXARG) * sizeof(short) + 
sizeof(InstrRecord);
+               int space = p->maxarg * sizeof(short) + sizeof(InstrRecord);
                pn = GDKmalloc(space + MAXARG * sizeof(short));
                memcpy((char *) pn, (char *) p, space);
                pn->maxarg += MAXARG;
@@ -1852,6 +1855,10 @@
                        mb->stmt[pc] = pn;
                        break;
                }
+               /* we have to keep track on the maximal arguments/block
+                 because it is needed by the interpreter */
+               if( mb->maxarg < pn->maxarg)
+                       mb->maxarg= pn->maxarg;
                GDKfree(p);
                p = pn;
        }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to