develooper Front page | perl.perl5.porters | Postings from April 2006

add svt_local slot to magic vtable

Thread Next
From:
Nicholas Clark
Date:
April 28, 2006 07:49
Subject:
add svt_local slot to magic vtable
Message ID:
20060428144922.GG31638@plum.flirble.org

> ==== //depot/maint-5.8/perl/ext/threads/shared/shared.xs#24 (text) ====
> Index: perl/ext/threads/shared/shared.xs
> --- perl/ext/threads/shared/shared.xs#23~26626~	2006-01-03 12:05:49.000000000 -0800
> +++ perl/ext/threads/shared/shared.xs	2006-04-28 07:12:06.000000000 -0700
> @@ -196,6 +196,7 @@
>   sharedsv_shared_mg_free,	/* free */
>   0,				/* copy */
>   0,				/* dup */
> + 0				/* local */
>  };

> +	if ((mg->mg_flags & MGf_LOCAL) && vtbl->svt_local)
> +	    (void)CALL_FPTR(vtbl->svt_local)(aTHX_ nsv, mg);
> +	else

> @@ -38,8 +39,9 @@
>  #define MGf_MINMATCH   1        /* PERL_MAGIC_regex_global only */
>  #define MGf_REFCOUNTED 2
>  #define MGf_GSKIP      4
> -#define MGf_COPY       8
> -#define MGf_DUP        16
> +#define MGf_COPY       8	/* has an svt_copy  MGVTBL entry */
> +#define MGf_DUP     0x10 	/* has an svt_dup   MGVTBL entry */
> +#define MGf_LOCAL   0x20	/* has an svt_local MGVTBL entry */

I realise that I've just integrate this to maint as-is, and that we've already
released these flags as 5.9.3 to CPAN, and that we missed the first chance
with MGf_DUP, but I was wondering:

Given that you can't have a MGf_LOCAL entry without already having a MGf_DUP
entry, would it make sense to conserve the limited supply of flag bits by
using 0x10 for DUP, 0x20 for DUP+LOCAL and 0x30 for DUP+LOCAL+the_next_one

Alternatively, would it make some sense to add a flags word to the vtable
after DUP, so that future stretching of the vtable can be done without eating
into flags bits?

I can see that it might be nice to have a bless vtable entry, because right
now as I understand it, blessing a shared object can't work, as there's no
way to signal to the bless code to do something extra.

Although I'm not sure how useful this is with shared objects, because if
thread A blesses a shared object, thread B's local proxy never gets to learn
about it.

Nicholas Clark

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