Changeset: c69fe4009472 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c69fe4009472 Modified Files: MonetDB5/src/mal/mal_interpreter.mx Branch: default Log Message:
Merge with Oct2010 branch. diffs (truncated from 1237 to 300 lines): diff -r cc4c5ff7fc5d -r c69fe4009472 MonetDB5/src/mal/mal_interpreter.mx --- a/MonetDB5/src/mal/mal_interpreter.mx Thu Oct 07 16:38:51 2010 +0200 +++ b/MonetDB5/src/mal/mal_interpreter.mx Thu Oct 07 16:50:11 2010 +0200 @@ -54,11 +54,11 @@ mal_export MalStkPtr prepareMALstack(MalBlkPtr mb, int size); mal_export str runMAL(Client c, MalBlkPtr mb, int startpc, MalBlkPtr mbcaller, MalStkPtr env, InstrPtr pcicaller); -mal_export str runMALdataflow( Client cntxt, MalBlkPtr mb, int startpc, +mal_export str runMALdataflow( Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr pcicaller); mal_export str reenterMAL(Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr pcicaller); -mal_export str callMAL(Client cntxt, MalBlkPtr mb, MalStkPtr *glb, +mal_export str callMAL(Client cntxt, MalBlkPtr mb, MalStkPtr *glb, ValPtr argv[], char debug); mal_export void garbageElement(Client cntxt, ValPtr v); mal_export void garbageCollector(Client cntxt, MalBlkPtr mb, MalStkPtr stk, int flag); @@ -78,7 +78,7 @@ #define SLOW 1 #define FAST 0 -static str runMALsequence( Client cntxt, MalBlkPtr mb, int startpc, +static str runMALsequence( Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr pcicaller); static void displayVolume(Client cntxt, lng vol); @@ -129,11 +129,11 @@ case TYPE_lng: ret= (ptr) & v->val.lval; break; case TYPE_str: ret= (ptr) & v->val.sval; break; default: - ret= (ptr) & v->val.pval; + ret= (ptr) & v->val.pval; } return ret; #endif -} +} /* code is obsolete, because all should be handled as exceptions */ void showErrors(Client cntxt) { @@ -147,19 +147,19 @@ } } @- -The bigfoot memory tracker keeps track on the space occupancy of BATs. +The bigfoot memory tracker keeps track on the space occupancy of BATs. The property 'memory' illustrates the total amount of memory claimed. It ignores for the time being the heaps for the variable sized atoms. Moreover, it is not thread safe and it can not correctly handle aliases embedded in MAL assignments. This means that the footprint is only to be used as indicative. @c -static INLINE void +static INLINE void updateBigFoot(Client cntxt, int bid, int add) { BAT *b; lng total = 0,vol = 0; - + if (bid != bat_nil ){ BUN cnt = 0; b= BBPquickdesc(ABS(bid),TRUE); @@ -174,11 +174,11 @@ total += cnt * sizeof(int); if ( b->T->hash ) total += cnt * sizeof(int); - + if (add) { cntxt->vmfoot += total; cntxt->memory += total; - } else + } else cntxt->vmfoot -= total; /* correct for limitations by resetting */ if (cntxt->vmfoot < 0) @@ -189,7 +189,7 @@ } @- Copy the constant values onto the stack frame -Also we cannot overwrite values on the stack as this maybe part of a +Also we cannot overwrite values on the stack as this maybe part of a sequence of factory calls. BEWARE WE ASSUME THAT FIRST VARIABLES ON THE STACK ALIGN WITH THE SIGNATURE. @= initStack @@ -212,7 +212,7 @@ { int k; for (k=start; k<p->argc; k++) - if( getArg(p,k)== a) + if( getArg(p,k)== a) return 0; return 1; } @@ -226,7 +226,7 @@ assert(size >= mb->vsize); stk= newGlobalStack(size); memset((char *) stk, 0, stackSize(size)); - stk->stktop= mb->vtop; + stk->stktop= mb->vtop; stk->stksize= size; stk->blk= mb; @@ -234,7 +234,7 @@ return stk; } -str runMAL(Client cntxt, MalBlkPtr mb, int startpc, MalBlkPtr mbcaller, +str runMAL(Client cntxt, MalBlkPtr mb, int startpc, MalBlkPtr mbcaller, MalStkPtr env, InstrPtr pcicaller){ MalStkPtr stk= NULL; int i; @@ -264,14 +264,14 @@ /* the global stack should be large enough */ if( mbcaller== NULL && env != NULL){ stk = env; - if( mb != stk->blk) + if( mb != stk->blk) showScriptException(mb,0,MAL,"runMAL:misalignment of symbols\n"); if( mb->vtop > stk->stksize) showScriptException(mb,0,MAL,"stack too small\n"); pci= pcicaller; } else { newStack(stk,mb->vsize); - stk->stktop= mb->vtop; + stk->stktop= mb->vtop; stk->stksize= mb->vsize; stk->blk= mb; stk->cmd= cntxt->itrace; /* set debug mode */ @@ -285,14 +285,14 @@ /* we are running low on stack space */ throw(MAL, "mal.interpreter", MAL_STACK_FAIL); } - } + } if( env && mbcaller){ InstrPtr pp; int k; @- Beware, a function signature f(a1..an):(b1..bn) is parsed in such a way that -the symbol table and stackframe contains the sequence +the symbol table and stackframe contains the sequence f,a1..an,b1..bn. This slightly complicates the implementation of the return statement. @c @@ -306,7 +306,7 @@ for(k=pp->retc; i<pci->argc; i++,k++){ lhs = &stk->stk[pp->argv[k]]; /* variable arguments ? */ - if( k== pp->argc-1) k--; + if( k== pp->argc-1) k--; rhs = &env->stk[pci->argv[i]]; VALcopy(lhs,rhs); @@ -314,18 +314,18 @@ BBPincref(lhs->val.bval, TRUE); } stk->up = env; - } + } @- An optimization is to copy all constant variables used in functions immediately onto the value stack. Then we do not have to check for their location later on any more. At some point, the effect is optimal, if at least several -constants are referenced in a function (a gain on tst400a of 20% has been +constants are referenced in a function (a gain on tst400a of 20% has been observed due the small size of the function). Moreover, we have to copy the result types to the stack for later use. The stack value is cleared to avoid misinterpretation of left-over information. Since a stack frame may contain values of a previous call, -we should first remove garbage. +we should first remove garbage. @c if (env && mbcaller) { @:initStack(pci->argc)@ @@ -339,7 +339,7 @@ ret = runMALsequence(cntxt, mb, startpc, 0, stk, env, pcicaller); /* pass the new debug mode to the caller */ - if (stk->cmd && env && stk->cmd!='f') env->cmd = stk->cmd; + if (stk->cmd && env && stk->cmd!='f') env->cmd = stk->cmd; if ( !stk->keepAlive && garbageControl(getInstrPtr(mb,0)) ) garbageCollector(cntxt, mb,stk, env != stk); @:endProfile(stk)@ @@ -354,7 +354,7 @@ This is used in the area where we need to support co-routines. A special case for MAL interpretation is to execute just one instruction. -This is typically used by optimizers and schedulers that need part of the +This is typically used by optimizers and schedulers that need part of the answer to direct their actions. Or, a dataflow scheduler could step in to enforce a completely different execution order. @c @@ -382,10 +382,10 @@ procedural abstractions. The argument list points to the arguments for the block to be executed. An old stack frame may be re-used, but it is then up to the caller to ensure it is properly -initialized. +initialized. The call does not return values, they are ignored. @c -str +str callMAL(Client cntxt, MalBlkPtr mb, MalStkPtr *env, ValPtr argv[], char debug){ MalStkPtr stk= NULL; str ret= MAL_SUCCEED; @@ -409,7 +409,7 @@ if( *env==NULL){ stk=newGlobalStack(mb->vsize); memset((char *) stk, 0, stackSize(mb->vtop)); - stk->stktop= mb->vtop; + stk->stktop= mb->vtop; stk->stksize= mb->vsize; stk->blk= mb; stk->up = 0; @@ -443,9 +443,9 @@ and starts the interpretation at the designated instruction. Note that the stack frame is aligned and initialized in the enclosing routine. @c -str runMALsequence( Client cntxt, MalBlkPtr mb, int startpc, +str runMALsequence( Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr pcicaller) -{ +{ ValPtr lhs,rhs,v; int i,k; InstrPtr pci=0; @@ -475,7 +475,7 @@ if( cntxt->flags & timerFlag) oldtimer= cntxt->timer= GDKusec(); oldMemory.arena= 0; - + stkpc = startpc; exceptionVar = -1; @- @@ -487,13 +487,13 @@ Preferrably we should introduce a itrace flag PROFILE We rely on optimizing compilers to remove the redundant code. @c - if (mb->recycle == TRUE && malProfileMode == 0 && + if (mb->recycle == TRUE && malProfileMode == 0 && cntxt->itrace==0 && cntxt->flags == 0 && GDKdebug == 0) { while(stkpc < mb->stop && stkpc != stoppc ){ pci = getInstrPtr(mb,stkpc); if (malProfileMode + cntxt->itrace) goto workslow; - + @:MALrecycleStart(stk)@ { @:MALinterpret(FAST)@ } @@ -505,7 +505,7 @@ pci = getInstrPtr(mb,stkpc); if (malProfileMode + cntxt->itrace + mb->trap) goto workslow; - + @:MALinterpret(FAST)@ @:MALflowofcontrol(FAST,continue)@ } @@ -542,7 +542,7 @@ @:beginProfile(stk,1)@ @:MALrecycleStart(stk)@ { - @:MALinterpret(FAST)@ + @:MALinterpret(FAST)@ } @:MALflowofcontrol(FAST,continue)@ @:endProfile(stk)@ @@ -564,7 +564,7 @@ This way the function can inform the caller to skip the block when dataflow execution was performed. @h -mal_export str runMALdataflow( Client cntxt, MalBlkPtr mb, int startpc, +mal_export str runMALdataflow( Client cntxt, MalBlkPtr mb, int startpc, int stoppc, MalStkPtr stk, MalStkPtr env, InstrPtr pcicaller); @- The flow graphs should be organized such that parallel threads can @@ -580,7 +580,7 @@ typedef struct queue { int size; /* size of queue */ int last; /* last element in the queue */ - void **data; + void **data; MT_Lock l; /* its a shared resource, ie we need locks */ MT_Sema s; /* threads wait on empty queues */ } queue; @@ -590,7 +590,7 @@ MT_Id tid; int id; queue *todo; /* pending actions for this client */ - lng clk; + lng clk; } FlowTask; typedef struct DataFlow { _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list