develooper Front page | perl.perl5.porters | Postings from November 2005

Re: XS-assisted SWASHGET (esp. for t/uni/class.t speedup)

Thread Previous | Thread Next
From:
SADAHIRO Tomoyuki
Date:
November 24, 2005 08:16
Subject:
Re: XS-assisted SWASHGET (esp. for t/uni/class.t speedup)
Message ID:
20051125011410.24E9.BQW10602@nifty.com

On Wed, 23 Nov 2005 23:06:15 +0000, Dave Mitchell <davem@iabyn.com> wrote

> On Wed, Nov 23, 2005 at 05:57:34PM +0900, SADAHIRO Tomoyuki wrote:
> > In particular, removal of save_re_context, PUSHSTACKi and POPSTACK
> > from Perl_swash_fetch seems to save much times.
> 
> As far as I can see, the PUSHSTACKi is still required, since
> Perl_swash_fetch may extend the stack, and it is called from places that
> may not expect the stack to be extended (and thus reallocated).

I see.
There is a patch below, which makes PUSHSTACKi and POPSTACK come back.
(This patch also includes document fix. The lib/unicore/* files are
loaded from SWASHNEW, by the sentence of < $list = do $file; >)

> Also, I don't understand why SWASHGET remains as a perl-level function
> that just calls the XS utf8::SWASHGET_heavy; why not just rename
> utf8::SWASHGET_heavy to utf8::SWASHGET ?

The argument DEBUG of utf8::SWASHGET_heavy may be unnecessary
if people need not the "debug" information from SWASHGET
or utf8::DEBUG subroutine is called from XS.
(I think the debug codes in SWASHGET_heavy are quite redundant.)

For a furthur advance, I wonder why we need call SWASHGET as a method.

The details of swashes are not (and should not be, I think) documented,
and SWASHGET are called only from Perl_swash_fetch and SWASHGET
itself (recursively).

SWASHGET may expect that all the swash objects are created by
utf8::SWASHNEW as an only constructor, and we can know the data
structures of the return value from utf8::SWASHNEW.

Parhaps SWASHGET may be able to recast as a C-level function
rather than XS. For example,

/* returning a swash vector string, called from swash_fetch */
STATIC SV*
S_swash_get(pTHX_ SV *swash, UV start_code_point, STRLEN vector_length)
{
   ....
}

Regards
SADAHIRO Tomoyuki

diff -ur perl~patch26201/utf8.c perl/utf8.c
--- perl~patch26201/utf8.c	Thu Nov 24 01:01:37 2005
+++ perl/utf8.c	Fri Nov 25 00:25:10 2005
@@ -1364,7 +1364,7 @@
 The "swashp" is a pointer to the swash to use.
 
 Both the special and normal mappings are stored lib/unicore/To/Foo.pl,
-and loaded by SWASHGET, using lib/utf8_heavy.pl.  The special (usually,
+and loaded by SWASHNEW, using lib/utf8_heavy.pl.  The special (usually,
 but not always, a multicharacter mapping), is tried first.
 
 The "special" is a string like "utf8::ToSpecLower", which means the
@@ -1696,8 +1696,8 @@
 	    SV *errsv_save;
 	    ENTER;
 	    SAVETMPS;
-	/*  save_re_context();  */
-	/*  PUSHSTACKi(PERLSI_MAGIC);  */
+	/*  save_re_context(); */ /* Now SWASHGET doesn't use regex */
+	    PUSHSTACKi(PERLSI_MAGIC);
 	    PUSHMARK(SP);
 	    EXTEND(SP,3);
 	    PUSHs((SV*)sv);
@@ -1714,7 +1714,7 @@
 	    if (!SvTRUE(ERRSV))
 		sv_setsv(ERRSV, errsv_save);
 	    SvREFCNT_dec(errsv_save);
-	/*  POPSTACK; */
+	    POPSTACK;
 	    FREETMPS;
 	    LEAVE;
 	    if (IN_PERL_COMPILETIME)
### End of patch



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About