X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=autovivification.xs;h=0ca1714b8440bbe13ed9b88993255aa2ad9f9cee;hb=4ae96f44338cb71d96e4be848b4bdd3e7fd353e4;hp=23e20729b5db4e3c8b78c08a42c00e219de3b56a;hpb=73772795ebcb8df2c461e190ec0b90b02617144f;p=perl%2Fmodules%2Fautovivification.git diff --git a/autovivification.xs b/autovivification.xs index 23e2072..0ca1714 100644 --- a/autovivification.xs +++ b/autovivification.xs @@ -160,7 +160,8 @@ static I32 a_loaded = 0; #if A_THREADSAFE #define PTABLE_NAME ptable_loaded -#define PTABLE_VAL_FREE(V) NOOP +#define PTABLE_NEED_DELETE 1 +#define PTABLE_NEED_WALK 0 #include "ptable.h" @@ -241,6 +242,8 @@ typedef struct { #define PTABLE_NAME ptable_hints #define PTABLE_VAL_FREE(V) A_HINT_FREE(V) +#define PTABLE_NEED_DELETE 0 +#define PTABLE_NEED_WALK 1 #define pPTBL pTHX #define pPTBL_ pTHX_ @@ -257,7 +260,8 @@ typedef struct { #endif /* A_WORKAROUND_REQUIRE_PROPAGATION */ #define PTABLE_NAME ptable_seen -#define PTABLE_VAL_FREE(V) NOOP +#define PTABLE_NEED_DELETE 0 +#define PTABLE_NEED_WALK 0 #include "ptable.h" @@ -479,12 +483,15 @@ typedef struct { #define PTABLE_NAME ptable_map #define PTABLE_VAL_FREE(V) PerlMemShared_free(V) +#define PTABLE_NEED_DELETE 1 +#define PTABLE_NEED_WALK 0 #include "ptable.h" /* PerlMemShared_free() needs the [ap]PTBLMS_? default values */ #define ptable_map_store(T, K, V) ptable_map_store(aPTBLMS_ (T), (K), (V)) #define ptable_map_delete(T, K) ptable_map_delete(aPTBLMS_ (T), (K)) +#define ptable_map_free(T) ptable_map_free(aPTBLMS_ (T)) static ptable *a_op_map = NULL; @@ -1252,14 +1259,19 @@ static OP *a_ck_deref(pTHX_ OP *o) { } o = old_ck(aTHX_ o); - if (hint & A_HINT_DO) { #if A_HAS_MULTIDEREF - if (old_ck == a_old_ck_rv2sv && o->op_flags & OPf_KIDS) { - OP *kid = cUNOPo->op_first; - if (kid && kid->op_type == OP_GV) + if (old_ck == a_old_ck_rv2sv && o->op_flags & OPf_KIDS) { + OP *kid = cUNOPo->op_first; + if (kid && kid->op_type == OP_GV) { + if (hint & A_HINT_DO) a_map_store(kid, kid->op_ppaddr, NULL, hint); + else + a_map_delete(kid); } + } #endif + + if (hint & A_HINT_DO) { a_map_store_root(o, o->op_ppaddr, hint); o->op_ppaddr = a_pp_deref; } else @@ -1558,6 +1570,10 @@ static void a_teardown(pTHX_ void *root) { ptable_map_free(a_op_map); a_op_map = NULL; + +#ifdef USE_ITHREADS + MUTEX_DESTROY(&a_op_map_mutex); +#endif } A_LOADED_UNLOCK; @@ -1592,6 +1608,7 @@ static void a_setup(pTHX) { PERL_HASH(a_hash, __PACKAGE__, __PACKAGE_LEN__); a_op_map = ptable_new(); + #ifdef USE_ITHREADS MUTEX_INIT(&a_op_map_mutex); #endif