Author: chromatic
Date: Mon Jun 11 01:28:12 2007
New Revision: 18924
Modified:
trunk/src/inter_call.c
trunk/src/pmc.c
Log:
[PCC] Register all Key PMCs used for argument passing with GC temporarily so
they don't go away accidentally, then unregister them so they don't leak memory.
Modified: trunk/src/inter_call.c
==============================================================================
--- trunk/src/inter_call.c (original)
+++ trunk/src/inter_call.c Mon Jun 11 01:28:12 2007
@@ -195,9 +195,10 @@
}
/* create key needed to iterate the hash */
- st->key = pmc_new(interp, enum_class_Key);
+ st->key = pmc_new(interp, enum_class_Key);
PMC_int_val(st->key) = 0;
PMC_data(st->key) = (void*)INITBucketIndex;
+ dod_register_pmc(interp, st->key);
}
else {
/* src ought to be an array */
@@ -263,14 +264,22 @@
UVal_pmc(st->val) = va_arg(*ap, PMC*);
if (st->src.sig & PARROT_ARG_FLATTEN) {
+ int retval;
start_flatten(interp, st, UVal_pmc(st->val));
+
/* if the :flat arg is empty, just go to the next arg */
if (!st->src.slurp_n) {
st->src.mode &= ~CALL_STATE_FLATTEN;
st->src.i++;
}
+
st->src.used = 1;
- return Parrot_fetch_arg(interp, st);
+ retval = Parrot_fetch_arg(interp, st);
+
+ if (!PMC_IS_NULL(st->key))
+ dod_unregister_pmc(interp, st->key);
+
+ return retval;
}
break;
}
@@ -302,14 +311,22 @@
: CTX_REG_PMC(st->src.ctx, idx);
if (st->src.sig & PARROT_ARG_FLATTEN) {
+ int retval;
start_flatten(interp, st, UVal_pmc(st->val));
+
/* if the :flat arg is empty, just go to the next arg */
if (!st->src.slurp_n) {
st->src.mode &= ~CALL_STATE_FLATTEN;
st->src.i++;
}
+
st->src.used = 1;
- return Parrot_fetch_arg(interp, st);
+ retval = Parrot_fetch_arg(interp, st);
+
+ if (!PMC_IS_NULL(st->key))
+ dod_unregister_pmc(interp, st->key);
+
+ return retval;
}
break;
}
@@ -333,7 +350,7 @@
if (st->src.mode & CALL_STATE_FLATTEN) {
PMC *elem;
assert(st->src.slurp_i < st->src.slurp_n);
- if (st->key) {
+ if (!PMC_IS_NULL(st->key)) {
st->src.slurp_i++;
st->name = (STRING *)parrot_hash_get_idx(interp,
(Hash *)PMC_struct_val(st->src.slurp), st->key);
@@ -349,7 +366,9 @@
/* done with flattening */
if (st->src.slurp_i == st->src.slurp_n) {
st->src.mode &= ~CALL_STATE_FLATTEN;
- st->key = NULL;
+ if (!PMC_IS_NULL(st->key))
+ dod_unregister_pmc(interp, st->key);
+ st->key = PMCNULL;
st->src.i++;
}
@@ -777,7 +796,7 @@
st->optionals = 0;
st->params = st->dest.n;
st->name = NULL;
- st->key = NULL;
+ st->key = PMCNULL;
st->first_named = -1;
}
Modified: trunk/src/pmc.c
==============================================================================
--- trunk/src/pmc.c (original)
+++ trunk/src/pmc.c Mon Jun 11 01:28:12 2007
@@ -525,7 +525,7 @@
}
else
registry = interp->DOD_registry;
- VTABLE_set_pmc_keyed(interp, registry, pmc, NULL);
+ VTABLE_set_pmc_keyed(interp, registry, pmc, PMCNULL);
Parrot_unblock_DOD(interp);
}