Dan Sugalski <[EMAIL PROTECTED]> wrote:
> At 05:43 PM 6/19/2001 -0500, David L. Nicol wrote:
> >         set $B to copy-on-write mode, so future changes to $B do not 
> > affect $A
> 
> The one problem with copy-on-write is that, if we implement it in software, 
> we end up paying the price to check it on every string write. (No free 
> depending on the hardware, alas)
> 
> Not that this should shoot down the idea of COW strings, but it is a cost 
> that needs considering. (I suppose we could have a COW subtype of the basic 
> scalar and string scalar)

I had always assumed this would be done with 'wrapper' vtable types -
eg a PMC which holds 1 item of data - a pointer to the real PMC,
and which has all its read-ish vtable slots pointing to a function which
just passes on the request to real PMC, and whose write-ish slots all point
to a function which calls some sort of clone method on the real PMC then
updates its own vtable pointer to point to the real vtable.

The penalty is that while the data is shared, you have an extra indirect
function call overhead.

Reply via email to