Changeset: f99f7ab1a066 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f99f7ab1a066
Modified Files:
        monetdb5/optimizer/opt_mutation.c
        monetdb5/scheduler/mut_policy.c
        monetdb5/scheduler/mut_transforms.c
        monetdb5/scheduler/run_mutation.c
Branch: mutation
Log Message:

Handle the side effects of mutation
Since the mutation may change the stack, we should pre-allocate
enough space to avoid a complex communication from the dataflow
back into the interpreter, whenit changes the stack frame.


diffs (104 lines):

diff --git a/monetdb5/optimizer/opt_mutation.c 
b/monetdb5/optimizer/opt_mutation.c
--- a/monetdb5/optimizer/opt_mutation.c
+++ b/monetdb5/optimizer/opt_mutation.c
@@ -19,6 +19,12 @@
 #include "monetdb_config.h"
 #include "opt_mutation.h"
 
+
+/* (c) M Kersten
+ * Make sure the symbol table has enough slack to accomodate
+ * variables used during the call
+ */
+
 int 
 OPTmutationImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci)
 {
@@ -50,5 +56,10 @@ OPTmutationImplementation(Client cntxt, 
                if( old[i])
                        freeInstruction(old[i]);
        GDKfree(old);
+       /* resize the symbol table */
+       slimit = mb->vtop;
+       for ( i = 0; i <limit; i++)
+               (void) newTmpVariable(mb,TYPE_any);
+       mb->vtop = slimit;
        return 1;
 }
diff --git a/monetdb5/scheduler/mut_policy.c b/monetdb5/scheduler/mut_policy.c
--- a/monetdb5/scheduler/mut_policy.c
+++ b/monetdb5/scheduler/mut_policy.c
@@ -48,8 +48,7 @@ str
 MUTpolicy(Client cntxt, Mutant m) 
 {
        MalBlkPtr src = m->src;
-       MalStkPtr stk = m->stk;
-       int i, target = 0, stop, vtop;
+       int i, target = 0, stop;
        InstrPtr p;
 
        (void) cntxt;
@@ -83,7 +82,6 @@ MUTpolicy(Client cntxt, Mutant m)
        /* safe the previous version in the history list */
        if ( mutationCandidate(src,  p = getInstrPtr(src, m->target)) ){
                stop = src->stop;
-               vtop = src->vtop;
 
                /* apply heuristics */
                if ( getModuleId(p) && strncmp(getModuleId(p), "algebra",7)== 0)
@@ -100,14 +98,9 @@ MUTpolicy(Client cntxt, Mutant m)
                for( i = 0; i < src->stop; i++)
                        src->profiler[i].ticks = 0;
 
-               /* initialize the possibly expanded stack frame */
-               if ( vtop < src->vtop){
-                       stk= (MalStkPtr) GDKrealloc(stk, stackSize(src->vtop) + 
sizeof(MalStack));
-                       for (i = vtop ; i< src->vtop; i++)
-                               stk->stk[i].val.lval = 0;
-               }
                src->calls = 0;
                chkProgram(cntxt->fdout,cntxt->nspace,src);
+               chkFlow(cntxt->fdout,src);
                DEBUG_MUTATION
                        printFunction(cntxt->fdout, src,0,LIST_MAL_ALL);
                if ( src->errors)
diff --git a/monetdb5/scheduler/mut_transforms.c 
b/monetdb5/scheduler/mut_transforms.c
--- a/monetdb5/scheduler/mut_transforms.c
+++ b/monetdb5/scheduler/mut_transforms.c
@@ -56,10 +56,12 @@ mutationSelect(Client cntxt, Mutant m){
                                v1:= algebra.select(b1,l,h);
                                v2:= algebra.select(b2,l,h);
                                v:= mat.pack(v1,v2);
-                         Also initialize the corresponding stk, which may 
actually
-                         have to be extended.
+                         Be careful not to change the size of the stack,
+                         for we can not easily pass it back to the 
+                         current interpreter call sequence
                        */
-                       m->stk = (MalStkPtr) GDKrealloc(m->stk, 
stackSize(m->src->vtop + 4));
+                       if ( m->stk->stksize < m->src->vtop + 4)
+                               continue;
                        q= newStmt(m->src, batRef, partitionRef);
                        setVarType(m->src, getArg(q,0), getArgType(m->src, p, 
p->retc));
                        b1 = getArg(q,0);
@@ -93,7 +95,7 @@ mutationSelect(Client cntxt, Mutant m){
                        for (j = i; j < limit; j++) {
                                q= old[j];
                                if ( getModuleId(q) == matRef && 
getFunctionId(q) == packRef){
-                                       for( k= q->retc; k < q->argc; k++)
+                                       for( k= old[j]->retc; k < old[j]->argc; 
k++)
                                                if ( getArg(q,k) == 
getArg(p,0)){
                                                        /* replace this 
argument */
                                                        matpc++;
diff --git a/monetdb5/scheduler/run_mutation.c 
b/monetdb5/scheduler/run_mutation.c
--- a/monetdb5/scheduler/run_mutation.c
+++ b/monetdb5/scheduler/run_mutation.c
@@ -83,7 +83,7 @@ RUNmutation(Client cntxt, MalBlkPtr mb, 
                return msg;
        
        clk = GDKusec();
-       msg = runMALdataflow(cntxt, mb, getPC(mb,pci), pci->jump, mutant->stk);
+       msg = runMALdataflow(cntxt, mutant->src, getPC(mb,pci), pci->jump, 
mutant->stk);
        mutant->runtime += GDKusec()- clk;
        
        *ret = 0;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to