Dan Sugalski <[EMAIL PROTECTED]> wrote:
> At 11:44 PM 8/5/00 -0400, Chaim Frenkel wrote:
> >Why waste space on flags? The vtbl should handle that.
>
> Because some flags are universal, and if they're not, this field
> gets tossed.
Flags that vary only when the vptr varies could go in a field of the
vtable for speedy access. I'd like to see us try to avoid a flags
element in the Perl 6 SV.
> >Put the sync data into a seperate area and then access the external data.
>
> There lies race conditions. (cf 5.6.0's lock issues) For synchronization
> data to be valid it must be there at creation time. If it needs to be
> tacked on later you run into race issues with multiple threads trying to
> init the sync data.
If the stuff lives in an arena, have one mutex-init lock per page of
the arena. I imagine every arena page will be aligned on 4k or so and
will have a structure at the beginning containing the interpreter
pointer and stuff like this mutex. This structure will be found by
masking the final bits of the variable_data pointer.
struct arena_page_header {
Interpreter* owner;
Lock share_init_lock;
/* ... ? */
};
struct arena_page_header* sv_get_page_header(SV* sv) {
return (struct arena_page_header*)sv->variable_data & ~0xfff;
}
void sv_init_mutex(SV* sv) {
Lock* init_lock = &sv_get_page_header(sv)->share_init_lock;
lock(init_lock);
sv_upgrade_to_shared(sv);
/* sv_lock(sv); */
unlock(init_lock);
}
This avoids requiring non-shared values to contain individual mutexen.
> >And why carry around IV/NV and ptr? Make it into a union, to allow
> >room.
>
> Speed? Valid tradeoff, though. We can do it both ways to see what's
> better.
>
> >The string/number duality should be handled by the vtbl. So a
> >string that is never accessed as a number, doesn't waste the
> >space. And numbers that are rarely accessed as a string save some
> >room. And as needed the vtbl can be promoted to a duality version
> >that maintains both.
>
> I agree with this, though I'm pretty sure most scalars end up with
> multiple types. I'm up for either way, though--
Really? I find Perl 5's IV/NV/PV/PVIV/PVNV contraption with the fake
structure offsets kind of charming.
--
John Tobey, late nite hacker <[EMAIL PROTECTED]>
\\\ ///
]]] With enough bugs, all eyes are shallow. [[[
/// \\\