Changeset: b9c6440a6434 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b9c6440a6434
Removed Files:
monetdb5/optimizer/Tests/flowgraph.malC
monetdb5/optimizer/Tests/flowgraph.stable.err
monetdb5/optimizer/Tests/flowgraph.stable.out
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
clients/Tests/exports.stable.out
monetdb5/mal/mal.h
monetdb5/mal/mal_builder.c
monetdb5/mal/mal_builder.h
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_debugger.c
monetdb5/mal/mal_function.c
monetdb5/mal/mal_function.h
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_instruction.h
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_session.c
monetdb5/modules/mal/manifold.c
monetdb5/modules/mal/orderidx.c
monetdb5/optimizer/Tests/All
monetdb5/optimizer/opt_garbageCollector.c
monetdb5/optimizer/opt_macro.c
monetdb5/optimizer/opt_profiler.c
monetdb5/scheduler/run_adder.c
sql/backends/monet5/sql_execute.c
sql/backends/monet5/sql_optimizer.c
Branch: default
Log Message:
Block allocate the symbol table
The symbol table in a MAL block has been converted from a pointer list
into a large (re-)allocatable block.
This reduces somewhat possible memory fragmentation.
diffs (truncated from 1477 to 300 lines):
diff --git a/clients/Tests/MAL-signatures.stable.out
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -7912,8 +7912,6 @@ Ready.
[ "mcurl", "putrequest", "command mcurl.putrequest(s:str):str ",
"CURLputRequest;", "Perform a http put request" ]
[ "mdb", "List", "pattern mdb.List(M:str, F:str):void ",
"MDBlist3Detail;", "Dump the routine M.F on standard out." ]
[ "mdb", "List", "pattern mdb.List():void ", "MDBlistDetail;",
"Dump the current routine on standard out." ]
-[ "mdb", "dot", "pattern mdb.dot(M:str, F:str, s:str):void ",
"MDBshowFlowGraph;", "Dump the data flow of the function \n\tM.F in a format
recognizable by the \n\tcommand 'dot' on the file s" ]
-[ "mdb", "dot", "pattern mdb.dot(s:str):void ", "MDBshowFlowGraph;",
"Dump the data flow of the current routine in a format recognizable by the
command 'dot' to the file s" ]
[ "mdb", "dump", "pattern mdb.dump():void ", "MDBdump;", "Dump
instruction, stacktrace, and stack" ]
[ "mdb", "getContext", "command mdb.getContext(s:str):str ",
"MDBgetExceptionContext;", "Extract the context string from the exception
message" ]
[ "mdb", "getDebug", "command mdb.getDebug():int ", "MDBgetDebug;",
"Get the kernel debugging bit-set.\nSee the MonetDB configuration file for
details" ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -10273,8 +10273,6 @@ Ready.
[ "mcurl", "putrequest", "command mcurl.putrequest(s:str):str ",
"CURLputRequest;", "Perform a http put request" ]
[ "mdb", "List", "pattern mdb.List(M:str, F:str):void ",
"MDBlist3Detail;", "Dump the routine M.F on standard out." ]
[ "mdb", "List", "pattern mdb.List():void ", "MDBlistDetail;",
"Dump the current routine on standard out." ]
-[ "mdb", "dot", "pattern mdb.dot(M:str, F:str, s:str):void ",
"MDBshowFlowGraph;", "Dump the data flow of the function \n\tM.F in a format
recognizable by the \n\tcommand 'dot' on the file s" ]
-[ "mdb", "dot", "pattern mdb.dot(s:str):void ", "MDBshowFlowGraph;",
"Dump the data flow of the current routine in a format recognizable by the
command 'dot' to the file s" ]
[ "mdb", "dump", "pattern mdb.dump():void ", "MDBdump;", "Dump
instruction, stacktrace, and stack" ]
[ "mdb", "getContext", "command mdb.getContext(s:str):str ",
"MDBgetExceptionContext;", "Extract the context string from the exception
message" ]
[ "mdb", "getDebug", "command mdb.getDebug():int ", "MDBgetDebug;",
"Get the kernel debugging bit-set.\nSee the MonetDB configuration file for
details" ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1994,7 +1994,6 @@ str convertConstant(malType type, ValPtr
InstrPtr copyInstruction(InstrPtr p);
MalBlkPtr copyMalBlk(MalBlkPtr mb);
str copyRef;
-int copyVariable(MalBlkPtr dst, VarPtr v);
str copy_fromRef;
str countRef;
str count_no_nilRef;
@@ -2163,7 +2162,6 @@ int initQlog(void);
int initTrace(void);
int inlineMALblock(MalBlkPtr mb, int pc, MalBlkPtr mc);
str inplaceRef;
-void insertInstruction(MalBlkPtr mb, InstrPtr p, int pc);
void insertSymbol(Module scope, Symbol prg);
str instruction2str(MalBlkPtr mb, MalStkPtr stl, InstrPtr p, int hidden);
str instructionCall(MalBlkPtr mb, InstrPtr p, str s, str base, size_t len);
@@ -2244,6 +2242,7 @@ MT_Lock mal_delayLock;
void mal_exit(void);
void mal_factory_reset(void) __attribute__((__visibility__("hidden")));
int mal_init(void);
+void mal_instruction_reset(void);
void mal_linker_reset(void) __attribute__((__visibility__("hidden")));
void mal_module_reset(void) __attribute__((__visibility__("hidden")));
void mal_namespace_reset(void) __attribute__((__visibility__("hidden")));
@@ -2322,8 +2321,8 @@ InstrPtr newFcnCall(MalBlkPtr mb, char *
Symbol newFunction(str mod, str nme, int kind);
MalStkPtr newGlobalStack(int size);
InstrPtr newInstruction(MalBlkPtr mb, str modnme, str fcnnme);
-MalBlkPtr newMalBlk(int maxvars, int maxstmts);
-int newMalBlkStmt(MalBlkPtr mb, int maxstmts);
+MalBlkPtr newMalBlk(int elements);
+int newMalBlkStmt(MalBlkPtr mb, int elements);
Module newModule(Module scope, str nme);
Plant newPlant(MalBlkPtr mb);
InstrPtr newRaiseStmt(MalBlkPtr mb, str nme);
@@ -2387,7 +2386,7 @@ InstrPtr pushBit(MalBlkPtr mb, InstrPtr
InstrPtr pushBte(MalBlkPtr mb, InstrPtr q, bte val);
InstrPtr pushDbl(MalBlkPtr mb, InstrPtr q, dbl val);
InstrPtr pushEmptyBAT(MalBlkPtr mb, InstrPtr q, int tpe);
-void pushEndInstruction(MalBlkPtr mb);
+InstrPtr pushEndInstruction(MalBlkPtr mb);
InstrPtr pushFlt(MalBlkPtr mb, InstrPtr q, flt val);
InstrPtr pushHge(MalBlkPtr mb, InstrPtr q, hge val);
void pushInstruction(MalBlkPtr mb, InstrPtr p);
@@ -2431,7 +2430,7 @@ str replaceRef;
str replicatorRef;
void resetMalBlk(MalBlkPtr mb, int stop);
void resetScenario(Client c);
-void resizeMalBlk(MalBlkPtr mb, int maxstmt, int maxvar);
+void resizeMalBlk(MalBlkPtr mb, int elements);
int resolveType(int dsttype, int srctype);
str resultSetRef;
str reuseRef;
@@ -2467,7 +2466,6 @@ void setHeartbeat(int delay);
void setPolymorphic(InstrPtr p, int tpe, int force);
void setReturnArgument(InstrPtr p, int varid);
str setScenario(Client c, str nme);
-void setVarType(MalBlkPtr mb, int i, int tpe);
str setVariableRef;
void setVariableScope(MalBlkPtr mb);
str setWriteModeRef;
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -197,7 +197,7 @@ typedef struct MALBLK {
int vtop; /* next free slot */
int vsize; /* size of variable arena */
int vid; /* generate local variable
counter */
- VarRecord **var; /* Variable table */
+ VarRecord *var; /* Variable table */
int stop; /* next free slot */
int ssize; /* byte size of arena */
InstrPtr *stmt; /* Instruction location */
diff --git a/monetdb5/mal/mal_builder.c b/monetdb5/mal/mal_builder.c
--- a/monetdb5/mal/mal_builder.c
+++ b/monetdb5/mal/mal_builder.c
@@ -178,6 +178,21 @@ newExitStmt(MalBlkPtr mb, str nme)
return q;
}
+InstrPtr
+pushEndInstruction(MalBlkPtr mb)
+{
+ InstrPtr p;
+
+ p = newInstruction(mb,NULL, NULL);
+ p->token = ENDsymbol;
+ p->barrier = 0;
+ p->argc = 0;
+ p->retc = 0;
+ p->argv[0] = 0;
+ pushInstruction(mb, p);
+ return p;
+}
+
int
getIntConstant(MalBlkPtr mb, int val)
{
@@ -526,7 +541,7 @@ pushNil(MalBlkPtr mb, InstrPtr q, int tp
cst.vtype = TYPE_bat;
cst.val.bval = bat_nil;
_t = defConstant(mb,TYPE_bat,&cst);
- mb->var[_t]->type = tpe;
+ getVarType(mb,_t) = tpe;
}
q= pushArgument(mb, q, _t);
setVarUDFtype(mb,getArg(q,q->argc-1)); /* needed */
diff --git a/monetdb5/mal/mal_builder.h b/monetdb5/mal/mal_builder.h
--- a/monetdb5/mal/mal_builder.h
+++ b/monetdb5/mal/mal_builder.h
@@ -21,6 +21,7 @@ mal_export InstrPtr newExitStmt(MalBlkPt
mal_export InstrPtr newReturnStmt(MalBlkPtr mb);
mal_export InstrPtr newFcnCall(MalBlkPtr mb, char *mod, char *fcn);
mal_export InstrPtr pushSht(MalBlkPtr mb, InstrPtr q, sht val);
+mal_export InstrPtr pushEndInstruction(MalBlkPtr mb);
mal_export InstrPtr pushInt(MalBlkPtr mb, InstrPtr q, int val);
mal_export InstrPtr pushLng(MalBlkPtr mb, InstrPtr q, lng val);
#ifdef HAVE_HGE
diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -410,7 +410,7 @@ DFLOWworker(void *T)
/* update the numa information. keep the thread-id producing
the value */
p= getInstrPtr(flow->mb,fe->pc);
for( i = 0; i < p->argc; i++)
- flow->mb->var[getArg(p,i)]->worker = thr->tid;
+ setVarWorker(flow->mb,getArg(p,i),thr->tid);
MT_lock_set(&flow->flowlock);
fe->state = DFLOWwrapup;
diff --git a/monetdb5/mal/mal_debugger.c b/monetdb5/mal/mal_debugger.c
--- a/monetdb5/mal/mal_debugger.c
+++ b/monetdb5/mal/mal_debugger.c
@@ -66,12 +66,11 @@ mdbInit(void)
/*
* Each client has its own breakpoint administration, kept in a
* global table. Although a little space consumptive, it is the
- * easiest to maintain and much less expensive than reserving
- * debugger space in each instruction.
+ * easiest to maintain and much less expensive as reserving debugger
+ * space in each instruction.
*/
- if (mdbTable)
- memset(mdbTable, 0, sizeof(mdbStateRecord) * MAL_MAXCLIENTS);
- else if ((mdbTable = GDKzalloc(sizeof(mdbStateRecord) *
MAL_MAXCLIENTS)) == NULL) {
+ mdbTable = GDKzalloc(sizeof(mdbStateRecord) * MAL_MAXCLIENTS);
+ if (mdbTable == NULL) {
showException(GDKout,MAL, "mdbInit",MAL_MALLOC_FAIL);
return -1;
}
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -33,7 +33,7 @@ Symbol newFunction(str mod, str nme,int
return NULL;
}
- p = newInstruction(NULL,mod,nme);
+ p = newInstruction(NULL, mod, nme);
if (p == NULL) {
freeSymbol(s);
return NULL;
@@ -570,14 +570,15 @@ setVariableScope(MalBlkPtr mb)
for (k = 0; k < mb->vtop; k++)
if( isVarConstant(mb,k)){
setVarScope(mb,k,0);
- mb->var[k]->declared = 0;
- mb->var[k]->updated = 0;
- mb->var[k]->eolife = mb->stop;
+ setVarDeclared(mb,k,0);
+ setVarUpdated(mb,k,0);
+ setVarEolife(mb,k,mb->stop);
} else {
setVarScope(mb,k,0);
- mb->var[k]->declared = 0;
- mb->var[k]->updated = 0;
- mb->var[k]->eolife = 0;
+ mb->var[k].declared = 0;
+ setVarDeclared(mb,k,0);
+ setVarUpdated(mb,k,0);
+ setVarEolife(mb,k,0);
}
for (pc = 0; pc < mb->stop; pc++) {
@@ -598,20 +599,20 @@ setVariableScope(MalBlkPtr mb)
for (k = 0; k < p->argc; k++) {
int v = getArg(p,k);
- if( isVarConstant(mb,v) && mb->var[v]->updated == 0)
- mb->var[v]->updated= pc;
+ if( isVarConstant(mb,v) && getVarUpdated(mb,v) == 0)
+ setVarUpdated(mb,v, pc);
- if (mb->var[v]->declared == 0 ){
- mb->var[v]->declared = pc;
+ if ( getVarDeclared(mb,v) == 0 ){
+ setVarDeclared(mb,v, pc);
setVarScope(mb,v,depth);
}
if (k < p->retc )
- mb->var[v]->updated= pc;
+ setVarUpdated(mb,v, pc);
if ( getVarScope(mb,v) == depth )
- mb->var[v]->eolife = pc;
+ setVarEolife(mb,v,pc);
if ( k >= p->retc && getVarScope(mb,v) < depth )
- mb->var[v]->eolife = -1;
+ setVarEolife(mb,v,-1);
}
/*
* At a block exit we can finalize all variables defined within
that block.
@@ -620,10 +621,10 @@ setVariableScope(MalBlkPtr mb)
*/
if( blockExit(p) ){
for (k = 0; k < mb->vtop; k++)
- if ( mb->var[k]->eolife == 0 && getVarScope(mb,k)
==depth )
- mb->var[k]->eolife = pc;
- else if ( mb->var[k]->eolife == -1 )
- mb->var[k]->eolife = pc;
+ if ( getVarEolife(mb,k) == 0 && getVarScope(mb,k)
==depth )
+ setVarEolife(mb,k,pc);
+ else if ( getVarEolife(mb,k) == -1 )
+ setVarEolife(mb,k,pc);
if( dflow == depth)
dflow= -1;
@@ -631,8 +632,8 @@ setVariableScope(MalBlkPtr mb)
}
}
for (k = 0; k < mb->vtop; k++)
- if( mb->var[k]->eolife == 0)
- mb->var[k]->eolife = mb->stop-1;
+ if( getVarEolife(mb,k) == 0)
+ setVarEolife(mb,k, mb->stop-1);
}
int
@@ -705,8 +706,8 @@ malGarbageCollector(MalBlkPtr mb)
for (i = 0; i < mb->vtop; i++)
if( isVarCleanup(mb,i) && getEndScope(mb,i) >= 0) {
- mb->var[i]->eolife = getEndScope(mb,i);
- mb->stmt[mb->var[i]->eolife]->gc |= GARBAGECONTROL;
+ setVarEolife(mb,i, getEndScope(mb,i));
+ mb->stmt[getVarEolife(mb,i)]->gc |= GARBAGECONTROL;
}
}
/*
@@ -743,6 +744,8 @@ void chkDeclarations(stream *out, MalBlk
short blks[MAXDEPTH], top= 0, blkId=1;
int dflow = -1;
+ if( mb->errors)
+ return;
blks[top] = blkId;
/* initialize the scope */
diff --git a/monetdb5/mal/mal_function.h b/monetdb5/mal/mal_function.h
--- a/monetdb5/mal/mal_function.h
+++ b/monetdb5/mal/mal_function.h
@@ -13,9 +13,9 @@
#include "mal_module.h"
#include "mal_resolve.h"
-#define getLastUpdate(L,I) ((L)->var[I]->updated)
-#define getEndScope(L,I) ((L)->var[I]->eolife)
-#define getBeginScope(L,I) ((L)->var[I]->declared)
+#define getLastUpdate(L,I) ((L)->var[I].updated)
+#define getEndScope(L,I) ((L)->var[I].eolife)
+#define getBeginScope(L,I) ((L)->var[I].declared)
/* #define DEBUG_MAL_FCN */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list