On 10/6/14, 3:53 AM, Cameron Zwarich wrote:
Where do most of the small strings larger than a single character that benefit 
from the inline small string optimization originate, the DOM or user JS code?

That's a good question.

When the optimization was added, strings that originated in the DOM never ended up using the inline small string optimization (because they ended up as "external strings" instead).

Even now, strings returned via nsAString out params (which is most APIs) end up as "external string".

The one case when DOM-provided strings get inlined on the JS side is when we're using a DOMString out param (which a small number of DOM methods use). See <https://bugzilla.mozilla.org/show_bug.cgi?id=934544>.

None of which really answers your question, since it depends on the call frequencies of DOM methods. But I expect that JS-originating strings dominate here. Could be measured.

Note that "short" in this case is 11 utf-16 code points for non-latin1 strings and 23 bytes for latin-1 strings, which actually covers a surprising number of strings that occur in real life.

Thanks for the reference. That function takes a char16_t*, but now that they’ve 
done the Latin1 optimization, it seems like it should be possible to also make 
a Latin1 variant.

Absolutely. https://bugzilla.mozilla.org/show_bug.cgi?id=1038099 is related but distinct; worth filing an explicit bug on a latin1 external string version.

There is an interesting question of whether it will ever be a good idea for a 
JS engine to make something like WTF-8 its native string type, or if the 
difficulties with random access outweigh the advantages. It seems like a 
daunting task to do that at this point for Gecko / SM, even if it would work in 
theory.

Yeah, coevolving Gecko and SpiderMonkey here is a pain without boil-the-ocean kind of patches. :(

That said, we've considered doing it; the hard part would be avoiding performance problems during the (probably longish) transition period when conversions have to happen some places.

-Boris
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to