[svn:parrot] r46289 - in trunk: include/parrot src src/gc src/ops src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Tue May 4 22:16:05 UTC 2010


Author: bacek
Date: Tue May  4 22:16:04 2010
New Revision: 46289
URL: https://trac.parrot.org/parrot/changeset/46289

Log:
Remove PMC_sync from PMC

Modified:
   trunk/include/parrot/gc_api.h
   trunk/include/parrot/pobj.h
   trunk/src/gc/alloc_resources.c
   trunk/src/gc/api.c
   trunk/src/gc/mark_sweep.c
   trunk/src/hll.c
   trunk/src/ops/set.ops
   trunk/src/pmc.c
   trunk/src/pmc/object.pmc
   trunk/src/pmc/parrotinterpreter.pmc
   trunk/src/pmc/scalar.pmc
   trunk/src/thread.c

Modified: trunk/include/parrot/gc_api.h
==============================================================================
--- trunk/include/parrot/gc_api.h	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/include/parrot/gc_api.h	Tue May  4 22:16:04 2010	(r46289)
@@ -179,11 +179,6 @@
 int Parrot_gc_active_sized_buffers(PARROT_INTERP)
         __attribute__nonnull__(1);
 
-void Parrot_gc_add_pmc_sync(PARROT_INTERP, ARGMOD(PMC *pmc))
-        __attribute__nonnull__(1)
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*pmc);
-
 void Parrot_gc_allocate_buffer_storage_aligned(PARROT_INTERP,
     ARGOUT(Buffer *buffer),
     size_t size)
@@ -257,10 +252,6 @@
         __attribute__nonnull__(2)
         FUNC_MODIFIES(*pmc);
 
-void Parrot_gc_free_pmc_sync(SHIM_INTERP, ARGMOD(PMC *p))
-        __attribute__nonnull__(2)
-        FUNC_MODIFIES(*p);
-
 void Parrot_gc_free_string_header(PARROT_INTERP, ARGMOD(STRING *s))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -370,9 +361,6 @@
 #define ASSERT_ARGS_Parrot_gc_active_sized_buffers \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_Parrot_gc_add_pmc_sync __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(interp) \
-    , PARROT_ASSERT_ARG(pmc))
 #define ASSERT_ARGS_Parrot_gc_allocate_buffer_storage_aligned \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
@@ -419,8 +407,6 @@
 #define ASSERT_ARGS_Parrot_gc_free_pmc_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(pmc))
-#define ASSERT_ARGS_Parrot_gc_free_pmc_sync __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
-       PARROT_ASSERT_ARG(p))
 #define ASSERT_ARGS_Parrot_gc_free_string_header __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp) \
     , PARROT_ASSERT_ARG(s))

Modified: trunk/include/parrot/pobj.h
==============================================================================
--- trunk/include/parrot/pobj.h	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/include/parrot/pobj.h	Tue May  4 22:16:04 2010	(r46289)
@@ -92,17 +92,11 @@
     DPOINTER       *data;
 
     PMC *_metadata;      /* properties */
-    /*
-     * PMC access synchronization for shared PMCs
-     * s. parrot/thread.h
-     */
-    struct _Sync *_synchronize;
 };
 
 #define PMC_data(pmc)                   (pmc)->data
 #define PMC_data_typed(pmc, type) (type)(pmc)->data
 #define PMC_metadata(pmc)         ((pmc)->_metadata)
-#define PMC_sync(pmc)             ((pmc)->_synchronize)
 
 #define POBJ_FLAG(n) ((UINTVAL)1 << (n))
 /* PObj flags */

