📄 mal_interpreter.c
字号:
if( stk->stk[getArg(pci,i)].vtype == TYPE_bat && stk->stk[getArg(pci,i)].val.br.id ){ b= BATdescriptor(stk->stk[getArg(pci,i)].val.br.id); if( b == NULL) continue; if( cntxt->errbuf && cntxt->errbuf[0]){ oldmsg= GDKstrdup(cntxt->errbuf); *cntxt->errbuf= 0; } if( b->batStamp <= stamp){ if( GDKdebug & 8) #line 946 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"{ if (b->H != b->T) { BATpropcheck(BATmirror(b), BATPROPS_QUICK); } BATpropcheck(b, BATPROPS_QUICK);}#line 995 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" } else if( GDKdebug & 2) #line 946 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"{ if (b->H != b->T) { BATpropcheck(BATmirror(b), BATPROPS_QUICK); } BATpropcheck(b, BATPROPS_QUICK);}#line 998 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" BBPunfix(b->batCacheid); if( cntxt->errbuf && cntxt->errbuf[0]) { if( oldmsg){ strcpy(cntxt->errbuf,oldmsg); GDKfree(oldmsg); } throw(MAL, "mal.propertyCheck", "Errors found"); } if( oldmsg){ *cntxt->errbuf = *oldmsg; GDKfree(oldmsg); } } }#line 884 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" ret = 0; #line 1263 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" #line 1499 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"if( cntxt->flags && stk->cmd != 't' && stk->cmd != 'C'){ if( cntxt->flags & timerFlag) stream_printf(cntxt->fdout,"#%6d usec",GDKusec()-cntxt->timer);#ifdef HAVE_SYS_RESOURCE_H if( cntxt-> flags & ioFlag){ struct rusage resource; getrusage(RUSAGE_SELF, &resource); if( resource.ru_inblock - oldinblock || resource.ru_oublock - oldoublock ) { stream_printf(cntxt->fdout,"# %3d R", resource.ru_inblock- oldinblock); stream_printf(cntxt->fdout," %3d W", resource.ru_oublock- oldoublock); } }#endif if( cntxt->flags & memoryFlag){ struct mallinfo memory; memory= MT_mallinfo(); if( memory.arena- oldMemory.arena > 0) stream_printf(cntxt->fdout,"# %6d bytes", memory.arena-oldMemory.arena ); } if( cntxt->flags & flowFlag){ /* calculate the read/write byte flow */ stream_printf(cntxt->fdout,"# "); getVolume(cntxt,mb,stk,pci,0); getVolume(cntxt,mb,stk,pci,1); /* getVolume(cntxt,mb,stk,pci,2);*/ } if( cntxt->flags & timerFlag){ printTraceCall(cntxt,mb,stk,stkpc); cntxt->timer = GDKusec(); }}#line 1263 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"if( ret != MAL_SUCCEED ) { str msg = 0, nxt; if( stk->cmd ) { stream_printf(cntxt->fdout,"!ERROR: %s\n",ret); stk->cmd='n'; mdbStep(cntxt,mb,stk,stkpc); if( stk->cmd == 'x' || stk->cmd == 'q' ) { stkpc= mb->stop; continue; } if( stk->cmd == 'r') { stk->cmd = 'n'; stkpc = startpc; exceptionVar = -1; continue; } } /* Detect any exception received from the implementation. */ /* The first identifier is an optional exception name */ msg = strchr(ret,':'); if(msg) { *msg= 0; exceptionVar = findVariableLength(mb,ret,msg-ret); *msg=':'; exceptionPC = stkpc; } else { if( ret == MAL_SUCCEED && cntxt->errbuf){ /* trap hidden (GDK) exception */ msg= GDKstrdup(cntxt->errbuf); exceptionVar= findVariable(mb,"GDKerror"); exceptionPC = stkpc; } else { exceptionVar = getDestVar(pci); exceptionPC = stkpc; } } /* unknown exceptions lead to propagation */ if( exceptionVar == -1){ #line 1484 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"#ifdef MALprofiler if( malProfileMode == 0) /* mostly true */; else{ if( mb->profiler== NULL) initProfiler(mb); newclk= GDKusec(); mb->profiler[stkpc].counter++; mb->profiler[stkpc].ticks += (long) (newclk - mb->profiler[stkpc].clk); if( mb->profiler[stkpc].clk) profilerEvent(cntxt->nspace,mb,stk,stkpc); }#endif#line 1302 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" stkpc= mb->stop; continue; } msg++; /* assure correct variable type */ nxt= (str) setDynamicType(mb,getVar(mb,exceptionVar),TYPE_str,stkpc); if( nxt == 0){ v= &stk->stk[exceptionVar]; if( getVarType(mb,exceptionVar) == TYPE_any) setVarType(mb, exceptionVar, TYPE_str); v->vtype = TYPE_str; v->val.pval= ret; v->len= strlen(v->val.pval); ret = 0; } else GDKfree(nxt); /* position yourself at the catch instruction for further decisions */ #line 1188 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" if( stk->cmd == 'C') { stk->cmd = 'n'; mdbStep(cntxt,mb,stk,stkpc); if( stk->cmd == 'x') { stkpc = mb->stop; continue; } } /* skip to catch block or end */ for( ; stkpc<mb->stop; stkpc++){ InstrPtr l= getInstrPtr(mb,stkpc); if( l->barrier == CATCHsymbol ){ int j= -1; for(j=0;j<l->retc; j++) if( getArg(l,j) == exceptionVar) break; if(j>=0) break; } } if( stkpc== mb->stop) { #line 1484 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"#ifdef MALprofiler if( malProfileMode == 0) /* mostly true */; else{ if( mb->profiler== NULL) initProfiler(mb); newclk= GDKusec(); mb->profiler[stkpc].counter++; mb->profiler[stkpc].ticks += (long) (newclk - mb->profiler[stkpc].clk); if( mb->profiler[stkpc].clk) profilerEvent(cntxt->nspace,mb,stk,stkpc); }#endif#line 1207 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" continue; }#line 1319 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" pci= getInstrPtr(mb,stkpc);}#line 886 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"}#line 712 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" break; case PATcall: #line 1091 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" if( pci->fcn== NULL) ret = createScriptException(mb, stkpc, MAL, NULL, "address of pattern missing"); else { #line 928 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"#ifdef STACKTRACE printf("safeTarget %d\n", needsCleanup(pci)); printInstruction(GDKout,mb,pci, LIST_MAL_ALL);#endif if( needsCleanup(pci) ){ for(i=0; i<pci->retc; i++) { sbackup[i]= 0; backup[i]= 0; if( stk->stk[getArg(pci,i)].vtype == TYPE_bat){ backup[i]= stk->stk[getArg(pci,i)].val.br.id; stamp= BBPcurstamp(); } else if( stk->stk[getArg(pci,i)].vtype == TYPE_str){ backup[i]= stk->stk[getArg(pci,i)].len; sbackup[i]= stk->stk[getArg(pci,i)].val.sval; } } } #line 1095 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" ret = (str) (*pci->fcn)(mb,stk,pci); #line 953 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"#ifdef STACKTRACE printf("restoreTarget %d\n", needsCleanup(pci));#endif if( needsCleanup(pci) ){ for(i=0; i<pci->retc; i++) if( stk->stk[getArg(pci,i)].vtype == TYPE_bat){ if( backup[i] ){ if( backup[i]== stk->stk[getArg(pci,i)].val.br.id){ /* target and source are identical, which means its logical reference count is one too high . */ BBPreleaselref(backup[i]); } else /* possible garbage collect the variable */ BBPdecref(backup[i],TRUE); } } else if( stk->stk[getArg(pci,i)].vtype == TYPE_str){ int a= getArg(pci,i); if( sbackup[i] && sbackup[i]!= stk->stk[a].val.sval){ if( backup[i] > 0) GDKfree(sbackup[i]); backup[i]=0; sbackup[i]=0; } } } /* Provide debugging support */ if( GDKdebug & 10 ){ BAT *b; str oldmsg =0; for( i=0; i< pci->retc; i++) if( stk->stk[getArg(pci,i)].vtype == TYPE_bat && stk->stk[getArg(pci,i)].val.br.id ){ b= BATdescriptor(stk->stk[getArg(pci,i)].val.br.id); if( b == NULL) continue; if( cntxt->errbuf && cntxt->errbuf[0]){ oldmsg= GDKstrdup(cntxt->errbuf); *cntxt->errbuf= 0; } if( b->batStamp <= stamp){ if( GDKdebug & 8) #line 946 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"{ if (b->H != b->T) { BATpropcheck(BATmirror(b), BATPROPS_QUICK); } BATpropcheck(b, BATPROPS_QUICK);}#line 995 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" } else if( GDKdebug & 2) #line 946 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"{ if (b->H != b->T) { BATpropcheck(BATmirror(b), BATPROPS_QUICK); } BATpropcheck(b, BATPROPS_QUICK);}#line 998 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" BBPunfix(b->batCacheid); if( cntxt->errbuf && cntxt->errbuf[0]) { if( oldmsg){ strcpy(cntxt->errbuf,oldmsg); GDKfree(oldmsg); } throw(MAL, "mal.propertyCheck", "Errors found"); } if( oldmsg){ *cntxt->errbuf = *oldmsg; GDKfree(oldmsg); } } }#line 1097 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" #line 1263 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" #line 1499 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"if( cntxt->flags && stk->cmd != 't' && stk->cmd != 'C'){ if( cntxt->flags & timerFlag) stream_printf(cntxt->fdout,"#%6d usec",GDKusec()-cntxt->timer);#ifdef HAVE_SYS_RESOURCE_H if( cntxt-> flags & ioFlag){ struct rusage resource; getrusage(RUSAGE_SELF, &resource); if( resource.ru_inblock - oldinblock || resource.ru_oublock - oldoublock ) { stream_printf(cntxt->fdout,"# %3d R", resource.ru_inblock- oldinblock); stream_printf(cntxt->fdout," %3d W", resource.ru_oublock- oldoublock); } }#endif if( cntxt->flags & memoryFlag){ struct mallinfo memory; memory= MT_mallinfo(); if( memory.arena- oldMemory.arena > 0) stream_printf(cntxt->fdout,"# %6d bytes", memory.arena-oldMemory.arena ); } if( cntxt->flags & flowFlag){ /* calculate the read/write byte flow */ stream_printf(cntxt->fdout,"# "); getVolume(cntxt,mb,stk,pci,0); getVolume(cntxt,mb,stk,pci,1); /* getVolume(cntxt,mb,stk,pci,2);*/ } if( cntxt->flags & timerFlag){ printTraceCall(cntxt,mb,stk,stkpc); cntxt->timer = GDKusec(); }}#line 1263 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"if( ret != MAL_SUCCEED ) { str msg = 0, nxt; if( stk->cmd ) { stream_printf(cntxt->fdout,"!ERROR: %s\n",ret); stk->cmd='n'; mdbStep(cntxt,mb,stk,stkpc); if( stk->cmd == 'x' || stk->cmd == 'q' ) { stkpc= mb->stop; continue; } if( stk->cmd == 'r') { stk->cmd = 'n'; stkpc = startpc; exceptionVar = -1; continue; } } /* Detect any exception received from the implementation. */ /* The first identifier is an optional exception name */ msg = strchr(ret,':'); if(msg) { *msg= 0; exceptionVar = findVariableLength(mb,ret,msg-ret); *msg=':'; exceptionPC = stkpc; } else { if( ret == MAL_SUCCEED && cntxt->errbuf){ /* trap hidden (GDK) exception */ msg= GDKstrdup(cntxt->errbuf); exceptionVar= findVariable(mb,"GDKerror"); exceptionPC = stkpc; } else { exceptionVar = getDestVar(pci); exceptionPC = stkpc; } } /* unknown exceptions lead to propagation */ if( exceptionVar == -1){ #line 1484 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx"#ifdef MALprofiler if( malProfileMode == 0) /* mostly true */; else{ if( mb->profiler== NULL) initProfiler(mb); newclk= GDKusec(); mb->profiler[stkpc].counter++; mb->profiler[stkpc].ticks += (long) (newclk - mb->profiler[stkpc].clk); if( mb->profiler[stkpc].clk) profilerEvent(cntxt->nspace,mb,stk,stkpc); }#endif#line 1302 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" stkpc= mb->stop; continue; } msg++; /* assure correct variable type */ nxt= (str) setDynamicType(mb,getVar(mb,exceptionVar),TYPE_str,stkpc); if( nxt == 0){ v= &stk->stk[exceptionVar]; if( getVarType(mb,exceptionVar) == TYPE_any) setVarType(mb, exceptionVar, TYPE_str); v->vtype = TYPE_str; v->val.pval= ret; v->len= strlen(v->val.pval); ret = 0; } else GDKfree(nxt); /* position yourself at the catch instruction for further decisions */ #line 1188 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_interpreter.mx" if( stk->cmd == 'C') { stk->cmd = 'n'; mdbStep(cntxt,mb,stk,stkpc); if( stk->cmd == 'x') { stkpc = mb->stop; continue; } } /* skip to catch block or end */ for( ; stkpc<mb->stop; stkpc++){ InstrPtr l= getInstrPtr(mb,stkpc); if( l->barrier == CATCHsymbol ){ int j= -1; for(j=0;j<l->retc; j++) if( getArg(l,j) == exceptionVar) break; if(j>=0) break; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -