On 6/7/2013 10:03 AM, Patrick Walton wrote:
Was there discussion about whether string buffers should be refcounted
or GCed (or copied, but I'm pretty sure that would cause memory
explosion)?
Ref counting versus GC is determined on a case-by-case basis in Servo.
There's no one-size-fits-all solution: we're using threadsafe
reference counting, or unique strings, or possibly-interned strings,
as the situation calls for it. Admittedly this is kind of a
non-answer. :) I'd be curious as to which specific situations you had
in mind.
Well... I don't think I understand the answer yet.
If strings are immutable, you have two basic options for passing them
around:
* You can pass pointers to the actual string objects around. This
requires that pretty much all code has a shared understanding of whether
the objects are refcounted or GCed, I think. You *may* have the
possibility to allocate both the "string object" and its backing buffer
in a single allocation, which potentially saves memory. This is the
pattern in the JS engine.
* String objects are lightweight (flags + pointer to buffer). String
assignment just shares the buffer. This is the current XPCOM pattern. In
this case, the actual string objects could be inline or separately
allocated. But then the question is really about the buffers: would it
make more sense to GC or refcount them? Note that if strings are
mutable, then this is really the only sane way to pass strings around,
since you use copy-on-write semantics for the buffers.
Currently in XPCOM, buffers use threadsafe refcounting because we do
pass strings between threads (mainly in networking-land). If we are sure
that these strings are not going to be assigned across threads, we
should probably just use non-threadsafe refcounting for the buffers.
I haven't spent a lot of time understanding rust or servo architecture
other than reading the occasional traffic on this list (is there a guide
doc now?). I understand that layout operates on a separate task, but it
wasn't clear what kinds of structures were being sent to that task or
how they were synchronized.
--BDS
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo