Search the web
Sign In
New User? Sign Up
perl5-porters
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
[PATCH] Threadsafe PMOPs! We might still win this war.   Message List  
Reply | Forward Message #89842 of 89846 |
Below is a patch that moves REGEXP out of PMOPs and into an PL_regex_padav.
The offset is stored in PMOP->op_pmoffset.

As soon as Perl_re_dup is finished (incoming later from AMS) this will clone all
regexes to be
thread specific. This does not put them on the pad as Sarathy suggest, putting
the regexes
on the pad changes semantics of perl and is rather non trivial compared to this.
It can however be done later.

Problems might be the pm flags, if so we will have to move them out of this and
onto a seperate list.
I don't fully grok the flags and left them as existing. Could somone comment on
this?

All tests pass, my threads test pass, I suggest applying it.

Artur

--- perl-current-copy/sv.c Wed Jul 11 11:50:54 2001
+++ perl-current/sv.c Wed Jul 11 13:53:02 2001
@@ -9693,6 +9693,19 @@
PL_statusvalue_vms = proto_perl->Istatusvalue_vms;
#endif

+ /* Clone the regex array */
+ PL_regex_padav = newAV();
+ {
+ I32 len = av_len((AV*)proto_perl->Iregex_padav);
+ SV** regexen = AvARRAY((AV*)proto_perl->Iregex_padav);
+ for(i = 0; i <= len; i++) {
+ av_push(PL_regex_padav,
+ newSViv((IV)re_dup((REGEXP*) SvIV(regexen[i])) ));
+ }
+ }
+ PL_regex_pad = AvARRAY(PL_regex_padav);
+
+
/* shortcuts to various I/O objects */
PL_stdingv = gv_dup(proto_perl->Istdingv, param);
PL_stderrgv = gv_dup(proto_perl->Istderrgv, param);
--- perl-current-copy/op.h Wed Jul 11 11:50:53 2001
+++ perl-current/op.h Wed Jul 11 12:38:10 2001
@@ -235,7 +235,11 @@
OP * op_pmreplroot;
OP * op_pmreplstart;
PMOP * op_pmnext; /* list of all scanpats */
- REGEXP * op_pmregexp; /* compiled expression */
+#ifdef USE_ITHREADS
+ I32 op_pmoffset;
+#else
+ REGEXP * op_pmregexp; /* compiled expression */
+#endif
U16 op_pmflags;
U16 op_pmpermflags;
U8 op_pmdynflags;
@@ -246,8 +250,13 @@
#endif
};

+#ifdef USE_ITHREADS
+#define PM_GETRE(o) ((REGEXP*)SvIV(PL_regex_pad[(o)->op_pmoffset]))
+#define PM_SETRE(o,r) (sv_setiv(PL_regex_pad[(o)->op_pmoffset], (IV)r))
+#else
#define PM_GETRE(o) ((o)->op_pmregexp)
#define PM_SETRE(o,r) ((o)->op_pmregexp = (r))
+#endif

#define PMdf_USED 0x01 /* pm has been used once already */
#define PMdf_TAINTED 0x02 /* pm compiled from tainted pattern */
--- perl-current-copy/op.c Wed Jul 11 11:50:53 2001
+++ perl-current/op.c Wed Jul 11 12:38:16 2001
@@ -2952,7 +2952,16 @@
pmop->op_pmpermflags |= PMf_LOCALE;
pmop->op_pmflags = pmop->op_pmpermflags;

- /* link into pm list */
+ #ifdef USE_ITHREADS
+ {
+ SV* repointer = newSViv(0);
+ av_push(PL_regex_padav,repointer);
+ pmop->op_pmoffset = av_len(PL_regex_padav);
+ PL_regex_pad = AvARRAY(PL_regex_padav);
+ }
+ #endif
+
+ /* link into pm list */
if (type != OP_TRANS && PL_curstash) {
pmop->op_pmnext = HvPMROOT(PL_curstash);
HvPMROOT(PL_curstash) = pmop;
--- perl-current-copy/intrpvar.h Wed Jul 11 11:50:53 2001
+++ perl-current/intrpvar.h Wed Jul 11 12:22:10 2001
@@ -475,6 +475,11 @@

#endif

+#if defined(USE_ITHREADS)
+PERLVAR(Iregex_pad, SV**) /* All regex objects */
+PERLVAR(Iregex_padav, AV*) /* All regex objects */
+#endif
+
/* New variables must be added to the very end for binary compatibility.
* XSUB.h provides wrapper functions via perlapi.h that make this
* irrelevant, but not all code may be expected to #include XSUB.h. */
--- perl-current-copy/perl.c Wed Jul 11 11:50:53 2001
+++ perl-current/perl.c Wed Jul 11 12:23:53 2001
@@ -312,7 +312,9 @@
PL_fdpid = newAV(); /* for remembering popen pids by fd */
PL_modglobal = newHV(); /* pointers to per-interpreter module
globals */
PL_errors = newSVpvn("",0);
-
+#ifdef USE_ITHREADS
+ PL_regex_padav = newAV();
+#endif
ENTER;
}






Wed Jul 11, 2001 12:23 pm

artur@...
Send Email Send Email

Forward
Message #89842 of 89846 |
Expand Messages Author Sort by Date

Below is a patch that moves REGEXP out of PMOPs and into an PL_regex_padav. The offset is stored in PMOP->op_pmoffset. As soon as Perl_re_dup is finished...
Artur Bergman
artur@...
Send Email
Jul 11, 2001
12:19 pm

... Might some of the pm flags belong in the REGEXP rather than in the PMOP? If so, I'd suggest moving them there. Overall, looks like good progress (assuming...
Gurusamy Sarathy
gsar@...
Send Email
Jul 11, 2001
2:28 pm
< Prev Topic  |  Next Topic >
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help