Changeset: afe9c35471a8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/afe9c35471a8
Modified Files:
monetdb5/mal/mal_interpreter.c
Branch: Dec2025
Log Message:
Don't allocate values of MAL variables on thread-local stack.
diffs (116 lines):
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -509,17 +509,17 @@ runMALsequence(Client cntxt, MalBlkPtr m
if (stk == NULL)
throw(MAL, "mal.interpreter", MAL_STACK_FAIL);
- allocator *ma = MT_thread_getallocator();
- allocator_state ma_state = ma_open(ma);
+ allocator *ta = MT_thread_getallocator();
+ allocator_state ta_state = ma_open(ta);
/* prepare extended backup and garbage structures */
if (startpc + 1 == stoppc) {
pci = getInstrPtr(mb, startpc);
if (pci->argc > 16) {
- backup = ma_alloc(ma, pci->retc * sizeof(ValRecord));
- garbage = (int *) ma_zalloc(ma, pci->argc *
sizeof(int));
+ backup = ma_alloc(ta, pci->retc * sizeof(ValRecord));
+ garbage = (int *) ma_zalloc(ta, pci->argc *
sizeof(int));
if (backup == NULL || garbage == NULL) {
- ma_close(&ma_state);
+ ma_close(&ta_state);
throw(MAL, "mal.interpreter", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
}
} else {
@@ -528,10 +528,10 @@ runMALsequence(Client cntxt, MalBlkPtr m
memset(garbages, 0, sizeof(garbages));
}
} else if (mb->maxarg > 16) {
- backup = ma_alloc(ma, mb->maxarg * sizeof(ValRecord));
- garbage = (int *) ma_zalloc(ma, mb->maxarg * sizeof(int));
+ backup = ma_alloc(ta, mb->maxarg * sizeof(ValRecord));
+ garbage = (int *) ma_zalloc(ta, mb->maxarg * sizeof(int));
if (backup == NULL || garbage == NULL) {
- ma_close(&ma_state);
+ ma_close(&ta_state);
throw(MAL, "mal.interpreter", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
}
} else {
@@ -550,7 +550,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
&& cntxt->qryctx.starttime - cntxt->session >
cntxt->sessiontimeout) {
runtimeProfileFinish(cntxt, mb, stk);
- ma_close(&ma_state);
+ ma_close(&ta_state);
throw(MAL, "mal.interpreter",
SQLSTATE(HYT00) RUNTIME_SESSION_TIMEOUT);
}
@@ -767,9 +767,9 @@ runMALsequence(Client cntxt, MalBlkPtr m
InstrPtr q;
int ii, arg;
- allocator_state ma_state2 = ma_open(ma);
+ allocator_state ta_state2 = ma_open(ta);
- nstk = prepareMALstack(ma, pci->blk, pci->blk->vsize);
+ nstk = prepareMALstack(ta, pci->blk, pci->blk->vsize);
if (nstk == 0) {
ret = createException(MAL, "mal.interpreter",
MAL_STACK_FAIL);
break;
@@ -783,14 +783,14 @@ runMALsequence(Client cntxt, MalBlkPtr m
if (nstk->calldepth > 256) {
ret = createException(MAL, "mal.interpreter",
MAL_CALLDEPTH_FAIL);
- ma_close(&ma_state2);
+ ma_close(&ta_state2);
break;
}
if ((unsigned) nstk->stkdepth >
THREAD_STACK_SIZE / sizeof(mb->var[0]) / 4 &&
THRhighwater()) {
/* we are running low on stack space */
ret = createException(MAL, "mal.interpreter",
MAL_STACK_FAIL);
- ma_close(&ma_state2);
+ ma_close(&ta_state2);
break;
}
@@ -800,8 +800,8 @@ runMALsequence(Client cntxt, MalBlkPtr m
for (ii = pci->retc; ii < pci->argc; ii++, arg++) {
lhs = &nstk->stk[q->argv[arg]];
rhs = &stk->stk[pci->argv[ii]];
- if (VALcopy(ma, lhs, rhs) == NULL) {
- ma_close(&ma_state2);
+ if (VALcopy(mb->ma, lhs, rhs) == NULL) {
+ ma_close(&ta_state2);
ret = createException(MAL,
"mal.interpreter",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
break;
@@ -819,7 +819,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
BBPrelease(lhs->val.bval);
}
}
- ma_close(&ma_state2);
+ ma_close(&ta_state2);
break;
}
case REMsymbol:
@@ -1210,7 +1210,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
for (int i = 0; i < pci->retc; i++) {
rhs = &stk->stk[pp->argv[i]];
lhs = &env->stk[pci->argv[i]];
- if (VALcopy(ma, lhs, rhs) == NULL) {
+ if (VALcopy(mb->ma, lhs, rhs) == NULL) {
ret = createException(MAL,
"mal.interpreter",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
break;
@@ -1270,7 +1270,7 @@ runMALsequence(Client cntxt, MalBlkPtr m
}
if (startedProfileQueue)
runtimeProfileFinish(cntxt, mb, stk);
- ma_close(&ma_state);
+ ma_close(&ta_state);
return ret;
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]