Modified: trunk/src/gc/alloc_resources.c
==============================================================================
--- trunk/src/gc/alloc_resources.c	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/gc/alloc_resources.c	Tue May  4 22:16:04 2010	(r46289)
@@ -1433,14 +1433,11 @@
 
         for (i = 0; i < cur_arena->used; ++i) {
             if (!PObj_on_free_list_TEST(p) && PObj_is_PMC_TEST(p)) {
-                if (PObj_is_PMC_shared_TEST(p))
-                    PMC_sync(p)->owner = dest_interp;
-                else
-                    Parrot_ex_throw_from_c_args(dest_interp, NULL,
-                        EXCEPTION_INTERP_ERROR,
-                        "Unshared PMC still alive after interpreter"
-                        "destruction. address=%p, base_type=%d\n",
-                        p, p->vtable->base_type);
+                Parrot_ex_throw_from_c_args(dest_interp, NULL,
+                    EXCEPTION_INTERP_ERROR,
+                    "Unshared PMC still alive after interpreter"
+                    "destruction. address=%p, base_type=%d\n",
+                    p, p->vtable->base_type);
             }
 
             p = (PMC *)((char *)p + object_size);

Modified: trunk/src/gc/api.c
==============================================================================
--- trunk/src/gc/api.c	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/gc/api.c	Tue May  4 22:16:04 2010	(r46289)
@@ -177,13 +177,6 @@
         /* if object is a PMC and contains buffers or PMCs, then attach the PMC
          * to the chained mark list. */
         if (PObj_is_special_PMC_TEST(obj)) {
-            if (PObj_is_PMC_shared_TEST(obj)) {
-                Parrot_Interp i = PMC_sync(obj)->owner;
-
-                if (!i->mem_pools->gc_mark_ptr)
-                    i->mem_pools->gc_mark_ptr = obj;
-            }
-
             if (PObj_custom_mark_TEST(obj))
                 VTABLE_mark(interp, obj);
         }
@@ -336,9 +329,6 @@
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ALLOCATION_ERROR,
             "Parrot VM: PMC allocation failed!\n");
 
-    if (flags & PObj_is_PMC_shared_FLAG)
-        Parrot_gc_add_pmc_sync(interp, pmc);
-
     PObj_get_FLAGS(pmc) = PObj_is_PMC_FLAG|flags;
     pmc->vtable         = NULL;
     PMC_data(pmc)       = NULL;
@@ -366,59 +356,6 @@
 
 /*
 
-=item C<void Parrot_gc_free_pmc_sync(PARROT_INTERP, PMC *p)>
-
-Frees the PMC_sync field of the PMC, if one exists.
-
-=cut
-
-*/
-
-void
-Parrot_gc_free_pmc_sync(SHIM_INTERP, ARGMOD(PMC *p))
-{
-    ASSERT_ARGS(Parrot_gc_free_pmc_sync)
-
-    if (PObj_is_PMC_shared_TEST(p) && PMC_sync(p)) {
-        MUTEX_DESTROY(PMC_sync(p)->pmc_lock);
-        mem_internal_free(PMC_sync(p));
-        PMC_sync(p) = NULL;
-    }
-}
-
-/*
-
-=item C<void Parrot_gc_add_pmc_sync(PARROT_INTERP, PMC *pmc)>
-
-Adds a C<Sync*> structure to the given C<PMC>. Initializes the PMC's owner
-field and the synchronization mutext. Throws an exception if Sync allocation
-fails.
-
-=cut
-
-*/
-
-void
-Parrot_gc_add_pmc_sync(PARROT_INTERP, ARGMOD(PMC *pmc))
-{
-    ASSERT_ARGS(Parrot_gc_add_pmc_sync)
-
-    /* This mutex already exists, leave it alone. */
-    if (PMC_sync(pmc))
-        return;
-
-    PMC_sync(pmc) = mem_gc_allocate_zeroed_typed(interp, Sync);
-
-    if (!PMC_sync(pmc))
-        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_ALLOCATION_ERROR,
-            "Parrot VM: PMC Sync allocation failed!\n");
-
-    PMC_sync(pmc)->owner = interp;
-    MUTEX_INIT(PMC_sync(pmc)->pmc_lock);
-}
-
-/*
-
 =item C<STRING * Parrot_gc_new_string_header(PARROT_INTERP, UINTVAL flags)>
 
 Returns a new C<STRING> header from the string pool or the constant string

Modified: trunk/src/gc/mark_sweep.c
==============================================================================
--- trunk/src/gc/mark_sweep.c	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/gc/mark_sweep.c	Tue May  4 22:16:04 2010	(r46289)
@@ -355,25 +355,6 @@
 {
     ASSERT_ARGS(mark_special)
 
-    /*
-     * If the object is shared, we have to use the arena and gc
-     * pointers of the originating interpreter.
-     *
-     * We are possibly changing another interpreter's data here, so
-     * the mark phase of GC must run only on one interpreter of a pool
-     * at a time. However, freeing unused objects can occur in parallel.
-     * And: to be sure that a shared object is dead, we have to finish
-     * the mark phase of all interpreters in a pool that might reference
-     * the object.
-     */
-    if (PObj_is_PMC_shared_TEST(obj)) {
-        interp = PMC_sync(obj)->owner;
-        PARROT_ASSERT(interp);
-
-        if (!mem_pools->gc_mark_ptr)
-            mem_pools->gc_mark_ptr = obj;
-    }
-
     PObj_get_FLAGS(obj) |= PObj_custom_GC_FLAG;
 
     /* clearing the flag is much more expensive then testing */

