Luke Palmer <[EMAIL PROTECTED]> wrote:
> This patch re-implements the register backing stacks as PObjs (so they
> can be garbage-collected), honors their COW flags, and adds them to the
> interpreter context (where they should be, honest!).

> As a healthy side-effect, it encapsulates their behavior nicely into
> register.c, when before their guts were splattered all over the source.

Applied, thanks.

Some remarks WRT the patch:
1) struct RegStack doesn't need the chunk_size data member
   top->data.buflen has the exact size
   So ctx.<type>_reg_stack could be a general StackChunkBuf
2) pad, control and user stacks could very likely use the same
   stack infrastructure. COW copying of these is still b0rken but
   needed as well.
3) The LEA allocators implementation does only handle COW copying
   of string memory. This should be fixed, that is, allocate one
   sizeof(int) + the requested memory and consider the memory at
   buffer+size as the refcount (used during DOD) - or increment
   bufstart by sizeof(int), so that the actual allocated memory
   ptr is at bufstart - sizeof(int). But that has to be consistent
   for strings and plain buffers.
4) Several Parrot_allocate_zeroed could be just Parrot_allocate
   as the memory is either copied over or initialized later.

And finally a remark WRT COWed Buffers:

5) cow_copy_context() could still be wrong. Both contexts share the
   same Buffer header. When now this shared buffer header is marked COW
   each change to the context would unshare the buffer by creating a
   distinct copy. This also means, that if the COWed stack copy isn't
   changed in the Sub and after return from the Sub an item is pushed
   on that stack, it would be copied.

   I know that I did this for other buffers in the context
   but it is wrong somehow - IMHO.

   COWed strings also seem to suffer from that problem. Both buffer
   headers are marked COW. Even if the shared copy goes out of scope,
   the COW flag remains - so changing that string later would do a
   copy of the buffer first, which isn't needed as there is only one
   user of the buffer left.

   It could be simpler if we have an explicit refcount for COWed objects.
   We need that during DOD anyway with some overhead.

Takers for these steps wanted, please drop a short note.

thanks,
leo

Reply via email to