[svn:parrot] r39329 - in branches/no_pmc_reuse: include/parrot src

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Jun 2 09:41:10 UTC 2009


Author: bacek
Date: Tue Jun  2 09:41:09 2009
New Revision: 39329
URL: https://trac.parrot.org/parrot/changeset/39329

Log:
[core] Remove Parrot_pmc_try_reuse function. It's dangerous to reuse dest pmc.

Modified:
   branches/no_pmc_reuse/include/parrot/pmc.h
   branches/no_pmc_reuse/src/pmc.c

Modified: branches/no_pmc_reuse/include/parrot/pmc.h
==============================================================================
--- branches/no_pmc_reuse/include/parrot/pmc.h	Tue Jun  2 09:40:35 2009	(r39328)
+++ branches/no_pmc_reuse/include/parrot/pmc.h	Tue Jun  2 09:41:09 2009	(r39329)
@@ -49,16 +49,6 @@
         __attribute__nonnull__(1);
 
 PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-PMC* Parrot_pmc_try_reuse(PARROT_INTERP,
-    ARGIN(PMC *self),
-    ARGIN_NULLOK(PMC * value),
-    ARGIN_NULLOK(PMC *dest))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2);
-
-PARROT_EXPORT
 INTVAL PMC_is_null(SHIM_INTERP, ARGIN_NULLOK(const PMC *pmc));
 
 PARROT_EXPORT
@@ -143,9 +133,6 @@
     || PARROT_ASSERT_ARG(pmc)
 #define ASSERT_ARGS_Parrot_create_mro __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)
-#define ASSERT_ARGS_Parrot_pmc_try_reuse __attribute__unused__ int _ASSERT_ARGS_CHECK = \
-       PARROT_ASSERT_ARG(interp) \
-    || PARROT_ASSERT_ARG(self)
 #define ASSERT_ARGS_PMC_is_null __attribute__unused__ int _ASSERT_ARGS_CHECK = 0
 #define ASSERT_ARGS_pmc_new __attribute__unused__ int _ASSERT_ARGS_CHECK = \
        PARROT_ASSERT_ARG(interp)

Modified: branches/no_pmc_reuse/src/pmc.c
==============================================================================
--- branches/no_pmc_reuse/src/pmc.c	Tue Jun  2 09:40:35 2009	(r39328)
+++ branches/no_pmc_reuse/src/pmc.c	Tue Jun  2 09:41:09 2009	(r39329)
@@ -227,56 +227,6 @@
 
 
 /*
-=item C<PMC* Parrot_pmc_try_reuse(PARROT_INTERP, PMC *self, PMC * value, PMC
-*dest)>
-
-Try to reuse dest PMC if possible. We are going to kill C<dest> anyway. So try
-to reuse it before.
-
-TODO Write nice POD about sideeffects here.
-
-=cut
-*/
-
-PARROT_EXPORT
-PARROT_CANNOT_RETURN_NULL
-PARROT_WARN_UNUSED_RESULT
-PMC*
-Parrot_pmc_try_reuse(PARROT_INTERP, ARGIN(PMC *self), ARGIN_NULLOK(PMC * value),
-    ARGIN_NULLOK(PMC *dest))
-{
-    ASSERT_ARGS(Parrot_pmc_try_reuse)
-    /* Can't reuse dest because we'll lost value */
-    if (dest == value)
-        return pmc_new(interp, VTABLE_type(interp, self));
-
-    /* Can't reuse Null */
-    if (PMC_IS_NULL(dest))
-        return pmc_new(interp, VTABLE_type(interp, self));
-
-    /* Can't reuse read-only variables */
-    if (dest->vtable->flags & VTABLE_IS_READONLY_FLAG)
-        return pmc_new(interp, VTABLE_type(interp, self));
-
-    /* It's safe in this case. Caller want to replace us anyway */
-    if (dest == self)
-        return dest;
-
-    /* Morph to self type is required */
-    {
-        INTVAL type = VTABLE_type(interp, self);
-        if (type >= enum_class_core_max)
-            /* We are not core PMC. Just clone self to preserve semantic of VTABLEs */
-            dest = VTABLE_clone(interp, self);
-        else
-            pmc_reuse(interp, dest, type, 0);
-    }
-
-    return dest;
-}
-
-
-/*
 
 =item C<static void check_pmc_reuse_flags(PARROT_INTERP, UINTVAL srcflags,
 UINTVAL destflags)>


More information about the parrot-commits mailing list