]> git.vpit.fr Git - perl/modules/Lexical-Types.git/blobdiff - Types.xs
Clean up map entries associated to uncatched OPs
[perl/modules/Lexical-Types.git] / Types.xs
index 8970e9116ecf6822520cc46eed2a94d203bd9327..bcf5fa15c9ac6937ac4e74347ff1a0b1b64631e3 100644 (file)
--- a/Types.xs
+++ b/Types.xs
@@ -114,7 +114,6 @@ STATIC void lt_thread_cleanup(pTHX_ void *);
 
 STATIC void lt_thread_cleanup(pTHX_ void *ud) {
  int *level = ud;
- SV  *id;
 
  if (*level) {
   *level = 0;
@@ -182,20 +181,20 @@ STATIC U32 lt_hash = 0;
 
 STATIC SV *lt_hint(pTHX) {
 #define lt_hint() lt_hint(aTHX)
- SV *id;
+ SV *hint;
 #if LT_HAS_PERL(5, 9, 5)
id = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash,
-                                     NULL,
-                                     __PACKAGE__, __PACKAGE_LEN__,
-                                     0,
-                                     lt_hash);
hint = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash,
+                                       NULL,
+                                       __PACKAGE__, __PACKAGE_LEN__,
+                                       0,
+                                       lt_hash);
 #else
  SV **val = hv_fetch(GvHV(PL_hintgv), __PACKAGE__, __PACKAGE_LEN__, lt_hash);
  if (!val)
   return 0;
id = *val;
hint = *val;
 #endif
- return (id && SvOK(id)) ? id : NULL;
+ return (hint && SvOK(hint)) ? hint : NULL;
 }
 
 /* ... op => info map ...................................................... */
@@ -264,6 +263,19 @@ STATIC const lt_op_info *lt_map_fetch(const OP *o, lt_op_info *oi) {
  return val;
 }
 
+STATIC void lt_map_delete(pTHX_ const OP *o) {
+#define lt_map_delete(O) lt_map_delete(aTHX_ (O))
+#ifdef USE_ITHREADS
+ MUTEX_LOCK(&lt_op_map_mutex);
+#endif
+
+ ptable_map_store(lt_op_map, o, NULL);
+
+#ifdef USE_ITHREADS
+ MUTEX_UNLOCK(&lt_op_map_mutex);
+#endif
+}
+
 /* --- Hooks --------------------------------------------------------------- */
 
 /* ... Our pp_padsv ........................................................ */
@@ -421,9 +433,11 @@ STATIC OP *lt_ck_padany(pTHX_ OP *o) {
   lt_pp_padsv_save();
 
   lt_map_store(o, orig_pkg, type_pkg, type_meth, lt_pp_padsv_saved);
+ } else {
+skip:
+  lt_map_delete(o);
  }
 
-skip:
  return o;
 }
 
@@ -432,6 +446,8 @@ STATIC OP *(*lt_old_ck_padsv)(pTHX_ OP *) = 0;
 STATIC OP *lt_ck_padsv(pTHX_ OP *o) {
  lt_pp_padsv_restore(o);
 
+ lt_map_delete(o);
+
  return CALL_FPTR(lt_old_ck_padsv)(aTHX_ o);
 }