summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embed.fnc4
-rw-r--r--embed.h4
-rw-r--r--global.sym2
-rw-r--r--op.c20
-rw-r--r--op.h9
-rw-r--r--proto.h2
-rw-r--r--regcomp.c10
7 files changed, 38 insertions, 13 deletions
diff --git a/embed.fnc b/embed.fnc
index 614e975f90..64d052fe91 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -361,8 +361,10 @@ p |I32 |keyword |char* d|I32 len
Ap |void |leave_scope |I32 base
p |void |lex_end
p |void |lex_start |SV* line
-Ap |void |op_null |OP* o
+Ap |void |op_null |OP* o
p |void |op_clear |OP* o
+Ap |void |op_refcnt_lock
+Ap |void |op_refcnt_unlock
p |OP* |linklist |OP* o
p |OP* |list |OP* o
p |OP* |listkids |OP* o
diff --git a/embed.h b/embed.h
index d082754694..05878012b6 100644
--- a/embed.h
+++ b/embed.h
@@ -443,6 +443,8 @@
#ifdef PERL_CORE
#define op_clear Perl_op_clear
#endif
+#define op_refcnt_lock Perl_op_refcnt_lock
+#define op_refcnt_unlock Perl_op_refcnt_unlock
#ifdef PERL_CORE
#define linklist Perl_linklist
#endif
@@ -3067,6 +3069,8 @@
#ifdef PERL_CORE
#define op_clear(a) Perl_op_clear(aTHX_ a)
#endif
+#define op_refcnt_lock() Perl_op_refcnt_lock(aTHX)
+#define op_refcnt_unlock() Perl_op_refcnt_unlock(aTHX)
#ifdef PERL_CORE
#define linklist(a) Perl_linklist(aTHX_ a)
#endif
diff --git a/global.sym b/global.sym
index d97151ebf1..0ff88886df 100644
--- a/global.sym
+++ b/global.sym
@@ -223,6 +223,8 @@ Perl_is_utf8_xdigit
Perl_is_utf8_mark
Perl_leave_scope
Perl_op_null
+Perl_op_refcnt_lock
+Perl_op_refcnt_unlock
Perl_load_module
Perl_vload_module
Perl_looks_like_number
diff --git a/op.c b/op.c
index 614e211135..8a5c765bc7 100644
--- a/op.c
+++ b/op.c
@@ -271,6 +271,7 @@ Perl_op_free(pTHX_ OP *o)
{
register OP *kid, *nextkid;
OPCODE type;
+ PADOFFSET refcnt;
if (!o || o->op_static)
return;
@@ -284,11 +285,10 @@ Perl_op_free(pTHX_ OP *o)
case OP_SCOPE:
case OP_LEAVEWRITE:
OP_REFCNT_LOCK;
- if (OpREFCNT_dec(o)) {
- OP_REFCNT_UNLOCK;
- return;
- }
+ refcnt = OpREFCNT_dec(o);
OP_REFCNT_UNLOCK;
+ if (refcnt)
+ return;
break;
default:
break;
@@ -474,6 +474,18 @@ Perl_op_null(pTHX_ OP *o)
o->op_ppaddr = PL_ppaddr[OP_NULL];
}
+void
+Perl_op_refcnt_lock(pTHX)
+{
+ OP_REFCNT_LOCK;
+}
+
+void
+Perl_op_refcnt_unlock(pTHX)
+{
+ OP_REFCNT_UNLOCK;
+}
+
/* Contextualizers */
#define LINKLIST(o) ((o)->op_next ? (o)->op_next : linklist((OP*)o))
diff --git a/op.h b/op.h
index d72c52e77c..2e7316890d 100644
--- a/op.h
+++ b/op.h
@@ -481,8 +481,13 @@ struct loop {
#ifdef USE_ITHREADS
# define OP_REFCNT_INIT MUTEX_INIT(&PL_op_mutex)
-# define OP_REFCNT_LOCK MUTEX_LOCK(&PL_op_mutex)
-# define OP_REFCNT_UNLOCK MUTEX_UNLOCK(&PL_op_mutex)
+# ifdef PERL_CORE
+# define OP_REFCNT_LOCK MUTEX_LOCK(&PL_op_mutex)
+# define OP_REFCNT_UNLOCK MUTEX_UNLOCK(&PL_op_mutex)
+# else
+# define OP_REFCNT_LOCK op_refcnt_lock()
+# define OP_REFCNT_UNLOCK op_refcnt_unlock()
+# endif
# define OP_REFCNT_TERM MUTEX_DESTROY(&PL_op_mutex)
#else
# define OP_REFCNT_INIT NOOP
diff --git a/proto.h b/proto.h
index bd14810c02..5897eada69 100644
--- a/proto.h
+++ b/proto.h
@@ -340,6 +340,8 @@ PERL_CALLCONV void Perl_lex_end(pTHX);
PERL_CALLCONV void Perl_lex_start(pTHX_ SV* line);
PERL_CALLCONV void Perl_op_null(pTHX_ OP* o);
PERL_CALLCONV void Perl_op_clear(pTHX_ OP* o);
+PERL_CALLCONV void Perl_op_refcnt_lock(pTHX);
+PERL_CALLCONV void Perl_op_refcnt_unlock(pTHX);
PERL_CALLCONV OP* Perl_linklist(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_list(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_listkids(pTHX_ OP* o);
diff --git a/regcomp.c b/regcomp.c
index 97e81bc728..7b4d647995 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -4967,6 +4967,7 @@ Perl_pregfree(pTHX_ struct regexp *r)
int n = r->data->count;
PAD* new_comppad = NULL;
PAD* old_comppad;
+ PADOFFSET refcnt;
while (--n >= 0) {
/* If you add a ->what type here, update the comment in regcomp.h */
@@ -4989,13 +4990,10 @@ Perl_pregfree(pTHX_ struct regexp *r)
new_comppad : Null(PAD *)
);
OP_REFCNT_LOCK;
- if (!OpREFCNT_dec((OP_4tree*)r->data->data[n])) {
- OP_REFCNT_UNLOCK;
+ refcnt = OpREFCNT_dec((OP_4tree*)r->data->data[n]);
+ OP_REFCNT_UNLOCK;
+ if (!refcnt)
op_free((OP_4tree*)r->data->data[n]);
- }
- else {
- OP_REFCNT_UNLOCK;
- }
PAD_RESTORE_LOCAL(old_comppad);
SvREFCNT_dec((SV*)new_comppad);