develooper Front page | perl.perl5.porters | Postings from May 2013

Re: SV_CHECK_THINKFIRST() needs to be rethought and further COWwoes....

Thread Previous | Thread Next
From:
bulk88
Date:
May 11, 2013 07:26
Subject:
Re: SV_CHECK_THINKFIRST() needs to be rethought and further COWwoes....
Message ID:
BLU0-SMTP24651813F4D3A9A06D1A63ADFA60@phx.gbl
Tony Cook wrote:
> 
> Maybe:
> 
> /* before I touch the buffer */
> char *sv_buffer_lock(sv, size, flags);
> 
> SBLf_UTF8 - make the existing buffer UTF-8 (ignored for SBLf_UNINIT)
> 
> SBLf_BYTES - make existing buffer bytes (ignored for SBLf_UNINIT)
> 
> SBLf_UNINIT - just give me a buffer, I'll only write to it (a debug
> perl might fill it with trash)
> 
> SBLf_CROAK - croak if SBLf_BYTES can't be honoured.
> 
> SBLf_NOMAGIC - don't SvGETMAGIC()
> 
> /* I need more space */
> char *sv_buffer_grow(sv, size, flags);
> 
> valid flags:
> SBLf_UNINIT - ignore the existing data
> 
> /* I've finished, offset would commonly be 0 */
> void sv_buffer_unlock(sv, offset, size, flags);
> 
> SBLf_UTF8 - the new data is UTF-8 (ignore the previous flag set)
> 
> SBLf_BYTES - the new data is bytes/latin1 (ignore the previous flag set)
> 
> SBLf_DISCARD - just make it undef (offset, size ignored)
> 
> SBLf_NOMAGIC - don't SvSETMAGIC()
> 
> A debugging perl could panic() if SvPVfoo() was called on a buffer
> locked SV.
> 
> For older perls, ppport.h could provide an implementation.
> 
> We might provide variants to avoid complex macros in ppport.h:
> 
>   sv_buffer_lock_uninit()
>   sv_buffer_unlock_undef()
> 
> Tony

What happens with recursion? You lock the buffer, fire off a C FSM/event 
system, C FSM might call back into pure perl on one event, and/or write 
to the buffer on a different event, in callback to pure perl, pure perl 
  calls XSUB, xsub tried to acquire lock again. Now what?

Recursion counter with 1 unlock for each lock being mandatory or croak()?

Any way to macro function call bypass optimize the lock/SV adjusting 
code (like SvTRUE and SvPV)?

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