Modified: trunk/src/hll.c
==============================================================================
--- trunk/src/hll.c	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/hll.c	Tue May  4 22:16:04 2010	(r46289)
@@ -52,16 +52,6 @@
 /* for shared HLL data, do COW stuff */
 #define START_READ_HLL_INFO(interp, hll_info)
 #define END_READ_HLL_INFO(interp, hll_info)
-#define START_WRITE_HLL_INFO(interp, hll_info) \
-    do { \
-        if (PObj_is_PMC_shared_TEST(hll_info) && PMC_sync((interp)->HLL_info)) { \
-            (hll_info) = (interp)->HLL_info = \
-                Parrot_clone((interp), (interp)->HLL_info); \
-            if (PMC_sync((interp)->HLL_info)) \
-                mem_internal_free(PMC_sync((interp)->HLL_info)); \
-        } \
-    } while (0)
-#define END_WRITE_HLL_INFO(interp, hll_info)
 
 
 /*
@@ -160,8 +150,6 @@
 
     hll_info = interp->HLL_info;
 
-    START_WRITE_HLL_INFO(interp, hll_info);
-
     idx      = VTABLE_elements(interp, hll_info);
     entry    = new_hll_entry(interp, hll_name);
 
@@ -190,9 +178,6 @@
     VTABLE_set_pointer(interp, type_hash, parrot_new_intval_hash(interp));
     VTABLE_set_pmc_keyed_int(interp, entry, e_HLL_typemap, type_hash);
 
-    /* UNLOCK */
-    END_WRITE_HLL_INFO(interp, hll_info);
-
     return idx;
 }
 
@@ -217,8 +202,6 @@
     PMC   *hll_info = interp->HLL_info;
     INTVAL nelements, i;
 
-    START_WRITE_HLL_INFO(interp, hll_info);
-
     nelements = VTABLE_elements(interp, hll_info);
 
     for (i = 0; i < nelements; ++i) {
@@ -246,8 +229,6 @@
         VTABLE_set_string_native(interp, name, hll_lib);
         VTABLE_set_pmc_keyed_int(interp, new_entry, e_HLL_lib, name);
 
-        END_WRITE_HLL_INFO(interp, hll_info);
-
         return 0;
     }
 }
@@ -357,15 +338,6 @@
         Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_GLOBAL_NOT_FOUND,
             "no such HLL ID (%vd)", hll_id);
 
-    /* the type might already be registered in a non-conflicting way, in which
-     * ca se we can avoid copying */
-    if (PObj_is_PMC_shared_TEST(hll_info) && PMC_sync(hll_info)) {
-        if (hll_type == Parrot_get_HLL_type(interp, hll_id, core_type))
-            return;
-    }
-
-    START_WRITE_HLL_INFO(interp, hll_info);
-
     entry     = VTABLE_get_pmc_keyed_int(interp, hll_info, hll_id);
     PARROT_ASSERT(!PMC_IS_NULL(entry));
 
@@ -373,8 +345,6 @@
     PARROT_ASSERT(!PMC_IS_NULL(type_hash));
 
     VTABLE_set_integer_keyed_int(interp, type_hash, core_type, hll_type);
