# New Ticket Created by NotFound
# Please include the string: [perl #56678]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=56678 >
The DOD_registry member of the interpreter is initialized and checked
from several places, and there is a XXX in the code about what to do
if not initialized when unregistering a pmc.
This patch solves the issue by initializing it at interpreter
creation, and asserting that it is initialized in all usages. Also
deletes the Parrot_get_dod_registry funtion, because is never used
and, given that exposes an internal detail, I suppose it must never be
used.
--
Salu2
Index: src/gc/dod.c
===================================================================
--- src/gc/dod.c (revisión: 29127)
+++ src/gc/dod.c (copia de trabajo)
@@ -315,9 +315,9 @@
/* Now mark the class hash */
pobject_lives(interp, (PObj *)interp->class_hash);
- /* Mark the registry if any */
- if (interp->DOD_registry)
- pobject_lives(interp, (PObj *)interp->DOD_registry);
+ /* Mark the registry */
+ PARROT_ASSERT(interp->DOD_registry);
+ pobject_lives(interp, (PObj *)interp->DOD_registry);
/* Mark the transaction log */
/* XXX do this more generically? */
Index: src/pmc.c
===================================================================
--- src/pmc.c (revisión: 29127)
+++ src/pmc.c (copia de trabajo)
@@ -600,8 +600,7 @@
/* Better not trigger a DOD run with a potentially unanchored PMC */
Parrot_block_GC_mark(interp);
- if (!interp->DOD_registry)
- interp->DOD_registry = pmc_new(interp, enum_class_AddrRegistry);
+ PARROT_ASSERT(interp->DOD_registry);
VTABLE_set_pmc_keyed(interp, interp->DOD_registry, pmc, PMCNULL);
Parrot_unblock_GC_mark(interp);
@@ -620,9 +619,7 @@
void
dod_unregister_pmc(PARROT_INTERP, ARGIN(PMC* pmc))
{
- /* XXX or signal exception? */
- if (!interp->DOD_registry)
- return;
+ PARROT_ASSERT(interp->DOD_registry);
VTABLE_delete_keyed(interp, interp->DOD_registry, pmc);
}
Index: src/inter_create.c
===================================================================
--- src/inter_create.c (revisión: 29127)
+++ src/inter_create.c (copia de trabajo)
@@ -223,8 +223,8 @@
interp->code = NULL;
interp->profile = NULL;
- /* null out the root set registry */
- interp->DOD_registry = NULL;
+ /* create the root set registry */
+ interp->DOD_registry = pmc_new(interp, enum_class_AddrRegistry);
/* create exceptions list */
interp->current_runloop_id = 0;
Index: src/extend.c
===================================================================
--- src/extend.c (revisión: 29127)
+++ src/extend.c (copia de trabajo)
@@ -1176,31 +1176,6 @@
/*
-=item C<Parrot_PMC Parrot_get_dod_registry>
-
-Return Parrot's internal DOD registry PMC.
-See also: F<src/pmc/addrregistry.pmc>.
-
-=cut
-
-*/
-
-PARROT_API
-Parrot_PMC
-Parrot_get_dod_registry(PARROT_INTERP)
-{
- PMC *registry = interp->DOD_registry;
- PARROT_CALLIN_START(interp);
- if (!registry) {
- registry = interp->DOD_registry =
- pmc_new(interp, enum_class_AddrRegistry);
- }
- PARROT_CALLIN_END(interp);
- return registry;
-}
-
-/*
-
=item C<void Parrot_PMC_set_vtable>
Replaces the vtable of the PMC.
Index: include/parrot/extend.h
===================================================================
--- include/parrot/extend.h (revisión: 29127)
+++ include/parrot/extend.h (copia de trabajo)
@@ -124,10 +124,6 @@
void Parrot_free_cstring(ARGIN_NULLOK(char *string));
PARROT_API
-Parrot_PMC Parrot_get_dod_registry(PARROT_INTERP)
- __attribute__nonnull__(1);
-
-PARROT_API
Parrot_Int Parrot_get_intreg(PARROT_INTERP, Parrot_Int regnum)
__attribute__nonnull__(1);