-
-    END_WRITE_HLL_INFO(interp, hll_info);
 }
 
 /*

Modified: trunk/src/ops/set.ops
==============================================================================
--- trunk/src/ops/set.ops	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/ops/set.ops	Tue May  4 22:16:04 2010	(r46289)
@@ -511,7 +511,6 @@
         /* don't let the clone's destruction destroy the destination's data */
         PObj_custom_destroy_CLEAR(clone);
         PMC_data(clone)        = NULL;
-        PMC_sync(clone)        = NULL;
         PMC_metadata(clone)    = NULL;
 
         /* Restore metadata. */

Modified: trunk/src/pmc.c
==============================================================================
--- trunk/src/pmc.c	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/pmc.c	Tue May  4 22:16:04 2010	(r46289)
@@ -119,9 +119,6 @@
 
     PObj_gc_CLEAR(pmc);
 
-    if (PObj_is_PMC_shared_TEST(pmc) && PMC_sync(pmc))
-        Parrot_gc_free_pmc_sync(interp, pmc);
-
     if (pmc->vtable->attr_size)
         Parrot_gc_free_pmc_attributes(interp, pmc);
     else
@@ -852,7 +849,6 @@
     &&  (_class == _class->vtable->pmc_class))
         interp->vtables[type]->pmc_class = _class;
     else {
-        Parrot_gc_free_pmc_sync(interp, _class);
         gc_flag_CLEAR(is_special_PMC, _class);
         PObj_is_PMC_shared_CLEAR(_class);
         interp->vtables[type]->pmc_class = _class;

Modified: trunk/src/pmc/object.pmc
==============================================================================
--- trunk/src/pmc/object.pmc	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/pmc/object.pmc	Tue May  4 22:16:04 2010	(r46289)
@@ -888,7 +888,6 @@
         VTABLE_setprop(INTERP, ret, CONST_STRING(interp, "_ro"), _true);
 
         SELF->vtable->pmc_class = master->vtables[type_num]->pmc_class;
-        Parrot_gc_add_pmc_sync(INTERP, ret);
         PObj_is_PMC_shared_SET(ret);
 
         data = PARROT_CLASS(classobj)->parents;

Modified: trunk/src/pmc/parrotinterpreter.pmc
==============================================================================
--- trunk/src/pmc/parrotinterpreter.pmc	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/pmc/parrotinterpreter.pmc	Tue May  4 22:16:04 2010	(r46289)
@@ -82,7 +82,6 @@
     if (flags & PARROT_CLONE_HLL) {
         /* we'd like to share the HLL data. Give it a PMC_sync structure
            if it doesn't have one already */
-        Parrot_gc_add_pmc_sync(s, s->HLL_info);
         d->HLL_info = s->HLL_info;
         Parrot_regenerate_HLL_namespaces(d);
     }

Modified: trunk/src/pmc/scalar.pmc
==============================================================================
--- trunk/src/pmc/scalar.pmc	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/pmc/scalar.pmc	Tue May  4 22:16:04 2010	(r46289)
@@ -944,7 +944,6 @@
         VTABLE_setprop(INTERP, ret, CONST_STRING(INTERP, "_ro"), _true);
 
         /* We're sharing this, so make sure it has a PMC_sync */
-        Parrot_gc_add_pmc_sync(INTERP, ret);
         PObj_is_PMC_shared_SET(ret);
 
         /* XXX FIXME workaround lack of metadata sharing*/

Modified: trunk/src/thread.c
==============================================================================
--- trunk/src/thread.c	Tue May  4 21:54:44 2010	(r46288)
+++ trunk/src/thread.c	Tue May  4 22:16:04 2010	(r46289)
@@ -339,8 +339,6 @@
     if (is_ro)
         pmc->vtable = pmc->vtable->ro_variant_vtable;
 
-    Parrot_gc_add_pmc_sync(interp, pmc);
-
     PObj_is_PMC_shared_SET(pmc);
 
     /* make sure metadata doesn't go away unexpectedly */


More information about the parrot-commits mailing list